{"record":{"id":"bc5ba9053c6b9e44","repo":"kubernetes/kops","slug":"error-reading-s-on-config-drive-v","errorCode":null,"errorMessage":"error reading '%s' on config drive: %v","messagePattern":"error reading '(.+?)' on config drive: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go","lineNumber":128,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to run blkid: %v\", err)\n\t\t}\n\t\tdev = strings.TrimSpace(string(out))\n\t}\n\n\terr := mds.mounter.Mount(dev, mds.mountTarget, \"iso9660\", []string{\"ro\"})\n\tif err != nil {\n\t\terr = mds.mounter.Mount(dev, mds.mountTarget, \"vfat\", []string{\"ro\"})\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error mounting configdrive '%s': %v\", dev, err)\n\t}\n\tdefer mds.mounter.Unmount(mds.mountTarget)\n\n\tf, err := os.Open(\n\t\tpath.Join(mds.mountTarget, mds.configDrivePath))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading '%s' on config drive: %v\", mds.configDrivePath, err)\n\t}\n\tdefer f.Close()\n\n\treturn mds.parseMetadata(f)\n}\n\n// getFromMetadataService tries to get metadata from a metadata service endpoint and returns it as InstanceMetadata.\n// If the service endpoint cannot be contacted or reports a different status than StatusOK it will return an error.\nfunc (mds MetadataService) getFromMetadataService() (*InstanceMetadata, error) {\n\tvar client http.Client\n\n\tresp, err := client.Get(mds.serviceURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == http.StatusOK {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go#L110-L146","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nf, err := os.Open(path.Join(mds.mountTarget, mds.configDrivePath))\nif err != nil {\n    return nil, fmt.Errorf(\"error reading '%s' on config drive: %v\", mds.configDrivePath, err)\n}\n// after — check the file exists first for a clearer diagnosis\nmetaPath := path.Join(mds.mountTarget, mds.configDrivePath)\nif _, err := os.Stat(metaPath); os.IsNotExist(err) {\n    return nil, fmt.Errorf(\"config drive mounted but %s is missing; wrong drive or layout\", metaPath)\n}\nf, err := os.Open(metaPath)","handlingStrategy":"validation","validationCode":"// After mounting, verify the expected metadata file exists before opening it\nmetaPath := filepath.Join(\"/mnt/config-drive\", \"openstack/latest/meta_data.json\")\nif fi, err := os.Stat(metaPath); err != nil || fi.IsDir() {\n    return fmt.Errorf(\"expected metadata file %s not present on config drive\", metaPath)\n}","typeGuard":null,"tryCatchPattern":"meta, err := mds.getFromConfigDrive()\nif err != nil {\n    var pathErr *fs.PathError\n    if errors.As(err, &pathErr) && strings.Contains(err.Error(), \"on config drive\") {\n        // wrong layout or wrong device — fall back to the metadata service\n        return mds.getFromMetadataService()\n    }\n    return nil, err\n}","preventionTips":["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."],"tags":["openstack","config-drive","file-read","metadata"],"backgroundTag":"config-drive-file-missing","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}