Skip to content

Commit

Permalink
Issue 169: Preventing modification of useHostNameAsBookieID post depl…
Browse files Browse the repository at this point in the history
…oyment (#170)

Signed-off-by: SrishT <[email protected]>

Co-authored-by: SrishT <[email protected]>
  • Loading branch information
SrishT and SrishT authored Sep 22, 2021
1 parent 8f6fafd commit 9526230
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/apis/bookkeeper/v1alpha1/bookkeepercluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 14 additions & 2 deletions test/e2e/cmchanges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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())
Expand Down

0 comments on commit 9526230

Please sign in to comment.