Files
Benjamin Satzger af0d3ed67b Fix race with cert server leaving vm stuck in prep
When creating a VM attached to a load balancer, cert server puts a
certificate into the folder /vm/inhost_name/cert by executing
`sudo host/bin/setup-cert-server put-certificate inhost_name`

During that call, before writing the certs, it first creates the cert
folder using `mkdir_p` (as the root user). If  /vm/inhost_name
didn't exist yet at that point, the folder /vm/inhost_name was
created like this:

```
ll inhost_name
total 12
drwxr-xr-x 3 root root 4096 May  9 12:52 ./
drwxr-xr-x 7 root root 4096 May  9 12:52 ../
drwxr-xr-x 2 root root 4096 May  9 12:52 cert/
```

This is what subsequently happens to VM provisioning in that case:

* create_unix_user: succeeds but gives this warning
```
adduser: Warning: The home directory `/vm/inhost_name'
does not belong to the user you are currently creating.
```

* prep: Fails with `tee: /vm/inhost_name/prep.json: Permission denied`

As a fix, we use `mkdir` instead of `mkdir_p` and just ignore the
error indicating that the folder already exists. That way, it won't
create the /vm/inhost_name folder. Putting the certificate should
succeed after `create_unix_user` has created /vm/inhost_name.
2025-05-12 09:01:21 +02:00
..
2025-05-06 23:18:09 +09:00