kubernetes/kops · error

error deleting %s: %w

Error message

error deleting %s: %w

What it means

Returned by SSHPath.Remove when the SFTP client's Remove call fails for a reason other than not-exist (which is passed through). The remote filesystem rejected the unlink — permission denied on the parent directory, the path is a non-empty directory, or the connection dropped — while deleting a single file over SFTP.

Source

Thrown at util/pkg/vfs/sshfs.go:111

}

func (p *SSHPath) String() string {
	return p.Path()
}

func (p *SSHPath) Remove(ctx context.Context) error {
	sftpClient, err := p.newClient(ctx)
	if err != nil {
		return err
	}
	defer sftpClient.Close()

	err = sftpClient.Remove(p.path)
	if err != nil {
		if os.IsNotExist(err) {
			return err
		}
		return fmt.Errorf("error deleting %s: %w", p, err)
	}

	return nil
}

func (p *SSHPath) RemoveAll(ctx context.Context) error {
	tree, err := p.ReadTree(ctx)
	if err != nil {
		return err
	}

	for _, filePath := range tree {
		err := filePath.Remove(ctx)
		if err != nil {
			return fmt.Errorf("error removing file %s: %w", filePath, err)
		}
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check permissions on the remote parent directory and use an appropriately privileged user
  2. Use RemoveAll for directory trees instead of Remove on directories
  3. Retry on transient connection drops after re-establishing the SFTP session
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at util/pkg/vfs/sshfs.go:111 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/fb7f1bee9ce8b24e. Report an issue: GitHub.