provisioner: explicitly sync state file on writes

Scripts sometimes reboot the preload VM with sysrq-trigger. This type of
reboot will not sync any pending writes to disk. This can result in the
state file not being up to date on the next reboot.

One consequence of this is potentially running some steps multiple
times, when they shouldn't be run multiple times. Let's avoid this by
explicitly syncing the state file on every write.

BUG=b/288441792
TEST=`bazel test`, ./run_tests

Change-Id: I5f8c641a4f142b02a9dd52e54c73cb9c4c85bb1a
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/71291
Reviewed-by: Sejal Sharma <sejalsharma@google.com>
Tested-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
1 file changed
tree: 48707fef93e8484e8b33aa252a846f5425212357
  1. coverage/
  2. release/
  3. src/
  4. testing/
  5. .gitignore
  6. BUILD.bazel
  7. cloudbuild.yaml
  8. CONTRIBUTING.md
  9. deps.bzl
  10. go.mod
  11. go.sum
  12. LICENSE
  13. postsubmit-cloudbuild.yaml
  14. README.md
  15. run_tests.sh
  16. run_unit_tests.sh
  17. WORKSPACE
README.md

Tools for Container-Optimized OS

This is a repository of various tools developed for Container-Optimized OS. Examples include cos-gpu-installer, cos-toolbox, etc.

See CONTRIBUTING.md for how to contribute.