Skip to content

Commit

Permalink
fix: Rollback to previous cluster when cluster set fails (#631)
Browse files Browse the repository at this point in the history
## Description:
<!-- Describe this change, how it works, and the motivation behind it.
-->
When `kurtosis cluster set` fails, we wrongly call `kurtosis cluster
set` on `clusterName` again instead of rolling back to
`clusterPriorToUpdate` as intended.

## Is this change user facing?
YES
<!-- If yes, please add the "user facing" label to the PR -->
<!-- If yes, don't forget to include docs changes where relevant -->

## References (if applicable):
<!-- Add relevant Github Issues, Discord threads, or other helpful
information. -->
  • Loading branch information
victorcolombo committed May 22, 2023
1 parent c4cd286 commit 0e212c9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions cli/cli/commands/cluster/set/set.go
Expand Up @@ -49,11 +49,6 @@ func run(ctx context.Context, flags *flags.ParsedFlags, args *args.ParsedArgs) e
return stacktrace.Propagate(err, "'%s' is not a valid name for Kurtosis cluster", clusterName)
}

engineManager, err := engine_manager.NewEngineManager(ctx)
if err != nil {
return stacktrace.Propagate(err, "An error occurred creating an engine manager.")
}

clusterUpdateSuccessful := false
clusterSettingStore := kurtosis_cluster_setting.GetKurtosisClusterSettingStore()
clusterPriorToUpdate, err := clusterSettingStore.GetClusterSetting()
Expand All @@ -74,15 +69,19 @@ func run(ctx context.Context, flags *flags.ParsedFlags, args *args.ParsedArgs) e
if clusterUpdateSuccessful {
return
}
if err = clusterSettingStore.SetClusterSetting(clusterName); err != nil {
if err = clusterSettingStore.SetClusterSetting(clusterPriorToUpdate); err != nil {
logrus.Errorf("An error happened updating cluster to '%s'. KUrtosis tried to roll back to the "+
"previous value '%s' but the roll back failed. You have to roll back manually running "+
"'kurtosis %s %s %s'", clusterName, clusterPriorToUpdate, command_str_consts.ClusterCmdStr,
command_str_consts.ClusterSetCmdStr, clusterPriorToUpdate)
}
}()
logrus.Infof("Clustet set to '%s', Kurtosis engine will now be restarted", clusterName)
logrus.Infof("Cluster set to '%s', Kurtosis engine will now be restarted", clusterName)

engineManager, err := engine_manager.NewEngineManager(ctx)
if err != nil {
return stacktrace.Propagate(err, "An error occurred creating an engine manager.")
}
// We try to do our best to restart an engine on the same version the current on is on
_, engineClientCloseFunc, restartEngineErr := engineManager.RestartEngineIdempotently(ctx, logrus.InfoLevel, noEngineVersion, restartEngineOnSameVersionIfAnyRunning)
if restartEngineErr != nil {
Expand Down

0 comments on commit 0e212c9

Please sign in to comment.