{"record":{"id":"3f8338160ce2c35a","repo":"kubernetes/kops","slug":"error-reading-systemd-file-q-v","errorCode":null,"errorMessage":"Error reading systemd file %q: %v","messagePattern":"Error reading systemd file %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/nodetasks/service.go","lineNumber":203,"sourceCode":"func (e *InstallService) Find(_ *fi.InstallContext) (*InstallService, error) {\n\tactual, err := e.Service.Find(nil)\n\tif actual == nil || err != nil {\n\t\treturn nil, err\n\t}\n\treturn &InstallService{*actual}, nil\n}\nfunc (e *Service) Find(_ *fi.NodeupContext) (*Service, error) {\n\tsystemdSystemPath, err := e.systemdSystemPath()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tservicePath := path.Join(systemdSystemPath, e.Name)\n\n\td, err := os.ReadFile(servicePath)\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn nil, fmt.Errorf(\"Error reading systemd file %q: %v\", servicePath, err)\n\t\t}\n\n\t\t// Not found\n\t\treturn &Service{\n\t\t\tName:       e.Name,\n\t\t\tDefinition: nil,\n\t\t\tRunning:    new(false),\n\t\t}, nil\n\t}\n\n\tactual := &Service{\n\t\tName:       e.Name,\n\t\tDefinition: new(string(d)),\n\n\t\t// Avoid spurious changes\n\t\tManageState:  e.ManageState,\n\t\tSmartRestart: e.SmartRestart,\n\t}","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/nodetasks/service.go#L185-L221","documentation":"Service.Find reads the unit file at <systemdSystemPath>/<name>. If the read fails for any reason other than the file not existing (permissions, I/O error, path is a directory), the task cannot compare actual vs desired state and returns this error instead of treating the service as absent.","triggerScenarios":"os.ReadFile on path.Join(systemdSystemPath, e.Name) fails with a non-ENOENT error: unit file exists but is unreadable (wrong permissions), the path is a directory, or the filesystem returns EIO/EBUSY.","commonSituations":"Unit files created by another tool with restrictive modes (e.g. 0600 root-only while nodeup runs as non-root), leftover directories where a unit file is expected, or corrupted node disks producing I/O errors on /etc/systemd/system.","solutions":["Check permissions/ownership of the unit file: ls -l /etc/systemd/system/<name>; make it readable (chmod 0644) by the nodeup user","If the path is a directory or stale file, remove it and re-run nodeup","Check dmesg / filesystem health if the error is I/O related","Re-run nodeup as root, which is the normal invocation for nodeup"],"exampleFix":"# before\n$ ls -l /etc/systemd/system/kops.service\n-rw------- 1 root root ...  # unreadable by nodeup user\n# after\n$ chmod 0644 /etc/systemd/system/kops.service","handlingStrategy":"try-catch","validationCode":"// Pre-check on the node:\nls -l /etc/systemd/system/<unit> 2>/dev/null && sudo cat /etc/systemd/system/<unit> >/dev/null && echo readable || echo 'unreadable or missing'","typeGuard":null,"tryCatchPattern":"if _, err := svc.Find(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"Error reading systemd file\") {\n\t\t// check perms / fs health before retrying\n\t\treturn fmt.Errorf(\"unit file unreadable: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Ensure unit files are 0644 root:root","Run nodeup as root","Avoid creating directories where unit files are expected","Monitor node disks for I/O errors"],"tags":["nodeup","systemd","filesystem","permissions"],"backgroundTag":"unit-file-read-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"}