Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ func runStartCmd(_ *cobra.Command, _ []string) {
ctrlctx.KubeNamespacedInformerFactory.Core().V1().Secrets(),
ctrlctx.KubeNamespacedInformerFactory.Core().V1().ConfigMaps(),
ctrlctx.ConfigInformerFactory.Config().V1().Infrastructures(),
ctrlctx.ConfigInformerFactory,
ctrlctx.FeatureGatesHandler,
)
if err != nil {
klog.Fatalf("unable to start cert rotation controller: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ require (
github.com/onsi/gomega v1.38.2
github.com/opencontainers/go-digest v1.0.0
github.com/openshift-eng/openshift-tests-extension v0.0.0-20260127124016-0fed2b824818
github.com/openshift/api v0.0.0-20260326111139-30c2ef7a272e
github.com/openshift/api v0.0.0-20260408160412-464776f95207
github.com/openshift/client-go v0.0.0-20260330134249-7e1499aaacd7
github.com/openshift/library-go v0.0.0-20260303171201-5d9eb6295ff6
github.com/openshift/library-go v0.0.0-20260409165127-c57da2bf5720
github.com/openshift/runtime-utils v0.0.0-20230921210328-7bdb5b9c177b
github.com/prometheus/client_golang v1.23.2
github.com/rs/zerolog v1.34.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ github.com/opencontainers/selinux v1.13.0 h1:Zza88GWezyT7RLql12URvoxsbLfjFx988+L
github.com/opencontainers/selinux v1.13.0/go.mod h1:XxWTed+A/s5NNq4GmYScVy+9jzXhGBVEOAyucdRUY8s=
github.com/openshift-eng/openshift-tests-extension v0.0.0-20260127124016-0fed2b824818 h1:jJLE/aCAqDf8U4wc3bE1IEKgIxbb0ICjCNVFA49x/8s=
github.com/openshift-eng/openshift-tests-extension v0.0.0-20260127124016-0fed2b824818/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
github.com/openshift/api v0.0.0-20260326111139-30c2ef7a272e h1:SbgwHvkc6vgiqHOfGrbumjPvtOvJmCwJoFEwr7rAKzY=
github.com/openshift/api v0.0.0-20260326111139-30c2ef7a272e/go.mod h1:pyVjK0nZ4sRs4fuQVQ4rubsJdahI1PB94LnQ8sGdvxo=
github.com/openshift/api v0.0.0-20260408160412-464776f95207 h1:56S2U6pUgD3uYe8cQMsaBxQmUWIBpFw9YHOPFvfdfN4=
github.com/openshift/api v0.0.0-20260408160412-464776f95207/go.mod h1:pyVjK0nZ4sRs4fuQVQ4rubsJdahI1PB94LnQ8sGdvxo=
github.com/openshift/client-go v0.0.0-20260330134249-7e1499aaacd7 h1:5GSoQlywIwYsRCw3qN+ZDmN6HrXTMZfI33bdRNm2jRQ=
github.com/openshift/client-go v0.0.0-20260330134249-7e1499aaacd7/go.mod h1:HhXTUIMhgzxR3Ln/zEkr4QjTL0NN7A+t9Py/we9j2ug=
github.com/openshift/kubernetes v1.30.1-0.20260305123649-d18f3f005eaa h1:/gPMWR7fdCC3S4wHALD6Em+vztl1q9/cOpdMkFZwDus=
Expand Down Expand Up @@ -675,8 +675,8 @@ github.com/openshift/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0
github.com/openshift/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0-20260305123649-d18f3f005eaa/go.mod h1:6wqqkK0+5hV+CLJ3uz9A1lkjxXRvkbq+5RnZdUZx/H8=
github.com/openshift/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20260305123649-d18f3f005eaa h1:JY4k94JmDGQp2Pj94Cw2xtIjs7MpPkU9n8zNPDTbiKo=
github.com/openshift/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20260305123649-d18f3f005eaa/go.mod h1:CnFDBq5NGnfOSMeOP8l4SNYJrxK6Z1kUaKdu3Qq9Uik=
github.com/openshift/library-go v0.0.0-20260303171201-5d9eb6295ff6 h1:xjqy0OolrFdJ+ofI/aD0+2k9+MSk5anP5dXifFt539Q=
github.com/openshift/library-go v0.0.0-20260303171201-5d9eb6295ff6/go.mod h1:D797O/ssKTNglbrGchjIguFq+DbyRYdeds5w4/VTrKM=
github.com/openshift/library-go v0.0.0-20260409165127-c57da2bf5720 h1:ljxETzJc/vDgMJlaSB8GRryBHZOAIENA2Wo5arD8avM=
github.com/openshift/library-go v0.0.0-20260409165127-c57da2bf5720/go.mod h1:3bi4pLpYRdVd1aEhsHfRTJkwxwPLfRZ+ZePn3RmJd2k=
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20251120221002-696928a6a0d7 h1:02E4Ttpu+7yCQLQxtY42JfcfHU7TBGnje6uB2ytBSdU=
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20251120221002-696928a6a0d7/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
github.com/openshift/runtime-utils v0.0.0-20230921210328-7bdb5b9c177b h1:oXzC1N6E9gw76/WH2gEA8GEHvuq09wuVQ9GoCuR8GF4=
Expand Down
49 changes: 33 additions & 16 deletions pkg/controller/certrotation/certrotation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ import (
"k8s.io/utils/clock"

configv1 "github.com/openshift/api/config/v1"
features "github.com/openshift/api/features"
configclientset "github.com/openshift/client-go/config/clientset/versioned"
configinformersexternal "github.com/openshift/client-go/config/informers/externalversions"
machineclientset "github.com/openshift/client-go/machine/clientset/versioned"

"github.com/openshift/library-go/pkg/controller/factory"
"github.com/openshift/library-go/pkg/operator/certrotation"
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/pki"

aroclientset "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"

Expand Down Expand Up @@ -82,10 +85,25 @@ func New(
mcoSecretInformer coreinformersv1.SecretInformer,
mcoConfigMapInfomer coreinformersv1.ConfigMapInformer,
infraInformer configinformers.InfrastructureInformer,
configInformerFactory configinformersexternal.SharedInformerFactory,
featureGatesHandler ctrlcommon.FeatureGatesHandler,
) (*CertRotationController, error) {

recorder := events.NewLoggingEventRecorder(componentName, clock.RealClock{})

cachesToSync := []cache.InformerSynced{
maoSecretInformer.Informer().HasSynced,
mcoSecretInformer.Informer().HasSynced,
mcoConfigMapInfomer.Informer().HasSynced,
infraInformer.Informer().HasSynced,
}

var pkiProfileProvider pki.PKIProfileProvider
if configInformerFactory != nil && featureGatesHandler != nil && featureGatesHandler.Enabled(features.FeatureGateConfigurablePKI) {
pkiProfileProvider = pki.NewClusterPKIProfileProvider(configInformerFactory.Config().V1alpha1().PKIs().Lister())
cachesToSync = append(cachesToSync, configInformerFactory.Config().V1alpha1().PKIs().Informer().HasSynced)
}

c := &CertRotationController{
kubeClient: kubeClient,
configClient: configClient,
Expand All @@ -95,12 +113,7 @@ func New(
mcoConfigMapInfomer: mcoConfigMapInfomer,
mcoSecretLister: mcoSecretInformer.Lister(),
maoSecretLister: maoSecretInformer.Lister(),
cachesToSync: []cache.InformerSynced{
maoSecretInformer.Informer().HasSynced,
mcoSecretInformer.Informer().HasSynced,
mcoConfigMapInfomer.Informer().HasSynced,
infraInformer.Informer().HasSynced,
},
cachesToSync: cachesToSync,

hostnamesRotation: &DynamicServingRotation{hostnamesChanged: make(chan struct{}, 10)},
hostnamesQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
Expand All @@ -124,12 +137,14 @@ func New(
JiraComponent: "Machine Config Operator",
Description: "CA used to sign the MachineConfigServer TLS certificate",
},
Validity: mcsCAExpiry,
Refresh: mcsCARefresh,
Informer: mcoSecretInformer,
Lister: c.mcoSecretLister,
Client: kubeClient.CoreV1(),
EventRecorder: recorder,
Validity: mcsCAExpiry,
Refresh: mcsCARefresh,
CertificateName: "machine-config.machine-config-server-signer",
PKIProfileProvider: pkiProfileProvider,
Informer: mcoSecretInformer,
Lister: c.mcoSecretLister,
Client: kubeClient.CoreV1(),
EventRecorder: recorder,
Comment on lines +140 to +147

@coderabbitai coderabbitai Bot Apr 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use the operator-scoped certificate names here.

These identifiers are what the configurable PKI flow keys on. Using machine-config.* here means a profile configured for the MCO certs under machine-config-operator.* will never be resolved, so the new feature silently falls back to the default profile.

Proposed fix
-			CertificateName:    "machine-config.machine-config-server-signer",
+			CertificateName:    "machine-config-operator.machine-config-server-signer",
...
-			CertificateName:    "machine-config.machine-config-server-serving",
+			CertificateName:    "machine-config-operator.machine-config-server-serving",

Also applies to: 174-179

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/controller/certrotation/certrotation_controller.go` around lines 140 -
147, The CertificateName value is using the cluster-scoped "machine-config.*"
identifier so configurable PKI profiles keyed under the operator-scoped names
are never matched; update the CertificateName fields in the cert rotation setup
(the entries that set CertificateName:
"machine-config.machine-config-server-signer" and the other similar occurrences
around lines 174-179) to use the operator-scoped names (e.g.,
"machine-config-operator.machine-config-server-signer" or the correct
operator-prefixed identifiers) so the PKIProfileProvider resolves the intended
profile; keep the surrounding parameters (Validity, Refresh, PKIProfileProvider,
Informer mcoSecretInformer, Lister c.mcoSecretLister, Client
kubeClient.CoreV1(), EventRecorder recorder) unchanged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

machine-config.* will be the configuration names.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanchezl, understood — machine-config.* is the intentional and correct naming convention for the PKI CertificateName values in this context. I'll note this for future reviews.


📝 Learnings were identified and not saved (knowledge base disabled). Enable

},
certrotation.CABundleConfigMap{
Namespace: ctrlcommon.MCONamespace,
Expand All @@ -156,10 +171,12 @@ func New(
Hostnames: c.hostnamesRotation.GetHostnames,
HostnamesChanged: c.hostnamesRotation.hostnamesChanged,
},
Informer: mcoSecretInformer,
Lister: c.mcoSecretLister,
Client: kubeClient.CoreV1(),
EventRecorder: recorder,
CertificateName: "machine-config.machine-config-server-serving",
PKIProfileProvider: pkiProfileProvider,
Informer: mcoSecretInformer,
Lister: c.mcoSecretLister,
Client: kubeClient.CoreV1(),
EventRecorder: recorder,
},
recorder,
NewCertRotationStatusReporter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (f *fixture) newController() *CertRotationController {
f.infraLister = append(f.infraLister, infra.(*configv1.Infrastructure))
}

c, err := New(f.kubeClient, f.configClient, f.machineClient, f.aroClient, f.k8sI.Core().V1().Secrets(), f.k8sI.Core().V1().Secrets(), f.k8sI.Core().V1().ConfigMaps(), f.infraInformer.Config().V1().Infrastructures())
c, err := New(f.kubeClient, f.configClient, f.machineClient, f.aroClient, f.k8sI.Core().V1().Secrets(), f.k8sI.Core().V1().Secrets(), f.k8sI.Core().V1().ConfigMaps(), f.infraInformer.Config().V1().Infrastructures(), nil, nil)
require.NoError(f.t, err)

c.StartInformers()
Expand Down
6 changes: 6 additions & 0 deletions vendor/github.com/openshift/api/.golangci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/openshift/api/config/v1/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion vendor/github.com/openshift/api/config/v1/types_dns.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading