theborch / rackspace_lbaas Goto Github PK
View Code? Open in Web Editor NEWLibraries for managing Rackspace Cloud Load Balancers with Chef.
License: Apache License 2.0
Libraries for managing Rackspace Cloud Load Balancers with Chef.
License: Apache License 2.0
It looks like fog supports a host of additional parameters, e.g.:
https://github.com/fog/fog/blob/master/lib/fog/rackspace/load_balancers.rb#L34-L76
Maybe we could expose those somehow?
Instead of this https://github.com/theborch/rackspace_lbaas/blob/master/libraries/helpers.rb#L122-L124:
rescue Fog::Rackspace::LoadBalancers::ServiceError => e
raise "An error occured updating the load balancer (#{name}) : #{e}"
end
You could also do something like:
rescue
raise
end
That would be nice because you don't have to write as many error messages, and you'd pass the true reasons directly back to the user/chef run.
There are some methods that call fail
when they should probably call raise
, just in case the caller cookbook wants to catch and do something with it, e.g.:
https://github.com/theborch/rackspace_lbaas/blob/master/libraries/helpers.rb#L31-L55
Consider writing a full on mocked API test a la https://github.com/rackspace-cookbooks/rackspace_cloudbackup/tree/master/spec/unit/libraries. You could verify your providers actually yield the correct HTTP requests. That would be awesome/epic testing coverage.
I'd challenge you to drop the poise dependencies like https://github.com/theborch/rackspace_lbaas/blob/master/libraries/provider_load_balancer.rb. I don't think you're really taking advantage of anything major, and you'd get one major benefit: true idempotency.
Currently, that provider's actions always run, instead of:
If someone were to set a notifies
on the current resources and providers, they'd fire every time, even if the load balancer or LB node wasn't modified. You'd also get a much nicer why-run
mode, where you could tell the chef-run / chef-client if you're really going to make an API call.
This pattern happens a lot in the library:
def create_node(id = retrieve_lb_id, addr, port)
return if check_node_exists(id, addr, port)
begin
<do something>
rescue <various errors>
<log some stuff>
end
end
Perhaps you could abstract that out into its own method that accepts a block, and then just pass the various specifics into the more generic method. You'd do this under the hood, still having the end users see the nice method names, but underneath, you'd really have very simple logic.
For docs/usage/etc
In https://github.com/theborch/rackspace_lbaas/blob/master/libraries/helpers.rb#L12, US endpoint is hardcoded.
Are these too generic? Or do you think this could genuinely handle non-rackspace load balancers via fog?
There are some class instance variables that should probably just be local variables to each method.
There are some constants like https://github.com/theborch/rackspace_lbaas/blob/master/libraries/helpers.rb#L35 that could probably go in the top of the module, or better yet, use the Fog constants at https://github.com/fog/fog/blob/master/lib/fog/rackspace/models/load_balancers/load_balancer.rb#L8-L14.
Maybe something closer to https://github.com/johnbellone/chef-provisioning-cookbook/blob/master/recipes/fog.rb#L19-L25 would be better? You'd fail faster. I'd look at how other cookbooks install fog, and see what the common pattern is. Additionally, I don't see any cookbook on Supermarket that installs the fog gem -- this could totally be a simple community cookbook that you could also write.
I noticed there are some exceptions that aren't scoped to any particular class or module:
https://github.com/theborch/rackspace_lbaas/blob/master/libraries/helpers.rb#L1-L4
class StatusPendingError < StandardError
end
class StatusError < StandardError
end
These should probably be inside modules whenever possible.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.