Skip to content

fix: system executor fails trigger on cm/secret create errors and reads active job conditions - #7100

Open
prakash100198 wants to merge 1 commit into
developfrom
fix/system-executor-job-errors-7080-oss
Open

prakash100198 wants to merge 1 commit into
developfrom
fix/system-executor-job-errors-7080-oss

Conversation

@prakash100198

Copy link
Copy Markdown
Contributor

Description

Fixes #7080

Two bugs in SystemWorkflowExecutorImpl, the executor used when the workflow executor type is SYSTEM (Kubernetes Jobs instead of Argo).

1. ConfigMap/Secret create errors were ignored. createCmAndSecrets logged them "but ignoring" and the Job was resumed anyway. The pod then sits in CreateContainerConfigError until the active deadline, and the build looks stuck with no reason shown.

  • Any create error is now returned, except AlreadyExists. The still-suspended Job is deleted with foreground propagation, so any cm/secret it already owns is garbage-collected. The CI and pre/post-CD triggers already mark the run Failed with the error message.
  • AlreadyExists is still tolerated, as before. The object is there, so the pod can start, and failing on it would turn today's working runs into failures.
  • This matches the Argo executor, where a failed create step fails the workflow before the main step runs.

2. GetWorkflowStatus returned Conditions[0].Type whatever its status. A resumed Job keeps Suspended=False as its first condition. On k8s 1.31+ the job controller also adds SuccessCriteriaMet/FailureTarget before Complete/Failed. So the status was Suspended even for finished Jobs.

  • The only caller is the CI failure cron (UpdateCiWorkflowStatusFailure). It compares the status with Failed to detect deleted pods and to auto-retry via HandlePodDeleted, and that comparison never matched.
  • The status now comes from an active Complete/Failed condition if there is one, else the latest active condition. Inactive conditions are skipped.

Only pkg/pipeline/executors/systemWorkflow.go changes. No API, schema or Wire changes.

How Has This Been Tested?

Unit tests (systemWorkflow_test.go, new): an httptest fake API records every call. 11 ExecuteWorkflow cases (happy path, external cm/secret, forbidden/invalid/500 on cm or secret, AlreadyExists, cleanup failure, Job already gone), 11 job-condition cases, and GetWorkflowStatus.

  • On this branch: all pass.
  • Same tests on develop: exactly the 6 error-path cases and the status case fail. The happy path and AlreadyExists cases pass on both, so behaviour there is unchanged.

Real-cluster E2E on GKE 1.35, also run on the enterprise copy of this file with identical results: the actual executor against a live API server, job controller, RBAC and GC, using throwaway namespaces (deleted afterwards). The forbidden cases use a ServiceAccount without cm or secret create.

Scenario develop this branch
happy (cm + secret via envFrom) completes, status Suspended completes, status Complete
job exits 1 status Suspended status Failed
pod deleted while running status Suspended, cron does not treat as pod-deleted status Failed, cron treats as pod-deleted
cm already exists completes, status Suspended completes, status Complete
cm create forbidden no error, Job resumed, pod CreateContainerConfigError, Job and secret left behind Forbidden returned, Job and secret removed
secret create forbidden no error, Job resumed, pod CreateContainerConfigError, Job and cm left behind Forbidden returned, Job and cm removed

Terminal conditions seen on both: [Suspended=False, SuccessCriteriaMet=True, Complete=True] and [Suspended=False, FailureTarget=True, Failed=True]. Pod outcomes and conditions are identical between the two runs. Only the rows above differ.

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?

With the SYSTEM workflow executor, a build or pre/post-deploy stage now fails immediately with the Kubernetes error when its ConfigMap or Secret cannot be created, instead of hanging until timeout. Deleted build pods are detected correctly on Kubernetes 1.31+.

🤖 Generated with Claude Code

…ds active job conditions

- return cm/secret create errors (other than AlreadyExists) instead of resuming the job, and delete the still-suspended job
- derive workflow status from an active Complete/Failed job condition instead of Conditions[0]

Fixes #7080

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bito-code-review

Copy link
Copy Markdown

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews. To trigger review, type /review in the comment and save. You can change the settings here, or contact the agent instance creator at shivam@devtron.ai.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant