Skip to content

fix: split pod controller from workflow controller (#14129) (release-3.6) #14263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions workflow/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const (
// AnnotationKeyArtifactGCStrategy is listed as an annotation on the Artifact GC Pod to identify
// the strategy whose artifacts are being deleted
AnnotationKeyArtifactGCStrategy = workflow.WorkflowFullName + "/artifact-gc-strategy"
// AnnotationKeyPodGCStrategy is listed as an annotation on the Pod
// the strategy for the pod, in case the pod is orphaned from its workflow
AnnotationKeyPodGCStrategy = workflow.WorkflowFullName + "/pod-gc-strategy"

// LabelKeyControllerInstanceID is the label the controller will carry forward to workflows/pod labels
// for the purposes of workflow segregation
Expand Down
13 changes: 4 additions & 9 deletions workflow/controller/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
apierr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/ptr"

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

obj, exists, err := woc.controller.podInformer.GetStore().Get(cache.ExplicitKey(woc.wf.Namespace + "/" + podName))
pod, err := woc.controller.PodController.GetPod(woc.wf.Namespace, podName)
if err != nil {
return nil, fmt.Errorf("failed to get pod from informer store: %w", err)
}
if exists {
existing, ok := obj.(*apiv1.Pod)
if ok {
log.WithField("podPhase", existing.Status.Phase).Debug("Skipped pod creation: already exists")
return existing, nil
}
if pod != nil {
return pod, nil
}

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

pod := &apiv1.Pod{
pod = &apiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Namespace: woc.wf.ObjectMeta.Namespace,
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/artifact_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (woc *wfOperationCtx) createArtifactGCPod(ctx context.Context, strategy wfv
// go through any GC pods that are already running and may have completed
func (woc *wfOperationCtx) processArtifactGCCompletion(ctx context.Context) error {
// check if any previous Artifact GC Pods completed
pods, err := woc.controller.podInformer.GetIndexer().ByIndex(indexes.WorkflowIndex, woc.wf.GetNamespace()+"/"+woc.wf.GetName())
pods, err := woc.controller.PodController.GetPodsByIndex(indexes.WorkflowIndex, woc.wf.GetNamespace()+"/"+woc.wf.GetName())
if err != nil {
return fmt.Errorf("failed to get pods from informer: %w", err)
}
Expand Down
Loading