Score:0

Required NFS/CIFS mount in fstab fail due to failed nameserver

kr flag

I have a setup in which I am mounting NFS/CIFS in my fstab which are then consumed by a service (in my case, the service is rendered by a docker container).

I have a systemd unit setup for my docker container:

[Unit]
Description=backup service with docker compose
Requires=docker.service
After=docker.service
StartLimitIntervalSec=0
RequiresMountsFor=/mnt/nas /mnt/restore /mnt/docker

[Service]
Type=oneshot
RemainAfterExit=true
WorkingDirectory=/srv/docker/backup
ExecStart=/usr/local/bin/docker-compose up -d --remove-orphans
ExecStop=/usr/local/bin/docker-compose down
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Generally speaking, everything works great. When the service launches, it ensures that the mount points are properly loaded. My mount points are defined using FQDN names which are resolved internally on my network:

nas.home.ca:/mnt/HomeNAS                        /mnt/nas nfs ro 0 0
nas.home.ca:/mnt/HomeNAS/VM/Config/Alma-Docker1 /mnt/docker nfs rw 0 0
//nas.home.ca/Restore                          /mnt/restore cifs credentials=/etc/fstab.credentials.backup,file_mode=0777,dir_mode=02777 0 0

The problem occurs when my internal Nameservers are offline when the service is starting up. The mounts fail fast with errors that they are unable to resolve and don't retry. Consequently, my backup service also fails to start and does not try to restart given that the dependencies have failed.

I looked through the x.systemd options available for fstab and don't find anything that would configure the mount units to restart/retry on failure.

[eric@dockervm2 system]$ sudo systemctl start mnt-nas.mount
Job failed. See "journalctl -xe" for details.
[eric@dockervm2 system]$ sudo systemctl start mnt-restore.mount
Job failed. See "journalctl -xe" for details.
[eric@dockervm2 system]$ sudo systemctl start mnt-docker.mount
Job failed. See "journalctl -xe" for details.
[eric@dockervm2 system]$ sudo journalctl -xe

Consequently, when I try to start my service, I get the following error message:

[eric@dockervm2 system]$ sudo systemctl start backup-docker-compose
A dependency job for backup-docker-compose.service failed. See 'journalctl -xe' for details.

How can I setup my mount points for them to retry? My issue is that my nameserver is offline, and I would have liked this to try and restart itself every XXX seconds until my nameserver is back up and running.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.