Skip to content

Commit

Permalink
chore: component annotations updated failed (#8634)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei authored Dec 13, 2024
1 parent 2f60dc9 commit cc0aa10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions controllers/apps/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"encoding/json"
"fmt"
"slices"
"strconv"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -1185,13 +1186,16 @@ var _ = Describe("Cluster Controller", func() {
})()).ShouldNot(HaveOccurred())

By("check cluster and component objects been upgraded")
var clusterGenerate int64
Eventually(testapps.CheckObj(&testCtx, clusterKey, func(g Gomega, cluster *appsv1.Cluster) {
g.Expect(cluster.Spec.ComponentSpecs[0].ComponentDef).Should(Equal(newCompDefObj.Name))
g.Expect(cluster.Spec.ComponentSpecs[0].ServiceVersion).Should(Equal(defaultServiceVersion))
clusterGenerate = cluster.Generation
})).Should(Succeed())
Eventually(testapps.CheckObj(&testCtx, compKey, func(g Gomega, comp *appsv1.Component) {
g.Expect(comp.Spec.CompDef).Should(Equal(newCompDefObj.Name))
g.Expect(comp.Spec.ServiceVersion).Should(Equal(defaultServiceVersion))
g.Expect(strconv.Itoa(int(clusterGenerate))).Should(Equal(comp.Annotations[constant.KubeBlocksGenerationKey]))
})).Should(Succeed())
})

Expand Down
6 changes: 2 additions & 4 deletions controllers/apps/transformer_cluster_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ func copyAndMergeComponent(oldCompObj, newCompObj *appsv1.Component) *appsv1.Com
compProto := newCompObj

// merge labels and annotations
ictrlutil.MergeMetadataMapInplace(compObjCopy.Annotations, &compProto.Annotations)
ictrlutil.MergeMetadataMapInplace(compObjCopy.Labels, &compProto.Labels)
compObjCopy.Annotations = compProto.Annotations
compObjCopy.Labels = compProto.Labels
ictrlutil.MergeMetadataMapInplace(compProto.Annotations, &compObjCopy.Annotations)
ictrlutil.MergeMetadataMapInplace(compProto.Labels, &compObjCopy.Labels)

// merge spec
compObjCopy.Spec.CompDef = compProto.Spec.CompDef
Expand Down

0 comments on commit cc0aa10

Please sign in to comment.