Skip to content

Commit

Permalink
return error if configMap not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen.Zhidong committed May 24, 2018
1 parent a436a06 commit 381c0ae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions operator/redisfailover/service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ func (r *RedisFailoverKubeClient) EnsureSentinelService(rf *redisfailoverv1alpha

// EnsureSentinelConfigMap makes sure the sentinel configmap exists
func (r *RedisFailoverKubeClient) EnsureSentinelConfigMap(rf *redisfailoverv1alpha2.RedisFailover, labels map[string]string, ownerRefs []metav1.OwnerReference) error {
if _, err := r.K8SService.GetConfigMap(rf.Namespace, GetSentinelConfigMapName(rf)); err != nil {
if rf.Spec.Sentinel.ConfigMap != "" {
if _, err := r.K8SService.GetConfigMap(rf.Namespace, rf.Spec.Sentinel.ConfigMap); err != nil {
return err
}
} else {
cm := generateSentinelConfigMap(rf, labels, ownerRefs)
return r.K8SService.CreateOrUpdateConfigMap(rf.Namespace, cm)
}
Expand All @@ -79,7 +83,11 @@ func (r *RedisFailoverKubeClient) EnsureRedisStatefulset(rf *redisfailoverv1alph

// EnsureRedisConfigMap makes sure the sentinel configmap exists
func (r *RedisFailoverKubeClient) EnsureRedisConfigMap(rf *redisfailoverv1alpha2.RedisFailover, labels map[string]string, ownerRefs []metav1.OwnerReference) error {
if _, err := r.K8SService.GetConfigMap(rf.Namespace, GetRedisConfigMapName(rf)); err != nil {
if rf.Spec.Redis.ConfigMap != "" {
if _, err := r.K8SService.GetConfigMap(rf.Namespace, rf.Spec.Redis.ConfigMap); err != nil {
return err
}
} else {
cm := generateRedisConfigMap(rf, labels, ownerRefs)
return r.K8SService.CreateOrUpdateConfigMap(rf.Namespace, cm)
}
Expand Down

0 comments on commit 381c0ae

Please sign in to comment.