kubernetes/kops · error
error reading '%s' on config drive: %v
Error message
error reading '%s' on config drive: %v
What it means
Once the config drive is mounted, getFromConfigDrive (upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go:128) opens the metadata JSON file at mds.configDrivePath inside the mount. If os.Open fails (file missing, wrong path, unreadable filesystem), this error naming the path is returned.
Source
Thrown at upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go:128
if err != nil {
return nil, fmt.Errorf("unable to run blkid: %v", err)
}
dev = strings.TrimSpace(string(out))
}
err := mds.mounter.Mount(dev, mds.mountTarget, "iso9660", []string{"ro"})
if err != nil {
err = mds.mounter.Mount(dev, mds.mountTarget, "vfat", []string{"ro"})
}
if err != nil {
return nil, fmt.Errorf("error mounting configdrive '%s': %v", dev, err)
}
defer mds.mounter.Unmount(mds.mountTarget)
f, err := os.Open(
path.Join(mds.mountTarget, mds.configDrivePath))
if err != nil {
return nil, fmt.Errorf("error reading '%s' on config drive: %v", mds.configDrivePath, err)
}
defer f.Close()
return mds.parseMetadata(f)
}
// getFromMetadataService tries to get metadata from a metadata service endpoint and returns it as InstanceMetadata.
// If the service endpoint cannot be contacted or reports a different status than StatusOK it will return an error.
func (mds MetadataService) getFromMetadataService() (*InstanceMetadata, error) {
var client http.Client
resp, err := client.Get(mds.serviceURL)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {View on GitHub (pinned to 4c8573c808)
Solutions
- Verify the expected file exists on the mounted drive: `ls <mountTarget>/<configDrivePath>`; adjust configDrivePath if your cloud lays files out differently.
- Regenerate the instance with a standard config drive (nova boot --config-drive true).
- Check the config-drive image integrity (e.g. `isoinfo -l -i <dev>`) and that the correct device was mounted.
- Confirm file permissions allow the reading user (root) to open the file.
Example fix
// before
f, err := os.Open(path.Join(mds.mountTarget, mds.configDrivePath))
if err != nil {
return nil, fmt.Errorf("error reading '%s' on config drive: %v", mds.configDrivePath, err)
}
// after — check the file exists first for a clearer diagnosis
metaPath := path.Join(mds.mountTarget, mds.configDrivePath)
if _, err := os.Stat(metaPath); os.IsNotExist(err) {
return nil, fmt.Errorf("config drive mounted but %s is missing; wrong drive or layout", metaPath)
}
f, err := os.Open(metaPath) Defensive patterns
Strategy: validation
Validate before calling
// After mounting, verify the expected metadata file exists before opening it
metaPath := filepath.Join("/mnt/config-drive", "openstack/latest/meta_data.json")
if fi, err := os.Stat(metaPath); err != nil || fi.IsDir() {
return fmt.Errorf("expected metadata file %s not present on config drive", metaPath)
} Try / catch
meta, err := mds.getFromConfigDrive()
if err != nil {
var pathErr *fs.PathError
if errors.As(err, &pathErr) && strings.Contains(err.Error(), "on config drive") {
// wrong layout or wrong device — fall back to the metadata service
return mds.getFromMetadataService()
}
return nil, err
} Prevention
- Match configDrivePath to the layout produced by your cloud (standard: openstack/latest/meta_data.json).
- Mount and inspect the config drive once manually to confirm its file layout.
- Regenerate instances with standard nova config drives if the layout differs.
- Keep the metadata service configured as a fallback in the search order.
When it happens
Trigger: os.Open(path.Join(mds.mountTarget, mds.configDrivePath)) fails — the expected file (e.g. openstack/latest/meta_data.json) is absent from the config drive, the drive content layout differs from the expected path, or the mount succeeded but the filesystem is unreadable/corrupt.
Common situations: Config drive produced by a tool that lays out files differently than the expected configDrivePath; truncated or corrupted config-drive image; mounting the wrong device as the config drive; permission problems on the mounted filesystem.
Related errors
- unable to run blkid: %v
- error mounting configdrive '%s': %v
- error getting cloud instance group %q: %v
- unable to fetch metadata: %w
- %s is not a valid metadata search order option. Supported op
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/bc5ba9053c6b9e44.
Report an issue: GitHub.