Skip to content

Commit 351d8cd

Browse files
gaurang9991workflow-automation
andauthored
feat: added config option to disable agent pod creation. Fixes argoproj#7891 (argoproj#15844)
Signed-off-by: workflow-automation <workflow-automation@msp.amadeus.net> Co-authored-by: workflow-automation <workflow-automation@msp.amadeus.net>
1 parent 89047a9 commit 351d8cd

6 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Description: Disable agent pod creation for plugins
2+
Authors: [Gaurang Mishra](https://github.com/gaurang9991)
3+
Component: General
4+
Issues: 7891
5+
6+
Allow users to disable agent pod creation for plugins. Workflow Controller watches the task sets updated by exeternal controllers or agents. User should be careful using this, when enabled it stop creating default agent pods for HTTP templates.

config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ type Config struct {
128128
// (e.g., due to Eviction, DiskPressure, Preemption). This allows recovery from transient
129129
// infrastructure issues without requiring a retryStrategy on templates.
130130
FailedPodRestart *FailedPodRestartConfig `json:"failedPodRestart,omitempty"`
131+
132+
// DisableAgentPodCreation disables the creation of agent pods for HTTP and Plugin templates.
133+
// This is useful when external agents are responsible for executing these templates and the controller should not create agent pods.
134+
// Note: when this is set to true, HTTP templates will not be reconciled and the controller will not attempt to create agent pods for them.
135+
DisableAgentPodCreation bool `json:"disableAgentPodCreation,omitempty"`
131136
}
132137

133138
// FailedPodRestartConfig configures automatic restart of pods that fail before entering Running state.

docs/workflow-controller-configmap.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Config contains the root of the configuration settings for the workflow controll
9898
| `Synchronization` | [`SyncConfig`](#syncconfig) | Synchronization via databases config |
9999
| `ArtifactDrivers` | `Array<`[`ArtifactDriver`](#artifactdriver)`>` | ArtifactDrivers lists artifact driver plugins we can use |
100100
| `FailedPodRestart` | [`FailedPodRestartConfig`](#failedpodrestartconfig) | FailedPodRestart configures automatic restart of pods that fail before entering Running state (e.g., due to Eviction, DiskPressure, Preemption). This allows recovery from transient infrastructure issues without requiring a retryStrategy on templates. |
101+
| `DisableAgentPodCreation` | `bool` | DisableAgentPodCreation disables the creation of agent pods for HTTP and Plugin templates. This is useful when external agents are responsible for executing these templates and the controller should not create agent pods. Note: when this is set to true, HTTP templates will not be reconciled and the controller will not attempt to create agent pods for them. |
101102

102103
## NodeEvents
103104

docs/workflow-controller-configmap.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,9 @@ data:
486486
# Workflow cannot run an arbitrary Workflow, use this option.
487487
workflowRestrictions: |
488488
templateReferencing: Strict
489+
490+
# disableAgentPodCreation disables the creation of agent pods for HTTP and Plugin templates.
491+
# This is useful when external agents are responsible for executing these templates and the controller should not create agent pods.
492+
# Note: when this is set to true, HTTP templates will not be reconciled and the controller will not attempt to create agent pods for them.
493+
# Defaults to false
494+
disableAgentPodCreation: "false"

workflow/controller/agent.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func (woc *wfOperationCtx) getCertVolumeMount(ctx context.Context, name string)
110110
}
111111

112112
func (woc *wfOperationCtx) createAgentPod(ctx context.Context) (*apiv1.Pod, error) {
113+
if woc.controller.Config.DisableAgentPodCreation {
114+
return nil, nil
115+
}
113116
podName := woc.getAgentPodName()
114117
ctx, log := woc.log.WithField("podName", podName).InContext(ctx)
115118

workflow/controller/agent_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,46 @@ func TestAssessAgentPodStatus(t *testing.T) {
171171
assert.Empty(t, msg)
172172
})
173173
}
174+
175+
func TestDisableAgentPodCreation(t *testing.T) {
176+
ctx := logging.TestContext(t.Context())
177+
wf := wfv1.MustUnmarshalWorkflow(`apiVersion: argoproj.io/v1alpha1
178+
kind: Workflow
179+
metadata:
180+
name: http-template
181+
namespace: default
182+
spec:
183+
podSpecPatch: |
184+
nodeName: virtual-node
185+
entrypoint: main
186+
templates:
187+
- name: main
188+
steps:
189+
- - name: good
190+
template: http
191+
arguments:
192+
parameters: [{name: url, value: "https://raw.githubusercontent.com/argoproj/argo-workflows/4e450e250168e6b4d51a126b784e90b11a0162bc/pkg/apis/workflow/v1alpha1/generated.swagger.json"}]
193+
- - name: bad
194+
template: http
195+
continueOn:
196+
failed: true
197+
arguments:
198+
parameters: [{name: url, value: "http://openlibrary.org/people/george08/nofound.json"}]
199+
200+
- name: http
201+
inputs:
202+
parameters:
203+
- name: url
204+
http:
205+
url: "{{inputs.parameters.url}}"
206+
207+
`)
208+
cancel, controller := newController(ctx, wf, defaultServiceAccount)
209+
woc := newWorkflowOperationCtx(ctx, wf, controller)
210+
woc.controller.Config.DisableAgentPodCreation = true
211+
defer cancel()
212+
woc.operate(ctx)
213+
pods, err := woc.controller.kubeclientset.CoreV1().Pods("default").List(ctx, v1.ListOptions{})
214+
require.NoError(t, err)
215+
assert.Empty(t, pods.Items)
216+
}

0 commit comments

Comments
 (0)