Skip to content

Commit

Permalink
Auto recreate redis replication statefulset when update failed (#586)
Browse files Browse the repository at this point in the history
Signed-off-by: drivebyer <[email protected]>
  • Loading branch information
drivebyer authored Aug 20, 2023
1 parent 97378b6 commit c826f89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions k8sutils/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package k8sutils

const (
AnnotationKeyRecreateStatefulset = "redis.opstreelabs.in/recreate-statefulset"
)
2 changes: 1 addition & 1 deletion k8sutils/redis-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func generateRedisClusterParams(cr *redisv1beta1.RedisCluster, replicas int32, e
if externalConfig != nil {
res.ExternalConfig = externalConfig
}
if _, found := cr.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/recreate-statefulset"]; found {
if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found {
res.RecreateStatefulSet = true
}
return res
Expand Down
3 changes: 3 additions & 0 deletions k8sutils/redis-replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func generateRedisReplicationParams(cr *redisv1beta1.RedisReplication) statefulS
if cr.Spec.ServiceAccountName != nil {
res.ServiceAccountName = cr.Spec.ServiceAccountName
}
if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found {
res.RecreateStatefulSet = true
}
return res
}

Expand Down
2 changes: 1 addition & 1 deletion k8sutils/redis-standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func generateRedisStandaloneParams(cr *redisv1beta1.Redis) statefulSetParameters
if cr.Spec.ServiceAccountName != nil {
res.ServiceAccountName = cr.Spec.ServiceAccountName
}
if _, found := cr.ObjectMeta.GetAnnotations()["redis.opstreelabs.in/recreate-statefulset"]; found {
if _, found := cr.ObjectMeta.GetAnnotations()[AnnotationKeyRecreateStatefulset]; found {
res.RecreateStatefulSet = true
}
return res
Expand Down

0 comments on commit c826f89

Please sign in to comment.