Merge ~smoser/cloud-init:feature/manual-cache-clean-file into cloud-init:master

Proposed by Scott Moser
Status: Merged
Merged at revision: e98709225510ee99ee0269c558c82b3e693e38e5
Proposed branch: ~smoser/cloud-init:feature/manual-cache-clean-file
Merge into: cloud-init:master
Diff against target: 50 lines (+15/-1)
3 files modified
cloudinit/cmd/main.py (+8/-1)
cloudinit/helpers.py (+1/-0)
cloudinit/stages.py (+6/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+315832@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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):
312 " would allow us to stop early.")312 " would allow us to stop early.")
313 else:313 else:
314 existing = "check"314 existing = "check"
315 if util.get_cfg_option_bool(init.cfg, 'manual_cache_clean', False):315 mcfg = util.get_cfg_option_bool(init.cfg, 'manual_cache_clean', False)
316 if mcfg:
317 LOG.debug("manual cache clean set from config")
316 existing = "trust"318 existing = "trust"
319 else:
320 mfile = path_helper.get_ipath_cur("manual_clean_marker")
321 if os.path.exists(mfile):
322 LOG.debug("manual cache clean found from marker: %s", mfile)
323 existing = "trust"
317324
318 init.purge_cache()325 init.purge_cache()
319 # Delete the non-net file as well326 # 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):
339 "vendordata_raw": "vendor-data.txt",339 "vendordata_raw": "vendor-data.txt",
340 "vendordata": "vendor-data.txt.i",340 "vendordata": "vendor-data.txt.i",
341 "instance_id": ".instance-id",341 "instance_id": ".instance-id",
342 "manual_clean_marker": "manual-clean",
342 }343 }
343 # Set when a datasource becomes active344 # Set when a datasource becomes active
344 self.datasource = ds345 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):
188 def _write_to_cache(self):188 def _write_to_cache(self):
189 if self.datasource is NULL_DATA_SOURCE:189 if self.datasource is NULL_DATA_SOURCE:
190 return False190 return False
191 if util.get_cfg_option_bool(self.cfg, 'manual_cache_clean', False):
192 # The empty file in instance/ dir indicates manual cleaning,
193 # and can be read by ds-identify.
194 util.write_file(
195 self.paths.get_ipath_cur("manual_clean_marker"),
196 omode="w", content="")
191 return _pkl_store(self.datasource, self.paths.get_ipath_cur("obj_pkl"))197 return _pkl_store(self.datasource, self.paths.get_ipath_cur("obj_pkl"))
192198
193 def _get_datasources(self):199 def _get_datasources(self):

Subscribers

People subscribed via source and target branches