Conversation
Older systemd (AlmaLinux 8, Amazon Linux 2) ignores --output=json for list-units and prints the classic table, which made unschedule fail with "error decoding JSON". Prefer JSON when available, otherwise parse the plain table (and re-run with --plain --no-legend if needed). Fixes creativeprojects#516
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On older systemd (AlmaLinux 8 / Amazon Linux 2),
systemctl list-units --output=jsonis ignored and the classic table is printed instead.unschedule/Scheduled()then failed with:error decoding JSON: invalid character 'U'...(UNIT header)json: cannot unmarshal number into Go value of type []schedule.SystemdUnit(footer like2 loaded units listed)This change:
--plain --no-legendfor a cleaner whitespace-separated formatFixes #516
Test plan
go test ./schedule/ -count=1 -run 'SystemctlUnits|ParseSystemctl|DecodeSystemctl|DetectPermissionSystemd|HandlerSystemd$'resticprofile unscheduleno longer logs JSON decode errors