Skip to content

Commit

Permalink
Fix: upstream update should deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
marccampbell committed Jul 22, 2020
1 parent fc59877 commit 8f77a5f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/kots/cli/upstream-upgrade.go
Expand Up @@ -153,7 +153,7 @@ func UpstreamUpgradeCmd() *cobra.Command {
},
}

cmd.Flags().Bool("deploy", false, "when set, automatically deploy the latest version downloads")
cmd.Flags().Bool("deploy", false, "when set, automatically deploy the latest version")

cmd.Flags().Bool("debug", false, "when set, log full error traces in some cases where we provide a pretty message")
cmd.Flags().MarkHidden("debug")
Expand Down
27 changes: 27 additions & 0 deletions kotsadm/pkg/updatechecker/updatechecker.go
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/pkg/errors"
"github.com/replicatedhq/kots/kotsadm/pkg/app"
"github.com/replicatedhq/kots/kotsadm/pkg/downstream"
"github.com/replicatedhq/kots/kotsadm/pkg/kotsutil"
"github.com/replicatedhq/kots/kotsadm/pkg/license"
"github.com/replicatedhq/kots/kotsadm/pkg/logger"
Expand Down Expand Up @@ -205,6 +206,32 @@ func CheckForUpdates(appID string, deploy bool) (int64, error) {

// if there are updates, go routine it
if len(updates) == 0 {
if !deploy {
return 0, nil
}

// ensure that the latest version is deployed
allVersions, err := version.GetVersions(a.ID)
if err != nil {
return 0, errors.Wrap(err, "failed to list app versions")
}

// get the first version, the array must contain versions at this point
// this function can't run without an app
latestVersion := allVersions[len(allVersions)-1]
downstreams, err := downstream.ListDownstreamsForApp(a.ID)
if err != nil {
return 0, errors.Wrap(err, "failed to list downstreams for app")
}
downstream := downstreams[0]

if latestVersion.Sequence != downstream.CurrentSequence {
err := version.DeployVersion(a.ID, latestVersion.Sequence)
if err != nil {
return 0, errors.Wrap(err, "failed to deploy latest version")
}
}

return 0, nil
}

Expand Down

0 comments on commit 8f77a5f

Please sign in to comment.