diff --git a/pkg/apis/bookkeeper/v1alpha1/bookkeepercluster_types.go b/pkg/apis/bookkeeper/v1alpha1/bookkeepercluster_types.go index 8260daed..893e8ff0 100644 --- a/pkg/apis/bookkeeper/v1alpha1/bookkeepercluster_types.go +++ b/pkg/apis/bookkeeper/v1alpha1/bookkeepercluster_types.go @@ -745,6 +745,12 @@ func (bk *BookkeeperCluster) validateConfigMap() error { return fmt.Errorf("failed to get configmap (%s): %v", configmap.Name, err) } } + if val, ok := bk.Spec.Options["useHostNameAsBookieID"]; ok { + eq := configmap.Data["BK_useHostNameAsBookieID"] == val + if !eq { + return fmt.Errorf("value of useHostNameAsBookieID should not be changed") + } + } if val, ok := bk.Spec.Options["journalDirectories"]; ok { eq := configmap.Data["BK_journalDirectories"] == val if !eq { diff --git a/test/e2e/cmchanges_test.go b/test/e2e/cmchanges_test.go index 59442c9a..172f05b6 100644 --- a/test/e2e/cmchanges_test.go +++ b/test/e2e/cmchanges_test.go @@ -44,6 +44,7 @@ func testCMUpgradeCluster(t *testing.T) { cluster.Spec.Version = initialVersion cluster.Spec.Options["minorCompactionThreshold"] = "0.4" cluster.Spec.Options["journalDirectories"] = "/bk/journal" + cluster.Spec.Options["useHostNameAsBookieID"] = "true" cluster.Spec.JVMOptions.GcOpts = gcOpts bookkeeper, err := bookkeeper_e2eutil.CreateBKCluster(t, f, ctx, cluster) @@ -58,7 +59,7 @@ func testCMUpgradeCluster(t *testing.T) { err = bookkeeper_e2eutil.CheckConfigMap(t, f, ctx, bookkeeper, "BOOKIE_GC_OPTS", gcOptions) g.Expect(err).NotTo(HaveOccurred()) - // updating bookkeeper option + // updating modifiable bookkeeper option gcOpts = []string{"-XX:-UseParallelGC", "-XX:MaxGCPauseMillis=10"} gcOptions = strings.Join(gcOpts, " ") bookkeeper.Spec.Version = upgradeVersion @@ -81,7 +82,7 @@ func testCMUpgradeCluster(t *testing.T) { g.Expect(bookkeeper.Spec.Version).To(Equal(upgradeVersion)) g.Expect(bookkeeper.Spec.Options["minorCompactionThreshold"]).To(Equal("0.5")) - // updating bookkeeper option + // updating non-modifiable bookkeeper option journalDirectories bookkeeper.Spec.Options["journalDirectories"] = "journal" //updating bookkeepercluster @@ -92,6 +93,17 @@ func testCMUpgradeCluster(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(bookkeeper.Spec.Options["journalDirectories"]).To(Equal("/bk/journal")) + // updating non-modifiable bookkeeper option useHostNameAsBookieID + bookkeeper.Spec.Options["useHostNameAsBookieID"] = "false" + + //updating bookkeepercluster + err = bookkeeper_e2eutil.UpdateBKCluster(t, f, ctx, bookkeeper) + g.Expect(strings.ContainsAny(err.Error(), "value of useHostNameAsBookieID should not be changed")).To(Equal(true)) + + bookkeeper, err = bookkeeper_e2eutil.GetBKCluster(t, f, ctx, bookkeeper) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(bookkeeper.Spec.Options["useHostNameAsBookieID"]).To(Equal("true")) + // Delete cluster err = bookkeeper_e2eutil.DeleteBKCluster(t, f, ctx, bookkeeper) g.Expect(err).NotTo(HaveOccurred())