-
Notifications
You must be signed in to change notification settings - Fork 20
Refactor upgrade logic to skip pre upgrade job in case of patch upgrades #137
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
base: develop
Are you sure you want to change the base?
Conversation
@@ -45,7 +45,7 @@ spec: | |||
{{end}} | |||
{{if .PreUpgrade}} | |||
- name: pre-upgrade | |||
args: ["io.cdap.cdap.master.upgrade.UpgradeJobMain", "{{.HostName}}", "11015"] | |||
args: ["io.cdap.cdap.master.upgrade.UpgradeJobMain", "{{.HostName}}", "11015", "{{.SkipPreUpgrade}}"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the argument being set if the preupgrade job doesn't need to be started?
@@ -418,9 +422,24 @@ func compareVersion(l, r *Version) int { | |||
return -1 | |||
} | |||
|
|||
lenL, lenR := len(l.components), len(r.components) | |||
// Check if it only a patch upgrade |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting is broken. Please run make vet fmt
to fix it.
func (s *VersionUpgradeJobSpec) SetSkipPreUpgrade(isPatchUpgrade bool) *VersionUpgradeJobSpec { | ||
s.SkipPreUpgrade = isPatchUpgrade && s.SkipPreUpgradeFlag | ||
return s | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing new line at the end of the file.
@@ -607,3 +611,8 @@ func (s *VersionUpgradeJobSpec) SetPostUpgrade(isPostUpgrade bool) *VersionUpgra | |||
s.PostUpgrade = isPostUpgrade | |||
return s | |||
} | |||
|
|||
func (s *VersionUpgradeJobSpec) SetSkipPreUpgrade(isPatchUpgrade bool) *VersionUpgradeJobSpec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the term patch upgrade
@@ -68,6 +68,7 @@ const ( | |||
confTwillSecurityWorkerSecretDiskPath = "twill.security.worker.secret.disk.path" | |||
confJMXServerPort = "jmx.metrics.collector.server.port" | |||
confSecretMountDefaultMode = "secret.mount.default.mode" | |||
confSkipPreUpgradeFlag = "cdap-operator.skip.preupgrade-job" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be named cdap-operator.preupgrade-job.skip
for consistency.
@@ -577,6 +577,8 @@ type VersionUpgradeJobSpec struct { | |||
HConf string `json:"hadoopConf,omitempty"` | |||
PreUpgrade bool `json:"preUpgrade,omitempty"` | |||
PostUpgrade bool `json:"postUpgrade,omitempty"` | |||
SkipPreUpgradeFlag bool `json:"skipPreUpgradeFlag,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a need for 2 fields for the same things?
@@ -55,6 +55,21 @@ var _ = Describe("Controller Suite", func() { | |||
Expect(compareVersion(high, low)).To(Equal(1)) | |||
} | |||
}) | |||
It("Compare image versions in patch upgrade", func() { | |||
imagePairs := []Pair{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is formatting broken?
Refactor upgrade logic to skip pre upgrade job in case of patch upgrades
Description
This change prevents pre upgrade job from stopping pipelines in case of patch upgrades.
Code change
upgrade-job.yaml, spec.go, version_update.go, constants.go
Unit Tests
version_update_test.go, pre_upgrade_job.json