Skip to content

Conversation

@anshumanks
Copy link
Contributor

@anshumanks anshumanks commented Feb 11, 2025

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

  • Modified upgrade-job.yaml, spec.go, version_update.go, constants.go

Unit Tests

  • Modified version_update_test.go, pre_upgrade_job.json
  • Modified old tests to incorporate new return value from compareVersions function (-2 for patch upgrade)
  • Added a new test to check for patch upgrade
  • Modified json file to incorporate new argument added to pre upgrade job

{{if .PreUpgrade}}
- name: pre-upgrade
args: ["io.cdap.cdap.master.upgrade.UpgradeJobMain", "{{.HostName}}", "11015"]
args: ["io.cdap.cdap.master.upgrade.UpgradeJobMain", "{{.HostName}}", "11015", "{{.SkipPreUpgrade}}"]
Copy link
Contributor

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?

}

lenL, lenR := len(l.components), len(r.components)
// Check if it only a patch upgrade
Copy link
Contributor

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
}
Copy link
Contributor

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.

return s
}

func (s *VersionUpgradeJobSpec) SetSkipPreUpgrade(isPatchUpgrade bool) *VersionUpgradeJobSpec {
Copy link
Contributor

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

confTwillSecurityWorkerSecretDiskPath = "twill.security.worker.secret.disk.path"
confJMXServerPort = "jmx.metrics.collector.server.port"
confSecretMountDefaultMode = "secret.mount.default.mode"
confSkipPreUpgradeFlag = "cdap-operator.skip.preupgrade-job"
Copy link
Contributor

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.

HConf string `json:"hadoopConf,omitempty"`
PreUpgrade bool `json:"preUpgrade,omitempty"`
PostUpgrade bool `json:"postUpgrade,omitempty"`
SkipPreUpgradeFlag bool `json:"skipPreUpgradeFlag,omitempty"`
Copy link
Contributor

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?

}
})
It("Compare image versions in patch upgrade", func() {
imagePairs := []Pair{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is formatting broken?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants