argoproj/argo-workflows · error

failed to archive workflow: %w

Error message

failed to archive workflow: %w

What it means

archiveWorkflowAux (workflow/controller/controller.go:1407) fails when wfc.wfArchive.ArchiveWorkflow cannot persist the hydrated workflow into the workflow archive store (server-side archive backed by persist/sqldb, Postgres or MySQL). The workflow completed fine; only its archive copy failed, so it will be retried while it remains in the cluster.

Source

Thrown at workflow/controller/controller.go:1407

func (wfc *WorkflowController) archiveWorkflowAux(ctx context.Context, obj any) error {
	un, ok := obj.(*unstructured.Unstructured)
	if !ok {
		return nil
	}
	wf, err := util.FromUnstructured(un)
	if err != nil {
		return fmt.Errorf("failed to convert to workflow from unstructured: %w", err)
	}
	err = wfc.hydrator.Hydrate(ctx, wf)
	if err != nil {
		return fmt.Errorf("failed to hydrate workflow: %w", err)
	}
	logger := logging.RequireLoggerFromContext(ctx)
	logger.WithFields(logging.Fields{"namespace": wf.Namespace, "workflow": wf.Name, "uid": wf.UID}).Info(ctx, "archiving workflow")
	err = wfc.wfArchive.ArchiveWorkflow(ctx, wf)
	if err != nil {
		return fmt.Errorf("failed to archive workflow: %w", err)
	}
	data, err := json.Marshal(map[string]any{
		"metadata": metav1.ObjectMeta{
			Labels: map[string]string{
				common.LabelKeyWorkflowArchivingStatus: "Archived",
			},
		},
	})
	if err != nil {
		return fmt.Errorf("failed to marshal patch: %w", err)
	}
	_, err = wfc.wfclientset.ArgoprojV1alpha1().Workflows(un.GetNamespace()).Patch(
		ctx,
		un.GetName(),
		types.MergePatchType,
		data,
		metav1.PatchOptions{},
	)

View on GitHub (pinned to 35bff19146)

Solutions

  1. Inspect the wrapped DB error; fix connectivity/credentials in the persistence config (workflow-controller-configmap persistence block).
  2. Apply the schema migrations matching your Argo version to the archive database (persist/sqldb migration scripts).
  3. If it's a duplicate-UID insert, verify the existing archived row — the archive is keyed by UID; stale rows may need manual cleanup.
  4. Scale DB connections / fix pool settings if max_connections is exhausted; retry happens on subsequent archiving passes.
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: verify archive DB schema and connection
rows, err := db.Query("SELECT uid FROM argo_archived_workflows LIMIT 1")
if err != nil { log.Fatal("archive schema missing or DB unreachable: ", err) }

Try / catch

err := wfc.wfArchive.ArchiveWorkflow(ctx, wf)
if err != nil {
    if util/errors.IsTransientErr(ctx, err) { requeueWithBackoff(err) }
    return fmt.Errorf("failed to archive workflow: %w", err)
}

Prevention

When it happens

Trigger: Insert into the archived_workflows table fails — archive DB unreachable, schema mismatch (older archive table without newer columns), duplicate-UID insert rejected due to a UNIQUE constraint on an already-archived workflow with the same UID, or connection-pool exhaustion.

Common situations: Archive DB out of disk/space or max_connections hit; upgrading Argo without running the DB schema migrations for the new archive tables; archived workflow for the same UID already present (resubmitted workflows keeping UIDs); MySQL/Postgres credentials rotated.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/0b9745c57e97608e. Report an issue: GitHub.