kubernetes/kops · error

error writing %s: %v

Error message

error writing %s: %v

What it means

Returned when io.Copy from the source data stream into the GCS object writer fails during a WriteFile on a GSPath. The copy can fail because the source reader errors mid-stream, the network connection to GCS drops, or the uploaded bytes do not match the MD5 hash set on the writer (GCS rejects the upload). The writer is closed before returning so the partial upload is finalized or discarded by the SDK.

Source

Thrown at util/pkg/vfs/gsfs.go:211

			klog.V(4).Infof("Writing file %q", p)
		}

		if _, err := data.Seek(0, 0); err != nil {
			return false, fmt.Errorf("error seeking to start of data stream for write to %s: %v", p, err)
		}

		client, err := p.getStorageClient(ctx)
		if err != nil {
			return false, err
		}

		w := client.Bucket(p.bucket).Object(p.key).NewWriter(ctx)
		// The upload is rejected if the data does not match this MD5 hash
		w.MD5 = md5Hash.HashValue
		w.ACL = objectACL
		if _, err := io.Copy(w, data); err != nil {
			w.Close()
			return false, fmt.Errorf("error writing %s: %v", p, err)
		}
		if err := w.Close(); err != nil {
			return false, fmt.Errorf("error writing %s: %v", p, err)
		}

		return true, nil
	})
	if err != nil {
		return err
	} else if done {
		return nil
	} else {
		// Shouldn't happen - we always return a non-nil error with false
		return wait.ErrWaitTimeout
	}
}

// To prevent concurrent creates on the same file while maintaining atomicity of writes,

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the underlying error: an MD5 mismatch means the data stream changed between hashing and upload — regenerate the hash from the same seek position before retrying
  2. Verify network connectivity and GCS permissions (storage.objects.create on the bucket)
  3. Ensure the data io.ReadSeeker is fully populated before the write; re-seek to 0 and retry once on transient network errors
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at util/pkg/vfs/gsfs.go:211 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/184351704fd8070e. Report an issue: GitHub.