mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-21 15:18:19 +00:00
49ffae9862
packimage deleted every rootimg.* file before it packed, and wrote the new cpio or tar archive under its final name with mode 0600. Until the pack finished, a node that booted got HTTP 403 for its image. When the pack failed, the image was gone or left truncated, and no node could boot until a later pack succeeded. Build every archive in a temporary directory inside the image directory, and rename the archive over the final name only after the pack succeeds, as the openEuler path already did with a temporary file. With --tracker, ctorrent builds the metainfo in the same directory, from the new archive under its final name. The previous metainfo is removed before the archive is renamed, and the new metainfo is renamed after it, so no failure leaves a metainfo that describes another archive. The other rootimg.* files are removed after the rename. The next pack on the same host removes a temporary directory that an interrupted pack left. Image locks are per host, so temporary directories of other hosts that share the directory stay. A pack now also fails when find cannot list the image or cpio cannot read a file, as on the openEuler path. Before, only the compressor status counted, and such a pack published an incomplete archive. Every failure after packimage switches a StateLite tree to stateless files now switches it back. That includes a failure to create the temporary directory or the squashfs staging directory, which File::Temp reports with die. packimage records each file that it moves and checks each move. When a file cannot be moved back, the original stays in .statebackup, packimage reports it, and the next pack refuses to run until the files are restored. The new archive replaces the previous one only after the StateLite files are back. Before, a failed pack left the tree switched, and a retry overwrote the saved StateLite files. The image lock is per host, and service nodes mount a shared image directory without NFS locks. So a pack also holds the directory .packimage-publish while it replaces the archive and removes the other formats. mkdir is atomic for every host, also on NFS without locks. When the lock is older than 60 seconds, or stays held for 60 seconds, the pack fails, names the holder, and keeps the previous archive. packimage does not take the lock over, because its holder can still be running. A ctorrent failure now fails the pack, and the previous archive and metainfo stay. Before, a failed ctorrent left a partial metainfo, and nodeset pointed nodes at it.