diff --git a/operator/redisfailover/service/generator.go b/operator/redisfailover/service/generator.go index 3d1f9c936..83afaa088 100644 --- a/operator/redisfailover/service/generator.go +++ b/operator/redisfailover/service/generator.go @@ -280,6 +280,7 @@ func generateRedisStatefulSet(rf *redisfailoverv1.RedisFailover, labels map[stri ss := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ + Annotations: rf.Annotations, Name: name, Namespace: namespace, Labels: labels, diff --git a/operator/redisfailover/util/label.go b/operator/redisfailover/util/label.go index e60450d46..381489964 100644 --- a/operator/redisfailover/util/label.go +++ b/operator/redisfailover/util/label.go @@ -11,3 +11,15 @@ func MergeLabels(allLabels ...map[string]string) map[string]string { } return res } + +// MergeAnnotations merges all the annotations maps received as argument into a single new label map. +func MergeAnnotations(allMergeAnnotations ...map[string]string) map[string]string { + res := map[string]string{} + + for _, labels := range allMergeAnnotations { + for k, v := range labels { + res[k] = v + } + } + return res +} diff --git a/service/k8s/statefulset.go b/service/k8s/statefulset.go index 0bbbee003..5031ab9c9 100644 --- a/service/k8s/statefulset.go +++ b/service/k8s/statefulset.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "github.com/spotahome/redis-operator/operator/redisfailover/util" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -99,6 +101,7 @@ func (s *StatefulSetService) CreateOrUpdateStatefulSet(namespace string, statefu // namespace is our spec(https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#concurrency-control-and-consistency), // we will replace the current namespace state. statefulSet.ResourceVersion = storedStatefulSet.ResourceVersion + statefulSet.Annotations = util.MergeAnnotations(statefulSet.Annotations, storedStatefulSet.Annotations) return s.UpdateStatefulSet(namespace, statefulSet) } diff --git a/service/redis/client.go b/service/redis/client.go index e3d070b2f..63d722a17 100644 --- a/service/redis/client.go +++ b/service/redis/client.go @@ -306,7 +306,8 @@ func (c *client) SetCustomRedisConfig(ip string, port string, configs []string, return err } // If the configuration is an empty line , it will result in an incorrect configSet, which will not run properly down the line. - if strings.TrimSpace(param) == "" || strings.TrimSpace(value) == "" { + // `config set save ""` should support + if strings.TrimSpace(param) == "" { continue } if err := c.applyRedisConfig(param, value, rClient); err != nil {