Skip to content

Commit 6c5608e

Browse files
authored
fix: split pod controller from workflow controller (#14129)
Signed-off-by: Alan Clucas <[email protected]>
1 parent 6977eb8 commit 6c5608e

22 files changed

+872
-460
lines changed

workflow/common/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ const (
5252
// AnnotationKeyArtifactGCStrategy is listed as an annotation on the Artifact GC Pod to identify
5353
// the strategy whose artifacts are being deleted
5454
AnnotationKeyArtifactGCStrategy = workflow.WorkflowFullName + "/artifact-gc-strategy"
55+
// AnnotationKeyPodGCStrategy is listed as an annotation on the Pod
56+
// the strategy for the pod, in case the pod is orphaned from its workflow
57+
AnnotationKeyPodGCStrategy = workflow.WorkflowFullName + "/pod-gc-strategy"
5558

5659
// LabelKeyControllerInstanceID is the label the controller will carry forward to workflows/pod labels
5760
// for the purposes of workflow segregation

workflow/controller/agent.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
apierr "k8s.io/apimachinery/pkg/api/errors"
1111
"k8s.io/apimachinery/pkg/api/resource"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13-
"k8s.io/client-go/tools/cache"
1413
"k8s.io/utils/ptr"
1514

1615
"github.com/argoproj/argo-workflows/v3/errors"
@@ -113,16 +112,12 @@ func (woc *wfOperationCtx) createAgentPod(ctx context.Context) (*apiv1.Pod, erro
113112
podName := woc.getAgentPodName()
114113
log := woc.log.WithField("podName", podName)
115114

116-
obj, exists, err := woc.controller.podInformer.GetStore().Get(cache.ExplicitKey(woc.wf.Namespace + "/" + podName))
115+
pod, err := woc.controller.PodController.GetPod(woc.wf.Namespace, podName)
117116
if err != nil {
118117
return nil, fmt.Errorf("failed to get pod from informer store: %w", err)
119118
}
120-
if exists {
121-
existing, ok := obj.(*apiv1.Pod)
122-
if ok {
123-
log.WithField("podPhase", existing.Status.Phase).Debug("Skipped pod creation: already exists")
124-
return existing, nil
125-
}
119+
if pod != nil {
120+
return pod, nil
126121
}
127122

128123
certVolume, certVolumeMount, err := woc.getCertVolumeMount(ctx, common.CACertificatesVolumeMountName)
@@ -197,7 +192,7 @@ func (woc *wfOperationCtx) createAgentPod(ctx context.Context) (*apiv1.Pod, erro
197192
agentMainCtr.Name = common.MainContainerName
198193
agentMainCtr.Args = append([]string{"agent", "main"}, woc.getExecutorLogOpts()...)
199194

200-
pod := &apiv1.Pod{
195+
pod = &apiv1.Pod{
201196
ObjectMeta: metav1.ObjectMeta{
202197
Name: podName,
203198
Namespace: woc.wf.ObjectMeta.Namespace,

workflow/controller/artifact_gc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func (woc *wfOperationCtx) createArtifactGCPod(ctx context.Context, strategy wfv
503503
// go through any GC pods that are already running and may have completed
504504
func (woc *wfOperationCtx) processArtifactGCCompletion(ctx context.Context) error {
505505
// check if any previous Artifact GC Pods completed
506-
pods, err := woc.controller.podInformer.GetIndexer().ByIndex(indexes.WorkflowIndex, woc.wf.GetNamespace()+"/"+woc.wf.GetName())
506+
pods, err := woc.controller.PodController.GetPodsByIndex(indexes.WorkflowIndex, woc.wf.GetNamespace()+"/"+woc.wf.GetName())
507507
if err != nil {
508508
return fmt.Errorf("failed to get pods from informer: %w", err)
509509
}

0 commit comments

Comments
 (0)