Bug 1227580

Summary: yast2-services-manager fails to build with systemd v256
Product: [openSUSE] openSUSE Tumbleweed Reporter: Franck Bui <fbui>
Component: YaST2Assignee: Franck Bui <fbui>
Status: NEW --- QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None CC: ana.guerrero, fvogt
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: yast2_services_manager_log

Description Franck Bui 2024-07-09 14:08:07 UTC
Hi,

It seems that there's a regression in yast2-services-manager with the latest version of systemd (v256 submitted via sr#1186155).

For more details please check the following link: 
https://build.opensuse.org/package/show/openSUSE:Factory:Staging:K/yast2-services-manager

Could you have a look ?

Thanks.
Comment 1 Ana Guerrero 2024-07-09 14:37:46 UTC
Created attachment 875964 [details]
yast2_services_manager_log

Log attached since systemd is likely to change Staging letter.
Comment 2 Stefan Hundhammer 2024-07-10 08:05:13 UTC
Summary of failed unit tests:

>>  rspec ./test/dialogs/services_manager_test.rb:122 # Y2ServicesManager::Dialogs::ServicesManager#run when logs button should not be shown does not offer a button to show logs
>>  rspec ./test/dialogs/services_manager_test.rb:134 # Y2ServicesManager::Dialogs::ServicesManager#run when logs button should be shown offers a button to show logs
>>  rspec ./test/dialogs/services_manager_test.rb:146 # Y2ServicesManager::Dialogs::ServicesManager#run when start/stop button should be shown offers a button to start/stop services
>>  rspec ./test/dialogs/services_manager_test.rb:157 # Y2ServicesManager::Dialogs::ServicesManager#run when start/stop button should not be shown does not offer a button to start/stop services
>>  rspec ./test/dialogs/services_manager_test.rb:168 # Y2ServicesManager::Dialogs::ServicesManager#run when apply button should be shown offers a button to apply changes
>>  rspec ./test/dialogs/services_manager_test.rb:182 # Y2ServicesManager::Dialogs::ServicesManager#run when apply button should be shown and there are no changes yet disables the 'Apply' button
>>  rspec ./test/dialogs/services_manager_test.rb:195 # Y2ServicesManager::Dialogs::ServicesManager#run when apply button should not be shown does not offer a button to apply changes
>>  rspec ./test/dialogs/services_manager_test.rb:207 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Cancel' button shows a confirmation popup
>>  rspec ./test/dialogs/services_manager_test.rb:213 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Cancel' button closes the dialog
>>  rspec ./test/dialogs/services_manager_test.rb:219 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Cancel' button returns false
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:8:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button shows a confirmation popup with a summary of changes
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:8:2] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button tries to apply all changes
>>  rspec ./test/dialogs/services_manager_test.rb:296 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button and all changes are correctly applied closes the dialog
>>  rspec ./test/dialogs/services_manager_test.rb:302 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button and all changes are correctly applied returns true
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:8:4:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button and some changes cannot be applied asks whether to continue editing
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:8:4:2:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button and some changes cannot be applied and user wants to continue editing refreshes the services list
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:8:4:3:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button and some changes cannot be applied and user does not want to continue editing closes the dialog
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:8:4:3:2] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'OK' button and some changes cannot be applied and user does not want to continue editing returns false
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:9:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button shows a confirmation popup with a summary of changes
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:9:2] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button tries to apply all changes
>>  rspec ./test/dialogs/services_manager_test.rb:324 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button and all changes are correctly applied refreshes the services list
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:9:4:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button and some changes cannot be applied asks whether to continue editing
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:9:4:2:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button and some changes cannot be applied and user wants to continue editing refreshes the services list
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:9:4:3:1] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button and some changes cannot be applied and user does not want to continue editing closes the dialog
>>  rspec ./test/dialogs/services_manager_test.rb[1:1:9:4:3:2] # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Apply' button and some changes cannot be applied and user does not want to continue editing returns false
>>  rspec ./test/dialogs/services_manager_test.rb:345 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Show Log' button shows the systemd journal entries for the selected service
>>  rspec ./test/dialogs/services_manager_test.rb:358 # Y2ServicesManager::Dialogs::ServicesManager#run when user selects 'Help' button shows a popup with the help
>>  
>>  rspec ./test/widgets/target_selector_test.rb:60 # Y2ServicesManager::Widgets::TargetSelector#widget returns a Yast::Term
>>  
>>  rspec ./test/widgets/target_selector_test.rb:64 # Y2ServicesManager::Widgets::TargetSelector#widget offers all possible targets
Comment 3 Stefan Hundhammer 2024-07-10 08:11:14 UTC
I see this 29 times in that build log: 

>>  NameError:
>>    uninitialized constant #<Class:Yast2::Systemd::Target>::SystemctlError
Comment 4 Stefan Hundhammer 2024-07-10 09:16:32 UTC
I don't see a class definition for 'SystemctlError' (no matter which namespace) anywhere in the YaST code. I suspect that it was always missing, but that never became obvious because it's a very rare error.

AFAICS it's raised only here:

https://github.com/yast/yast-yast2/blob/master/library/systemd/src/lib/yast2/systemd/target.rb#L81-L86

>>  def get_default # rubocop:disable Naming/AccessorMethodName
>>    result = Systemctl.execute("get-default")
>>    raise(SystemctlError, result) unless result.exit.zero?
>>
>>    find(result.stdout.strip)
>>  end


...which would mean that   systemctl get-default   doesn't work anymore on this systemd version.
Comment 5 Stefan Hundhammer 2024-07-10 09:20:32 UTC
Franck, if that is the case ('systemd get-default' not working on this systemd version), is that intentional? Is there a replacement command? Or how should this now be handled?
Comment 6 Stefan Hundhammer 2024-07-10 11:45:10 UTC
It looks like this commit removed the error class, but did not add a new one in another class or module (which was probably intended):

https://github.com/yast/yast-yast2/commit/e4ab10035ba30f739175009344872c4062c26db6#diff-8ddc7418f9da5ef96888a536c77c9e4c3330414a4b9a14f4ad95830dd00547aeL4-L12

That was part of this PR

  https://github.com/yast/yast-yast2/pull/799

back in mid-2018, 6 years ago.
Comment 7 Stefan Hundhammer 2024-07-10 12:29:41 UTC
PR that fixes the missing error class:

  https://github.com/yast/yast-yast2/pull/1312

This will not fix the underlying problem:

  systemctl get-default

failing. But it will show the original error message of the 'systemctl' command.
Comment 8 Franck Bui 2024-07-10 12:46:42 UTC
(In reply to Stefan Hundhammer from comment #5)
> Franck, if that is the case ('systemd get-default' not working on this
> systemd version), is that intentional? Is there a replacement command? Or
> how should this now be handled?

AFAICS `systemctl get-default` is still available and still works as expected on my system running v256.
Comment 9 Stefan Hundhammer 2024-07-10 14:03:11 UTC
So let's wait what the next iteration brings; the PR is now merged. We should now get a clear error message why 'systemctl get-default' fails.
Comment 10 Stefan Hundhammer 2024-07-10 14:10:12 UTC
SR to OBS: https://build.opensuse.org/request/show/1186617
Comment 11 Stefan Hundhammer 2024-07-11 15:03:59 UTC
Franck, Ana, any news on this?

Are we getting a more specific error message now that it doesn't crash anymore in the process of throwing the error?
Comment 13 Fabian Vogt 2024-07-12 09:31:50 UTC
(In reply to Stefan Hundhammer from comment #11)
> Franck, Ana, any news on this?
> 
> Are we getting a more specific error message now that it doesn't crash
> anymore in the process of throwing the error?

Yes:

[   10s]         Systemctl command failed: #<OpenStruct exit=1, stderr="Failed to connect to bus: No such file or directory\n", stdout="", command=" LANG=C TERM=dumb COLUMNS=1024 /usr/bin/systemctl --plain --full --no-legend --no-pager --no-ask-password get-default">

i.e. new systemd get-default requires a running system?
Comment 14 Franck Bui 2024-07-12 09:40:17 UTC
(In reply to Fabian Vogt from comment #13)
> i.e. new systemd get-default requires a running system?

No it shouldn't. I also just verified that the command still works in a chroot.
Comment 15 Stefan Hundhammer 2024-07-17 15:10:09 UTC
Franck has been working on this since last week. Reassigning.