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

Upgrading generate_yamls.py for easier configuration automation. #506

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

syberkitten
Copy link

@syberkitten syberkitten commented Nov 21, 2017

To make creating clusters simpler, faster, easier and error prone
i've extended generate_yamls.py so it is now more automated
and covers more options that can be supplied via the command line.

for usage: generate_yamls.py --help
also updated usage in readme.md.

let me know what you think and any questions...
and thanks again for this great project. 👍

I've actually managed to set up my first
two datacenter setup after finishing this upgrade,
so it works quite well.

in the future, it would be possible to add some tests
so the creation of clusters can be made sure to not break.

but for now, it should help quickly start a new setup
without having to drown in many yml files that need to be updated
manually.

If you think something else should be added please let know...

@syberkitten syberkitten changed the title Upgrading generate_yamls.py for faster and error prone configuration creation. Upgrading generate_yamls.py for faster and error prone configuration automation. Nov 21, 2017
@syberkitten syberkitten changed the title Upgrading generate_yamls.py for faster and error prone configuration automation. Upgrading generate_yamls.py for easier configuration automation. Nov 23, 2017
Copy link
Contributor

@hashbrowncipher hashbrowncipher left a comment

Choose a reason for hiding this comment

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

Thanks for making this script better! This change overlaps a lot with my own first contribution to Dynomite, which was the cluster generation functionality in #494 and #495. We'll want to merge the two pieces of functionality eventually, and I'd love to hear any input you have on how the testing use-case from #494 is similar to or different from the automation use-case here.

If you want to, you're welcome to do the merging yourself. It would involve factoring DynoSpec out of cluster_generator.py to be used by both scripts.



parser.add_argument(
'-cp',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we go with two dashes for multi-character arguments?

'dyn_port': args.peer_port,
'dyn_listen': '0.0.0.0:' + args.peer_port,
'datacenter': ip_dc[2],
'rack': """{}""".format(ip_dc[1]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to do just 'rack': rack?


output_path = args.output_dir

if os.path.isabs(dir):
Copy link
Contributor

Choose a reason for hiding this comment

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

This error message doesn't match the test condition, which checks whether the path is absolute.

if os.path.isabs(dir):
print "path exists:{}".format(dir)
else:
output_path = os.path.join(dir, args.output_dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

To me, if I specify generate_yamls.py ... -o foobar, I expect foobar to created in my current working directory. It would be surprising to me if it were instead put next to the script itself.

key = y.split(':')
dyn_seeds.append(key[0] + ':' + str(args.peer_port) + ':' + key[1] + ':' + key[2] + ':' + str(z))

ip_dc = k.split(':')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would work better as ip, rack, datacenter = k.split(':')

default=DEFAULT_CLIENT_PORT,
help="""
Client port to use (The client port Dynomite provides instead of directly accessing redis or memcache)
Default is: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of formatting the string ourselves, let's do %(default)s here, and let argparse do the work.

parser.add_argument(
'-sp',
dest='server_port',
type=str,
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be an int type?

)


parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

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

This and --mem would be a good use of action="store_const" and ArgumentParser.add_mutually_exclusive_group


More commands:
```
python generate_yamls.py --help
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just leave a reference to the fact that help is available, and not include the whole help text. Something like:

For full help output, do `scripts/dynomite/generate_yamls.py --help`

output_path = os.path.join(dir, args.output_dir)
if (not os.path.exists(output_path)):
os.makedirs(output_path)
print "creating output path %s" % output_path
Copy link
Contributor

Choose a reason for hiding this comment

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

Following the Python convention of EAFP, I would do (in Python 3):

try:
    os.makedirs(output_path)
    print("Created output path {}".format(output_path), file=sys.stderr)
except FileExistsError:
    pass

""")

parser.add_argument('nodes', type=str, nargs='+',
help="""
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we get this help text down to a single line describing how to correctly format a node description? I think some extraneous stuff snuck in here.

@syberkitten
Copy link
Author

Hi Guys 👍
Thanks for all the great comments, I'll get back to it ASAP.

@ipapapa
Copy link
Contributor

ipapapa commented Apr 25, 2018

@syberkitten Do you think we can move forward with this and merge it once the requested changes are in place? What is your expected time frame?

@syberkitten
Copy link
Author

syberkitten commented Apr 25, 2018

@ipapapa Hey, I'm not exactly continuing with this right now because we are not using Dynomite.
and I need to find some free spare time on top of all other stuff In my life.

If someone else can take it over would be great, if not
I cannot promise a date right now.

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

Successfully merging this pull request may close these issues.

None yet

3 participants