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

Resolve Dependencies Once #148

Merged
merged 10 commits into from
Sep 4, 2017
Merged

Resolve Dependencies Once #148

merged 10 commits into from
Sep 4, 2017

Conversation

citruspi
Copy link
Contributor

@citruspi citruspi commented Sep 3, 2017

A common pattern in Tyr is inheriting from a parent Server type and then in the configure method:

  • Calling super(Type).configure()
  • Modifying the server's configuration (e.g. IAM policies, security groups, etc)
  • Re-resolving these dependencies

However, this means that when provisioning e.g. a MongoDataNode you end up setting the Chef attributes 4 times, resolving the security groups twice, and resolving the IAM policies thrice. That's a lot of wasted time.

This moves

  • resolution of IAM stuff
  • resolution of security groups
  • resolution of ingress groups to add
  • setting of Chef attributes

to a method called resolve_dependencies which should be invoked once before invoking launch and after every invocation of configure has been completed.

I've made the necessary adjustments to autorun in Server and provision in the IIS and Nginx clusters to invoke it.

Essentially this significantly reduces the time spent between establish_logger and launch and removes a number of API requests for information that we already have.

* master:
  Enforce the replica_set attr in MongoDataNode after calling super().__init__()
  Added the platform and use_latest_ami args to nodes missing it
  Removed the '-backup' suffix from the highlights data replica set mod
  Added modifiers for replica sets with irregular names
  Support config and router Zuun data bag item configuration
  Set Zuun chef attributes in MongoNode
  Defined the node's Zuun deployment in MongoNode
  Moved the mongodb_version argument to MongoNode
  Added a mongo_configDB param to the MongoRouterNode
  Consolidated Zuun chef attribute configuration
  Updated the MongoConfigNode to accept a replica set param
  Added a MongoRouterNode class
  Don't overwrite Zuun data bag replica sets
@citruspi
Copy link
Contributor Author

citruspi commented Sep 3, 2017

In addition, the resolve_dependencies method formats each IAM policy, security group, and ingress group to add. So instead of writing

self.ingress_groups_to_add.extend([		
    "{env}-web".format(env=env_prefix),		
    "{env}-nginx".format(env=env_prefix),		
    "{env}-queueproc-jobs".format(env=env_prefix)		
])

you can just write

self.ingress_groups_to_add.extend([		
    '{env}-web',
    '{env}-nginx',
    '{env}-queueproc-jobs'
])

The following variables are available during formatting:

Variable Value Example
environment environment prod
env environment[0] p
group group speedtest
type server_type mongo
envcl {env}-{group}-{type} p-speedtest-mongo

I've set the default security groups for each server to

['management', '{env}-{type}-management',  '{envcl}', 'chef-nodes']

@citruspi citruspi merged commit aaf6567 into master Sep 4, 2017
@citruspi citruspi deleted the STRUCT-Resolve-Dependencies branch September 4, 2017 20:35
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.

1 participant