Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Deploy bug fixes and clean up #532

Merged
merged 3 commits into from
May 25, 2017
Merged

Conversation

chouseknecht
Copy link
Contributor

@chouseknecht chouseknecht commented May 19, 2017

ISSUE TYPE
  • Bugfix Pull Request
SUMMARY

@chouseknecht chouseknecht requested a review from ryansb May 24, 2017 19:02
@chouseknecht chouseknecht changed the title WIP: Deploy bug fixes and clean up Deploy bug fixes and clean up May 24, 2017
def image_namespace(self):
# When pushing images or deploying, we need to know the registry namespace
namespace = self.project_name
if self.engine_name in ('k8s', 'openshift'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we shouldn't be referencing exceptional values for specific engines outside of the engine implementation. If this needs to be a feature of an engine implementation, let's do that. But I don't want to have special engine-specific overrides outside of the engine itself any more than we have to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to know what config thinks the namespace is, so seemed logical to add a single method to the config object. There is prior art within config referencing the engine_name value, so not sure why it's suddenly an issue here.

@@ -106,7 +116,7 @@ def set_env(self, env):
config['volumes'][vol_key] = docker_settings
elif self.engine_name in ('openshift', 'k8s'):
# For openshift/k8s remove unrelated attributes
for vol_key in config['volumes'].keys():
for vol_key in list(config['volumes'].keys()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the py3 way of doing this: for vol_key in config['volumes']:? Why the cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. I'm so tired of Python 2 vs 3.

@@ -46,11 +46,12 @@

@host_only
def hostcmd_init(base_path, project=None, **kwargs):
force = kwargs.pop('force')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add to explicit args and set a default?

container/cli.py Outdated
@@ -264,14 +260,19 @@ def __call__(self):
LOGGING['loggers']['container']['level'] = 'DEBUG'
config.dictConfig(LOGGING)

vargs = vars(args)
if not vargs['project_name']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of init, wouldn't this make more sense to be part of the container.yml settings? So it doesn't have to be specified every single time the user invokes ansible-container?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add project_name to settings, yes. However, that's not the point of this change. The point here is to reduce redundant code in core.py.

'host_user_uid': os.getuid(),
'host_user_gid': os.getgid(),
}
if config.get('settings', {}).get('k8s_auth'):
params['k8s_auth'] = config['settings']['k8s_auth']
if config.get('settings', {}).get('k8s_namespace'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reiterated comment about trying best we can to keep engine-specific snowflakes in the engine specification.

output_path = params['deployment_output_path']
for path in ('files', 'templates'):
shutil.rmtree(os.path.join(output_path, path), ignore_errors=True)
if not self.debug:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be devel instead of debug? I'm not sure either way.

if service_config.get('roles'):
if url and namespace:
# Reference previously pushed image
self.services[service_name][u'image'] = '{}/{}/{}'.format(re.sub(r'/$', '', url), namespace,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this without re - kinda heavy handed. Just do url.rstrip('/')

@@ -9,7 +9,7 @@
import container
from container.config import AnsibleContainerConfig, AnsibleContainerConductorConfig
from container.exceptions import AnsibleContainerConfigException
from ansible.vars import Templar
from ansible.template import Templar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QTNA: Do we want to try/except these imports?

@@ -8,7 +8,7 @@
import os
import json

from ansible.vars import Templar
from ansible.template import Templar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QTNA: Do we want to try/except these imports?

@chouseknecht chouseknecht force-pushed the develop branch 2 times, most recently from fde348a to 1af8c1f Compare May 25, 2017 14:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants