{"record":{"id":"57fbef7b4b0e3dba","repo":"kubernetes/kops","slug":"unable-to-parse-service-execmainstarttimestamp-q","errorCode":null,"errorMessage":"unable to parse service ExecMainStartTimestamp %q: %v","messagePattern":"unable to parse service ExecMainStartTimestamp %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/nodetasks/service.go","lineNumber":380,"sourceCode":"\t\t\t\tmodTime := stat.ModTime()\n\t\t\t\tif newest.IsZero() || newest.Before(modTime) {\n\t\t\t\t\tnewest = modTime\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif !newest.IsZero() {\n\t\t\t\tproperties, err := getSystemdStatus(e.Name)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tstartedAt := properties[\"ExecMainStartTimestamp\"]\n\t\t\t\tif startedAt == \"\" {\n\t\t\t\t\tklog.Warningf(\"service was running, but did not have ExecMainStartTimestamp: %q\", serviceName)\n\t\t\t\t} else {\n\t\t\t\t\tstartedAtTime, err := time.Parse(\"Mon 2006-01-02 15:04:05 MST\", startedAt)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"unable to parse service ExecMainStartTimestamp %q: %v\", startedAt, err)\n\t\t\t\t\t}\n\t\t\t\t\tif startedAtTime.Before(newest) {\n\t\t\t\t\t\tklog.V(2).Infof(\"will restart service %q because dependency changed after service start\", serviceName)\n\t\t\t\t\t\taction = \"restart\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\tklog.V(2).Infof(\"will not restart service %q - started after dependencies\", serviceName)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif action != \"\" && fi.ValueOf(e.ManageState) {\n\t\targs := []string{\"systemctl\", action, serviceName}\n\t\t// We use --no-block to avoid hanging if the service has issues stopping/starting\n\t\targs = append(args, \"--no-block\")\n\t\tcmd := exec.Command(args[0], args[1:]...)\n\t\tklog.Infof(\"Restarting service %q (running %q)\", serviceName, strings.Join(cmd.Args, \" \"))","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/nodetasks/service.go#L362-L398","documentation":"The SmartRestart feature compares each dependency service's start time against the newest dependency change. It parses systemd's ExecMainStartTimestamp using the layout \"Mon 2006-01-02 15:04:05 MST\"; if systemd emits a timestamp in a different format/locale, time.Parse fails and the task aborts rather than making an unsafe restart decision.","triggerScenarios":"After `systemctl show <dep>`, ExecMainStartTimestamp is non-empty but does not match the hardcoded layout — e.g. non-English locale (localized month/timezone names), unusual timezone abbreviations like \"-03\" numeric offsets, or format differences across systemd versions.","commonSituations":"Nodes with LC_TIME set to a non-C locale, or systemd versions/patches that render timestamps differently than the assumed US-English format, breaking SmartRestart on dependency changes.","solutions":["Force a C/POSIX locale for the systemctl invocation or the node (e.g. LC_ALL=C systemctl show ...)","Upgrade or patch nodeup to parse the timestamp with a more tolerant layout or use ExecMainStartTimestampMonotonic/usec instead","Disable SmartRestart (set it to false) on the Service task to skip timestamp parsing","Check systemd version on the node; align nodeup with the distro's systemd output format"],"exampleFix":"// before\nstartedAtTime, err := time.Parse(\"Mon 2006-01-02 15:04:05 MST\", startedAt)\n// after\nusec := properties[\"ExecMainStartTimestampMonotonic\"] // or parse numeric timestamp\nstartedAtTime, err := parseSystemdTimestamp(startedAt) // tolerant multi-layout parser","handlingStrategy":"fallback","validationCode":"// Detect risky locale on the node beforehand:\n[ \"$LC_ALL$LC_TIME\" = '' ] || echo 'non-C locale may break ExecMainStartTimestamp parsing'","typeGuard":null,"tryCatchPattern":"if err := task.RenderLocal(...); err != nil {\n\tif strings.Contains(err.Error(), \"ExecMainStartTimestamp\") {\n\t\t// fall back: disable SmartRestart or restart unconditionally\n\t\tklog.Warningf(\"smart restart unavailable: %v\", err)\n\t\treturn restartService(serviceName) // fallback action\n\t}\n\treturn err\n}","preventionTips":["Set LC_ALL=C for nodeup/systemctl environments","Prefer numeric systemd timestamps (ExecMainStartTimestampMonotonic) in custom patches","Disable SmartRestart on distros with nonstandard systemd timestamp formats","Test SmartRestart on each new base image"],"tags":["nodeup","systemd","time-parsing","locale"],"backgroundTag":"timestamp-parse-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"}