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
1diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
2index 65b15ed..7c65257 100644
3--- a/cloudinit/cmd/main.py
4+++ b/cloudinit/cmd/main.py
5@@ -312,8 +312,15 @@ def main_init(name, args):
6 " would allow us to stop early.")
7 else:
8 existing = "check"
9- if util.get_cfg_option_bool(init.cfg, 'manual_cache_clean', False):
10+ mcfg = util.get_cfg_option_bool(init.cfg, 'manual_cache_clean', False)
11+ if mcfg:
12+ LOG.debug("manual cache clean set from config")
13 existing = "trust"
14+ else:
15+ mfile = path_helper.get_ipath_cur("manual_clean_marker")
16+ if os.path.exists(mfile):
17+ LOG.debug("manual cache clean found from marker: %s", mfile)
18+ existing = "trust"
19
20 init.purge_cache()
21 # Delete the non-net file as well
22diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
23index 4528fb0..38f5f89 100644
24--- a/cloudinit/helpers.py
25+++ b/cloudinit/helpers.py
26@@ -339,6 +339,7 @@ class Paths(object):
27 "vendordata_raw": "vendor-data.txt",
28 "vendordata": "vendor-data.txt.i",
29 "instance_id": ".instance-id",
30+ "manual_clean_marker": "manual-clean",
31 }
32 # Set when a datasource becomes active
33 self.datasource = ds
34diff --git a/cloudinit/stages.py b/cloudinit/stages.py
35index b0552dd..2176381 100644
36--- a/cloudinit/stages.py
37+++ b/cloudinit/stages.py
38@@ -188,6 +188,12 @@ class Init(object):
39 def _write_to_cache(self):
40 if self.datasource is NULL_DATA_SOURCE:
41 return False
42+ if util.get_cfg_option_bool(self.cfg, 'manual_cache_clean', False):
43+ # The empty file in instance/ dir indicates manual cleaning,
44+ # and can be read by ds-identify.
45+ util.write_file(
46+ self.paths.get_ipath_cur("manual_clean_marker"),
47+ omode="w", content="")
48 return _pkl_store(self.datasource, self.paths.get_ipath_cur("obj_pkl"))
49
50 def _get_datasources(self):

Subscribers

People subscribed via source and target branches