-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow for management kindless upgrades (#6622)
This branchs out the code at the command level and uses a different workflow if kindless upgrades are enabled. This facilitates the transition once we are ready to flip the switch and avoids having to maintain multiple codepaths in the existing workflow, which from experience, it has proven to be difficult and prone to errors. The tradeoff is we need to mainetain the same functionality in two workflows until we decide to deprecate the old one.
- Loading branch information
1 parent
770bfdd
commit 5349a0b
Showing
20 changed files
with
1,359 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package management | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/eks-anywhere/pkg/logger" | ||
"github.com/aws/eks-anywhere/pkg/task" | ||
"github.com/aws/eks-anywhere/pkg/types" | ||
"github.com/aws/eks-anywhere/pkg/workflows" | ||
) | ||
|
||
type ensureEtcdCAPIComponentsExist struct{} | ||
|
||
// Run ensureEtcdCAPIComponentsExist ensures ETCD CAPI providers on the management cluster. | ||
func (s *ensureEtcdCAPIComponentsExist) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { | ||
logger.Info("Ensuring etcd CAPI providers exist on management cluster before upgrade") | ||
if err := commandContext.CAPIManager.EnsureEtcdProvidersInstallation(ctx, commandContext.ManagementCluster, commandContext.Provider, commandContext.CurrentClusterSpec); err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
return &pauseGitOpsReconcile{} | ||
} | ||
|
||
func (s *ensureEtcdCAPIComponentsExist) Name() string { | ||
return "ensure-etcd-capi-components-exist" | ||
} | ||
|
||
func (s *ensureEtcdCAPIComponentsExist) Checkpoint() *task.CompletedTask { | ||
return &task.CompletedTask{ | ||
Checkpoint: nil, | ||
} | ||
} | ||
|
||
func (s *ensureEtcdCAPIComponentsExist) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { | ||
return &pauseGitOpsReconcile{}, nil | ||
} | ||
|
||
type upgradeCoreComponents struct { | ||
UpgradeChangeDiff *types.ChangeDiff | ||
} | ||
|
||
// Run upgradeCoreComponents upgrades pre cluster upgrade components. | ||
func (s *upgradeCoreComponents) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { | ||
logger.Info("Upgrading core components") | ||
|
||
err := commandContext.Provider.PreCoreComponentsUpgrade( | ||
ctx, | ||
commandContext.ManagementCluster, | ||
commandContext.ClusterSpec, | ||
) | ||
if err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
|
||
changeDiff, err := commandContext.CAPIManager.Upgrade(ctx, commandContext.ManagementCluster, commandContext.Provider, commandContext.CurrentClusterSpec, commandContext.ClusterSpec) | ||
if err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
commandContext.UpgradeChangeDiff.Append(changeDiff) | ||
|
||
if err = commandContext.GitOpsManager.Install(ctx, commandContext.ManagementCluster, commandContext.CurrentClusterSpec, commandContext.ClusterSpec); err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
|
||
changeDiff, err = commandContext.GitOpsManager.Upgrade(ctx, commandContext.ManagementCluster, commandContext.CurrentClusterSpec, commandContext.ClusterSpec) | ||
if err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
commandContext.UpgradeChangeDiff.Append(changeDiff) | ||
|
||
changeDiff, err = commandContext.ClusterManager.Upgrade(ctx, commandContext.ManagementCluster, commandContext.CurrentClusterSpec, commandContext.ClusterSpec) | ||
if err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
commandContext.UpgradeChangeDiff.Append(changeDiff) | ||
|
||
changeDiff, err = commandContext.EksdUpgrader.Upgrade(ctx, commandContext.ManagementCluster, commandContext.CurrentClusterSpec, commandContext.ClusterSpec) | ||
if err != nil { | ||
commandContext.SetError(err) | ||
return &workflows.CollectMgmtClusterDiagnosticsTask{} | ||
} | ||
commandContext.UpgradeChangeDiff.Append(changeDiff) | ||
s.UpgradeChangeDiff = commandContext.UpgradeChangeDiff | ||
|
||
return &preClusterUpgrade{} | ||
} | ||
|
||
func (s *upgradeCoreComponents) Name() string { | ||
return "upgrade-core-components" | ||
} | ||
|
||
func (s *upgradeCoreComponents) Checkpoint() *task.CompletedTask { | ||
return &task.CompletedTask{ | ||
Checkpoint: s.UpgradeChangeDiff, | ||
} | ||
} | ||
|
||
func (s *upgradeCoreComponents) Restore(ctx context.Context, commandContext *task.CommandContext, completedTask *task.CompletedTask) (task.Task, error) { | ||
s.UpgradeChangeDiff = &types.ChangeDiff{} | ||
if err := task.UnmarshalTaskCheckpoint(completedTask.Checkpoint, s.UpgradeChangeDiff); err != nil { | ||
return nil, err | ||
} | ||
commandContext.UpgradeChangeDiff = s.UpgradeChangeDiff | ||
return &preClusterUpgrade{}, nil | ||
} |
Oops, something went wrong.