feat: store AIWorkload CRs in a dedicated system namespace - #160
Draft
thbertoldi wants to merge 1 commit into
Draft
feat: store AIWorkload CRs in a dedicated system namespace#160thbertoldi wants to merge 1 commit into
thbertoldi wants to merge 1 commit into
Conversation
Consolidate AIWorkload custom resources into a single control-cluster namespace (default aif-workloads) instead of mirroring each workload's deployment namespace. The deployment target stays carried by Spec.TargetNamespace, decoupling where a workload's CR lives from where it deploys. - config: add GetWorkloadNamespace (WORKLOAD_NAMESPACE, default aif-workloads) - api: create stores the CR in the workload namespace regardless of the request path; add path-less POST /api/v1/aiworkloads route; update and delete keep addressing the CR by its real namespace so pre-migration CRs still work - chart: create the workload namespace and inject WORKLOAD_NAMESPACE - migrate: add an idempotent, restartable relocation tool (cmd/migrate) that recreates CRs in the workload namespace, strips the cleanup finalizer before deleting the source so the live workload is not torn down, sweeps orphaned pull-secret bundles, and skips name collisions - ui: decouple the CR namespace from spec.targetNamespace in the install and manage wizards - docs: add the Phase 2 migration runbook and Job manifest
thbertoldi
marked this pull request as draft
July 21, 2026 23:52
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.
Summary
Consolidates
AIWorkloadcustom resources into a single control-cluster namespace (defaultaif-workloads) instead of creating them in namespaces that mirror each workload's deployment target.Today an
AIWorkloadCR lands in a caller-supplied namespace taken from the API path, which sprawls namespaces on the control cluster and conflates two concerns: where the CR is stored (a control-plane bookkeeping location) versus where the workload deploys (already carried bySpec.TargetNamespace). This change makesSpec.TargetNamespacethe sole source of truth for deployment location and turns the CR's namespace into pure metadata.This is safe because the downstream deployment identity (Fleet Bundle / HelmOp / Helm release name, target namespace, target cluster) is derived from the CR's name + chart +
Spec.TargetNamespace+ cluster — never from the CR's own namespace. A relocated CR with the same name recomputes identical downstream names, so the operator re-adopts the already-running workload with no redeploy.Phase 1 — new workloads go to
aif-workloadsGetWorkloadNamespace()(envWORKLOAD_NAMESPACE, defaultaif-workloads).POST /api/v1/aiworkloadsroute. Update/delete keep addressing the CR by its real namespace so CRs created before this change still work during the transition.aif-workloadsnamespace (resource-policy: keep) and injectsWORKLOAD_NAMESPACEinto the manager. Operator cache stays cluster-scoped.AppWizard/BlueprintInstallWizardnow keepspec.targetNamespaceas the true deploy target and address the CR by its real namespace for updates (previouslyform.value.namespacedid double duty).Phase 2 — opt-in relocation of existing workloads
cmd/migrate(shipped in the operator image;make build-migrate): idempotent, restartable relocation that, per workload:aif-workloads(same name/spec/status, annotatedai-factory.suse.com/migrated-from).ai-factory.suse.com/cleanupfinalizer before deleting the source — the key safety step, so deletion does not tear down the live downstream workload.Name collisions are reported and skipped, never auto-renamed (a rename would change downstream identity). Runbook + Job manifest in
docs/migration/. Migration is opt-in and only runnable after the Phase 1 image is deployed.Testing
go build ./...,go vet,gofmtclean.spec.targetNamespacepreserved, path-less route); migration (relocate + finalizer-strip, already-in-place, collision-skip, resume partial run, dry-run, orphan-bundle sweep)./e2e) passes, including theaiworkloadandinstallaiextensioncontroller suites.Manual verification still needed
The UI create → manage(update) → delete round-trip — especially the App Instances "Manage" entry point — could not be exercised here and should be smoke-tested against a real cluster before merge.