Skip to content

journalctl -o short-iso[-precise]: timezone as +02:00 instead of +0200#29134

Merged
bluca merged 2 commits intosystemd:mainfrom
nabijaczleweli:short-iso-timestamp
Sep 27, 2023
Merged

journalctl -o short-iso[-precise]: timezone as +02:00 instead of +0200#29134
bluca merged 2 commits intosystemd:mainfrom
nabijaczleweli:short-iso-timestamp

Conversation

@nabijaczleweli
Copy link
Copy Markdown
Contributor

Before:

$ journalctl -u r710_fan_controller -o short-iso -n10
2023-09-08T17:20:30+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:20:47+0200 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:20:47+0200 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 36 Celcius.
2023-09-08T17:20:47+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.
2023-09-08T17:22:28+0200 tarta r710_fan_controller.sh[20911]: Changing to fan level 3.
2023-09-08T17:22:28+0200 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:28+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:22:56+0200 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:22:56+0200 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:56+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.
$ journalctl -u r710_fan_controller -o short-iso-precise -n10
2023-09-08T17:20:30.655028+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:20:47.560211+0200 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:20:47.560211+0200 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 36 Celcius.
2023-09-08T17:20:47.560211+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.
2023-09-08T17:22:28.387008+0200 tarta r710_fan_controller.sh[20911]: Changing to fan level 3.
2023-09-08T17:22:28.387008+0200 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:28.387008+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:22:56.388270+0200 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:22:56.388270+0200 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:56.388270+0200 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.

After:

$ build/journalctl -u r710_fan_controller -o short-iso -n10
2023-09-08T17:20:30+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:20:47+02:00 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:20:47+02:00 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 36 Celcius.
2023-09-08T17:20:47+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.
2023-09-08T17:22:28+02:00 tarta r710_fan_controller.sh[20911]: Changing to fan level 3.
2023-09-08T17:22:28+02:00 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:28+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:22:56+02:00 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:22:56+02:00 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:56+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.
$ build/journalctl -u r710_fan_controller -o short-iso-precise -n10
2023-09-08T17:20:30.655028+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:20:47.560211+02:00 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:20:47.560211+02:00 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 36 Celcius.
2023-09-08T17:20:47.560211+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.
2023-09-08T17:22:28.387008+02:00 tarta r710_fan_controller.sh[20911]: Changing to fan level 3.
2023-09-08T17:22:28.387008+02:00 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:28.387008+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 43 Celcius.
2023-09-08T17:22:56.388270+02:00 tarta r710_fan_controller.sh[20911]: Changing to fan level 4.
2023-09-08T17:22:56.388270+02:00 tarta r710_fan_controller.sh[20911]: Highest CPU core temperature: 35 Celcius.
2023-09-08T17:22:56.388270+02:00 tarta r710_fan_controller.sh[20911]: Highest drive temperature: 44 Celcius.

Since now

$ build/systemd-analyze timestamp 2023-09-08T17:20:30+0200
Failed to parse "2023-09-08T17:20:30+0200": Invalid argument
$ build/systemd-analyze timestamp 2023-09-08T17:20:30+02:00
  Original form: 2023-09-08T17:20:30+02:00
Normalized form: Fri 2023-09-08 17:20:30 CEST
       (in UTC): Fri 2023-09-08 15:20:30 UTC
   UNIX seconds: @1694186430
       From now: 5min ago

Also, idk how --truncate-newline made it there, but it shouldn't have. Moved it out, but there's a better place in the list for it probably.

@github-actions github-actions Bot added documentation util-lib please-review PR is ready for (re-)review by a maintainer labels Sep 8, 2023
@poettering
Copy link
Copy Markdown
Member

hmm is the old syntax incorrect?

@nabijaczleweli
Copy link
Copy Markdown
Contributor Author

nabijaczleweli commented Sep 8, 2023

We don't parse it, and it's not part of the RFC3339 profile of ISO8601. I guess it is an ISO8601, sure. But it's extremely anti-user to have a format that, for no good reason, cannot be fed back to --since &c., and we parse a format that's a byte away. Especially since you said that RFC3339 is the only sane profile of ISO8601.

@poettering
Copy link
Copy Markdown
Member

ok make sense.

Comment thread src/shared/logs-show.c Outdated
Comment thread src/shared/logs-show.c Outdated
@nabijaczleweli nabijaczleweli force-pushed the short-iso-timestamp branch 2 times, most recently from b91d3ed to 9705b89 Compare September 8, 2023 18:57
@bluca bluca added needs-rebase and removed please-review PR is ready for (re-)review by a maintainer labels Sep 18, 2023
@YHNdnzj YHNdnzj added this to the v255 milestone Sep 20, 2023
@bluca
Copy link
Copy Markdown
Member

bluca commented Sep 26, 2023

@nabijaczleweli this just needs a rebase to fix merge conflicts (and re-test just in case) then looks ready

@nabijaczleweli
Copy link
Copy Markdown
Contributor Author

rebased

@github-actions github-actions Bot added please-review PR is ready for (re-)review by a maintainer and removed needs-rebase labels Sep 26, 2023
@bluca bluca added journal good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed please-review PR is ready for (re-)review by a maintainer labels Sep 26, 2023
@YHNdnzj YHNdnzj added the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Sep 26, 2023
@github-actions github-actions Bot removed the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Sep 26, 2023
@bluca bluca merged commit 93bd6e3 into systemd:main Sep 27, 2023
@github-actions github-actions Bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Sep 27, 2023
Comment thread src/shared/logs-show.c
xsprintf(usec, "%06"PRI_USEC, display_ts->realtime % USEC_PER_SEC);
memcpy(buf + 20, usec, 6);
int8_t h = tm.tm_gmtoff / 60 / 60;
int8_t m = labs((tm.tm_gmtoff / 60) % 60);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, where does the int8_t type come from? this is so weird, a signed byte? we have never used such a type, as when put in registers or in the stack is upgraded to int anyway.

moreover tm_gmtoff actually uses long as type, hence the artificially shorter width is just weird and smeels a lot like accidental loss of precision.

Quite frankly the compiler should warn assigning the result of a funciton like labs() that operates on long ints onto an int8_t...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From stdint.h, like all the others. If I had a type that went [0, 60) I would've used it, but this uses int8_t because it's derived from voreutils vore-time which carries a generic version of date(1) %z, but there it's

							std::int8_t hms[3];
							hms[2] = std::abs(tm_gmtoff_for(tm, ts) % 60);
							hms[1] = std::abs((tm_gmtoff_for(tm, ts) / 60) % 60);
							hms[0] = tm_gmtoff_for(tm, ts) / 60 / 60;

Comment thread src/shared/logs-show.c
/* No usec in strftime, need to append */
if (mode == OUTPUT_SHORT_ISO_PRECISE) {
snprintf(buf + tail, ELEMENTSOF(buf) - tail, ".%06"PRI_USEC, display_ts->realtime % USEC_PER_SEC);
tail += 7;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is a bit icky, if the buffer was too short, then you just jump into the void here...

should at least have an assert(ELEMENTS(buf) - tail >= 7) first

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes and in the original if buf was smaller than 28 you also jumped into the void so

Comment thread src/shared/logs-show.c
memcpy(buf + 20, usec, 6);
int8_t h = tm.tm_gmtoff / 60 / 60;
int8_t m = labs((tm.tm_gmtoff / 60) % 60);
snprintf(buf + tail, ELEMENTSOF(buf) - tail, "%+03"PRId8":%02"PRId8, h, m);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, this is going to be one character longer than before. This must be reflected in the definition of FORMAT_TIMESTAMP_MAX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FORMAT_TIMESTAMP_MAX is

 66 /* We assume a maximum timezone length of 6. TZNAME_MAX is not defined on Linux, but glibc internally initializes this
 67  * to 6. Let's rely on that. */
 68 #define FORMAT_TIMESTAMP_MAX (3U+1U+10U+1U+8U+1U+6U+1U+6U+1U)
 69 #define FORMAT_TIMESTAMP_RELATIVE_MAX 256U
 70 #define FORMAT_TIMESPAN_MAX 64U

which very helpfully both references some glibc-private macro and doesn't say which format it's describing, but that works out to 38 and "2023-09-08T17:20:47.560211+0200" is 31, so no it doesn't

@poettering
Copy link
Copy Markdown
Member

this really should have a test

@nabijaczleweli
Copy link
Copy Markdown
Contributor Author

show_journal_entry() doesn't have tests, so unclear to me how (i'm not writing generic show_journal_entry() tests)

@nabijaczleweli
Copy link
Copy Markdown
Contributor Author

#29356

Prashanth684 added a commit to Prashanth684/origin that referenced this pull request Jun 26, 2025
When testing openshift/release#66397 - the pivot
for the nodeimage to cs10 from cs9 seemed to work pretty well except one
test which failed in the e2e with:

```
[sig-node] Managed cluster should verify that nodes have no unexpected reboots [Late] [Suite:openshift/conformance/parallel]
```

This test failed because the timestamp has changed to be more compliant
with RFC339 (there was a PR in systemd about this a while back: systemd/systemd#29134).
This PR fixes that test to also support this layout.
Prashanth684 added a commit to Prashanth684/origin that referenced this pull request Jun 27, 2025
When testing openshift/release#66397 - the pivot
for the nodeimage to cs10 from cs9 seemed to work pretty well except one
test which failed in the e2e with:

```
[sig-node] Managed cluster should verify that nodes have no unexpected reboots [Late] [Suite:openshift/conformance/parallel]
```

This test failed because the timestamp has changed to be more compliant
with RFC339 (there was a PR in systemd about this a while back: systemd/systemd#29134).
This PR fixes that test to also support this layout.
votdev added a commit to openmediavault/openmediavault that referenced this pull request Nov 7, 2025
ShudiLi pushed a commit to ShudiLi/origin that referenced this pull request Dec 11, 2025
When testing openshift/release#66397 - the pivot
for the nodeimage to cs10 from cs9 seemed to work pretty well except one
test which failed in the e2e with:

```
[sig-node] Managed cluster should verify that nodes have no unexpected reboots [Late] [Suite:openshift/conformance/parallel]
```

This test failed because the timestamp has changed to be more compliant
with RFC339 (there was a PR in systemd about this a while back: systemd/systemd#29134).
This PR fixes that test to also support this layout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants