Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keystone-shell container #185

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Add keystone-shell container #185

wants to merge 11 commits into from

Conversation

timothyb89
Copy link
Member

@timothyb89 timothyb89 commented Aug 28, 2017

The keystone-shell is a container to help debug keystone instances in Kubernetes. It provides a ptipython-based shell with highlighting, autocomplete, and access to the Keystone and Kubernetes APIs, along with an OpenStack client and utility function to read and swap between credentials from secrets (in any namespace) at runtime.

The keystone-shell is a container to help debug keystone instances in
Kubernetes. It provides a ptipython-based shell with highlighting,
autocomplete, and access to the Keystone and Kubernetes APIs, along
with an OpenStack client and utility function to read and swap between
credentials from secrets (in any namespace) at runtime.
Copy link
Member

@matrixik matrixik left a comment

Choose a reason for hiding this comment

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

Some small suggestions for code, rest looks fine for me (take into account I still have no knowledge about Kubernetes).


| Variable | Default | Description |
|--------------------|------------------|---------------------------------|
| `LOG_LEVEL` | `INFO` | MySQL server host |
Copy link
Member

Choose a reason for hiding this comment

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

Wrong descriptions in many lines.

Copy link
Member Author

Choose a reason for hiding this comment

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

wow, looks like my copy&pasting skills are getting rusty!

if e.response.status_code != 404:
raise

return None
Copy link
Member

Choose a reason for hiding this comment

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

I think this return should have one less indentation level. I know you run it from except but this way you will make it default.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not that it matters a ton since the code paths are effectively equivalent but my feeling was that (without the conditional to check for a 404) is a bit more clear about the intent.

Ideally it would've been:

try:
    return client.get(...)
except NotFound:
    return None

... which I think makes the intent more clear - that is, None isn't the "default" branch so much as the "not found" branch. Since requests doesn't have exception subclasses for different error codes, it gets a bit uglier when we compare the error code ... I'm not sure how much more readable the end result is, though.


# purge existing keystone vars from the environment
for var in keystone_env_vars().keys():
print('unset {};'.format(var))
Copy link
Member

Choose a reason for hiding this comment

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

Should have some printed info that user need to use it.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you run this file output with eval.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, the user won't ever run this script directly, the bash alias will take care of evaling the output for them.

if __name__ == '__main__':
main()


Copy link
Member

Choose a reason for hiding this comment

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

Too many empty lines at the end of file.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, fixed


logger.info('now using account from secret %s', secret_name)
else:
logger.info('no secret name arg provided, will use default environment')
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you could move it up with reversed if len(sys.argv) > 1: to have it close to the place why did it run and not with just bare else after a lot of code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you're right, it's more clear to write that a bit differently.

@@ -0,0 +1,23 @@
FROM python:3.6-alpine3.6
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just use the monasca/python.
It should have all musl and stack-fix included already AFAIR.

apk add --no-cache --virtual build-dep \
musl-dev linux-headers git make g++ libffi-dev openssl-dev && \
gcc -shared -fPIC /stack-fix.c -o /stack-fix.so && \
pip install urllib3 ipaddress ipython ptpython python-openstackclient && \
Copy link
Contributor

Choose a reason for hiding this comment

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

With monasca/python we could always install latest master, but I am not really sure if that's needed at all ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, you're right, this should really be using monasca/python. The docker stuff is mostly a copy&paste hack job that came out of my frustration while debugging keystone-init.

I'm fine with holding off on merging until it's converted, though.

@kornicameister
Copy link
Contributor

I have really bad and nasty problems trying to make it run.
Most of them resolves around the keystone secret (tried to used some of those that monaca-helm has used) with kubectl get secret -n monitoring but without a success. Finally managed to launch that without KEYSTONE_SHELL and everything was fine until I tried to get a token from connected keystone. The error encountered was:

[Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/ptyprocess-0.5.2.dist-info/top_level.txt'

From within the container I called ```openstack token issue````

@matrixik
Copy link
Member

Monasca/python changes are merged so this change could be updated to reflect that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants