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

Improved configuration #14

Merged
merged 16 commits into from
Apr 20, 2016
Merged

Improved configuration #14

merged 16 commits into from
Apr 20, 2016

Conversation

misterbisson
Copy link
Contributor

@misterbisson misterbisson commented Apr 18, 2016

/cc @tgross

@@ -32,7 +32,7 @@

log = logging.getLogger('triton-mysql')

consul = pyconsul.Consul(host=os.environ.get('TRITON_MYSQL_CONSUL', 'consul'))
consul = pyconsul.Consul(host=os.environ.get('CONSUL', 'consul'))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For #11

@@ -175,7 +175,7 @@ def __init__(self):
self.user = os.environ.get('MANTA_SUBUSER', None)
self.role = os.environ.get('MANTA_ROLE', None)
self.key_id = os.environ.get('MANTA_KEY_ID', None)
self.private_key = os.environ.get('MANTA_PRIVATE_KEY')
self.private_key = os.environ.get('MANTA_PRIVATE_KEY') # @TODO: need changes here
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will need to be aware of the text munging of the input.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should do it:

self.private_key = os.environ.get('MANTA_PRIVATE_KEY').replace('#', '\n')

percona-xtrabackup \
python \
python-dev \
gcc \
Copy link
Contributor Author

@misterbisson misterbisson Apr 18, 2016

Choose a reason for hiding this comment

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

I'd love to try adding the pip install steps in here so we can apt-get purge GCC after it's done its job, similar to https://github.com/autopilotpattern/nfsserver/blob/wip/Dockerfile#L8-L19.

fi

# setup environment file
echo '# Environment variables for MySQL service' > _env
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do a check for the existence of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I called you on that, I need to do the same.

echo 'MANTA_ROLE=' >> _env

# MANTA_KEY_ID must be the md5 formatted key fingerprint. A SHA256 will result in errors.
echo MANTA_KEY_ID=$(ssh-keygen -E md5 -lf ${MANTA_PUBLIC_KEY_PATH} | awk '{print substr($2,5)}') >> _env
Copy link
Contributor

Choose a reason for hiding this comment

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

It occurs to me that rather than asking the user for their public key, we can just take the private key they're giving us and then fetching the signature from there. For example:

ssh-keygen -yl -E md5 -f ~/.ssh/timgross-joyent_id_rsa | awk '{print substr($2,5)}'
46:cc:9a:2d:66:83:1f:83:ce:01:74:5f:16:dc:b7:2d

That'd be one less argument to parse and one less place for user error to creep in.

@tgross
Copy link
Contributor

tgross commented Apr 20, 2016

Added one more comment about maybe dropping the requirement to provide both public and private keys if all we need is the ID, but other than that LGTM.

@@ -175,7 +175,7 @@ def __init__(self):
self.user = os.environ.get('MANTA_SUBUSER', None)
self.role = os.environ.get('MANTA_ROLE', None)
self.key_id = os.environ.get('MANTA_KEY_ID', None)
self.private_key = os.environ.get('MANTA_PRIVATE_KEY')
self.private_key = os.environ.get('MANTA_PRIVATE_KEY').replace('#', '\n')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error:

Traceback (most recent call last):
  File "/usr/local/bin/triton-mysql.py", line 955, in <module>
    manta_config = Manta()
  File "/usr/local/bin/triton-mysql.py", line 178, in __init__
    self.private_key = os.environ.get('MANTA_PRIVATE_KEY').replace('#', '\n')
AttributeError: 'NoneType' object has no attribute 'replace'
2016/04/20 16:17:46 exit status 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was caused by MANTA_PRIVATE_KEY being unset in the docker-compose.yml file. That was fixed in 9239d16

echo 'MANTA_URL=https://us-east.manta.joyent.com' >> _env

# MANTA_KEY_ID must be the md5 formatted key fingerprint. A SHA256 will result in errors.
echo MANTA_KEY_ID=$(ssh-keygen -yl -E md5 -f ${MANTA_PRIVATE_KEY_PATH} | awk '{print substr($2,5)}') >> _env
Copy link
Contributor

@tgross tgross Apr 20, 2016

Choose a reason for hiding this comment

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

The awk expression here should just be '{print $2}'. We want to keep the "MD5" at the front of the string.

Nevermind... I think I had a stale build or something.

- `MANTA_ROLE`: the Manta role name, if any.
- `MANTA_KEY_ID`: the MD5-format ssh key id for the Manta account/subuser (ex. `1a:b8:30:2e:57:ce:59:1d:16:f6:19:97:f2:60:2b:3d`).
- `MANTA_PRIVATE_KEY`: the private ssh key for the Manta account/subuser.
- `MANTA_BUCKET`: the path on Manta where backups will be stored. (ex. `/myaccount/stor/triton-mysql`)
- `LOG_LEVEL`: will set the logging level of the `triton-mysql.py` application. It defaults to `DEBUG` and uses the Python stdlib [log levels](https://docs.python.org/2/library/logging.html#levels). In production you'll want this to be at `INFO` or above.
- `TRITON_MYSQL_CONSUL` is the hostname for the Consul instance(s). Defaults to `consul`.
Copy link
Contributor

Choose a reason for hiding this comment

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

We changed this to CONSUL

@tgross
Copy link
Contributor

tgross commented Apr 20, 2016

LGTM.

@misterbisson misterbisson changed the title WIP: Improved configuration Improved configuration Apr 20, 2016
@misterbisson misterbisson merged commit 6ee9dc9 into master Apr 20, 2016
@misterbisson misterbisson deleted the 12-setup-and-demo-scripts branch June 9, 2016 22:49
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