Resolve the product variant once at startup - #5131
Conversation
The operator runs as a single variant for the lifetime of the process, and restarts when the Installation asks for a different one.
Reuses the informer the controllers already have for Installation instead of opening a second watch with a hand-built REST client.
Drops the hand-rolled client-go informer and its unstoppable goroutine. The shared cache isn't filtered, so the handler matches on name and namespace.
The installation controller no longer reboots the operator; the variant watch handles that. Missing Enterprise CRDs now fail at startup with a message rather than degrading on every reconcile.
It reports whether the cluster serves the Calico Enterprise APIs, which is no longer the same question as whether to start those controllers.
Controller registration and reconcile decisions use the variant the process booted as. GetInstallationSpec no longer returns the status variant, the enterprise-CRD-exists option is gone, and fillDefaults defaults to the process variant so main and the installation controller agree.
EnterpriseCRDsExist meant the enterprise CRDs were present, not that the operator ran as Enterprise. The mainline and pool suites install Calico.
updateCRDs read the spec variant before the overlay was merged in, so an overlay that set the variant would get the wrong CRD set.
The bootstrap flag now only ever selects which CRDs to install. Splits the non-blocking lookup out so the variant watch shares it.
| provider: opts.DetectedProvider, | ||
| clusterDomain: opts.ClusterDomain, | ||
| allowedTLSAssets: allowedAssets(opts.ClusterDomain), | ||
| enterprise: opts.Variant.IsEnterprise(), |
There was a problem hiding this comment.
Nit, could you rename the variable to isEnterprise just so it's apparent this is a bool when reading it / answering the question if it's enterprise or not.
| tierWatchReady: &utils.ReadyFlag{}, | ||
| status: status.New(mgr.GetClient(), "gatewayapi", opts.KubernetesVersion), | ||
| clusterDomain: opts.ClusterDomain, | ||
| variant: opts.Variant, |
There was a problem hiding this comment.
In some places you've change this to enterprise as a bool, and some you've just passed on the variant. Is there a reason to do this differently, or can we pass the variant everywhere or just pass the enterprise?
| } | ||
|
|
||
| // Resolve the variant now that the operator CRDs exist. | ||
| bootVariant := waitForVariant(ctx, c, setupLog) |
There was a problem hiding this comment.
This isn't the boot variant now, is it? It's the real variant, or am I missing something?
| log.Error(err, "Failed to read the Installation, will retry") | ||
| case variant != "": | ||
| return variant | ||
| case !waiting: |
There was a problem hiding this comment.
Is the point of the waiting variable just so that we log that info once?
| waiting = true | ||
| } | ||
|
|
||
| select { |
There was a problem hiding this comment.
I wonder if it would be more effective to add a watch instead of poll, since we require a change to happen if the variant isn't set.
The operator decides which variant it is running in four places: the
--variantflag, Enterprise CRD discovery, the Installation spec, and the Installation status. The one gating most controllers is CRD discovery, which is not what the user set and stays true after a downgrade because the CRDs outlive the variant change.This resolves the variant once from the Installation before any controller starts, and restarts the operator from a single watch when it changes. Design: https://github.com/tigera/designs/pull/89 (CORE-13240).
Description
mainfrom the Installation, merging the overlay, and passed to controllers as one optionGetInstallationSpecno longer returns the status variant, so controllers cannot re-derive it--variantflag is now bootstrap-only and validated; an unrecognised value used to be treated as Calico, which installs the wrong CRDs for the bootstrap-crds path where nothing runs afterwards to correct themupdateCRDsinstalls CRDs for the overlay-merged variant. It read the spec variant before the overlay was merged in, so an overlay that set the variant got the wrong CRD set.fillDefaultsdefaults to the process variant instead of hardcoding Calico, so it andmaincannot disagreeBehaviour changes worth calling out:
fillDefaultsoverrode it to Calico.Also fixes a latent ImageSet bug. During an Enterprise install the status variant lags the spec, so controllers asked for a
calico-ImageSet.GetImageSetonly errors when an ImageSet with the matching prefix exists, so on a cluster carrying onlyenterprise-<version>it found nothing, returned no error, and the components deployed with built-in image tags. Air-gapped clusters fail to pull; everyone else silently gets floating tags instead of the digests they pinned.