Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
cloud-init
cloud-init-purge-cache-py-ver-change.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File cloud-init-purge-cache-py-ver-change.patch of Package cloud-init
--- cloudinit/cmd/main.py.orig +++ cloudinit/cmd/main.py @@ -210,6 +210,24 @@ def attempt_cmdline_url(path, network=Tr "wrote cloud-config data from %s='%s' to %s" % (cmdline_name, url, path)) +def cache_pyver_maybe_purge_cache(init): + """Check if the Python version changed on us""" + pyver = '%d.%d' % (sys.version_info.major, sys.version_info.minor) + pyrefver = os.path.join(init.paths.get_cpath('data'), 'python-version') + if os.path.exists(pyrefver): + cached_pyver = open(pyrefver).read() + # The Python version has changed out from under us, anything that was + # pickled previously is likely useless due to API changes. + if cached_pyver != pyver: + LOG.debug('Python version change detected purging cache') + init.purge_cache(True) + else: + LOG.debug( + 'Could not determine Python version used to write cache, purging' + ) + init.purge_cache(True) + util.write_file(pyrefver, pyver) + def main_init(name, args): deps = [sources.DEP_FILESYSTEM, sources.DEP_NETWORK] @@ -277,6 +295,7 @@ def main_init(name, args): util.logexc(LOG, "Failed to initialize, likely bad things to come!") # Stage 4 path_helper = init.paths + cache_pyver_maybe_purge_cache(init) mode = sources.DSMODE_LOCAL if args.local else sources.DSMODE_NETWORK if mode == sources.DSMODE_NETWORK:
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor