@@ -23,7 +23,6 @@ import (
2323
2424 "github.com/go-logr/logr"
2525 appsv1 "k8s.io/api/apps/v1"
26- v1 "k8s.io/api/batch/v1"
2726 corev1 "k8s.io/api/core/v1"
2827 apiErrors "k8s.io/apimachinery/pkg/api/errors"
2928 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -75,15 +74,6 @@ func Migrate(ctx context.Context, log logr.Logger, c client.Client) error {
7574}
7675
7776func migrate (ctx context.Context , log logr.Logger , c client.Client ) error {
78- if err := removeWhereaboutsIPReconcileCronJob (ctx , log , c ); err != nil {
79- // not critical for the operator operation, safer to ignore
80- log .V (consts .LogLevelWarning ).Info ("ignore error during whereabouts CronJob removal" )
81- }
82- if err := removeStateLabelFromNVIpamConfigMap (ctx , log , c ); err != nil {
83- // critical for the operator operation, will fail NVIPAM migration
84- log .V (consts .LogLevelError ).Error (err , "error trying to remove state label on NV IPAM configmap" )
85- return err
86- }
8777 if err := handleSingleMofedDS (ctx , log , c ); err != nil {
8878 // critical for the operator operation, will fail Mofed migration
8979 log .V (consts .LogLevelError ).Error (err , "error trying to handle single MOFED DS" )
@@ -92,64 +82,6 @@ func migrate(ctx context.Context, log logr.Logger, c client.Client) error {
9282 return nil
9383}
9484
95- // reason: update whereabouts to version v0.6.1 in network-operator v23.4.0
96- // remove whereabouts-ip-reconciler CronJob from network-operator namespace
97- // IP reconciliation logic is now built in whereabouts, and we don't need to deploy CronJob separately.
98- // The network-operator will not deploy CronJob for new deployments anymore, and we also need to remove the job
99- // which were deployed by the previous Network-operator version.
100- func removeWhereaboutsIPReconcileCronJob (ctx context.Context , log logr.Logger , c client.Client ) error {
101- namespace := config .FromEnv ().State .NetworkOperatorResourceNamespace
102- cronJobName := "whereabouts-ip-reconciler"
103- err := c .Delete (ctx , & v1.CronJob {ObjectMeta : metav1.ObjectMeta {Namespace : namespace , Name : cronJobName }})
104- if err == nil {
105- log .V (consts .LogLevelDebug ).Info ("whereabouts IP reconciler CronJob removed" )
106- return nil
107- }
108- if ! apiErrors .IsNotFound (err ) {
109- log .V (consts .LogLevelError ).Error (err , "failed to remove whereabouts IP reconciler CronJob" )
110- return err
111- }
112- return nil
113- }
114-
115- // reason: remove state label on NV IPAM config map if exists, to allow migration to IPPool CR
116- // If the state label is present, the config map will be removed by the NCP Controller as a stale object
117- func removeStateLabelFromNVIpamConfigMap (ctx context.Context , log logr.Logger , c client.Client ) error {
118- namespace := config .FromEnv ().State .NetworkOperatorResourceNamespace
119- cmName := "nvidia-k8s-ipam-config"
120- cfg := & corev1.ConfigMap {}
121- key := types.NamespacedName {
122- Name : cmName ,
123- Namespace : namespace ,
124- }
125- err := c .Get (ctx , key , cfg )
126- if apiErrors .IsNotFound (err ) {
127- log .V (consts .LogLevelDebug ).Info ("NVIPAM config map not found, skip remove state label" )
128- return nil
129- } else if err != nil {
130- log .V (consts .LogLevelError ).Error (err , "fail to get NVIPAM configmap" )
131- return err
132- }
133- _ , ok := cfg .Labels [consts .StateLabel ]
134- if ok {
135- log .V (consts .LogLevelDebug ).Info ("clear State label from NVIPAM configmap" )
136- patch := []byte (fmt .Sprintf ("[{\" op\" : \" remove\" , \" path\" : \" /metadata/labels/%s\" }]" , consts .StateLabel ))
137- err = c .Patch (ctx , & corev1.ConfigMap {
138- ObjectMeta : metav1.ObjectMeta {
139- Name : cmName ,
140- Namespace : namespace ,
141- },
142- }, client .RawPatch (types .JSONPatchType , patch ))
143- if err != nil {
144- log .V (consts .LogLevelError ).Error (err , "fail to remove State label from NVIPAM configmap" )
145- return err
146- }
147- } else {
148- log .V (consts .LogLevelDebug ).Info ("state label not set on NVIPAM configmap" )
149- }
150- return nil
151- }
152-
15385func handleSingleMofedDS (ctx context.Context , log logr.Logger , c client.Client ) error {
15486 ncp := & mellanoxv1alpha1.NicClusterPolicy {}
15587 key := types.NamespacedName {
0 commit comments