Skip to content

Commit

Permalink
feat(ec): migration from v1 to v2 - fixes (#5111)
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh authored Jan 23, 2025
1 parent e62b5e9 commit 29c846c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require (
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20241217212717-16e5694e39aa
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20250121224829-68f86fdec4e9
github.com/replicatedhq/kotskinds v0.0.0-20240718194123-1018dd404e95
github.com/replicatedhq/kurlkinds v1.5.0
github.com/replicatedhq/troubleshoot v0.115.1
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,8 @@ github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDO
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20241217212717-16e5694e39aa h1:fXPI/I8F2goWhpGrmJops8SW5y6RnBJ9tZGdw+Qd+x0=
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20241217212717-16e5694e39aa/go.mod h1:+M1m6F45l4m7z8L6sBe+iLg/IVDZkR7jEHDgM8WwEfE=
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20250121224829-68f86fdec4e9 h1:d2lxqo8Qmh3xnknchklnn94GzHyneDZLOQ6vSUZS1Tg=
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20250121224829-68f86fdec4e9/go.mod h1:SeowBlFk6Eh4dUIb4p4cckjjzg+fshqlFBA3yuMCS+c=
github.com/replicatedhq/kotskinds v0.0.0-20240718194123-1018dd404e95 h1:JhwPz4Bgbz5iYl3UV2EB+HnF9oW/eCRi+hASAz+J6XI=
github.com/replicatedhq/kotskinds v0.0.0-20240718194123-1018dd404e95/go.mod h1:QjhIUu3+OmHZ09u09j3FCoTt8F3BYtQglS+OLmftu9I=
github.com/replicatedhq/kurlkinds v1.5.0 h1:zZ0PKNeh4kXvSzVGkn62DKTo314GxhXg1TSB3azURMc=
Expand Down Expand Up @@ -2292,7 +2292,6 @@ google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a h1:UIpYSuWdWHSzjwcAFRLjKcPXFZVVLXGEM23W+NWqipw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
7 changes: 4 additions & 3 deletions pkg/embeddedcluster/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func startClusterUpgrade(
logger.Errorf("Failed to notify upgrade started: %v", err)
}

err = runClusterUpgrade(ctx, k8sClient, newInstall, registrySettings, license, versionLabel)
err = runClusterUpgrade(ctx, k8sClient, newcfg, newInstall, registrySettings, license, versionLabel)
if err != nil {
if err := NotifyUpgradeFailed(ctx, license.Spec.Endpoint, newInstall, current, err.Error()); err != nil {
logger.Errorf("Failed to notify upgrade failed: %v", err)
Expand All @@ -105,7 +105,8 @@ func startClusterUpgrade(
// operator, wait for the CRD to be up-to-date, and then apply the installation object.
func runClusterUpgrade(
ctx context.Context, k8sClient kubernetes.Interface,
in *embeddedclusterv1beta1.Installation, registrySettings registrytypes.RegistrySettings,
newcfg embeddedclusterv1beta1.ConfigSpec, in *embeddedclusterv1beta1.Installation,
registrySettings registrytypes.RegistrySettings,
license kotsv1beta1.License, versionLabel string,
) error {
var bin string
Expand Down Expand Up @@ -151,7 +152,7 @@ func runClusterUpgrade(
}
args = append(args, "--installation", "-")

if os.Getenv("ENABLE_V2_MIGRATION") == "true" {
if newcfg.V2Enabled {
err := createV2MigrationSecret(ctx, k8sClient, license)
if err != nil {
return fmt.Errorf("create v2 migration secret: %w", err)
Expand Down
22 changes: 21 additions & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,18 @@ func (o *Operator) waitForClusterUpgrade(appID string, appSlug string) error {
}
return nil // we try to deploy the app even if the cluster upgrade failed
}
if err := upgradeservicetask.SetStatusUpgradingCluster(appSlug, ins.Status.State); err != nil {
msg := ins.Status.State
if checkInstallationConditionStatus(ins.Status, embeddedclusterv1beta1.ConditionTypeV2MigrationInProgress) == metav1.ConditionTrue {
msg = "V2MigrationInProgress"
}
if msg == "" {
// if the status was the same previously, do not overwrite the previous message with an empty one
taskStatus, taskMsg, _ := upgradeservicetask.GetStatus(appSlug)
if taskStatus == string(upgradeservicetask.StatusUpgradingCluster) {
msg = taskMsg
}
}
if err := upgradeservicetask.SetStatusUpgradingCluster(appSlug, msg); err != nil {
return errors.Wrap(err, "failed to set task status to upgrading cluster")
}
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -1124,3 +1135,12 @@ func (o *Operator) notifyClusterUpgradeFailed(ctx context.Context, kbClient kbcl
}
return nil
}

func checkInstallationConditionStatus(inStat embeddedclusterv1beta1.InstallationStatus, conditionName string) metav1.ConditionStatus {
for _, cond := range inStat.Conditions {
if cond.Type == conditionName {
return cond.Status
}
}
return ""
}
2 changes: 1 addition & 1 deletion web/src/components/modals/UpgradeStatusModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const UpgradeStatusModal = (props: Props) => {
);
}

let message;
let message: string;
if (props.status === "upgrading-cluster") {
message = Utilities.humanReadableClusterState(props.message);
} else if (props.status === "upgrading-app") {
Expand Down
4 changes: 4 additions & 0 deletions web/src/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,14 @@ export const Utilities = {
return "Upgrading addons";
case "PendingChartCreation":
return "Creating addons";
case "AddonsInstalled":
return "Addons upgraded";
case "HelmChartUpdateFailure":
return "Failed to upgrade addons";
case "Failed":
return "Failed";
case "V2MigrationInProgress":
return "Migrating cluster to v2";
default:
return "Unknown";
}
Expand Down

0 comments on commit 29c846c

Please sign in to comment.