diff --git a/go.mod b/go.mod index f40890fbefb5..0bc1e16ced29 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/go-logr/logr v1.4.1 github.com/go-logr/zapr v1.3.0 github.com/goburrow/cache v0.1.4 - github.com/golang-jwt/jwt/v4 v4.5.0 + github.com/golang-jwt/jwt/v4 v4.5.1 github.com/golang-migrate/migrate/v4 v4.17.0 github.com/golang/protobuf v1.5.4 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index f9d0e5ab100b..68120adac981 100644 --- a/go.sum +++ b/go.sum @@ -143,8 +143,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= +github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-migrate/migrate/v4 v4.17.0 h1:rd40H3QXU0AA4IoLllFcEAEo9dYKRHYND2gB4p7xcaU= github.com/golang-migrate/migrate/v4 v4.17.0/go.mod h1:+Cp2mtLP4/aXDTKb9wmXYitdrNx2HGs45rbWAo6OsKM= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= diff --git a/mk/dependencies/deps.lock b/mk/dependencies/deps.lock index 7c4df45b5e2c..592c082b0dc8 100644 --- a/mk/dependencies/deps.lock +++ b/mk/dependencies/deps.lock @@ -1 +1 @@ -715143257bf862fa0be82c4c9bc744565352f3e3 +e8e06c31bae5234be42cffb540eb98310bfebed2 diff --git a/mk/dev.mk b/mk/dev.mk index 1f6d3ca2a08e..c77aee002d4b 100644 --- a/mk/dev.mk +++ b/mk/dev.mk @@ -7,7 +7,7 @@ GIT_TAG = $(word 2, $(BUILD_INFO)) GIT_COMMIT = $(word 3, $(BUILD_INFO)) BUILD_DATE = $(word 4, $(BUILD_INFO)) CI_TOOLS_VERSION = $(word 5, $(BUILD_INFO)) -ENVOY_VERSION ?= 1.29.9 +ENVOY_VERSION ?= 1.29.10 KUMA_CHARTS_URL ?= https://kumahq.github.io/charts CHART_REPO_NAME ?= kuma PROJECT_NAME ?= kuma diff --git a/pkg/core/resources/store/options.go b/pkg/core/resources/store/options.go index b54e5f005374..c56aeb96321b 100644 --- a/pkg/core/resources/store/options.go +++ b/pkg/core/resources/store/options.go @@ -57,6 +57,7 @@ func CreateWithLabels(labels map[string]string) CreateOptionsFunc { type UpdateOptions struct { ModificationTime time.Time Labels map[string]string + ModifyLabels bool } func ModifiedAt(modificationTime time.Time) UpdateOptionsFunc { @@ -68,6 +69,7 @@ func ModifiedAt(modificationTime time.Time) UpdateOptionsFunc { func UpdateWithLabels(labels map[string]string) UpdateOptionsFunc { return func(opts *UpdateOptions) { opts.Labels = labels + opts.ModifyLabels = true } } diff --git a/pkg/plugins/resources/k8s/store.go b/pkg/plugins/resources/k8s/store.go index af1d6496957d..9086f04677bb 100644 --- a/pkg/plugins/resources/k8s/store.go +++ b/pkg/plugins/resources/k8s/store.go @@ -99,7 +99,11 @@ func (s *KubernetesStore) Update(ctx context.Context, r core_model.Resource, fs return errors.Wrapf(err, "failed to convert core model of type %s into k8s counterpart", r.Descriptor().Name) } - labels, annotations := splitLabelsAndAnnotations(opts.Labels, obj.GetAnnotations()) + updateLabels := r.GetMeta().GetLabels() + if opts.ModifyLabels { + updateLabels = opts.Labels + } + labels, annotations := splitLabelsAndAnnotations(updateLabels, obj.GetAnnotations()) obj.GetObjectMeta().SetLabels(labels) obj.GetObjectMeta().SetAnnotations(annotations) obj.SetMesh(r.GetMeta().GetMesh()) diff --git a/pkg/plugins/resources/memory/store.go b/pkg/plugins/resources/memory/store.go index 8503dc273f05..92dcb42cac4b 100644 --- a/pkg/plugins/resources/memory/store.go +++ b/pkg/plugins/resources/memory/store.go @@ -184,7 +184,9 @@ func (c *memoryStore) Update(_ context.Context, r core_model.Resource, fs ...sto } meta.Version = meta.Version.Next() meta.ModificationTime = opts.ModificationTime - meta.Labels = opts.Labels + if opts.ModifyLabels { + meta.Labels = opts.Labels + } r.SetMeta(meta) record.Version = meta.Version diff --git a/pkg/plugins/resources/postgres/pgx_store.go b/pkg/plugins/resources/postgres/pgx_store.go index 97ec525eea63..3aaecaaac50b 100644 --- a/pkg/plugins/resources/postgres/pgx_store.go +++ b/pkg/plugins/resources/postgres/pgx_store.go @@ -159,7 +159,11 @@ func (r *pgxResourceStore) Update(ctx context.Context, resource core_model.Resou return errors.Wrap(err, "failed to convert meta version to int") } - labels, err := prepareLabels(opts.Labels) + updateLabels := resource.GetMeta().GetLabels() + if opts.ModifyLabels { + updateLabels = opts.Labels + } + labels, err := prepareLabels(updateLabels) if err != nil { return err } diff --git a/pkg/plugins/resources/postgres/pq_store.go b/pkg/plugins/resources/postgres/pq_store.go index 23159a985b75..ba7d701c69b5 100644 --- a/pkg/plugins/resources/postgres/pq_store.go +++ b/pkg/plugins/resources/postgres/pq_store.go @@ -110,7 +110,11 @@ func (r *postgresResourceStore) Update(_ context.Context, resource core_model.Re return errors.Wrap(err, "failed to convert meta version to int") } - labels, err := prepareLabels(opts.Labels) + updateLabels := resource.GetMeta().GetLabels() + if opts.ModifyLabels { + updateLabels = opts.Labels + } + labels, err := prepareLabels(updateLabels) if err != nil { return err } diff --git a/pkg/test/store/store_test_template.go b/pkg/test/store/store_test_template.go index b9780792e6e8..7b6336cdb5ed 100644 --- a/pkg/test/store/store_test_template.go +++ b/pkg/test/store/store_test_template.go @@ -223,6 +223,42 @@ func ExecuteStoreTests( } }) + It("should preserve labels", func() { + // given + name := "to-be-updated.demo" + resource := createResource(name, "foo", "bar") + + // when + resource.Spec.Conf.Destination["path"] = "new-path" + err := s.Update(context.Background(), resource) + + // then + Expect(err).ToNot(HaveOccurred()) + + res := core_mesh.NewTrafficRouteResource() + err = s.Get(context.Background(), res, store.GetByKey(name, mesh)) + Expect(err).ToNot(HaveOccurred()) + Expect(res.Meta.GetLabels()).To(HaveKeyWithValue("foo", "bar")) + }) + + It("should delete labels", func() { + // given a resources in storage + name := "to-be-updated.demo" + resource := createResource(name, "foo", "bar") + + // when + resource.Spec.Conf.Destination["path"] = "new-path" + err := s.Update(context.Background(), resource, store.UpdateWithLabels(map[string]string{})) + + // then + Expect(err).ToNot(HaveOccurred()) + + res := core_mesh.NewTrafficRouteResource() + err = s.Get(context.Background(), res, store.GetByKey(name, mesh)) + Expect(err).ToNot(HaveOccurred()) + Expect(res.Meta.GetLabels()).ToNot(HaveKeyWithValue("foo", "bar")) + }) + It("should update resource with status", func() { // given updated := meshservice_api.MeshServiceResource{