From 407530af8f2b834fdc7628fb26b35b0aa1816cb2 Mon Sep 17 00:00:00 2001 From: Bryan Cox Date: Wed, 17 Jun 2026 06:11:14 -0400 Subject: [PATCH] fix(OCPBUGS-88531): Remove CPO-side restart logic for CNO operands CNO now handles restart-date annotation propagation to all its operands (multus-admission-controller, network-node-identity, ovnkube-control-plane, cloud-network-config-controller) directly via the fix in CNO PR #3030. The CPO-side restart logic for these deployments is now redundant and can be removed. Co-Authored-By: Claude Opus 4.6 --- .../hostedcontrolplane_controller.go | 24 --------------- .../hostedcontrolplane/manifests/cno.go | 30 ------------------- .../hostedcontrolplane/v2/cno/component.go | 24 --------------- 3 files changed, 78 deletions(-) diff --git a/control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go b/control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go index 5861a1fda10d..586a188dce97 100644 --- a/control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go +++ b/control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go @@ -2021,30 +2021,6 @@ func (r *HostedControlPlaneReconciler) reconcileValidIDPConfigurationCondition(c } func (r *HostedControlPlaneReconciler) cleanupClusterNetworkOperatorResources(ctx context.Context, hcp *hyperv1.HostedControlPlane, hasRouteCap bool) error { - if restartAnnotation, ok := hcp.Annotations[hyperv1.RestartDateAnnotation]; ok { - // CNO manages overall multus-admission-controller deployment. CPO manages restarts. - // TODO: why is this not done in CNO? - // Only restart multus deployment if Multus is not disabled - if !netutil.IsDisableMultiNetwork(hcp) { - multusDeployment := manifests.MultusAdmissionControllerDeployment(hcp.Namespace) - if err := cnov2.SetRestartAnnotationAndPatch(ctx, r.Client, multusDeployment, restartAnnotation); err != nil { - return fmt.Errorf("failed to restart multus admission controller: %w", err) - } - } - - // CNO manages overall network-node-identity deployment. CPO manages restarts. - networkNodeIdentityDeployment := manifests.NetworkNodeIdentityDeployment(hcp.Namespace) - if err := cnov2.SetRestartAnnotationAndPatch(ctx, r.Client, networkNodeIdentityDeployment, restartAnnotation); err != nil { - return fmt.Errorf("failed to restart network node identity: %w", err) - } - - // CNO manages overall ovnkube-control-plane deployment. CPO manages restarts. Note that cnov2.SetRestartAnnotationAndPatch just returns err == nil if the deployment isn't found (so if OVN isn't being used) - ovnKubeControlPlaneDeployment := manifests.OVNKubeControlPlaneDeployment(hcp.Namespace) - if err := cnov2.SetRestartAnnotationAndPatch(ctx, r.Client, ovnKubeControlPlaneDeployment, restartAnnotation); err != nil { - return fmt.Errorf("failed to restart ovnkube-control-plane: %w", err) - } - } - // Clean up ovnkube-sbdb Route if exists if hasRouteCap { if _, err := k8sutil.DeleteIfNeeded(ctx, r.Client, manifests.OVNKubeSBDBRoute(hcp.Namespace)); err != nil { diff --git a/control-plane-operator/controllers/hostedcontrolplane/manifests/cno.go b/control-plane-operator/controllers/hostedcontrolplane/manifests/cno.go index b27d1911df3d..695b4421682f 100644 --- a/control-plane-operator/controllers/hostedcontrolplane/manifests/cno.go +++ b/control-plane-operator/controllers/hostedcontrolplane/manifests/cno.go @@ -10,9 +10,6 @@ import ( ) const clusterNetworkOperator = "cluster-network-operator" -const multusAdmissionController = "multus-admission-controller" -const networkNodeIdentity = "network-node-identity" -const ovnKubeControlPlane = "ovnkube-control-plane" func ClusterNetworkOperatorDeployment(ns string) *appsv1.Deployment { return &appsv1.Deployment{ @@ -50,33 +47,6 @@ func ClusterNetworkOperatorServiceAccount(namespace string) *corev1.ServiceAccou } } -func MultusAdmissionControllerDeployment(namespace string) *appsv1.Deployment { - return &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: namespace, - Name: multusAdmissionController, - }, - } -} - -func NetworkNodeIdentityDeployment(namespace string) *appsv1.Deployment { - return &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: namespace, - Name: networkNodeIdentity, - }, - } -} - -func OVNKubeControlPlaneDeployment(namespace string) *appsv1.Deployment { - return &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: namespace, - Name: ovnKubeControlPlane, - }, - } -} - func OVNKubeSBDBRoute(namespace string) *routev1.Route { return &routev1.Route{ ObjectMeta: metav1.ObjectMeta{ diff --git a/control-plane-operator/controllers/hostedcontrolplane/v2/cno/component.go b/control-plane-operator/controllers/hostedcontrolplane/v2/cno/component.go index 139e1163995f..bd98a41c04d1 100644 --- a/control-plane-operator/controllers/hostedcontrolplane/v2/cno/component.go +++ b/control-plane-operator/controllers/hostedcontrolplane/v2/cno/component.go @@ -1,7 +1,6 @@ package cno import ( - "context" "errors" "fmt" @@ -13,7 +12,6 @@ import ( "github.com/openshift/hypershift/support/podspec" appsv1 "k8s.io/api/apps/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/utils/ptr" @@ -82,28 +80,6 @@ func isAroHCP(cpContext component.WorkloadContext) bool { return azureutil.IsAroHCPByHCP(cpContext.HCP) } -func SetRestartAnnotationAndPatch(ctx context.Context, crclient client.Client, dep *appsv1.Deployment, restartAnnotation string) error { - if err := crclient.Get(ctx, client.ObjectKeyFromObject(dep), dep); err != nil { - if apierrors.IsNotFound(err) { - return nil - } - return fmt.Errorf("failed retrieve deployment: %w", err) - } - - patch := dep.DeepCopy() - podMeta := patch.Spec.Template.ObjectMeta - if podMeta.Annotations == nil { - podMeta.Annotations = map[string]string{} - } - podMeta.Annotations[hyperv1.RestartDateAnnotation] = restartAnnotation - - if err := crclient.Patch(ctx, patch, client.MergeFrom(dep)); err != nil { - return fmt.Errorf("failed to set restart annotation: %w", err) - } - - return nil -} - type operand struct { DeploymentName string ContainerName string