diff --git a/docker/kubernetes-agent-tentacle/scripts/configure-and-run.sh b/docker/kubernetes-agent-tentacle/scripts/configure-and-run.sh index c3640ca2a..56348b3b6 100644 --- a/docker/kubernetes-agent-tentacle/scripts/configure-and-run.sh +++ b/docker/kubernetes-agent-tentacle/scripts/configure-and-run.sh @@ -29,7 +29,9 @@ applicationsDirectory=/home/Octopus/Applications if [[ -n "$TentacleApplications" ]]; then applicationsDirectory="$TentacleApplications" fi - +echo "Creating config directory" +echo "Permissions for $configurationDirectory:" +ls -lan / | grep etc mkdir -p $configurationDirectory mkdir -p $applicationsDirectory diff --git a/source/Octopus.Tentacle/Services/Scripts/Kubernetes/KubernetesScriptServiceV1.cs b/source/Octopus.Tentacle/Services/Scripts/Kubernetes/KubernetesScriptServiceV1.cs index 668d7cd01..29725a143 100644 --- a/source/Octopus.Tentacle/Services/Scripts/Kubernetes/KubernetesScriptServiceV1.cs +++ b/source/Octopus.Tentacle/Services/Scripts/Kubernetes/KubernetesScriptServiceV1.cs @@ -124,7 +124,12 @@ public async Task CancelScriptAsync(CancelKube public async Task CompleteScriptAsync(CompleteKubernetesScriptCommandV1 command, CancellationToken cancellationToken) { var workspace = workspaceFactory.GetWorkspace(command.ScriptTicket, WorkspaceReadinessCheck.Skip); - await workspace.Delete(cancellationToken); + + var podExitCode = podStatusProvider.TryGetTrackedScriptPod(command.ScriptTicket)?.State.ExitCode ?? 0; + + // Preserve the workspace when the script pod failed so the files are available for debugging. + if (!KubernetesConfig.DisableAutomaticPodCleanup && podExitCode != 0) + await workspace.Delete(cancellationToken); scriptLogProvider.Delete(command.ScriptTicket); scriptPodSinceTimeStore.Delete(command.ScriptTicket);