Skip to content

feat(rest-api): add Provider-related capabilities to templated iPXE OS and make visible to tenants#4067

Draft
pbreton wants to merge 6 commits into
NVIDIA:mainfrom
pbreton:feat/ipxe-templated-os-4
Draft

feat(rest-api): add Provider-related capabilities to templated iPXE OS and make visible to tenants#4067
pbreton wants to merge 6 commits into
NVIDIA:mainfrom
pbreton:feat/ipxe-templated-os-4

Conversation

@pbreton

@pbreton pbreton commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR continues implementation of Templated iPXE Operating System in NICo REST API.
Specifically it adds Providers capabilities regarding Templated iPXE Operating System and makes Providers-created OS visible to Tenants.

Related issues

Builds on #3569.

Type of Change

  • Add - New feature or capability

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated

pbreton added 5 commits July 23, 2026 14:07
Add OperatingSystemFilterInput.ProviderOSVisibleAtSiteIDs and rework the
OperatingSystemDAO.GetAll owner filtering into an explicit switch covering
provider-only, tenant-only, dual-role, and tenant-admin views. The
tenant-admin view surfaces provider-owned OSes only when they are associated
with one of the tenant's accessible sites.

Foundation for provider-admin OS management (PR 4.2/4.3).
Switch the OperatingSystem GetAll and Get handlers to authorize both
provider and tenant admins via IsProviderOrTenant, and apply role-based
visibility:

- Provider admin lists/reads only provider-owned Operating Systems.
- Tenant admin additionally sees provider-owned Operating Systems that are
  associated with a Site the tenant can access (via the new
  ProviderOSVisibleAtSiteIDs filter).
- Dual-role callers see the union.

Adds the getTenantSiteIDs helper, handler visibility tests, and restores the
provider-admin path in the OpenAPI get-all/get descriptions. Create/Update/
Delete remain tenant-scoped and are handled in a follow-up PR.
Switch the OperatingSystem Create, Update, and Delete handlers to authorize
both provider and tenant admins via IsProviderOrTenant and enforce ownership:

- Provider admin may only create Provider-owned Operating Systems of type
  Templated iPXE; ownership (infrastructure_provider_id vs tenant_id) is
  derived from the caller's role.
- Update/Delete require the caller to own the Operating System for their role;
  cross-owner mutations are rejected with 403.
- Name uniqueness and site resolution are scoped to the owner (provider sites
  for provider-owned, tenant-accessible sites for tenant-owned).

Adds write-path ownership tests, updates the two existing tenant-mismatch
cases from 400 to 403 to reflect the ownership model, drops the now-unused
auth import, and updates the OpenAPI create description for the provider path.
Fold operatingsystem_ownership_test.go and operatingsystem_visibility_test.go
into operatingsystem_test.go (handler), and
operatingsystem_providervisibility_test.go into operatingsystem_test.go (db
model), following the one-test-file-per-type convention. No test logic changes.
Signed-off-by: Patrice Breton <pbreton@nvidia.com>
@pbreton
pbreton requested a review from a team as a code owner July 24, 2026 02:23
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1382fca1-a3d0-4bcf-a2ba-6c269f5eb393

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Operating System handlers now derive authorization from provider and tenant roles, persist provider- or tenant-owned records, enforce site-scoped visibility, and authorize updates and deletes by ownership. DAO filters, tests, and OpenAPI descriptions reflect the new behavior.

Changes

Operating System access control

Layer / File(s) Summary
Create ownership and site validation
rest-api/api/pkg/api/handler/operatingsystem.go, rest-api/api/pkg/api/handler/operatingsystem_test.go, rest-api/openapi/spec.yaml
Creation derives provider or tenant ownership from caller roles, restricts provider admins to templated iPXE systems, validates owner-scoped names and target sites, and persists the selected owner.
Listing visibility and DAO filtering
rest-api/api/pkg/api/handler/operatingsystem.go, rest-api/db/pkg/db/model/operatingsystem.go, rest-api/api/pkg/api/handler/operatingsystem_test.go, rest-api/db/pkg/db/model/operatingsystem_test.go, rest-api/openapi/spec.yaml
Listing supports provider-only, tenant-only, and dual-role visibility; tenant-admin provider records require associations with accessible sites.
Single-resource visibility
rest-api/api/pkg/api/handler/operatingsystem.go, rest-api/api/pkg/api/handler/operatingsystem_test.go, rest-api/openapi/spec.yaml
Single-record reads authorize matching ownership and permit tenant-admin access to provider-owned systems associated with accessible sites.
Update and delete ownership enforcement
rest-api/api/pkg/api/handler/operatingsystem.go, rest-api/api/pkg/api/handler/operatingsystem_test.go
Updates and deletes authorize tenant or provider ownership, scope update name checks by owner, and condition instance checks on tenant context.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant OperatingSystemHandler
  participant TenantSite
  participant OperatingSystemSQLDAO
  Caller->>OperatingSystemHandler: request Operating System access
  OperatingSystemHandler->>TenantSite: resolve tenant-accessible sites
  OperatingSystemHandler->>OperatingSystemSQLDAO: apply ownership and site visibility filters
  OperatingSystemSQLDAO-->>OperatingSystemHandler: return authorized Operating Systems
  OperatingSystemHandler-->>Caller: response or forbidden status
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the provider ownership and tenant visibility changes for templated iPXE operating systems.
Description check ✅ Passed The description is directly aligned with the changeset and accurately describes the provider capability and tenant visibility work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@pbreton
pbreton marked this pull request as draft July 24, 2026 02:24
@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@pbreton

pbreton commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔐 TruffleHog Secret Scan

No secrets or credentials found!

Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉

🔗 View scan details

🕐 Last updated: 2026-07-24 02:27:00 UTC | Commit: d0425e8

Send tenant_organization_id only for tenant-owned Operating Systems so provider-owned definitions remain provider-owned when synchronized to Core. Clarify reconciliation ownership and cover both request variants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant