(ctx context.Context)
| 110 | } |
| 111 | |
| 112 | func (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{ |
no test coverage detected