{"record":{"id":"a4584c27c236b5df","repo":"kubernetes/kops","slug":"unable-to-run-blkid-v","errorCode":null,"errorMessage":"unable to run blkid: %v","messagePattern":"unable to run blkid: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go","lineNumber":111,"sourceCode":"\t\treturn nil, err\n\t}\n\tdefer os.Remove(mountTarget)\n\n\treturn newMetadataService(MetadataLatestServiceURL, MetadataLatestPath, getDefaultMounter(), mountTarget, DefaultMetadataSearchOrder).getMetadata()\n}\n\n// getFromConfigDrive tries to get metadata by mounting a config drive and returns it as InstanceMetadata\n// It will return an error if there is no disk labelled as ConfigDriveLabel or other errors while mounting the disk, or reading the file occur.\nfunc (mds MetadataService) getFromConfigDrive() (*InstanceMetadata, error) {\n\tdev := path.Join(DiskByLabelPath, ConfigDriveLabel)\n\tif _, err := os.Stat(dev); os.IsNotExist(err) {\n\t\tout, err := mds.mounter.Exec.Command(\n\t\t\t\"blkid\", \"-l\",\n\t\t\t\"-t\", fmt.Sprintf(\"LABEL=%s\", ConfigDriveLabel),\n\t\t\t\"-o\", \"device\",\n\t\t).CombinedOutput()\n\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}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go#L93-L129","documentation":"getFromConfigDrive (upup/pkg/fi/cloudup/openstack/openstackmetadata/metadata.go:111) shells out to the blkid utility to locate the block device labeled with the config-drive label. If blkid is missing, not in PATH, or exits nonzero (including when no matching device exists), this error is returned.","triggerScenarios":"Executing `blkid -l -t LABEL=<ConfigDriveLabel> -o device` via the mounter's Exec returns a nonzero exit code — blkid not installed, insufficient privileges (needs root), or no device carrying the config-drive label.","commonSituations":"Instance booted without --config-drive true so no config-drive device exists; minimal container images (e.g. distroless) without blkid; running nodeup without root/CAP_SYS_ADMIN so blkid cannot probe devices.","solutions":["Boot the instance with a config drive attached, or fall back to the metadata service by configuring search order to include MetadataID.","Install the blkid binary (part of util-linux) in the image/environment where metadata lookup runs.","Run the process as root so blkid can probe block devices.","Manually verify with `blkid -l -t LABEL=config-2 -o device` on the instance to confirm a device is present."],"exampleFix":"// before\nout, err := mds.mounter.Exec.Command(\"blkid\", \"-l\", \"-t\", fmt.Sprintf(\"LABEL=%s\", ConfigDriveLabel), \"-o\", \"device\").CombinedOutput()\nif err != nil {\n    return nil, fmt.Errorf(\"unable to run blkid: %v\", err)\n}\n// after — no config drive? fall through so the metadata service can be tried\nout, err := mds.mounter.Exec.Command(\"blkid\", \"-l\", \"-t\", fmt.Sprintf(\"LABEL=%s\", ConfigDriveLabel), \"-o\", \"device\").CombinedOutput()\nif err != nil {\n    return nil, nil // no config drive present; getMetadata will try the next source\n}","handlingStrategy":"fallback","validationCode":"// Confirm blkid exists and a config-drive-labeled device is present before calling\nif _, err := exec.LookPath(\"blkid\"); err != nil {\n    return errors.New(\"blkid not installed; install util-linux or use the metadata service\")\n}\nout, err := exec.Command(\"blkid\", \"-l\", \"-t\", \"LABEL=config-2\", \"-o\", \"device\").CombinedOutput()\nif err != nil {\n    return errors.New(\"no config-drive device found; boot instance with --config-drive true\")\n}","typeGuard":null,"tryCatchPattern":"meta, err := mds.getFromConfigDrive()\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to run blkid\") {\n        // no config drive / no blkid — let getMetadata try the metadata service next\n        return mds.getFromMetadataService()\n    }\n    return nil, err\n}","preventionTips":["Include util-linux (blkid) in node images used for OpenStack instances.","Boot instances with a config drive attached.","Run metadata lookups as root so blkid can probe devices.","Configure search order \"configDrive, metadataService\" so a missing drive falls back gracefully."],"tags":["openstack","config-drive","blkid","metadata"],"backgroundTag":"blkid-command-failed","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"}