2 ms·
A lot of those are not idempotency. Whenever you check if the file exists before creating it assumes the content of the file that does exist is the same as what
by totony 5y ago
A lot of those are not idempotency. Whenever you check if the file exists before creating it assumes the content of the file that does exist is the same as what you're trying to put in, which is not always true. Same for the mkfs example. Presumably the volume might already have a fs on it that you want to overwrite which is not ext4
- sscarduzio 5y agoExactly, came here to say this. They should delete the line/file/partition if exists, and append/create/format it from scratch every time in order to respect idempotency. Another thing I would recommend is usage of temp directories: you can assume they are empty (easier to reason about). Then do all the work there, an when all operations were successful, you "commit" modified files with "mv/cp -r" and overwrite the real files. I would call the use of temporary files/folders "transactionality" rather than "idempotency" though.