Symptoms
Attempting to stop a container fails with the following error message:
Failed to stop the CT: PRL_ERR_VZCTL_OPERATION_FAILED (Details: Cannot lock the Container )
Cause
Some processes of the affected container are in D state due to refrigerator status, as evidenced by this command:
# vzps -E CTID axww -eLo eid,ppid,pid,tid,wchan:32,rsz,vsz,state,cmd | head
The output will be similar to the following:
CTID PPID PID TID WCHAN RSZ VSZ S CMD CTID 867154 95808 95808 request_wait_answer 1176 16260 D /usr/bin/unrar x -idp -o- -or -pzd8groOQNbaDFUW4 /root/Downloads/... CTID 867160 165474 165474 exit 0 0 Z [sleep] CTID 867166 166951 166951 refrigerator 308 9560 D /bin/bash /opt/plexguide/menu/pgui/mountcheck CTID 1 865644 865644 wait 0 0 S [systemd] CTID 865644 865999 865999 refrigerator 748 34880 D /lib/systemd/systemd-udevd CTID 865644 866007 866007 refrigerator 1112 48696 D /lib/systemd/systemd-networkd CTID 865644 866056 866056 refrigerator 572 49860 D /sbin/rpcbind -f -w CTID 865644 866125 866125 refrigerator 1204 45252 D /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation CTID 865644 866140 866140 refrigerator 1516 46412 D /lib/systemd/systemd-logind
Resolution
Check the freezer state of the affected CT with the following command (substitute with the container ID):
# cat /sys/fs/cgroup/freezer/machine.slice/<CTID>/freezer.state
If the state is FREEZING or FROZEN, change it to THAWED using the following command:
# echo THAWED > /sys/fs/cgroup/freezer/machine.slice/<CTID>/freezer.state
OR
# vzctl resume <CTID>
Once completed, the container should already be in a stopped or mounted state.