GoogleContainerTools/skaffold · error
deleting files: %w
Error message
deleting files: %w
What it means
Wraps failures from performing file deletion on a running Kubernetes pod/container during dev-loop file sync. When Skaffold detects deleted files and tries to remove them from the deployed container via `Perform` with the deleteFileFn, any underlying failure (kubectl exec or pod lookup failure) is wrapped with this message. It indicates sync's delete phase failed, not the build or deploy.
Source
Thrown at pkg/skaffold/sync/sync.go:319
return fmt.Errorf("post-sync hooks failed for artifact %q: %w", item.Artifact.ImageName, err)
}
return nil
}
func (s *PodSyncer) sync(ctx context.Context, item *Item) error {
if len(item.Copy) > 0 {
log.Entry(ctx).Info("Copying files:", item.Copy, "to", item.Image)
if err := Perform(ctx, item.Image, item.Copy, s.copyFileFn, *s.namespaces, s.kubectl.KubeContext); err != nil {
return fmt.Errorf("copying files: %w", err)
}
}
if len(item.Delete) > 0 {
log.Entry(ctx).Info("Deleting files:", item.Delete, "from", item.Image)
if err := Perform(ctx, item.Image, item.Delete, s.deleteFileFn, *s.namespaces, s.kubectl.KubeContext); err != nil {
return fmt.Errorf("deleting files: %w", err)
}
}
return nil
}
func Perform(ctx context.Context, image string, files syncMap, cmdFn func(context.Context, v1.Pod, v1.Container, syncMap) *exec.Cmd, namespaces []string, kubeContext string) error {
if len(files) == 0 {
return nil
}
errs, ctx := errgroup.WithContext(ctx)
client, err := kubernetesclient.Client(kubeContext)
if err != nil {
return fmt.Errorf("getting Kubernetes client: %w", err)
}
View on GitHub (pinned to a1189de023)
Solutions
- Inspect the wrapped cause (%w) below this message — fix the underlying kubectl/pod error it reports
- Verify the pod running the image is up and Running (`kubectl get pods -n <ns>`); retrigger sync after the pod is ready
- Check the kubeContext (--kube-context) and that kubectl can reach the cluster
- Confirm RBAC allows listing pods and exec into pods in the target namespaces
Example fix
// before: pod scaled to 0 causes delete failure skaffold dev --kube-context stale-context // after kubectl config use-context dev-cluster skaffold dev
Defensive patterns
Strategy: try-catch
Validate before calling
// before triggering sync, verify pods are reachable
pods, _ := kubeClient.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{FieldSelector: "status.phase=Running"})
if len(pods.Items) == 0 { return errors.New("no running pods; skip delete sync") } Type guard
if item.Delete == nil || len(item.Delete) == 0 { return nil } Try / catch
if err := syncer.Sync(ctx, out, item); err != nil {
var delErr error
if strings.Contains(err.Error(), "deleting files:") {
delErr = errors.Unwrap(err) // inspect underlying kubectl/pod error
}
log.Warnf("delete sync skipped: %v", delErr)
} Prevention
- Keep the kubeContext valid and reachable before starting skaffold dev
- Re-sync only when pods are Running (rollout status)
- Avoid scaling pods to zero during the dev loop
- Grant pods/list + exec RBAC in target namespaces
When it happens
Trigger: `SyncWorkflow`/`sync.Sync` is called with an item whose `item.Delete` is non-empty and `Perform(ctx, item.Image, item.Delete, s.deleteFileFn, namespaces, kubeContext)` returns an error — e.g. the target pod disappeared, the container command to rm files failed, or the Kubernetes client could not be created.
Common situations: Pod restarted or was deleted between change detection and sync; wrong/inaccessible kubeContext; namespace has no running pods; container image lacks a shell or the rm command fails; RBAC prevents listing pods.
Related errors
- didn't sync any files
- exiting dev mode because first deploy failed: %w
- starting logger: %w
- sync failed for artifact %q
- c.Message (pod status condition message)
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/bfb085aec69a82db.
Report an issue: GitHub.