Comments (5)
Here is the simplest "solution":
diff --git a/aminator/core.py b/aminator/core.py
index f73f9cf..5c22709 100644
--- a/aminator/core.py
+++ b/aminator/core.py
@@ -55,7 +55,7 @@ class Aminator(object):
def aminate(self):
with self.environment(self.config, self.plugin_manager) as env:
- error = env.provision()
+ error = not env.provision()
if not error:
log.info('Amination complete!')
return error
diff --git a/aminator/environment.py b/aminator/environment.py
index b3288ea..e4c927e 100644
--- a/aminator/environment.py
+++ b/aminator/environment.py
@@ -56,7 +56,7 @@ class Environment(object):
if not success:
log.critical('Finalizing failed!')
return False
- return None
+ return True
def __enter__(self):
return self
But that feels kind of icky.
from aminator.
Augh, that is entirely my fault again--documentation for sys.exit, of course, says success on 0 or None and says 'any other object' will result in a status code of 1.
The intention was to have whatever the success value was from the environment get passed on down through the stack to sys.exit. If everything succeeded, sys.exit would get None, if there was a failure, sys.exit would get False. sys.exit, it seems, actually returns a status code of 1 for a value of true of all things, so the above code will possibly cause the overall process to fail when it really succeeded:
% python -c 'import sys; sys.exit(True)'; echo $?
1
% python -c 'import sys; sys.exit(None)'; echo $?
0
% python -c 'import sys; sys.exit(False)'; echo $?
0
% python -c 'import sys; sys.exit("banana")'; echo $?
banana
1
The easiest way to fix that? Each of the checks in the context managers:
if not success:
log.critical('Finalizing failed!')
return False
for example, need to return True.
So, given
def provision(self):
[...]
success = provisioner.provision()
if not success:
log.critical('Provisioning failed!')
return True
success = finalizer.finalize()
if not success:
log.critical('Finalizing failed!')
return True
return None
This
def aminate(self):
with self.environment(self.config, self.plugin_manager) as env:
error = env.provision()
if not error:
log.info('Amination complete!')
return error
has error = True on failure, Amination complete will get logged on success, error is None if success, True if failure, and as we saw, sys.exit(True) is a failed execution. All is right with the world.
from aminator.
That said, for readability's sake, it probably makes a bit more sense to use some kind of value that will clearly indicate failure but doesn't require one to build truth tables to sort out because of funky logic inversion :)
from aminator.
Does this:
08a47de
Resolve this issue?
from aminator.
Yeah, I think it is fixed. Thanks Peter.
-Cory
from aminator.
Related Issues (20)
- Intermittent "umount: device is busy" errors HOT 4
- post provision kill process that may have started in chroot HOT 2
- TypeError: putenv() argument 2 must be string, not None HOT 2
- can't aminate latest HVM based amazon linux: mount: /dev/xvdf1 is write-protected, mounting read-only HOT 3
- Doesn't work with Ubuntu 14.04 Base AMI HOT 1
- RHEL images can't authenticate with Yum repos HOT 5
- Newer versions of pbr break aminator installation HOT 5
- Where has the wiki gone? HOT 2
- Aminator failing on apt_get_update HOT 1
- Linux BlockDevicePlugin assumes baking on PV instance
- stevedore 1.11.0 does not support python2.6
- 400 Bad Request Attachment point /dev/sdf is already in use
- Enable ENA support during AMI registration
- Automatic retry on duplicate AMI name via decorator fails due to improper exception handling
- actions in plugin __enter__ methods should be called outside of __enter__
- Retry for duplicate AMI name fails during register_ami
- Cannot compile version 2.1.85 in CentOS7
- Wrong parameter type in teardown_chroot_mounts call
- Support for NVMe devices? HOT 5
- Question: Why was the project dropped?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aminator.