Operator crashes when creating vcheck pod if an invalid value of topologySpreadConstraints.whenUnsatisfiable is given
#953 ouverte le 22 janv. 2023
Métriques du dépôt
- Stars
- (318 stars)
- Métriques de merge PR
- (Métriques PR en attente)
Description
What version of operator are you using? commit 561cf47d783c368fd8795acb82a5a39099a35984 (HEAD -> master)
What operating system and processor architecture are you using (kubectl version)?
Ubuntu. 20.04
What did you do?
I find that crdb-operator will crash when starting the vcheck job pod if whenUnsatisfiable under topologySpreadConstraints has an invalid value.
I created the cluster by applying the following custom resource file, note that the value of whenUnsatisfiable is wrongly spelled:
apiVersion: crdb.cockroachlabs.com/v1alpha1
kind: CrdbCluster
metadata:
name: test-cluster
spec:
additionalLabels:
crdb: is-cool
dataStore:
pvc:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
volumeMode: Filesystem
image:
name: cockroachdb/cockroach:v21.2.10
nodes: 3
resources:
limits:
cpu: 2
memory: 2Gi
requests:
cpu: 100m
memory: 1Gi
tlsEnabled: true
topologySpreadConstraints:
- maxSkew: 3
topologyKey: MYKEY
whenUnsatisfiable: DoNotScedule
(All files were applied using kubectl apply -f <filename> -n cockroach-operator-system)
What did you see?
The program crashed.
Comments
I checked the log of the operator and I found that a nil pointer dereference happened.
It seems that when whenUnsatisfiable is assigned with an invalid value, the operator cannot find the vcheck job pod while it expects to find it, leading to a nil pointer dereference at this line where Selector is nil while Selector.MatchLabels is accessed.