Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stop all services first to update the service status in the serv…
…ice registration during a `kurtosis enclave stop` execution (#1712) ## Description: unregister the enclave services during a `kurtosis enclave stop` execution ## Is this change user-facing? NO ## References (if applicable): Fix #1711
- Loading branch information
Showing
3 changed files
with
68 additions
and
28 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
35 changes: 35 additions & 0 deletions
35
cli/cli/helpers/shared_starlark_calls/shared_starlark_calls.go
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,35 @@ | ||
package shared_starlark_calls | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves" | ||
"github.com/kurtosis-tech/kurtosis/api/golang/core/lib/services" | ||
"github.com/kurtosis-tech/kurtosis/api/golang/core/lib/starlark_run_config" | ||
"github.com/kurtosis-tech/stacktrace" | ||
) | ||
|
||
const ( | ||
stopServiceStarlarkScript = ` | ||
def run(plan, args): | ||
plan.stop_service(name=args["service_name"]) | ||
` | ||
) | ||
|
||
func StopServiceStarlarkCommand(ctx context.Context, enclaveCtx *enclaves.EnclaveContext, serviceName services.ServiceName) error { | ||
params := fmt.Sprintf(`{"service_name": "%s"}`, serviceName) | ||
runResult, err := enclaveCtx.RunStarlarkScriptBlocking(ctx, stopServiceStarlarkScript, starlark_run_config.NewRunStarlarkConfig(starlark_run_config.WithSerializedParams(params))) | ||
if err != nil { | ||
return stacktrace.Propagate(err, "An unexpected error occurred on Starlark for stopping service") | ||
} | ||
if runResult.ExecutionError != nil { | ||
return stacktrace.NewError("An error occurred during Starlark script execution for stopping service: %s", runResult.ExecutionError.GetErrorMessage()) | ||
} | ||
if runResult.InterpretationError != nil { | ||
return stacktrace.NewError("An error occurred during Starlark script interpretation for stopping service: %s", runResult.InterpretationError.GetErrorMessage()) | ||
} | ||
if len(runResult.ValidationErrors) > 0 { | ||
return stacktrace.NewError("An error occurred during Starlark script validation for stopping service: %v", runResult.ValidationErrors) | ||
} | ||
return nil | ||
} |