Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status: Print systemd or ostree staged failure msg #1609

Closed
wants to merge 6 commits into from

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Oct 12, 2018

Follow-up from #1601.

Try to tease out a bit more info from the journal by looking at the
systemd message when the service transitions to the dead state or even
looking at the OSTree output itself.

Example outputs:

[root@f28-ros ~]# rpm-ostree status
State: idle
Warning: failed to finalize previous deployment
         error: opendir(ostree/deploy/fedora-atomic/deploy/887c95887a3047a60372016a0d84536530755b60df3cca33c819f7606e220adf.0): No such file or directory
         check `journalctl -b -1 -u ostree-finalize-staged.service`
AutomaticUpdates: disabled
...
[root@f28-ros ~]# rpm-ostree status
State: idle
Warning: failed to finalize previous deployment
         ostree-finalize-staged.service: Failed with result 'timeout'.
         check `journalctl -b -1 -u ostree-finalize-staged.service`
AutomaticUpdates: disabled
...

Sample output:

```
$ rpm-ostree status
State: idle
Warning: failed to finalize previous deployment
         check `journalctl -b -1 -u ostree-finalize-staged.service`
AutomaticUpdates: disabled
...
```

(Though open to tweaking it).

I also played with directly invoking `journalctl` for the user, but that
can get really spammy with e.g. `os-prober` output and such.

I wrote this in Rust using journal API wrappers because I also plan to
implement the `history` command in Rust and will also enhance that new
`journal` module there for that.

Requires: ostreedev/ostree#1750
Requires: codyps/rust-systemd#54
(Though I've pointed the manifest at my branch for now for CI).

Closes: coreos#1567
Nuke systemd source files for the same reasons as libcurl (see coreos#1554).
Also noticed that libz-sys was doing this, though it's not new to this
patch.

For reference, see: coreos#1554
Try to tease out a bit more info from the journal by looking at the
systemd message when the service transitions to the dead state or even
looking at the OSTree output itself.

Example outputs:

```
[root@f28-ros ~]# rpm-ostree status
State: idle
Warning: failed to finalize previous deployment
         error: opendir(ostree/deploy/fedora-atomic/deploy/887c95887a3047a60372016a0d84536530755b60df3cca33c819f7606e220adf.0): No such file or directory
         check `journalctl -b -1 -u ostree-finalize-staged.service`
AutomaticUpdates: disabled
...
```

```
[root@f28-ros ~]# rpm-ostree status
State: idle
Warning: failed to finalize previous deployment
         ostree-finalize-staged.service: Failed with result 'timeout'.
         check `journalctl -b -1 -u ostree-finalize-staged.service`
AutomaticUpdates: disabled
...
```
rust/src/lib.rs Outdated
JournalStagingFailure::SystemdMsg(m) | JournalStagingFailure::OstreeErrorMsg(m) => {
let cbuf = CUtf8Buf::from(m);
unsafe {
ptr::copy_nonoverlapping(cbuf.as_ptr(), buf, bufsize);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically memcpy.

@jlebon jlebon mentioned this pull request Oct 12, 2018
@cgwalters
Copy link
Member

Looks pretty elegant overall. I find myself wondering though if it's really worth the overhead of maintaining a nice API for this versus just moving the printf inside the Rust code and having the FFI function hence be the trivially correct void ror_status_print_staging_failure (void);.

@jlebon
Copy link
Member Author

jlebon commented Oct 12, 2018

I find myself wondering though if it's really worth the overhead of maintaining a nice API for this versus just moving the printf inside the Rust code

I was initially against this since it's odd to split the printing out across multiple places, though you can't argue with the difference in simplicity. Done in ⬆️!

Might as well stick with the simpler approach for now until there's a compelling reason to make it worth being more complex.

@jlebon
Copy link
Member Author

jlebon commented Oct 12, 2018

I added another fixup! so we don't completely error out if somehow querying the journal fails since that seems like a silly reason to not print the rest of the status output.

@jlebon
Copy link
Member Author

jlebon commented Oct 12, 2018

Part of #1601 (because that last fixup is actually needed to pass tests).

@jlebon jlebon closed this Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants