kubernetes/kops · error

error reading from %s

Error message

error reading from %s

What it means

Templates.loadFrom walks a vfs tree (base path, e.g. a model directory or S3/GCS location) to discover template resources. If ReadTree on the base path fails, the walk cannot proceed and the whole load fails with this error naming the base path. It deliberately discards the underlying error, so the cause must be inferred from the path.

Source

Thrown at pkg/templates/templates.go:59

	if err != nil {
		return nil, err
	}
	return t, nil
}

func (t *Templates) Find(key string) fi.Resource {
	return t.resources[key]
}

// IsTemplate reports whether key was loaded from a file ending in .template.
func (t *Templates) IsTemplate(key string) bool {
	return t.isTemplate[key]
}

func (t *Templates) loadFrom(ctx context.Context, base vfs.Path) error {
	files, err := base.ReadTree(ctx)
	if err != nil {
		return fmt.Errorf("error reading from %s", base)
	}

	for _, f := range files {
		contents, err := f.ReadFile(ctx)
		if err != nil {
			if os.IsNotExist(err) {
				// This is just an annoyance of gobindata - we can't tell the difference between files & directories.  Ignore.
				continue
			}
			return fmt.Errorf("error reading %s: %v", f, err)
		}

		key, err := vfs.RelativePath(base, f)
		if err != nil {
			return fmt.Errorf("error getting relative path for %s", f)
		}

		isTemplate := strings.HasSuffix(key, ".template")

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the base path exists and is spelled correctly (check the path printed in the error)
  2. Check cloud/storage credentials: run with -v=10 or test access to the VFS location (e.g. aws s3 ls s3://your-bucket)
  3. Check network connectivity / proxy settings to the storage backend
  4. If the directory is genuinely absent, recreate it or point LoadTemplates at the correct location

Example fix

// before
templates, err := templates.LoadTemplates(ctx, vfs.NewFSOrDie().BuildWritablePath("assetfs/model/wrongmodel"))
// after
templates, err := templates.LoadTemplates(ctx, vfs.NewFSOrDie().BuildWritablePath("assetfs/model/awsmodel"))
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the base path exists before LoadTemplates
if _, err := base.Exists(ctx); err != nil {
	return fmt.Errorf("template base %s unreachable: %w", base, err)
}

Prevention

When it happens

Trigger: Calling LoadTemplates with a base vfs.Path whose backing store is unreachable: the directory does not exist, cloud credentials are missing/invalid, a network error occurs, or the VFS location is wrong.

Common situations: Typo in the models directory or --model path, S3/GCS bucket deleted or inaccessible (expired credentials, wrong region), or running kops against a state store that was moved.

Related errors


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