|
| 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. |
0 commit comments