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

drop sys-v leftovers; assume systemctl is available for unknown platforms #1868

Merged
merged 2 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-05-10 15:53:37 UTC using RuboCop version 1.62.1.
# on 2024-05-11 14:14:06 UTC using RuboCop version 1.62.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -244,11 +244,10 @@ RSpec/ReceiveMessages:
- 'spec/beaker/test_suite_spec.rb'
- 'spec/helpers.rb'

# Offense count: 7
# Offense count: 4
RSpec/RepeatedDescription:
Exclude:
- 'spec/beaker/cli_spec.rb'
- 'spec/beaker/host/unix/exec_spec.rb'
- 'spec/beaker/host/unix/pkg_spec.rb'

# Offense count: 4
Expand Down
10 changes: 2 additions & 8 deletions lib/beaker/host/unix/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,14 @@ def clear_env_var key
# @return [Result] result of restarting the SSH service
def ssh_service_restart
case self['platform']
when /debian|ubuntu/
exec(Beaker::Command.new("service ssh restart"))
when /amazon|(el|centos|redhat|oracle|scientific)-[7-9]|fedora|archlinux-/
exec(Beaker::Command.new("systemctl restart sshd.service"))
when /el-|centos|redhat|oracle|scientific/
when /(el|centos|redhat|oracle|scientific)-[0-6]/
exec(Beaker::Command.new("/sbin/service sshd restart"))
when /opensuse|sles/
exec(Beaker::Command.new("/usr/sbin/rcsshd restart"))
Comment on lines -287 to -288
Copy link
Member

Choose a reason for hiding this comment

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

I think @joshcooper wanted to say that SLES 11 still hit this code. IMHO we should treat it like EL 6: special case it and less SLES 12+ fall through to systemd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'm good with defaulting to systemd and special casing older platforms. Can you restore the ability to start services on SLES 11 using /usr/sbin/rcsshd restart?

Copy link
Member Author

@bastelfreak bastelfreak May 15, 2024

Choose a reason for hiding this comment

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

#1883

but the question is the same as for EL6: How long will Puppet support those platforms? does it make sense for us to carry on with non-systemd support?

Copy link
Contributor

@joshcooper joshcooper May 15, 2024

Choose a reason for hiding this comment

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

RHEL 6 will have Extended LIfecycle Support until June 30, 2024 based on https://access.redhat.com/articles/4665701#6-how-can-i-continue-to-receive-software-maintenance-bug-and-security-fixes-and-full-technical-support-for-red-hat-enterprise-linux-6-6

But they could extend it, similar to how Oracle extended Solaris 10 until Jan 2027 https://blogs.oracle.com/solaris/post/new-end-date-of-extended-support-for-oracle-solaris-10-and-113

Also SLES 11 is something we will be supporting for some time.

when /solaris/
exec(Beaker::Command.new("svcadm restart svc:/network/ssh:default"))
when /(free|open)bsd/
exec(Beaker::Command.new("sudo /etc/rc.d/sshd restart"))
else
raise ArgumentError, "Unsupported Platform: '#{self['platform']}'"
exec(Beaker::Command.new("systemctl restart sshd.service"))
end
end

Expand Down
29 changes: 1 addition & 28 deletions spec/beaker/host/unix/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ def to_s
let(:ssh_command) { "echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit" }
let(:ssh_move) { "mv #{directory}/sshd_config.permit /etc/ssh/sshd_config" }

platforms = PlatformHelpers::SYSTEMDPLATFORMS + PlatformHelpers::DEBIANPLATFORMS + PlatformHelpers::SYSTEMVPLATFORMS

platforms.each do |platform|
PlatformHelpers::SYSTEMDPLATFORMS.each do |platform|
it "calls the correct commands for #{platform}" do
opts['platform'] = platform
expect(instance).to receive(:exec).twice
Expand Down Expand Up @@ -114,31 +112,6 @@ def to_s
expect { instance.ssh_service_restart }.not_to raise_error
end
end

PlatformHelpers::DEBIANPLATFORMS.each do |platform|
it "calls the correct command for #{platform}" do
opts['platform'] = platform
expect(instance).to receive(:exec)
expect(Beaker::Command).to receive(:new).with("service ssh restart")
expect { instance.ssh_service_restart }.not_to raise_error
end
end

PlatformHelpers::SYSTEMVPLATFORMS.each do |platform|
Copy link
Member

Choose a reason for hiding this comment

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

Would have been nice to keep this for EL6.

Copy link
Member Author

Choose a reason for hiding this comment

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

@joshcooper do you still rely on it? Vox Pupuli doesn't support EL6 anymore and I suspect you won't update to beaker 6 soonish and drop EL6 from your pipelines anyways?

Copy link
Member

Choose a reason for hiding this comment

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

We special cased it in the code. Either we should have dropped it or implemented tests. We kept it in at @joshcooper's request so I'd like to test it

it "calls the correct command for #{platform}" do
opts['platform'] = "#{platform}-arch"
expect(instance).to receive(:exec)
expect(Beaker::Command).to receive(:new).with("/sbin/service sshd restart")
expect { instance.ssh_service_restart }.not_to raise_error
end
end

it 'raises an error on unsupported platforms' do
opts['platform'] = 'notarealthing02-parts-arch'
expect do
instance.ssh_service_restart
end.to raise_error(ArgumentError, /#{opts['platform']}/)
end
end

describe '#prepend_commands' do
Expand Down
20 changes: 5 additions & 15 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,9 @@ module PlatformHelpers

SYSTEMDPLATFORMS = %w[amazon-2023
fedora
el-7
centos-7
redhat-7
oracle-7
scientific-7
el-8
centos-8
redhat-8
oracle-8]

SYSTEMVPLATFORMS = ['el-',
'centos',
'redhat',
'oracle',
'scientific',]
el-
centos
redhat
oracle
scientific].concat(DEBIANPLATFORMS)
end