Skip to content

Commit

Permalink
Fix the bug for upgrade flag (#7896)
Browse files Browse the repository at this point in the history
* Fixed the bug for upgrade

Signed-off-by: SahithiMy <sahithi.mylangam@progress.com>

* Fix for upgrade

Signed-off-by: SahithiMy <sahithi.mylangam@progress.com>

* updated error msg

Signed-off-by: SahithiMy <sahithi.mylangam@progress.com>

---------

Signed-off-by: SahithiMy <sahithi.mylangam@progress.com>
Co-authored-by: SahithiMy <sahithi.mylangam@progress.com>
  • Loading branch information
2 people authored and bvtejaswi committed May 24, 2023
1 parent 9a33cf7 commit 502ffe3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func tailFile(logFilePath string, executed chan struct{}) {

}
}
func doBootstrapEnv(airgapBundlePath string, saas bool) error {
func doBootstrapEnv(airgapBundlePath string, saas bool, frontend bool, backend bool) error {
conf := new(dc.AutomateConfig)
if err := mergeFlagOverrides(conf); err != nil {
return status.Wrap(
Expand Down Expand Up @@ -184,9 +184,21 @@ func doBootstrapEnv(airgapBundlePath string, saas bool) error {
return status.Annotate(err, status.DeployError)
}
if offlineMode {
err := moveFrontendBackendAirgapToTransferDir(airgapMetadata, airgapBundlePath)
if err != nil {
return status.Annotate(err, status.DeployError)
if frontend {
err := moveAirgapFrontendBundlesOnlyToTransferDir(airgapMetadata, upgradeRunCmdFlags.airgap)
if err != nil {
return status.Annotate(err, status.DeployError)
}
} else if backend {
err := moveAirgapBackendBundlesOnlyToTransferDir(airgapMetadata, upgradeRunCmdFlags.airgap)
if err != nil {
return status.Annotate(err, status.DeployError)
}
} else {
err := moveFrontendBackendAirgapToTransferDir(airgapMetadata, upgradeRunCmdFlags.airgap)
if err != nil {
return status.Annotate(err, status.DeployError)
}
}
}
return nil
Expand All @@ -203,7 +215,7 @@ func bootstrapEnv(dm deployManager, airgapBundlePath string, saas bool) error {
return status.New(status.InvalidCommandArgsError, errMLSA)
}
}
err := doBootstrapEnv(airgapBundlePath, saas)
err := doBootstrapEnv(airgapBundlePath, saas, upgradeRunCmdFlags.upgradefrontends, upgradeRunCmdFlags.upgradebackends)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion components/automate-cli/cmd/chef-automate/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func runAutomateHAFlow(args []string, offlineMode bool) error {
if offlineMode {
// Always upgrade the workspace
upgradeRunCmdFlags.upgradeHAWorkspace = "yes"
uperr, upgraded := upgradeWorspace(upgradeRunCmdFlags.airgap, upgradeRunCmdFlags.saas)
uperr, upgraded := upgradeWorspace(upgradeRunCmdFlags.airgap, upgradeRunCmdFlags.saas, upgradeRunCmdFlags.upgradefrontends, upgradeRunCmdFlags.upgradebackends)
if uperr != nil {
return status.Annotate(uperr, status.UpgradeError)
}
Expand Down
6 changes: 3 additions & 3 deletions components/automate-cli/cmd/chef-automate/workspaceUpgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func worspaceUpgradeCmdExecute(cmd *cobra.Command, args []string) error {
return status.Wrap(errors.New("Incorrect command usage"), 0, workspaceUpgradeHelpDocs)
}
if isA2HARBFileExist() {
err, upgraded := upgradeWorspace(args[0], upgradeRunCmdFlags.saas)
err, upgraded := upgradeWorspace(args[0], upgradeRunCmdFlags.saas, upgradeRunCmdFlags.upgradefrontends, upgradeRunCmdFlags.upgradebackends)
if err != nil {
return status.Annotate(err, status.UpgradeError)
}
Expand All @@ -59,7 +59,7 @@ func worspaceUpgradeCmdExecute(cmd *cobra.Command, args []string) error {
return errors.New(AUTOMATE_HA_INVALID_BASTION)
}

func upgradeWorspace(bundle string, saas bool) (error, bool) {
func upgradeWorspace(bundle string, saas bool, frontend bool, backend bool) (error, bool) {
updateAvailabe, err := checkIfNewBundleHaveWorkspaceUpdate(bundle, saas)
if err != nil {
writer.Println(err.Error())
Expand All @@ -86,7 +86,7 @@ func upgradeWorspace(bundle string, saas bool) (error, bool) {
}
if upgradeAccepted {
writer.Println("Bootstraping for new version.")
err := doBootstrapEnv(bundle, upgradeRunCmdFlags.saas)
err := doBootstrapEnv(bundle, upgradeRunCmdFlags.saas, frontend, backend)
if err != nil {
writer.Println(err.Error())
return nil, false
Expand Down

0 comments on commit 502ffe3

Please sign in to comment.