Skip to content

Commit 83ab6f4

Browse files
authored
Merge pull request #155 from projectsyn/fix/restart-holder-suppress-error
Ignore `kubectl` error output when extracting current holder pod generation
2 parents fe79022 + f4b5147 commit 83ab6f4

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

component/restart-holder-ds.libsonnet

+13-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ local script = |||
3939
while true; do
4040
# assumption: holder plugin daemonset is called
4141
# `csi-cephfsplugin-holder-${cephcluster:name}`
42-
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-%(cephcluster_name)s -ojsonpath='{.metadata.generation}')
43-
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-%(cephcluster_name)s -ojsonpath='{.metadata.generation}')
42+
# note: we don't care about the value of the variable if the daemonset
43+
# isn't there, since we'll check for pods in a K8s `List` which will
44+
# simply be empty if the plugin isn't enabled.
45+
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-%(cephcluster_name)s -ojsonpath='{.metadata.generation}' 2>/dev/null)
46+
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-%(cephcluster_name)s -ojsonpath='{.metadata.generation}' 2>/dev/null)
4447
needs_update=$( (\
4548
kubectl get pods -l app=csi-cephfsplugin-holder --field-selector spec.nodeName=${NODE_NAME} -ojson |\
4649
jq --arg wanted_gen ${cephfs_holder_wanted_gen} \
@@ -86,11 +89,19 @@ local daemonset = kube.DaemonSet('syn-holder-updater') {
8689
'non-daemonset pods are running on the node) and then deletes any ' +
8790
'outdated csi holder pods. Outdated holder pods are identified by ' +
8891
'comparing the DaemonSet generation with the pod generation.',
92+
// set sync wave 10 for the daemonset to ensure that the ConfigMap is
93+
// updated first.
94+
'argocd.argoproj.io/sync-wave': '10',
8995
},
9096
namespace: params.namespace,
9197
},
9298
spec+: {
9399
template+: {
100+
metadata+: {
101+
annotations+: {
102+
'script-checksum': std.md5(script),
103+
},
104+
},
94105
spec+: {
95106
serviceAccountName: serviceaccount.metadata.name,
96107
containers_: {

tests/golden/cephfs/rook-ceph/rook-ceph/50_restart_holder_ds.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ data:
5757
while true; do
5858
# assumption: holder plugin daemonset is called
5959
# `csi-cephfsplugin-holder-${cephcluster:name}`
60-
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-cluster -ojsonpath='{.metadata.generation}')
61-
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-cluster -ojsonpath='{.metadata.generation}')
60+
# note: we don't care about the value of the variable if the daemonset
61+
# isn't there, since we'll check for pods in a K8s `List` which will
62+
# simply be empty if the plugin isn't enabled.
63+
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-cluster -ojsonpath='{.metadata.generation}' 2>/dev/null)
64+
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-cluster -ojsonpath='{.metadata.generation}' 2>/dev/null)
6265
needs_update=$( (\
6366
kubectl get pods -l app=csi-cephfsplugin-holder --field-selector spec.nodeName=${NODE_NAME} -ojson |\
6467
jq --arg wanted_gen ${cephfs_holder_wanted_gen} \
@@ -100,6 +103,7 @@ apiVersion: apps/v1
100103
kind: DaemonSet
101104
metadata:
102105
annotations:
106+
argocd.argoproj.io/sync-wave: '10'
103107
syn.tools/description: DaemonSet which waits for node to be drained (by waiting
104108
until no non-daemonset pods are running on the node) and then deletes any outdated
105109
csi holder pods. Outdated holder pods are identified by comparing the DaemonSet
@@ -120,7 +124,8 @@ spec:
120124
name: syn-holder-updater
121125
template:
122126
metadata:
123-
annotations: {}
127+
annotations:
128+
script-checksum: 488da91788ef6e501cece9d3d67ff8b0
124129
labels:
125130
app.kubernetes.io/component: rook-ceph
126131
app.kubernetes.io/managed-by: commodore

tests/golden/defaults/rook-ceph/rook-ceph/50_restart_holder_ds.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ data:
5757
while true; do
5858
# assumption: holder plugin daemonset is called
5959
# `csi-cephfsplugin-holder-${cephcluster:name}`
60-
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-cluster -ojsonpath='{.metadata.generation}')
61-
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-cluster -ojsonpath='{.metadata.generation}')
60+
# note: we don't care about the value of the variable if the daemonset
61+
# isn't there, since we'll check for pods in a K8s `List` which will
62+
# simply be empty if the plugin isn't enabled.
63+
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-cluster -ojsonpath='{.metadata.generation}' 2>/dev/null)
64+
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-cluster -ojsonpath='{.metadata.generation}' 2>/dev/null)
6265
needs_update=$( (\
6366
kubectl get pods -l app=csi-cephfsplugin-holder --field-selector spec.nodeName=${NODE_NAME} -ojson |\
6467
jq --arg wanted_gen ${cephfs_holder_wanted_gen} \
@@ -100,6 +103,7 @@ apiVersion: apps/v1
100103
kind: DaemonSet
101104
metadata:
102105
annotations:
106+
argocd.argoproj.io/sync-wave: '10'
103107
syn.tools/description: DaemonSet which waits for node to be drained (by waiting
104108
until no non-daemonset pods are running on the node) and then deletes any outdated
105109
csi holder pods. Outdated holder pods are identified by comparing the DaemonSet
@@ -120,7 +124,8 @@ spec:
120124
name: syn-holder-updater
121125
template:
122126
metadata:
123-
annotations: {}
127+
annotations:
128+
script-checksum: 488da91788ef6e501cece9d3d67ff8b0
124129
labels:
125130
app.kubernetes.io/component: rook-ceph
126131
app.kubernetes.io/managed-by: commodore

tests/golden/openshift4/rook-ceph/rook-ceph/50_restart_holder_ds.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ data:
5757
while true; do
5858
# assumption: holder plugin daemonset is called
5959
# `csi-cephfsplugin-holder-${cephcluster:name}`
60-
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-cluster -ojsonpath='{.metadata.generation}')
61-
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-cluster -ojsonpath='{.metadata.generation}')
60+
# note: we don't care about the value of the variable if the daemonset
61+
# isn't there, since we'll check for pods in a K8s `List` which will
62+
# simply be empty if the plugin isn't enabled.
63+
cephfs_holder_wanted_gen=$(kubectl get ds csi-cephfsplugin-holder-cluster -ojsonpath='{.metadata.generation}' 2>/dev/null)
64+
rbd_holder_wanted_gen=$(kubectl get ds csi-rbdplugin-holder-cluster -ojsonpath='{.metadata.generation}' 2>/dev/null)
6265
needs_update=$( (\
6366
kubectl get pods -l app=csi-cephfsplugin-holder --field-selector spec.nodeName=${NODE_NAME} -ojson |\
6467
jq --arg wanted_gen ${cephfs_holder_wanted_gen} \
@@ -100,6 +103,7 @@ apiVersion: apps/v1
100103
kind: DaemonSet
101104
metadata:
102105
annotations:
106+
argocd.argoproj.io/sync-wave: '10'
103107
syn.tools/description: DaemonSet which waits for node to be drained (by waiting
104108
until no non-daemonset pods are running on the node) and then deletes any outdated
105109
csi holder pods. Outdated holder pods are identified by comparing the DaemonSet
@@ -120,7 +124,8 @@ spec:
120124
name: syn-holder-updater
121125
template:
122126
metadata:
123-
annotations: {}
127+
annotations:
128+
script-checksum: 488da91788ef6e501cece9d3d67ff8b0
124129
labels:
125130
app.kubernetes.io/component: rook-ceph
126131
app.kubernetes.io/managed-by: commodore

0 commit comments

Comments
 (0)