Skip to content

Commit

Permalink
Do not require enable-api-fields: alpha for entrypoint cancellation
Browse files Browse the repository at this point in the history
This commit removes the need for `enable-api-fields: alpha` to enable
the entrypoint cancellation. This feature should only behind the
`keep-pod-on-cancel: true` feature-flag.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Nov 28, 2023
1 parent 36cd0a1 commit 699cd73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1.TaskRun, taskSpec v1.Ta
defaultForbiddenEnv := config.FromContextOrDefaults(ctx).Defaults.DefaultForbiddenEnv
alphaAPIEnabled := featureFlags.EnableAPIFields == config.AlphaAPIFields
sidecarLogsResultsEnabled := config.FromContextOrDefaults(ctx).FeatureFlags.ResultExtractionMethod == config.ResultExtractionMethodSidecarLogs
enableKeepPodOnCancel := alphaAPIEnabled && featureFlags.EnableKeepPodOnCancel
enableKeepPodOnCancel := featureFlags.EnableKeepPodOnCancel
setSecurityContext := config.FromContextOrDefaults(ctx).FeatureFlags.SetSecurityContext

// Add our implicit volumes first, so they can be overridden by the user if they prefer.
Expand Down
4 changes: 1 addition & 3 deletions pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ func (c *Reconciler) reconcile(ctx context.Context, tr *v1.TaskRun, rtr *resourc
// current labels may not be set on a previously created Pod.
labelSelector := labels.Set{pipeline.TaskRunLabelKey: tr.Name}
pos, err := c.podLister.Pods(tr.Namespace).List(labelSelector.AsSelector())

if err != nil {
logger.Errorf("Error listing pods: %v", err)
return err
Expand Down Expand Up @@ -722,8 +721,7 @@ func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1.TaskRun, reason v1.
}

var err error
if reason == v1.TaskRunReasonCancelled &&
(config.FromContextOrDefaults(ctx).FeatureFlags.EnableKeepPodOnCancel && config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields == config.AlphaAPIFields) {
if reason == v1.TaskRunReasonCancelled && (config.FromContextOrDefaults(ctx).FeatureFlags.EnableKeepPodOnCancel) {
logger.Infof("Canceling task run %q by entrypoint", tr.Name)
err = podconvert.CancelPod(ctx, c.KubeClientSet, tr.Namespace, tr.Status.PodName)
} else {
Expand Down

0 comments on commit 699cd73

Please sign in to comment.