diff --git a/CHANGELOG.md b/CHANGELOG.md index 518d786..b93d27c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v0.14.3] - 2023-10-02 +### Fixed +- [#44] Fix a bug where the service discovery only updated one single ingress switching maintenance mode. + ## [v0.14.2] - 2023-09-20 ### Changed - [#38] updated go dependencies diff --git a/Dockerfile b/Dockerfile index 1a9be2a..7a05456 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN make compile-generic FROM gcr.io/distroless/static:nonroot LABEL maintainer="hello@cloudogu.com" \ NAME="k8s-service-discovery" \ - VERSION="0.14.2" + VERSION="0.14.3" WORKDIR / diff --git a/Makefile b/Makefile index 9af261a..b7cc68e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Set these to the desired values ARTIFACT_ID=k8s-service-discovery -VERSION=0.14.2 +VERSION=0.14.3 ## Image URL to use all building/pushing image targets IMAGE_DEV=${K3CES_REGISTRY_URL_PREFIX}/${ARTIFACT_ID}:${VERSION} diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 4fde7fa..f711c62 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -11,4 +11,4 @@ kind: Kustomization images: - name: controller newName: cloudogu/k8s-service-discovery - newTag: 0.14.2 + newTag: 0.14.3 diff --git a/controllers/maintenanceModeUpdater.go b/controllers/maintenanceModeUpdater.go index 1a0e6c8..fb91524 100644 --- a/controllers/maintenanceModeUpdater.go +++ b/controllers/maintenanceModeUpdater.go @@ -167,7 +167,8 @@ func (scu *maintenanceModeUpdater) getAllServices(ctx context.Context) (v1Servic var modifiableServiceList v1ServiceList for _, svc := range serviceList.Items { - modifiableServiceList = append(modifiableServiceList, &svc) + copySvc := svc + modifiableServiceList = append(modifiableServiceList, ©Svc) } return modifiableServiceList, nil diff --git a/controllers/maintenanceModeUpdater_test.go b/controllers/maintenanceModeUpdater_test.go index cbe28b2..6ae8aa9 100644 --- a/controllers/maintenanceModeUpdater_test.go +++ b/controllers/maintenanceModeUpdater_test.go @@ -2,6 +2,7 @@ package controllers import ( "context" + "sigs.k8s.io/controller-runtime/pkg/client" "testing" "time" @@ -487,6 +488,32 @@ func Test_maintenanceModeUpdater_getAllServices(t *testing.T) { assert.ErrorIs(t, err, assert.AnError) assert.ErrorContains(t, err, "failed to get list of all services in namespace [el-espacio-del-nombre]:") }) + + t.Run("should return multiple services", func(t *testing.T) { + // given + clientMock := newMockK8sClient(t) + serviceA := corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "A and not equal B"}} + serviceB := corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "B and not equal A"}} + services := []corev1.Service{serviceA, serviceB} + serviceList := &corev1.ServiceList{Items: services} + clientMock.EXPECT().List(testCtx, mock.Anything, mock.Anything).Run(func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) { + c := list.(*corev1.ServiceList) + c.Items = serviceList.Items + }).Return(nil) + + sut := &maintenanceModeUpdater{ + client: clientMock, + namespace: "el-espacio-del-nombre", + } + + // when + result, err := sut.getAllServices(testCtx) + + // then + require.NoError(t, err) + assert.Len(t, result, 2) + assert.NotEqual(t, result[0].Name, result[1].Name) + }) } func Test_maintenanceModeUpdater_deactivateMaintenanceMode(t *testing.T) {