kubernetes/kops · error
Error reading systemd file %q: %v
Error message
Error reading systemd file %q: %v
What it means
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.
Source
Thrown at upup/pkg/fi/nodeup/nodetasks/service.go:203
func (e *InstallService) Find(_ *fi.InstallContext) (*InstallService, error) {
actual, err := e.Service.Find(nil)
if actual == nil || err != nil {
return nil, err
}
return &InstallService{*actual}, nil
}
func (e *Service) Find(_ *fi.NodeupContext) (*Service, error) {
systemdSystemPath, err := e.systemdSystemPath()
if err != nil {
return nil, err
}
servicePath := path.Join(systemdSystemPath, e.Name)
d, err := os.ReadFile(servicePath)
if err != nil {
if !os.IsNotExist(err) {
return nil, fmt.Errorf("Error reading systemd file %q: %v", servicePath, err)
}
// Not found
return &Service{
Name: e.Name,
Definition: nil,
Running: new(false),
}, nil
}
actual := &Service{
Name: e.Name,
Definition: new(string(d)),
// Avoid spurious changes
ManageState: e.ManageState,
SmartRestart: e.SmartRestart,
}View on GitHub (pinned to 4c8573c808)
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
Example fix
# before $ ls -l /etc/systemd/system/kops.service -rw------- 1 root root ... # unreadable by nodeup user # after $ chmod 0644 /etc/systemd/system/kops.service
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check on the node: ls -l /etc/systemd/system/<unit> 2>/dev/null && sudo cat /etc/systemd/system/<unit> >/dev/null && echo readable || echo 'unreadable or missing'
Try / catch
if _, err := svc.Find(ctx); err != nil {
if strings.Contains(err.Error(), "Error reading systemd file") {
// check perms / fs health before retrying
return fmt.Errorf("unit file unreadable: %w", err)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error writing systemd service file: %v
- failed to update /etc/hosts: %w
- creating directories %q: %w
- unable to read snippet: %s, error: %s
- unable to read template: %s, error: %s
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/3f8338160ce2c35a.
Report an issue: GitHub.