Skip to content

Commit 21539f8

Browse files
committed
chore: remove old migrate flows
Signed-off-by: Fred Rolland <[email protected]>
1 parent 7b2710e commit 21539f8

File tree

2 files changed

+0
-98
lines changed

2 files changed

+0
-98
lines changed

pkg/migrate/migrate.go

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -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

7776
func 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-
15385
func handleSingleMofedDS(ctx context.Context, log logr.Logger, c client.Client) error {
15486
ncp := &mellanoxv1alpha1.NicClusterPolicy{}
15587
key := types.NamespacedName{

pkg/migrate/migrate_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,6 @@ var _ = Describe("Migrate", func() {
4343
_ = k8sClient.DeleteAllOf(goctx.Background(), &corev1.Node{})
4444
_ = k8sClient.DeleteAllOf(goctx.Background(), &corev1.Pod{})
4545
})
46-
It("should remove annotation on NVIPAM CM", func() {
47-
createConfigMap(true)
48-
err := Migrate(goctx.Background(), testLog, k8sClient)
49-
Expect(err).NotTo(HaveOccurred())
50-
cm := &corev1.ConfigMap{}
51-
err = k8sClient.Get(goctx.Background(),
52-
types.NamespacedName{Namespace: namespaceName, Name: nvIPAMcmName}, cm)
53-
Expect(err).NotTo(HaveOccurred())
54-
_, ok := cm.Labels[consts.StateLabel]
55-
Expect(ok).To(BeFalse())
56-
})
57-
It("should not fail if state label does not exists", func() {
58-
createConfigMap(false)
59-
err := Migrate(goctx.Background(), testLog, k8sClient)
60-
Expect(err).NotTo(HaveOccurred())
61-
})
62-
It("should not fail if NVIPAM CM does not exists", func() {
63-
err := Migrate(goctx.Background(), testLog, k8sClient)
64-
Expect(err).NotTo(HaveOccurred())
65-
})
6646
It("should delete MOFED DS", func() {
6747
upgrade.SetDriverName("ofed")
6848
createNCP()
@@ -91,16 +71,6 @@ var _ = Describe("Migrate", func() {
9171
})
9272
})
9373

94-
func createConfigMap(addLabel bool) {
95-
cm := &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Namespace: namespaceName, Name: nvIPAMcmName}}
96-
if addLabel {
97-
cm.Labels = make(map[string]string)
98-
cm.Labels[consts.StateLabel] = "state-nv-ipam-cni"
99-
}
100-
err := k8sClient.Create(goctx.Background(), cm)
101-
Expect(err).NotTo(HaveOccurred())
102-
}
103-
10474
func createMofedDS() {
10575
ds := &appsv1.DaemonSet{
10676
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)