Skip to content

Commit

Permalink
builders: Persist build pod when DEBUG is true (PROJQUAY-3710) (#1297)
Browse files Browse the repository at this point in the history
In the previous kubernetes executor the build job was persisted in DEBUG mode due to the virtual machine in the pod never exiting. This kept the job alive for users to view the debug information. The `kubernetesPodman` executor does not run the VM so it will be cleaned up due to `ttlSecondsAfterFinished` being set on the job. This change prevents the `ttlSecondsAfterFinished` field from being set when DEBUG is true, allowing the pod to stay alive to retrieve the logs.
  • Loading branch information
bcaton85 authored Apr 29, 2022
1 parent c2ceda5 commit d8ae686
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions buildman/manager/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,6 @@ def _job_resource(self, token, build_uuid):
"spec": {
"activeDeadlineSeconds": self.executor_config.get("MAXIMUM_JOB_TIME", 7200),
"backoffLimit": 1,
"ttlSecondsAfterFinished": self.executor_config.get(
"RETENTION_AFTER_FINISHED", 120
),
"template": {
"metadata": {
"labels": {
Expand All @@ -625,6 +622,12 @@ def _job_resource(self, token, build_uuid):
},
}

# If DEBUG isn't enabled, add a TTL on the job
if not self.executor_config.get("DEBUG", False):
job_resource["spec"]["ttlSecondsAfterFinished"] = self.executor_config.get(
"RETENTION_AFTER_FINISHED", 120
)

if self._is_openshift_kubernetes_distribution():
# Setting `automountServiceAccountToken` to false will prevent automounting API credentials for a service account.
job_resource["spec"]["template"]["spec"]["automountServiceAccountToken"] = False
Expand Down

0 comments on commit d8ae686

Please sign in to comment.