Skip to content

Commit 0b1c8e0

Browse files
authored
[Release-3.14.1] Add chef attribute to optionally skip the installation of dcv (#3076)
* Add chef attribute `['cluster']['dcv']['install_enabled']` to optionally skip the installation of dcv
1 parent 5053ffd commit 0b1c8e0

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

cookbooks/aws-parallelcluster-platform/attributes/platform.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
default['cluster']['nvidia']['nvlsm']['enabled'] = true
3131

3232
# DCV
33+
default['cluster']['dcv']['install_enabled'] = true
3334
default['cluster']['dcv']['authenticator']['user'] = "dcvextauth"
3435
default['cluster']['dcv']['authenticator']['user_id'] = node['cluster']['reserved_base_uid'] + 3
3536
default['cluster']['dcv']['authenticator']['group'] = node['cluster']['dcv']['authenticator']['user']

cookbooks/aws-parallelcluster-platform/resources/dcv/partial/_dcv_common.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def optionally_disable_rnd
100100
end
101101

102102
action :setup do
103+
unless node['cluster']['dcv']['install_enabled']
104+
Chef::Log.warn("Skipping DCV installation because node['cluster']['dcv']['install_enabled'] is set to false")
105+
return
106+
end
103107
return if dcv_installed?
104108
return if redhat_on_docker?
105109

cookbooks/aws-parallelcluster-platform/spec/unit/resources/dcv_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,39 @@ def self.nothing(chef_run)
657657
end
658658
end
659659

660+
context "when install_enabled is false" do
661+
cached(:chef_run) do
662+
runner = runner(platform: platform, version: version, step_into: ['dcv']) do |node|
663+
node_setup.call(node)
664+
node.override['cluster']['dcv']['install_enabled'] = false
665+
end
666+
stubs_for_resource('dcv') do |res|
667+
allow(res).to receive(:dcv_sha256sum).and_return(checksum)
668+
allow(res).to receive(:dcv_supported?).and_return(true)
669+
allow(res).to receive(:prereq_packages).and_return(alinux_prereq_packages) if platform == 'amazon'
670+
allow(res).to receive(:dcv_package).and_return(dcv_package)
671+
allow(res).to receive(:dcv_server).and_return(dcv_server)
672+
allow(res).to receive(:xdcv).and_return(xdcv)
673+
allow(res).to receive(:dcv_web_viewer).and_return(dcv_web_viewer)
674+
allow(res).to receive(:dcv_url_arch).and_return(dcv_url_arch)
675+
allow(res).to receive(:dcv_pkg_arch).and_return(dcv_pkg_arch)
676+
allow(res).to receive(:dcv_url).and_return(dcv_url)
677+
allow(res).to receive(:dcv_tarball).and_return(dcv_tarball)
678+
allow(res).to receive(:dcvauth_virtualenv).and_return(dcvauth_virtualenv)
679+
allow(res).to receive(:dcvauth_virtualenv_path).and_return(dcvauth_virtualenv_path)
680+
end
681+
method_setup.call
682+
ConvergeDcv.setup(runner)
683+
end
684+
685+
it 'does not install dcv when install_enabled is false' do
686+
is_expected.not_to create_if_missing_cookbook_file("#{scripts_dir}/pcluster_dcv_connect.sh")
687+
is_expected.not_to create_group(authenticator_group)
688+
is_expected.not_to create_user(authenticator_user)
689+
is_expected.not_to run_execute('set default systemd runlevel to multi-user.target')
690+
end
691+
end
692+
660693
context "when not official ami build" do
661694
cached(:chef_run) do
662695
runner = runner(platform: platform, version: version, step_into: ['dcv']) do |node|

cookbooks/aws-parallelcluster-platform/test/controls/dcv_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
control 'tag:install_dcv_connect_script_installed' do
1313
title 'Check pcluster dcv connect script is installed'
14-
only_if { !os_properties.redhat_on_docker? }
14+
only_if { instance.dcv_install_enabled? && !os_properties.redhat_on_docker? }
1515

1616
describe file("#{node['cluster']['scripts_dir']}/pcluster_dcv_connect.sh") do
1717
it { should be_file }
@@ -23,7 +23,7 @@
2323

2424
control 'tag:install_dcv_authenticator_user_and_group_set_up' do
2525
title 'Check that dcv authenticator user and group have been set up'
26-
only_if { !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
26+
only_if { instance.dcv_install_enabled? && !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
2727

2828
describe group(node['cluster']['dcv']['authenticator']['group']) do
2929
it { should exist }
@@ -39,7 +39,7 @@
3939

4040
control 'tag:install_dcv_disabled_lock_screen' do
4141
title 'Check that the lock screen has been disabled'
42-
only_if { !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
42+
only_if { instance.dcv_install_enabled? && !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
4343

4444
describe bash('gsettings get org.gnome.desktop.lockdown disable-lock-screen') do
4545
its('exit_status') { should eq 0 }
@@ -54,7 +54,7 @@
5454

5555
control 'tag:install_dcv_installed' do
5656
title 'Check dcv is installed'
57-
only_if { !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
57+
only_if { instance.dcv_install_enabled? && !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
5858

5959
pkgs = %W(nice-dcv-server nice-xdcv nice-dcv-web-viewer)
6060
pkgs.each do |pkg|
@@ -66,7 +66,7 @@
6666

6767
control 'tag:install_dcv_external_authenticator_virtualenv_created' do
6868
title 'Check dcv external authenticator virtual environment is created'
69-
only_if { !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
69+
only_if { instance.dcv_install_enabled? && !os_properties.redhat_on_docker? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
7070

7171
describe file("#{node['cluster']['dcv']['authenticator']['virtualenv_path']}/bin/activate") do
7272
it { should be_file }
@@ -76,7 +76,7 @@
7676

7777
control 'tag:install_dcv_debian_specific_setup' do
7878
title 'Check debian specific setup'
79-
only_if { os_properties.debian_family? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
79+
only_if { instance.dcv_install_enabled? && os_properties.debian_family? && !(os_properties.ubuntu? && os_properties.arm?) && !os_properties.alinux2023? }
8080

8181
pkgs = %W(whoopsie ubuntu-desktop mesa-utils)
8282
pkgs.each do |pkg|
@@ -97,7 +97,7 @@
9797

9898
control 'tag:install_dcv_rhel_and_centos_specific_setup' do
9999
title 'Check rhel and centos specific setup'
100-
only_if { !os_properties.on_docker? }
100+
only_if { instance.dcv_install_enabled? && !os_properties.on_docker? }
101101
only_if { !os_properties.alinux2023? }
102102
only_if { os_properties.centos? || os_properties.redhat? }
103103

@@ -136,7 +136,7 @@
136136
control 'tag:install_dcv_alinux2_specific_setup' do
137137
title 'Check alinux2 specific setup'
138138

139-
only_if { os_properties.alinux2? }
139+
only_if { instance.dcv_install_enabled? && os_properties.alinux2? }
140140

141141
prereq_packages = %w(gdm gnome-session gnome-classic-session gnome-session-xsession
142142
xorg-x11-server-Xorg xorg-x11-fonts-Type1 xorg-x11-drivers
@@ -160,7 +160,7 @@
160160

161161
control 'tag:install_dcv_switch_runlevel_to_multiuser_target' do
162162
title 'Check that runlevel is switched to multi-user.target'
163-
only_if { !os_properties.on_docker? }
163+
only_if { instance.dcv_install_enabled? && !os_properties.on_docker? }
164164
only_if { !os_properties.alinux2023? }
165165

166166
describe bash('systemctl get-default') do

cookbooks/aws-parallelcluster-shared/test/libraries/instance.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def dcv_installed?
3939
inspec.file("/etc/dcv/dcv.conf").exist?
4040
end
4141

42+
def dcv_install_enabled?
43+
inspec.node['cluster']['dcv']['install_enabled'] != false
44+
end
45+
4246
def imds_token
4347
@imds_token = inspec.http('http://169.254.169.254/latest/api/token', method: 'PUT', headers: {
4448
"X-aws-ec2-metadata-token-ttl-seconds": 900,

0 commit comments

Comments
 (0)