MCPcopy
hub / github.com/argoproj/argo-workflows / createAgentPod

Method createAgentPod

workflow/controller/agent.go:112–265  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

110}
111
112func (woc *wfOperationCtx) createAgentPod(ctx context.Context) (*apiv1.Pod, error) {
113 podName := woc.getAgentPodName()
114 ctx, log := woc.log.WithField("podName", podName).InContext(ctx)
115
116 pod, err := woc.controller.PodController.GetPod(woc.wf.Namespace, podName)
117 if err != nil {
118 return nil, fmt.Errorf("failed to get pod from informer store: %w", err)
119 }
120 if pod != nil {
121 return pod, nil
122 }
123
124 certVolume, certVolumeMount, err := woc.getCertVolumeMount(ctx, common.CACertificatesVolumeMountName)
125 if err != nil {
126 return nil, err
127 }
128
129 pluginSidecars, pluginVolumes, err := woc.getExecutorPlugins(ctx)
130 if err != nil {
131 return nil, err
132 }
133
134 envVars := []apiv1.EnvVar{
135 {Name: common.EnvVarWorkflowName, Value: woc.wf.Name},
136 {Name: common.EnvVarWorkflowUID, Value: string(woc.wf.UID)},
137 {Name: common.EnvAgentPatchRate, Value: env.LookupEnvStringOr(common.EnvAgentPatchRate, GetRequeueTime().String())},
138 {Name: common.EnvVarPluginAddresses, Value: wfv1.MustMarshallJSON(addresses(pluginSidecars))},
139 {Name: common.EnvVarPluginNames, Value: wfv1.MustMarshallJSON(names(pluginSidecars))},
140 }
141
142 // If the default number of task workers is overridden, then pass it to the agent pod.
143 if taskWorkers, exists := os.LookupEnv(common.EnvAgentTaskWorkers); exists {
144 envVars = append(envVars, apiv1.EnvVar{
145 Name: common.EnvAgentTaskWorkers,
146 Value: taskWorkers,
147 })
148 }
149
150 serviceAccountName := woc.execWf.Spec.ServiceAccountName
151 tokenVolume, tokenVolumeMount, err := woc.getServiceAccountTokenVolume(ctx, serviceAccountName)
152 if err != nil {
153 return nil, fmt.Errorf("failed to get token volumes: %w", err)
154 }
155
156 podVolumes := append(
157 pluginVolumes,
158 volumeVarArgo,
159 *tokenVolume,
160 )
161 podVolumeMounts := []apiv1.VolumeMount{
162 volumeMountVarArgo,
163 *tokenVolumeMount,
164 }
165 if certVolume != nil && certVolumeMount != nil {
166 podVolumes = append(podVolumes, *certVolume)
167 podVolumeMounts = append(podVolumeMounts, *certVolumeMount)
168 }
169 agentCtrTemplate := apiv1.Container{

Callers 1

reconcileAgentPodMethod · 0.95

Calls 15

getAgentPodNameMethod · 0.95
getCertVolumeMountMethod · 0.95
getExecutorPluginsMethod · 0.95
getExecutorLogOptsMethod · 0.95
addMetadataMethod · 0.95
addDNSConfigMethod · 0.95
requeueMethod · 0.95
LookupEnvStringOrFunction · 0.92
MinimalCtrSCFunction · 0.92
MinimalPodSCFunction · 0.92

Tested by

no test coverage detected