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

ayatana-indicators: init messaging indicator, module, test #243476

Merged
merged 3 commits into from
Dec 2, 2023

Conversation

OPNA2608
Copy link
Contributor

@OPNA2608 OPNA2608 commented Jul 14, 2023

Description of changes

Working towards #99090.

Ayatana Indicators are a continuation of Canonical's Application Indicators. Lomiri makes use of them for its top bar system: without at least ayatana-indicator-session, you won't be able to exit the session as there will be no way to trigger the dialogue 😛.

This PR:

  • Inits ayatana-indicator-messages as a start.
  • Inits a NixOS module for having ayatana-indicators.target bring up a list of desired indicators. I'll happily accept better solutions for this.
    • The individual indicator services normally bind to the target via WantedBy, but we don't install (user) services on NixOS so one of the sides from this interaction needs to be get an explicit Wants (to the best of my knowledge)
    • Rewriting the target all the services bind to seemed easier than rewriting all the services
    • A custom passthru.ayatana-indicators = [ "thingy" ] attribute is expected to be present in all requested indicator package, listing the indicator services they provide. There's no individual package with multiple services that I'm aware of, but I see no reason to disallow this in practice.
  • Adds a VM test that makes sure the various indicators we're going to add work & keep working.

Some future indicators will come with optional Lomiri-specific support. I'll enable this when possible, and try to keep an eye on closure size increase so future non-Lomiri uses won't be too affected. See #262118 for a first push for that + initial closure considerations there.

The test is using MATE because it's one of the DEs with theoretical support for them, and because the target is supposed to depend on a graphical session, but its support is not really being used. mate.mate-indicator-applet would first have to be patched to use Ayatana indicators and find new-style ones, it would require (graphical?) panel configuration to load the indicator applet, and it doesn't seem to support/show some indicators (only 1/3 of the ones I tested showed up, but maybe I just picked some not-useful ones). Maybe it can be rewritten to use Lomiri later on, which has none of those issues, but it's somewhat-secondry to me when the entire rendering part of the interplay is really DE-specific.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jul 14, 2023
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jul 14, 2023
@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch 2 times, most recently from 965ae03 to 915375d Compare August 4, 2023 15:22
@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Aug 4, 2023

Ehh, prolly good enough for review now.

@OPNA2608 OPNA2608 marked this pull request as ready for review August 4, 2023 15:42
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/2651

@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch from 915375d to 879c21f Compare October 12, 2023 16:00
@OPNA2608 OPNA2608 changed the title ayatana-indicators: init scope, messaging indicator & module ayatana-indicators: init scope, messaging indicator, module, test Oct 12, 2023
@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch from 879c21f to bed9247 Compare October 13, 2023 07:36
@OPNA2608 OPNA2608 requested a review from Janik-Haag October 13, 2023 07:38
@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch from bed9247 to 2d8ab09 Compare October 13, 2023 07:51
@Janik-Haag
Copy link
Member

Result of nixpkgs-review pr 243476 run on x86_64-linux 1

2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
3 packages built:
  • ayatana-indicators.ayatana-indicator-messages
  • ayatana-indicators.ayatana-indicator-messages.dev
  • ayatana-indicators.ayatana-indicator-messages.devdoc

nixos/tests/ayatana-indicators.nix Show resolved Hide resolved
Comment on lines 50 to 65
# Let all services do their startups, wait for potential post-launch crashes & crash-restart cycles to be done
# Not sure if there's a better way of awaiting this
machine.sleep(10)
Copy link
Member

Choose a reason for hiding this comment

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

you shouldn't really need this and usually only wait for services specif to your test, and the test also won't crash if some random systemd unit not related to your test script dies so I don't really see a benefit

Copy link
Contributor Author

@OPNA2608 OPNA2608 Oct 15, 2023

Choose a reason for hiding this comment

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

Comment is referring to the individual indicator services. wait_for_unit can't handle situations where a service launches fine, but crashes some time post-launch - it just looks at whatever the state is at the time. I've seen this happen with some of the indicators if wrapping or expected system services are missing, making the test give a false positive.

In addition, I can't figure out the best unit to await for the services being XDG autostarted, so more waiting there. Would be more than happy about better solution for this!

nixos/tests/ayatana-indicators.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/ayatana-indicators/default.nix Outdated Show resolved Hide resolved
@OPNA2608
Copy link
Contributor Author

Thanks for the review. Will rethink stuff when I have time.

@OPNA2608 OPNA2608 marked this pull request as draft October 15, 2023 10:33
@h7x4 h7x4 added 8.has: module (new) This PR adds a module in `nixos/` 8.has: tests This PR has tests and removed 8.has: module (update) This PR changes an existing module in `nixos/` labels Oct 16, 2023
@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch from 2d8ab09 to 8fd521b Compare October 20, 2023 09:51
@github-actions github-actions bot added the 8.has: module (update) This PR changes an existing module in `nixos/` label Oct 20, 2023
@OPNA2608 OPNA2608 changed the title ayatana-indicators: init scope, messaging indicator, module, test ayatana-indicators: init messaging indicator, module, test Oct 20, 2023
@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch from 8fd521b to 622342b Compare October 20, 2023 10:12
@OPNA2608 OPNA2608 force-pushed the init/lomiri/ayatana-messages branch from 622342b to 84605b1 Compare October 20, 2023 12:12
@OPNA2608
Copy link
Contributor Author

I think this should be better now?

@OPNA2608 OPNA2608 marked this pull request as ready for review October 20, 2023 12:24
Copy link
Member

@pbsds pbsds left a comment

Choose a reason for hiding this comment

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

  • module path fits the guidelines
  • module tests succeed on x86_64-liinux
  • options have appropriate types
  • options have default
  • options have example
  • options have descriptions
  • No unneeded package is added to environment.systemPackages
  • meta.maintainers is set
  • module documentation is declared in meta.doc
    • small internal module, not really needed. I consider ayatana-indicators.packages.description sufficient

Looks very good to me, just a couple of nits/questions.


# MATE relies on XDG autostart to bring up the indicators.
# Not sure *when* XDG autostart fires them up, and awaiting pgrep success seems to misbehave?
machine.sleep(10)
Copy link
Member

Choose a reason for hiding this comment

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

flaky tests are very annoying on hydra, and this one is very much affected by the current workload of the host. Is it possible to await the mate user shell or a dummy XDG autostart target?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe? I'll have to look. Perhaps xdg-desktop-autostart.target, but I'm not sure MATE uses SystemD for XDG autostart. Not sure if there's anything for MATE itself.

Copy link
Member

@pbsds pbsds Nov 27, 2023

Choose a reason for hiding this comment

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

Suggested change
machine.sleep(10)

I think wait_until_succeeds below is better

Copy link
Contributor Author

@OPNA2608 OPNA2608 Dec 1, 2023

Choose a reason for hiding this comment

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

We could instead wait_until_succeeds("pgrep [...]") below, and I would like the idea of not relying on sleep()s at all, but in my testing not sleep()ing anywhere will blow past all starts-but-immediately-segfaults situations. Even checking coredumpctl will report no errors, unless we sleep() to let it catch up with handling the coredumps.

Edit: Here is an example where I intentionally break ayatana-indicator-messages to not find its required schema and modify the VM test to not use any sleep()s.

  • wait_until_succeeds("pgrep [...]") succeeds, despite systemd working on handling a coredump of the XDG autostarted process
  • succeed("pkill [...]") succeeds, presumably interrupting the coredump handling completely
  • wait_for_unit("${service}") succeeds, either while a coredump of the systemd service gets handled or because the service got auto-restarted by systemd
  • fail("coredumpctl --json=short | grep 'ayatana-indicator'") succeeds, presumably because there hasn't been any time to register any coredumps

I'd prefer to use sleep()s between some steps to make sure the test steps are less likely to lie to me, unless you have any ideas for how to handle this?

Copy link
Member

Choose a reason for hiding this comment

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

Great exploration of the problem space. Even forcing coredumpctl to have a look wouldn't work unless we can guarantee a deficit would have caused a coredump by then. rg '\.sleep\(.*\)' -o | cut -d: -f2 | sort | uniq -c reveals to me that 10 seconds is a pretty common wait time, so lets stick with it.


# Now check if all indicators were brought up successfully, and kill them for later
'' + (runCommandPerIndicatorService (service: let serviceExec = builtins.replaceStrings [ "." ] [ "-" ] service; in ''
machine.succeed("pgrep -f ${serviceExec}")
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to await this with timeout or retry n times? If so then the sleep(10) above is sufficient.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
machine.succeed("pgrep -f ${serviceExec}")
machine.wait_until_succeeds("pgrep -f ${serviceExec}", timeout=100) # 900 default

nixos/tests/ayatana-indicators.nix Show resolved Hide resolved
@pbsds pbsds merged commit 598129e into NixOS:master Dec 2, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 8.has: tests This PR has tests 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants