Skip to content

fix: health status is set to healthy for statefulset with updateStrat… #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ func getStatefulSetHealth(obj *unstructured.Unstructured) (*HealthStatus, error)
Message: fmt.Sprintf("partitioned roll out complete: %d new pods have been updated...", sts.Status.UpdatedReplicas),
}, nil
}
if sts.Spec.UpdateStrategy.Type == appsv1.OnDeleteStatefulSetStrategyType {
return &HealthStatus{
Status: HealthStatusHealthy,
Message: fmt.Sprintf("statefulset has %d ready pods", sts.Status.ReadyReplicas),
Copy link

@glasser glasser May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the issue that this change was fixing and it makes sense to me that this counts as "healthy", but what do folks think about iterating on this so that the message lets you know whether or not UpdatedReplicas matches Replicas in the OnDelete case?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}, nil
}
if sts.Status.UpdateRevision != sts.Status.CurrentRevision {
return &HealthStatus{
Status: HealthStatusProgressing,
Expand Down
4 changes: 4 additions & 0 deletions pkg/health/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func TestStatefulSetHealth(t *testing.T) {
assertAppHealth(t, "./testdata/statefulset.yaml", HealthStatusHealthy)
}

func TestStatefulSetOnDeleteHealth(t *testing.T) {
assertAppHealth(t, "./testdata/statefulset-ondelete.yaml", HealthStatusHealthy)
}

func TestPVCHealth(t *testing.T) {
assertAppHealth(t, "./testdata/pvc-bound.yaml", HealthStatusHealthy)
assertAppHealth(t, "./testdata/pvc-pending.yaml", HealthStatusProgressing)
Expand Down
123 changes: 123 additions & 0 deletions pkg/health/testdata/statefulset-ondelete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1beta2","kind":"StatefulSet","metadata":{"annotations":{},"labels":{"app":"redis","app.kubernetes.io/instance":"redis","chart":"redis-3.6.5","heritage":"Tiller","release":"redis"},"name":"redis-master","namespace":"default"},"spec":{"selector":{"matchLabels":{"app":"redis","release":"redis","role":"master"}},"serviceName":"redis-master","template":{"metadata":{"labels":{"app":"redis","app.kubernetes.io/instance":"redis","release":"redis","role":"master"}},"spec":{"containers":[{"env":[{"name":"REDIS_REPLICATION_MODE","value":"master"},{"name":"REDIS_PASSWORD","valueFrom":{"secretKeyRef":{"key":"redis-password","name":"redis"}}},{"name":"REDIS_DISABLE_COMMANDS","value":"FLUSHDB,FLUSHALL"}],"image":"docker.io/bitnami/redis:4.0.10-debian-9","imagePullPolicy":"Always","livenessProbe":{"exec":{"command":["redis-cli","ping"]},"failureThreshold":5,"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":5},"name":"redis","ports":[{"containerPort":6379,"name":"redis"}],"readinessProbe":{"exec":{"command":["redis-cli","ping"]},"failureThreshold":5,"initialDelaySeconds":5,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1},"resources":{},"volumeMounts":[{"mountPath":"/bitnami/redis/data","name":"redis-data"}]}],"securityContext":{"fsGroup":1001,"runAsUser":1001},"serviceAccountName":"default"}},"updateStrategy":{"type":"OnDelete"},"volumeClaimTemplates":[{"metadata":{"labels":{"app":"redis","chart":"redis-3.6.5","component":"master","heritage":"Tiller","release":"redis"},"name":"redis-data"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"8Gi"}}}}]}}
creationTimestamp: 2018-07-20T08:23:04Z
generation: 1
labels:
app: redis
app.kubernetes.io/instance: redis
chart: redis-3.6.5
heritage: Tiller
release: redis
name: redis-master
namespace: default
resourceVersion: "514251"
selfLink: /apis/apps/v1/namespaces/default/statefulsets/redis-master
uid: 1f80ab97-8bf6-11e8-aff0-42010a8a0fc6
spec:
podManagementPolicy: OrderedReady
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: redis
release: redis
role: master
serviceName: redis-master
updateStrategy:
type: OnDelete
template:
metadata:
creationTimestamp: null
labels:
app: redis
app.kubernetes.io/instance: redis
release: redis
role: master
spec:
containers:
- env:
- name: REDIS_REPLICATION_MODE
value: master
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
key: redis-password
name: redis
- name: REDIS_DISABLE_COMMANDS
value: FLUSHDB,FLUSHALL
image: docker.io/bitnami/redis:4.0.10-debian-9
imagePullPolicy: Always
livenessProbe:
exec:
command:
- redis-cli
- ping
failureThreshold: 5
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: redis
ports:
- containerPort: 6379
name: redis
protocol: TCP
readinessProbe:
exec:
command:
- redis-cli
- ping
failureThreshold: 5
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /bitnami/redis/data
name: redis-data
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
fsGroup: 1001
runAsUser: 1001
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
updateStrategy:
type: OnDelete
volumeClaimTemplates:
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
creationTimestamp: null
labels:
app: redis
chart: redis-3.6.5
component: master
heritage: Tiller
release: redis
name: redis-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
status:
phase: Pending
status:
collisionCount: 0
currentReplicas: 1
currentRevision: redis-master-7b8f75b98
observedGeneration: 1
readyReplicas: 1
replicas: 1
updateRevision: redis-master-7b8f75b98