{"record":{"id":"7d483ceaf79ba70b","repo":"argoproj/argo-workflows","slug":"artifact-gc-pod-q-missing-annotation-q","errorCode":null,"errorMessage":"artifact gc pod %q missing annotation %q","messagePattern":"artifact gc pod %q missing annotation %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/artifact_gc.go","lineNumber":642,"sourceCode":"\t\t}\n\t\tfor _, a := range n.GetOutputs().GetArtifacts() {\n\t\t\t// artifact strategy is either based on overall Workflow ArtifactGC Strategy, or\n\t\t\t// if it's specified on the individual artifact level that takes priority\n\t\t\tartifactStrategy := woc.execWf.GetArtifactGCStrategy(&a)\n\t\t\tif artifactStrategy == strategy && !a.Deleted {\n\t\t\t\tresults = append(results, wfv1.ArtifactSearchResult{Artifact: a, NodeID: n.ID})\n\t\t\t}\n\t\t}\n\t}\n\treturn results\n}\n\nfunc (woc *wfOperationCtx) processCompletedArtifactGCPod(ctx context.Context, pod *corev1.Pod) error {\n\twoc.log.WithField(\"podName\", pod.Name).Info(ctx, \"processing completed Artifact GC Pod\")\n\n\tstrategyStr, found := pod.Annotations[common.AnnotationKeyArtifactGCStrategy]\n\tif !found {\n\t\treturn fmt.Errorf(\"artifact gc pod %q missing annotation %q\", pod.Name, common.AnnotationKeyArtifactGCStrategy)\n\t}\n\tstrategy := wfv1.ArtifactGCStrategy(strategyStr)\n\n\tif pod.Status.Phase == corev1.PodFailed {\n\t\terrMsg := fmt.Sprintf(\"Artifact Garbage Collection failed for strategy %s, pod %s exited with non-zero exit code: check pod logs for more information\", strategy, pod.Name)\n\t\twoc.addArtGCCondition(errMsg)\n\t\twoc.addArtGCEvent(errMsg)\n\t}\n\n\t// get associated WorkflowArtifactGCTasks\n\tlabelSelector := fmt.Sprintf(\"%s = %s\", common.LabelKeyArtifactGCPodHash, woc.artifactGCPodLabel(pod.Name))\n\ttaskList, err := woc.controller.wfclientset.ArgoprojV1alpha1().WorkflowArtifactGCTasks(woc.wf.Namespace).List(ctx, metav1.ListOptions{LabelSelector: labelSelector})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to List WorkflowArtifactGCTasks: %w\", err)\n\t}\n\n\tfor _, task := range taskList.Items {\n\t\tallArtifactsSucceeded, err := woc.processCompletedWorkflowArtifactGCTask(ctx, &task, strategy)","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/artifact_gc.go#L624-L660","documentation":"When a completed artifact GC pod is reconciled, the controller reads the strategy from the pod's AnnotationKeyArtifactGCStrategy annotation to record per-strategy GC results. A completed pod missing this annotation cannot be attributed to a strategy, so this error is returned at workflow/controller/artifact_gc.go:642.","triggerScenarios":"An artifact-gc pod (label components=artifact-gc / LabelKeyComponent) that succeeded or failed but lacks the artifactGCStrategy annotation — e.g. a manually created/edited pod mislabeled as artifact-gc, a pod created by an older controller version with different annotation keys, or an external tool stripping annotations.","commonSituations":"Manual kubectl edits to GC pods; users creating test pods with the artifact-gc component label but no annotations; upgrade scenarios where old-version pods used a different annotation name and are reconciled by a new controller.","solutions":["Delete the offending pod if it was manually created or is stale: kubectl -n <ns> delete pod <pod-name>.","If the annotation was stripped by manual edits, restore it (key: workflows.argoproj.io/artifact-gc-strategy) or delete and let the workflow re-create the GC pod.","Check for version skew: pods left over from a previous Argo version may carry different annotations; clean up leftover artifact-gc pods after upgrades.","Ensure no external controllers/mutators remove pod annotations in this namespace."],"exampleFix":"// before: pod has component label but annotation removed by manual edit\n// after: restore the annotation\nkubectl -n my-ns annotate pod my-wf-artgc-wfcomp-12345 \\\n  workflows.argoproj.io/artifact-gc-strategy=OnWorkflowCompletion\n// or simply delete the stale pod\nkubectl -n my-ns delete pod my-wf-artgc-wfcomp-12345","handlingStrategy":"validation","validationCode":"// Before letting a workflow delete, verify its artifact-gc pods are well-formed\npods, _ := k8s.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{\n    LabelSelector: \"workflows.argoproj.io/component=artifact-gc,\" + \"workflows.argoproj.io/workflow=\" + wfName})\nfor _, p := range pods.Items {\n    if p.Annotations[\"workflows.argoproj.io/artifact-gc-strategy\"] == \"\" &&\n       (p.Status.Phase == \"Succeeded\" || p.Status.Phase == \"Failed\") {\n        // malformed pod — delete it so the workflow can recreate a correct one\n    }\n}","typeGuard":"func hasGCStrategyAnnotation(pod *corev1.Pod) bool {\n    _, ok := pod.Annotations[common.AnnotationKeyArtifactGCStrategy]\n    return ok\n}","tryCatchPattern":"if strings.Contains(err.Error(), \"missing annotation\") { /* delete the malformed pod or re-add the annotation, then requeue */ }","preventionTips":["Do not manually create or edit pods carrying the artifact-gc component label.","Clean up leftover artifact-gc pods after Argo version upgrades.","Prevent annotation-stripping policies (OPA/Kyverno) from touching argo-managed pods."],"tags":["kubernetes","annotations","artifact-gc","pod-labels"],"backgroundTag":"missing-required-annotation","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}