Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: component annotations updated failed #8634

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading