Skip to content

Commit

Permalink
Merge pull request #415 from lucming/fix_svc_not_update
Browse files Browse the repository at this point in the history
fix bug that svc not update when crd changed
  • Loading branch information
ese authored Aug 30, 2022
2 parents 7b7fdc7 + b8987c3 commit 08b820d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions operator/redisfailover/service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func generateRedisSlaveRoleLabel() map[string]string {
// EnsureSentinelService makes sure the sentinel service exists
func (r *RedisFailoverKubeClient) EnsureSentinelService(rf *redisfailoverv1.RedisFailover, labels map[string]string, ownerRefs []metav1.OwnerReference) error {
svc := generateSentinelService(rf, labels, ownerRefs)
return r.K8SService.CreateIfNotExistsService(rf.Namespace, svc)
return r.K8SService.CreateOrUpdateService(rf.Namespace, svc)
}

// EnsureSentinelConfigMap makes sure the sentinel configmap exists
Expand Down Expand Up @@ -126,7 +126,7 @@ func (r *RedisFailoverKubeClient) EnsureRedisReadinessConfigMap(rf *redisfailove
// EnsureRedisService makes sure the redis statefulset exists
func (r *RedisFailoverKubeClient) EnsureRedisService(rf *redisfailoverv1.RedisFailover, labels map[string]string, ownerRefs []metav1.OwnerReference) error {
svc := generateRedisService(rf, labels, ownerRefs)
return r.K8SService.CreateIfNotExistsService(rf.Namespace, svc)
return r.K8SService.CreateOrUpdateService(rf.Namespace, svc)
}

// EnsureNotPresentRedisService makes sure the redis service is not present
Expand Down
4 changes: 2 additions & 2 deletions operator/redisfailover/service/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ func TestSentinelService(t *testing.T) {
generatedService := corev1.Service{}

ms := &mK8SService.Services{}
ms.On("CreateIfNotExistsService", rf.Namespace, mock.Anything).Once().Run(func(args mock.Arguments) {
ms.On("CreateOrUpdateService", rf.Namespace, mock.Anything).Once().Run(func(args mock.Arguments) {
s := args.Get(1).(*corev1.Service)
generatedService = *s
}).Return(nil)
Expand Down Expand Up @@ -1277,7 +1277,7 @@ func TestRedisService(t *testing.T) {
generatedService := corev1.Service{}

ms := &mK8SService.Services{}
ms.On("CreateIfNotExistsService", rf.Namespace, mock.Anything).Once().Run(func(args mock.Arguments) {
ms.On("CreateOrUpdateService", rf.Namespace, mock.Anything).Once().Run(func(args mock.Arguments) {
s := args.Get(1).(*corev1.Service)
generatedService = *s
}).Return(nil)
Expand Down

0 comments on commit 08b820d

Please sign in to comment.