Skip to content

Commit 5e7f809

Browse files
committed
move most compute-init docs to the role readme
1 parent 36cf771 commit 5e7f809

File tree

2 files changed

+120
-79
lines changed

2 files changed

+120
-79
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# EXPERIMENTAL: compute-init
2+
3+
Experimental / in-progress functionality to allow compute nodes to rejoin the
4+
cluster after a reboot.
5+
6+
To enable this add compute nodes (or a subset of them into) the `compute_init`
7+
group.
8+
9+
This works as follows:
10+
1. During image build, an ansible-init playbook and supporting files
11+
(e.g. templates, filters, etc) are installed.
12+
2. Cluster instances are created as usual; the above compute-init playbook does
13+
not run.
14+
3. The `site.yml` playbook is run as usual to configure all the instances into
15+
a cluster. In addition, with `compute-init` enabled, a `/exports/cluster` NFS
16+
share is created on the control node containing:
17+
- an /etc/hosts file for the cluster
18+
- Hostvars for each compute node
19+
4. On reboot of a compute node, ansible-init runs the compute-init playbook
20+
which:
21+
a. Checks whether the `enable_compute` metadata flag is set, and exits if
22+
not.
23+
b. Tries to mount the above `/exports/cluster` NFS share from the control
24+
node, and exits if it cannot.
25+
c. Configures itself using the exported hostvars, depending on the
26+
`enable_*` flags set in metadata.
27+
d. Issues an `scontrol` command to resume the node (because Slurm will
28+
consider it as "unexpectedly rebooted").
29+
30+
The check in 4b. above is what prevents the compute-init script from trying
31+
to configure the node before the services on the control node are available
32+
(which requires running the site.yml playbook).
33+
34+
The following roles are currently fully functional:
35+
- `resolv_conf`
36+
- `etc_hosts`
37+
- `stackhpc.openhpc`
38+
39+
# Development/debugging
40+
41+
To develop/debug this without actually having to build an image:
42+
43+
44+
1. Deploy a cluster using tofu and ansible/site.yml as normal. This will
45+
additionally configure the control node to export compute hostvars over NFS.
46+
Check the cluster is up.
47+
48+
2. Reimage the compute nodes:
49+
50+
ansible-playbook --limit compute ansible/adhoc/rebuild
51+
52+
3. Add metadata to a compute node e.g. via Horzon to turn on compute-init
53+
playbook functionality.
54+
55+
4. Fake an image build to deploy the compute-init playbook:
56+
57+
ansible-playbook ansible/fatimage.yml --tags compute_init
58+
59+
NB: This will also re-export the compute hostvars, as the nodes are not
60+
in the builder group, which conveniently means any changes made to that
61+
play also get picked up.
62+
63+
5. Fake a reimage of compute to run ansible-init and the compute-init playbook:
64+
65+
On compute node where metadata was added:
66+
67+
[root@rl9-compute-0 rocky]# rm -f /var/lib/ansible-init.done && systemctl restart ansible-init
68+
[root@rl9-compute-0 rocky]# systemctl status ansible-init
69+
70+
Use `systemctl status ansible-init` to view stdout/stderr from Ansible.
71+
72+
Steps 4/5 can be repeated with changes to the compute script. If required,
73+
reimage the compute node(s) first as in step 2 and/or add additional metadata
74+
as in step 3.
75+
76+
77+
# Design notes
78+
- Duplicating code in roles into the `compute-init` script is unfortunate, but
79+
does allow developing this functionality without wider changes to the
80+
appliance.
81+
82+
- In general, we don't want to rely on NFS export. So should e.g. copy files
83+
from this mount ASAP in the compute-init script. TODO:
84+
85+
- There are a couple of approaches to supporting existing roles using `compute-init`:
86+
87+
1. Control node copies files resulting from role into cluster exports,
88+
compute-init copies to local disk. Only works if files are not host-specific
89+
Examples: etc_hosts, eessi config?
90+
91+
2. Re-implement the role. Works if the role vars are not too complicated,
92+
(else they all need to be duplicated in compute-init). Could also only
93+
support certain subsets of role functionality or variables
94+
Examples: resolv_conf, stackhpc.openhpc
95+
96+
- Some hostvars are tempalted from hostvars from other nodes, which aren't
97+
available in the current approach:
98+
99+
```
100+
[root@rl9-compute-0 rocky]# grep hostvars /mnt/cluster/hostvars/rl9-compute-0/hostvars.yml
101+
"grafana_address": "{{ hostvars[groups['grafana'].0].api_address }}",
102+
"grafana_api_address": "{{ hostvars[groups['grafana'].0].internal_address }}",
103+
"mysql_host": "{{ hostvars[groups['mysql'] | first].api_address }}",
104+
"nfs_server_default": "{{ hostvars[groups['control'] | first ].internal_address }}",
105+
"openhpc_slurm_control_host": "{{ hostvars[groups['control'].0].api_address }}",
106+
"openondemand_address": "{{ hostvars[groups['openondemand'].0].api_address if groups['openondemand'] | count > 0 else '' }}",
107+
"openondemand_node_proxy_directives": "{{ _opeonondemand_unset_auth if (openondemand_auth == 'basic_pam' and 'openondemand_host_regex' and groups['grafana'] | length > 0 and hostvars[ groups['grafana'] | first]._grafana_auth_is_anonymous) else '' }}",
108+
"openondemand_servername": "{{ hostvars[ groups['openondemand'] | first].ansible_host }}",
109+
"prometheus_address": "{{ hostvars[groups['prometheus'].0].api_address }}",
110+
"{{ hostvars[groups['freeipa_server'].0].ansible_host }}"
111+
```
112+
113+
More generally, there is nothing to stop any group var depending on a
114+
"{{ hostvars[] }}" interpolation ...
115+
116+
Currently, the only functionality this has been problematic for is setting
117+
the control node address for the slurmd node, which has been done using
118+
the (metadata-provided) IP, given this is needed to do the NFS mount anyway
119+
in the absence of working internal DNS.

docs/experimental/compute-init.md

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,6 @@
11
# compute-init
22

3-
The following roles are currently functional:
4-
- resolv_conf
5-
- etc_hosts
6-
- stackhpc.openhpc
7-
8-
# Development
9-
10-
To develop/debug this without actually having to build an image:
11-
12-
13-
1. Deploy a cluster using tofu and ansible/site.yml as normal. This will
14-
additionally configure the control node to export compute hostvars over NFS.
15-
Check the cluster is up.
16-
17-
2. Reimage the compute nodes:
18-
19-
ansible-playbook --limit compute ansible/adhoc/rebuild
20-
21-
3. Add metadata to a compute node e.g. via Horzon to turn on compute-init
22-
playbook functionality.
23-
24-
4. Fake an image build to deploy the compute-init playbook:
25-
26-
ansible-playbook ansible/fatimage.yml --tags compute_init
27-
28-
NB: This will also re-export the compute hostvars, as the nodes are not
29-
in the builder group, which conveniently means any changes made to that
30-
play also get picked up.
31-
32-
5. Fake a reimage of compute to run ansible-init and the compute-init playbook:
33-
34-
On compute node where metadata was added:
35-
36-
[root@rl9-compute-0 rocky]# rm -f /var/lib/ansible-init.done && systemctl restart ansible-init
37-
[root@rl9-compute-0 rocky]# systemctl status ansible-init
38-
39-
Use `systemctl status ansible-init` to view stdout/stderr from Ansible.
40-
41-
Steps 4/5 can be repeated with changes to the compute script. If required,
42-
reimage the compute node(s) first as in step 2 and/or add additional metadata
43-
as in step 3.
3+
See the role README.md
444

455
# Results/progress
466

@@ -151,41 +111,3 @@ This commit - shows that hostvars have loaded:
151111
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27585]: [INFO] writing sentinel file /var/lib/ansible-init.done
152112
Dec 13 21:06:20 rl9-compute-0.rl9.invalid ansible-init[27585]: [INFO] ansible-init completed successfully
153113
Dec 13 21:06:20 rl9-compute-0.rl9.invalid systemd[1]: Finished ansible-init.service.
154-
155-
# Design notes
156-
157-
- In general, we don't want to rely on NFS export. So should e.g. copy files
158-
from this mount ASAP in the compute-init script. TODO:
159-
- There are a few possible approaches:
160-
161-
1. Control node copies files resulting from role into cluster exports,
162-
compute-init copies to local disk. Only works if files are not host-specific
163-
Examples: etc_hosts, eessi config?
164-
165-
2. Re-implement the role. Works if the role vars are not too complicated,
166-
(else they all need to be duplicated in compute-init). Could also only
167-
support certain subsets of role functionality or variables
168-
Examples: resolv_conf, stackhpc.openhpc
169-
170-
171-
# Problems with templated hostvars
172-
173-
Here are all the ones which actually rely on hostvars from other nodes,
174-
which therefore aren't available:
175-
176-
```
177-
[root@rl9-compute-0 rocky]# grep hostvars /mnt/cluster/hostvars/rl9-compute-0/hostvars.yml
178-
"grafana_address": "{{ hostvars[groups['grafana'].0].api_address }}",
179-
"grafana_api_address": "{{ hostvars[groups['grafana'].0].internal_address }}",
180-
"mysql_host": "{{ hostvars[groups['mysql'] | first].api_address }}",
181-
"nfs_server_default": "{{ hostvars[groups['control'] | first ].internal_address }}",
182-
"openhpc_slurm_control_host": "{{ hostvars[groups['control'].0].api_address }}",
183-
"openondemand_address": "{{ hostvars[groups['openondemand'].0].api_address if groups['openondemand'] | count > 0 else '' }}",
184-
"openondemand_node_proxy_directives": "{{ _opeonondemand_unset_auth if (openondemand_auth == 'basic_pam' and 'openondemand_host_regex' and groups['grafana'] | length > 0 and hostvars[ groups['grafana'] | first]._grafana_auth_is_anonymous) else '' }}",
185-
"openondemand_servername": "{{ hostvars[ groups['openondemand'] | first].ansible_host }}",
186-
"prometheus_address": "{{ hostvars[groups['prometheus'].0].api_address }}",
187-
"{{ hostvars[groups['freeipa_server'].0].ansible_host }}"
188-
```
189-
190-
More generally, there is nothing to stop any group var depending on a
191-
"{{ hostvars[] }}" interpolation ...

0 commit comments

Comments
 (0)