-
Notifications
You must be signed in to change notification settings - Fork 277
CNTRLPLANE-3213: Enable configurable PKI for managed certificate rotation #2958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,15 @@ import ( | |
| "time" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| features "github.com/openshift/api/features" | ||
| configclient "github.com/openshift/client-go/config/clientset/versioned" | ||
| configinformers "github.com/openshift/client-go/config/informers/externalversions" | ||
| "github.com/openshift/library-go/pkg/controller/controllercmd" | ||
| "github.com/openshift/library-go/pkg/operator/configobserver/featuregates" | ||
| "github.com/openshift/library-go/pkg/operator/loglevel" | ||
| "github.com/openshift/library-go/pkg/operator/management" | ||
| "github.com/openshift/library-go/pkg/operator/managementstatecontroller" | ||
| pkipkg "github.com/openshift/library-go/pkg/pki" | ||
| "k8s.io/apimachinery/pkg/api/meta" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
|
|
@@ -27,6 +29,7 @@ import ( | |
| cnoclient "github.com/openshift/cluster-network-operator/pkg/client" | ||
| "github.com/openshift/cluster-network-operator/pkg/controller" | ||
| "github.com/openshift/cluster-network-operator/pkg/controller/connectivitycheck" | ||
| pkictrl "github.com/openshift/cluster-network-operator/pkg/controller/pki" | ||
| "github.com/openshift/cluster-network-operator/pkg/controller/statusmanager" | ||
| "github.com/openshift/cluster-network-operator/pkg/hypershift" | ||
| "github.com/openshift/cluster-network-operator/pkg/names" | ||
|
|
@@ -140,12 +143,35 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller | |
| return err | ||
| } | ||
|
|
||
| // Set up PKI profile provider if ConfigurablePKI is enabled. | ||
| // Register the PKI informer on the existing configInformers factory, | ||
| // re-start to pick it up (idempotent for already-running informers), | ||
| // and wait for cache sync before controllers start reconciling. | ||
| var pkiProfileProvider pkipkg.PKIProfileProvider | ||
| if featureGates.Enabled(features.FeatureGateConfigurablePKI) { | ||
| configInformers.Config().V1alpha1().PKIs().Informer() | ||
| configInformers.Start(wait.NeverStop) | ||
| for t, synced := range configInformers.WaitForCacheSync(wait.NeverStop) { | ||
| if !synced { | ||
| return fmt.Errorf("failed to sync config informer for %v", t) | ||
| } | ||
| } | ||
|
Comment on lines
+146
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Read the relevant section of the operator.go file
cat -n pkg/operator/operator.go | sed -n '140,170p'Repository: openshift/cluster-network-operator Length of output: 1500 🏁 Script executed: # Check imports to understand available context/wait utilities
head -n 50 pkg/operator/operator.go | cat -nRepository: openshift/cluster-network-operator Length of output: 2361 🏁 Script executed: # Search for other WaitForCacheSync usages in the codebase to understand patterns
rg 'WaitForCacheSync' -A 3 -B 1Repository: openshift/cluster-network-operator Length of output: 37944 🏁 Script executed: # Look at the broader function context around lines 146-158 to check available variables
cat -n pkg/operator/operator.go | sed -n '100,180p'Repository: openshift/cluster-network-operator Length of output: 3832 🏁 Script executed: # Find the function signature that contains this code block
sed -n '50,100p' pkg/operator/operator.go | cat -nRepository: openshift/cluster-network-operator Length of output: 2544 🏁 Script executed: # Search for the function name containing line 146-162
rg -B 50 'Set up PKI profile provider if ConfigurablePKI' pkg/operator/operator.go | head -70Repository: openshift/cluster-network-operator Length of output: 1808 Bound the PKI informer sync wait. Line 154 uses Suggested fix if featureGates.Enabled(features.FeatureGateConfigurablePKI) {
configInformers.Config().V1alpha1().PKIs().Informer()
configInformers.Start(wait.NeverStop)
- for t, synced := range configInformers.WaitForCacheSync(wait.NeverStop) {
+ syncCtx, cancel := context.WithTimeout(ctx, time.Minute)
+ defer cancel()
+ for t, synced := range configInformers.WaitForCacheSync(syncCtx.Done()) {
if !synced {
- return fmt.Errorf("failed to sync config informer for %v", t)
+ return fmt.Errorf("failed to sync config informer for %v before timeout", t)
}
}
pkiProfileProvider = pkipkg.NewClusterPKIProfileProvider(🤖 Prompt for AI Agents |
||
| pkiProfileProvider = pkipkg.NewClusterPKIProfileProvider( | ||
| configInformers.Config().V1alpha1().PKIs().Lister(), | ||
| ) | ||
| } | ||
|
|
||
| // Add controller-runtime controllers | ||
| klog.Info("Adding controller-runtime controllers") | ||
| if err := controller.AddToManager(o.manager, o.StatusManager, o.client, featureGates); err != nil { | ||
| return fmt.Errorf("failed to add controllers to manager: %w", err) | ||
| } | ||
|
|
||
| // Add PKI controller separately — it needs the PKI profile provider | ||
| if err := pkictrl.Add(o.manager, o.StatusManager, featureGates, pkiProfileProvider); err != nil { | ||
| return fmt.Errorf("failed to add pki controller: %w", err) | ||
| } | ||
|
|
||
| // Initialize individual (non-controller-runtime) controllers | ||
|
|
||
| // logLevelController reacts to changes in the operator spec loglevel | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compute
CertificateNamefrom theOperatorPKIresource name.Hardcoding
"network.signer"and"network.peer"makes everyOperatorPKIresolve the same PKI profile. That breaks per-resource algorithm selection for resources likeovnvsnetwork-node-identity.Proposed fix
Also applies to: 242-243
🤖 Prompt for AI Agents