diff --git a/CHANGELOG.md b/CHANGELOG.md index 087f5a08a..fc96ffc96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.9.3] - 2021-06-02 + +### Fixed +- Failed to update Service if `spec.externalTrafficPolicy` was set to `Local` (#259) + ## [0.9.2] - 2021-06-01 ### Changed @@ -180,7 +185,8 @@ The `MySQLCluster` created by MOCO `< v0.5.0` has no compatibility with `>= v0.5 - Bootstrap a vanilla MySQL cluster with no replicas (#2). -[Unreleased]: https://github.com/cybozu-go/moco/compare/v0.9.2...HEAD +[Unreleased]: https://github.com/cybozu-go/moco/compare/v0.9.3...HEAD +[0.9.3]: https://github.com/cybozu-go/moco/compare/v0.9.2...v0.9.3 [0.9.2]: https://github.com/cybozu-go/moco/compare/v0.9.1...v0.9.2 [0.9.1]: https://github.com/cybozu-go/moco/compare/v0.9.0...v0.9.1 [0.9.0]: https://github.com/cybozu-go/moco/compare/v0.8.3...v0.9.0 diff --git a/controllers/mysqlcluster_controller.go b/controllers/mysqlcluster_controller.go index 8a6936ee3..581e03a2e 100644 --- a/controllers/mysqlcluster_controller.go +++ b/controllers/mysqlcluster_controller.go @@ -539,6 +539,9 @@ func (r *MySQLClusterReconciler) reconcileV1Service1(ctx context.Context, cluste if len(saSpec.ExternalTrafficPolicy) == 0 { saSpec.ExternalTrafficPolicy = svc.Spec.ExternalTrafficPolicy } + if saSpec.HealthCheckNodePort == 0 { + saSpec.HealthCheckNodePort = svc.Spec.HealthCheckNodePort + } if saSpec.IPFamilies == nil { saSpec.IPFamilies = svc.Spec.IPFamilies } diff --git a/controllers/mysqlcluster_controller_test.go b/controllers/mysqlcluster_controller_test.go index ee2064923..19427c58b 100644 --- a/controllers/mysqlcluster_controller_test.go +++ b/controllers/mysqlcluster_controller_test.go @@ -586,6 +586,36 @@ var _ = Describe("MySQLCluster reconciler", func() { err = k8sClient.Get(ctx, client.ObjectKey{Namespace: "test", Name: "moco-test"}, headless) Expect(err).NotTo(HaveOccurred()) Expect(headless.Spec.ExternalTrafficPolicy).NotTo(Equal(corev1.ServiceExternalTrafficPolicyTypeLocal)) + + // Edit Service again should succeed + Eventually(func() error { + cluster = &mocov1beta1.MySQLCluster{} + err := k8sClient.Get(ctx, client.ObjectKey{Namespace: "test", Name: "test"}, cluster) + if err != nil { + return err + } + cluster.Spec.ServiceTemplate = &mocov1beta1.ServiceTemplate{ + ObjectMeta: mocov1beta1.ObjectMeta{ + Annotations: map[string]string{"foo": "bar"}, + }, + Spec: &corev1.ServiceSpec{ + Type: corev1.ServiceTypeLoadBalancer, + ExternalTrafficPolicy: corev1.ServiceExternalTrafficPolicyTypeLocal, + }, + } + return k8sClient.Update(ctx, cluster) + }).Should(Succeed()) + + Eventually(func() error { + primary = &corev1.Service{} + if err := k8sClient.Get(ctx, client.ObjectKey{Namespace: "test", Name: "moco-test-primary"}, primary); err != nil { + return err + } + if primary.Annotations["foo"] != "bar" { + return errors.New("service does not have annotation foo") + } + return nil + }).Should(Succeed()) }) It("should reconcile statefulset", func() { diff --git a/kustomization.yaml b/kustomization.yaml index 6a8c18af6..ca6ec52f9 100644 --- a/kustomization.yaml +++ b/kustomization.yaml @@ -3,4 +3,4 @@ resources: images: - name: ghcr.io/cybozu-go/moco - newTag: 0.9.2 + newTag: 0.9.3 diff --git a/version.go b/version.go index 1daedc53a..e5cdb71fa 100644 --- a/version.go +++ b/version.go @@ -2,7 +2,7 @@ package moco const ( // Version is the MOCO version - Version = "0.9.2" + Version = "0.9.3" // FluentBitImage is the image for slow-log sidecar container. FluentBitImage = "quay.io/cybozu/fluent-bit:1.7.5.1"