Skip to content

Commit a4f95d1

Browse files
yuleiwandemartinofra
authored andcommitted
Disable x/gdm daemon on compute instance (#837)
* Set default systemd runlevel to multi-user.target on all OSes during ami creation. The runlevel is set to graphical.target only when DCV is enabled. * In ParallelCluster 2.10.0, centos7/centos8 use multi-user.target and ubuntu1804/alinux2 use graphical.target. multi-user.target won't start x/gdm service when booting. So, the solution is during ubuntu1804/alinux2 AMI build, switching graphical.target to multi-user.target to disable x/gdm service, then if dcv is enabled, switch multi-user.target to graphical.target and enable x/gdm service on head node. Signed-off-by: Yulei Wang <yuleiwan@amazon.com> Co-authored-by: Francesco De Martino <demartinof@icloud.com>
1 parent b361a53 commit a4f95d1

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This file is used to list changes made in each version of the AWS ParallelCluste
99
**ENHANCEMENTS**
1010
- Configure NFS threads to be max(8, num_cores) for performance. This enhancement will not take effect on Ubuntu 16.04 unless the instance is rebooted.
1111
- EFA kernel module now installed also on ARM instances with `alinux2` and `ubuntu1804`
12+
- Set default systemd runlevel to multi-user.target on all OSes during ami creation. The runlevel is set to graphical.target only when DCV is enabled.
1213

1314
**CHANGES**
1415
- Upgrade EFA installer to version 1.11.0

recipes/dcv_config.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@
2020

2121
# Configure the system to enable NICE DCV to have direct access to the Linux server's GPU and enable GPU sharing.
2222
def allow_gpu_acceleration
23-
# On CentOS fix circular dependency multi-user.target -> cloud-init-> isolate multi-user.target.
24-
# multi-user.target doesn't start until cloud-init run is finished. So isolate multi-user.target
25-
# is stuck into starting, which keep hanging chef until the 3600s timeout.
26-
unless node['platform'] == 'centos'
27-
# Turn off X
28-
execute "Turn off X" do
29-
command "systemctl isolate multi-user.target"
30-
end
31-
end
32-
3323
# Update the xorg.conf to set up NVIDIA drivers.
3424
# NOTE: --enable-all-gpus parameter is needed to support servers with more than one NVIDIA GPU.
3525
nvidia_xconfig_command = "nvidia-xconfig --preserve-busid --enable-all-gpus"
@@ -82,6 +72,15 @@ def allow_gpu_acceleration
8272
if node.default['cfncluster']['dcv']['is_graphic_instance']
8373
# Enable graphic acceleration in dcv conf file for graphic instances.
8474
allow_gpu_acceleration
75+
else
76+
bash 'set default systemd runlevel to graphical.target' do
77+
user 'root'
78+
code <<-SETUPX
79+
set -e
80+
systemctl set-default graphical.target
81+
systemctl isolate graphical.target &
82+
SETUPX
83+
end
8584
end
8685

8786
case node['platform']

recipes/dcv_install.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,10 @@ def disable_lock_screen
228228
end
229229
end
230230
end
231+
232+
# Switch runlevel to multi-user.target
233+
if node['init_package'] == 'systemd'
234+
execute "set default systemd runlevel to multi-user.target" do
235+
command "systemctl set-default multi-user.target"
236+
end
237+
end

recipes/tests.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,26 @@
250250
end
251251
end
252252

253+
if node['conditions']['dcv_supported'] && node['cfncluster']['dcv_enabled'] == "master" && node['cfncluster']['cfn_node_type'] == "MasterServer"
254+
execute 'check systemd default runlevel' do
255+
command "systemctl get-default | grep -i graphical.target"
256+
end
257+
if node['cfncluster']['os'] == "ubuntu1804" || node['cfncluster']['os'] == "alinux2"
258+
execute 'check gdm service is running' do
259+
command "systemctl show -p SubState gdm | grep -i running"
260+
end
261+
end
262+
elsif node['init_package'] == 'systemd'
263+
execute 'check systemd default runlevel' do
264+
command "systemctl get-default | grep -i multi-user.target"
265+
end
266+
if node['cfncluster']['os'] == "ubuntu1804" || node['cfncluster']['os'] == "alinux2"
267+
execute 'check gdm service is stopped' do
268+
command "systemctl show -p SubState gdm | grep -i dead"
269+
end
270+
end
271+
end
272+
253273
###################
254274
# EFA - Intel MPI
255275
###################
@@ -547,4 +567,4 @@ module load armpl/#{node['cfncluster']['armpl']['version']}
547567
ARMPL
548568
user node['cfncluster']['cfn_cluster_user']
549569
end
550-
end
570+
end

0 commit comments

Comments
 (0)