cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #01575
[Merge] ~smoser/cloud-init:feature/manual-cache-clean-file into cloud-init:master
Scott Moser has proposed merging ~smoser/cloud-init:feature/manual-cache-clean-file into cloud-init:master.
Commit message:
manual_cache_clean: check and write a marker file indicating manual clean.
When manual_cache_clean is enabled, write a file to
/var/lib/cloud/instance/manual-clean. That file can then be read by
ds-identify or another tool to indicate that manual cleaning is in place.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/315832
--
Your team cloud init development team is requested to review the proposed merge of ~smoser/cloud-init:feature/manual-cache-clean-file into cloud-init:master.
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
index 65b15ed..7c65257 100644
--- a/cloudinit/cmd/main.py
+++ b/cloudinit/cmd/main.py
@@ -312,8 +312,15 @@ def main_init(name, args):
" would allow us to stop early.")
else:
existing = "check"
- if util.get_cfg_option_bool(init.cfg, 'manual_cache_clean', False):
+ mcfg = util.get_cfg_option_bool(init.cfg, 'manual_cache_clean', False)
+ if mcfg:
+ LOG.debug("manual cache clean set from config")
existing = "trust"
+ else:
+ mfile = path_helper.get_ipath_cur("manual_clean_marker")
+ if os.path.exists(mfile):
+ LOG.debug("manual cache clean found from marker: %s", mfile)
+ existing = "trust"
init.purge_cache()
# Delete the non-net file as well
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index 4528fb0..38f5f89 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -339,6 +339,7 @@ class Paths(object):
"vendordata_raw": "vendor-data.txt",
"vendordata": "vendor-data.txt.i",
"instance_id": ".instance-id",
+ "manual_clean_marker": "manual-clean",
}
# Set when a datasource becomes active
self.datasource = ds
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index b0552dd..2176381 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -188,6 +188,12 @@ class Init(object):
def _write_to_cache(self):
if self.datasource is NULL_DATA_SOURCE:
return False
+ if util.get_cfg_option_bool(self.cfg, 'manual_cache_clean', False):
+ # The empty file in instance/ dir indicates manual cleaning,
+ # and can be read by ds-identify.
+ util.write_file(
+ self.paths.get_ipath_cur("manual_clean_marker"),
+ omode="w", content="")
return _pkl_store(self.datasource, self.paths.get_ipath_cur("obj_pkl"))
def _get_datasources(self):
References