feat: Infer tenant/provider ID from user's org membership#217
Draft
parmani-nv wants to merge 1 commit intoNVIDIA:mainfrom
Draft
feat: Infer tenant/provider ID from user's org membership#217parmani-nv wants to merge 1 commit intoNVIDIA:mainfrom
parmani-nv wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Replace explicit infrastructureProviderId and tenantId query parameters with automatic inference via the IsProviderOrTenant helper, aligning allocation and instancetype handlers with the pattern established by ipblock and site handlers. - Allocation GetAll/GetByID: replace manual provider/tenant validation with IsProviderOrTenant and dual-query-merge pattern using mapset - InstanceType GetAll/GetByID: same pattern migration from GetIsProviderRequest to IsProviderOrTenant - Instance/InstanceBatch create: infer TenantID from org when not provided in request body - Make TenantID optional in instance create request validation - Remove redundant ValidateOrgMembership calls (already performed inside IsProviderOrTenant) - Deprecate explicit infrastructureProviderId and tenantId query params - Fix siteId swagger annotation: marked as required (true) but code never enforced it — changed to optional (false) to match actual behavior, consistent with ipblock handler - Update tests to reflect inferred ID behavior Signed-off-by: Parham Armani <parmani@nvidia.com>
hwadekar-nv
reviewed
Mar 9, 2026
|
|
||
| // Create response | ||
| var filterTenantIDs []uuid.UUID | ||
| if provider != nil { |
Contributor
There was a problem hiding this comment.
Shouldn't be here 'tenant' instead provider?
Contributor
|
@parmani-nv Can we move this out of draft? Any implementation missing or is it ready to review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removes the need for callers to pass explicit
infrastructureProviderIdandtenantIdquery parameters on Allocation and InstanceType read endpoints by inferring the caller's provider/tenant identity directly from their org membership, aligning these handlers with the pattern already established by the IPBlock and Site handlers.Allocation (GetAll / GetByID)
IsProviderOrTenant.infrastructureProviderIdis fully deprecated.tenantIdis demoted to an optional provider-side filter (ignored when the caller only has the Tenant role).InstanceType (GetAll / GetByID)
GetIsProviderRequest(which required a disambiguation query param for dual-role users) toIsProviderOrTenantwith the same dual-query-merge pattern.infrastructureProviderIdandtenantIdquery params are deprecated.Instance / InstanceBatch Create
tenantIdin the request body is now optional; when omitted, the tenant is inferred from the caller's org membership.ValidateOrgMembershipcalls removed (already performed insideIsProviderOrTenant/GetTenantForOrg).Swagger / OpenAPI fixes
siteIdannotation on the Allocation and InstanceType endpoints fromrequired: truetorequired: false, matching actual runtime behaviour (the field was never enforced as required in code).Tests
Type of Change
Services Affected
Related Issues (Optional)
Breaking Changes
What changes:
The
infrastructureProviderIdandtenantIdquery parameters onGET /allocationandGET /instance-type(list and by-ID) are now deprecated and no longer required. Clients that currently pass them will not break — provider-sidetenantIdstill works as a filter — but the enforcement that at least one must be present is removed. Any integration test or client that asserted a 400 response when those params were absent will need to be updated.The
tenantIdfield in thePOST /instanceandPOST /instance/batchrequest body is now optional. Existing callers that supply it continue to work; the value is cross-validated against the org's inferred tenant.