A job ran as uid 1001 on a compute node where uid 1001 had no name. `whoami` failed, `id -un` failed, and anything that resolved a username broke. The home directory worked, which is what made it look fine: /home is NFS and the uids matched, so files landed in the right place while the account they belonged to did not exist on the machine writing them. The cause was ordering. wwctl image syncuser writes the head's accounts into the image chroot, and it ran in the Slurm role - after node_image had already compiled the image. The account reached the chroot and never the nodes. In the template build it was worse: golden.yml runs slurm before node_image, so it was syncing users into an image that had not been imported yet. The user is now created in the common role, install-tagged, and syncuser moved into node_image between the import and the build. It touches the chroot, so the staleness gate sees it and compiles - which is the gate working as intended rather than a special case. Both happen at template time, and it is the same account on every tenant, so a tenant pays nothing: provisioning still measured 138s. Copying /etc/passwd into an overlay would have been the faster-looking fix and the wrong one. The image has its own system accounts at its own uids; syncuser merges, and overwriting would have replaced them. Measured on a node in a cold-provisioned tenant: uid=1001 name=hpcuser whoami=hpcuser against `name=id: cannot find name for user ID 1001` before. This is a single-user fix, not multi-user support. Per-person identity in the portal and per-user accounting are deliberately not here.
110 lines
4.4 KiB
YAML
110 lines
4.4 KiB
YAML
---
|
|
# The compute node image is pulled from a registry, not built here.
|
|
#
|
|
# Warewulf imports node images from OCI, so the image is produced once by a
|
|
# container build (see hpcod/image/) and published. A tenant then pulls one
|
|
# immutable artefact instead of re-running dnf against EPEL and OpenHPC.
|
|
#
|
|
# This matters for more than the eight minutes it saves. Building on each
|
|
# tenant put the external package repositories in the provisioning path, so an
|
|
# outage at either meant no tenant could be created at all. It also made the
|
|
# image a moving target: two tenants provisioned a week apart got different
|
|
# package sets from the same playbook.
|
|
#
|
|
# An earlier version copied a built image between head nodes with rsync driven
|
|
# by the control plane, which runs unprivileged. That could not preserve
|
|
# ownership and silently skipped every file it could not read, producing images
|
|
# that booted to systemd and then dropped into emergency mode. An OCI layer
|
|
# carries ownership in its metadata and does not care who runs the transport.
|
|
#
|
|
# node_image_uri is the cache key: it names the stack the tenant asked for.
|
|
|
|
# wwctl uses the containers/image library, which reads this file. The token is
|
|
# read-only on purpose: a tenant head node needs to pull the image and has no
|
|
# business being able to publish one.
|
|
- name: Ensure the docker config directory exists
|
|
when: registry_pull_token | default('') | length > 0
|
|
ansible.builtin.file:
|
|
path: /root/.docker
|
|
state: directory
|
|
mode: "0700"
|
|
tags: [install]
|
|
|
|
- name: Install the registry pull credential
|
|
when: registry_pull_token | default('') | length > 0
|
|
ansible.builtin.copy:
|
|
dest: /root/.docker/config.json
|
|
owner: root
|
|
group: root
|
|
mode: "0600"
|
|
content: |
|
|
{
|
|
"auths": {
|
|
"{{ registry_host }}": {
|
|
"auth": "{{ (registry_pull_user ~ ':' ~ registry_pull_token) | b64encode }}"
|
|
}
|
|
}
|
|
}
|
|
no_log: true
|
|
tags: [install]
|
|
|
|
- name: Check whether the image is already imported
|
|
ansible.builtin.command: wwctl image list
|
|
register: node_image_list
|
|
changed_when: false
|
|
tags: [install]
|
|
|
|
- name: Import the node image from the registry
|
|
when: node_image_name not in node_image_list.stdout
|
|
ansible.builtin.command: >
|
|
wwctl image import {{ node_image_uri }} {{ node_image_name }} --syncuser
|
|
changed_when: true
|
|
tags: [install]
|
|
|
|
# Rebuilding is cheap and makes the boot artefacts match this head node's
|
|
# Warewulf version, rather than whatever built the image.
|
|
|
|
# Write the head's users into the image before it is compiled.
|
|
#
|
|
# A compute node resolves usernames from its own /etc/passwd, and its root
|
|
# filesystem is this image - so an account that is not in here does not
|
|
# exist on the node. syncuser merges rather than replaces, which is why the
|
|
# head's passwd file is not simply copied over: the image has its own
|
|
# system accounts at its own uids.
|
|
#
|
|
# Ordering is the whole point. This ran after the image was built once, and
|
|
# the effect was a cluster whose only user resolved on the head and nowhere
|
|
# else: jobs ran by uid, `whoami` failed on every node. It must happen
|
|
# between import and build, and it touches the chroot, so the staleness
|
|
# gate below sees it and compiles.
|
|
- name: Write the head's users into the image
|
|
ansible.builtin.command: wwctl image syncuser --write {{ node_image_name }}
|
|
changed_when: true
|
|
tags: [install]
|
|
|
|
# wwctl always recompresses, even when nothing changed, so the build is gated
|
|
# here instead. A tenant cloned from the template inherits a compiled image
|
|
# that is already current and skips ~28s of work; the gate still fires whenever
|
|
# the chroot is genuinely newer, which is what a real change looks like.
|
|
- name: Find the compiled image
|
|
ansible.builtin.stat:
|
|
path: /var/lib/warewulf/provision/images/{{ node_image_name }}.img
|
|
register: node_image_built
|
|
tags: [install]
|
|
|
|
- name: Find the newest file in the image chroot
|
|
ansible.builtin.command:
|
|
cmd: find /var/lib/warewulf/chroots/{{ node_image_name }}/rootfs -newer
|
|
/var/lib/warewulf/provision/images/{{ node_image_name }}.img -print -quit
|
|
register: node_image_newer
|
|
changed_when: false
|
|
failed_when: false
|
|
when: node_image_built.stat.exists
|
|
tags: [install]
|
|
|
|
- name: Build the image
|
|
ansible.builtin.command: wwctl image build {{ node_image_name }}
|
|
when: not node_image_built.stat.exists or node_image_newer.stdout | default('') | length > 0
|
|
changed_when: true
|
|
tags: [install]
|