Skip to content

Commit 00dea50

Browse files
committed
fix: Replace selector label strip patch with migration Job for upgrade-safe selector uniqueness
Signed-off-by: ntkathole <nikhilkathole2683@gmail.com>
1 parent f77bd1d commit 00dea50

6 files changed

Lines changed: 134 additions & 20 deletions

File tree

infra/feast-operator/config/overlays/odh/kustomization.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ namespace: opendatahub
66

77
resources:
88
- ../../default
9+
- selector_migration_job.yaml
910

1011

1112
patches:
1213
# patch to remove default `system` namespace in ../../manager/manager.yaml
1314
- path: delete-namespace.yaml
14-
# Remove app.kubernetes.io/name from the Deployment selector to avoid
15-
# immutable spec.selector errors on upgrade. The label remains in the
16-
# pod template so the metrics Service selector still targets only
17-
# feast-operator pods.
18-
- path: remove_selector_label_patch.yaml
19-
target:
20-
kind: Deployment
21-
name: controller-manager
2215

2316
configMapGenerator:
2417
- name: feast-operator-parameters
@@ -70,3 +63,13 @@ replacements:
7063
name: controller-manager
7164
fieldPaths:
7265
- spec.template.spec.containers.[name=manager].env.[name=OIDC_ISSUER_URL].value
66+
- source:
67+
kind: ConfigMap
68+
name: feast-operator-parameters
69+
fieldPath: data.RELATED_IMAGE_CRON_JOB
70+
targets:
71+
- select:
72+
kind: Job
73+
name: selector-migration
74+
fieldPaths:
75+
- spec.template.spec.containers.[name=migrate].image

infra/feast-operator/config/overlays/odh/remove_selector_label_patch.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: selector-migration
5+
namespace: system
6+
labels:
7+
app.kubernetes.io/name: feast-operator
8+
app.kubernetes.io/managed-by: kustomize
9+
spec:
10+
ttlSecondsAfterFinished: 300
11+
backoffLimit: 3
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: feast-operator
16+
spec:
17+
serviceAccountName: controller-manager
18+
restartPolicy: Never
19+
securityContext:
20+
runAsNonRoot: true
21+
seccompProfile:
22+
type: RuntimeDefault
23+
containers:
24+
- name: migrate
25+
image: origin-cli:latest
26+
securityContext:
27+
allowPrivilegeEscalation: false
28+
capabilities:
29+
drop:
30+
- ALL
31+
resources:
32+
requests:
33+
memory: "64Mi"
34+
cpu: "100m"
35+
limits:
36+
memory: "128Mi"
37+
cpu: "200m"
38+
command:
39+
- /bin/sh
40+
- -c
41+
- |
42+
set -e
43+
DEPLOY="feast-operator-controller-manager"
44+
NS="$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)"
45+
46+
HAS_LABEL=$(oc get deployment "$DEPLOY" -n "$NS" \
47+
-o jsonpath='{.spec.selector.matchLabels.app\.kubernetes\.io/name}' 2>/dev/null || true)
48+
49+
if [ -z "$HAS_LABEL" ]; then
50+
echo "Deployment $DEPLOY has old or missing selector."
51+
echo "Deleting so it can be recreated with the correct selector..."
52+
oc delete deployment "$DEPLOY" -n "$NS" --ignore-not-found=true
53+
echo "Done. The operator will recreate the Deployment."
54+
else
55+
echo "Deployment selector is already correct, no migration needed."
56+
fi

infra/feast-operator/config/overlays/rhoai/kustomization.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ namespace: redhat-ods-applications
66

77
resources:
88
- ../../default
9+
- selector_migration_job.yaml
910

1011

1112
patches:
1213
# patch to remove default `system` namespace in ../../manager/manager.yaml
1314
- path: delete-namespace.yaml
14-
# Remove app.kubernetes.io/name from the Deployment selector to avoid
15-
# immutable spec.selector errors on upgrade. The label remains in the
16-
# pod template so the metrics Service selector still targets only
17-
# feast-operator pods.
18-
- path: remove_selector_label_patch.yaml
19-
target:
20-
kind: Deployment
21-
name: controller-manager
2215

2316
configMapGenerator:
2417
- name: feast-operator-parameters
@@ -70,3 +63,13 @@ replacements:
7063
name: controller-manager
7164
fieldPaths:
7265
- spec.template.spec.containers.[name=manager].env.[name=OIDC_ISSUER_URL].value
66+
- source:
67+
kind: ConfigMap
68+
name: feast-operator-parameters
69+
fieldPath: data.RELATED_IMAGE_CRON_JOB
70+
targets:
71+
- select:
72+
kind: Job
73+
name: selector-migration
74+
fieldPaths:
75+
- spec.template.spec.containers.[name=migrate].image

infra/feast-operator/config/overlays/rhoai/remove_selector_label_patch.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: selector-migration
5+
namespace: system
6+
labels:
7+
app.kubernetes.io/name: feast-operator
8+
app.kubernetes.io/managed-by: kustomize
9+
spec:
10+
ttlSecondsAfterFinished: 300
11+
backoffLimit: 3
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: feast-operator
16+
spec:
17+
serviceAccountName: controller-manager
18+
restartPolicy: Never
19+
securityContext:
20+
runAsNonRoot: true
21+
seccompProfile:
22+
type: RuntimeDefault
23+
containers:
24+
- name: migrate
25+
image: origin-cli:latest
26+
securityContext:
27+
allowPrivilegeEscalation: false
28+
capabilities:
29+
drop:
30+
- ALL
31+
resources:
32+
requests:
33+
memory: "64Mi"
34+
cpu: "100m"
35+
limits:
36+
memory: "128Mi"
37+
cpu: "200m"
38+
command:
39+
- /bin/sh
40+
- -c
41+
- |
42+
set -e
43+
DEPLOY="feast-operator-controller-manager"
44+
NS="$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)"
45+
46+
HAS_LABEL=$(oc get deployment "$DEPLOY" -n "$NS" \
47+
-o jsonpath='{.spec.selector.matchLabels.app\.kubernetes\.io/name}' 2>/dev/null || true)
48+
49+
if [ -z "$HAS_LABEL" ]; then
50+
echo "Deployment $DEPLOY has old or missing selector."
51+
echo "Deleting so it can be recreated with the correct selector..."
52+
oc delete deployment "$DEPLOY" -n "$NS" --ignore-not-found=true
53+
echo "Done. The operator will recreate the Deployment."
54+
else
55+
echo "Deployment selector is already correct, no migration needed."
56+
fi

0 commit comments

Comments
 (0)