Skip to content

[trebuchet] force deployment of trebuchets via admin console#45

Open
sarahwada wants to merge 5 commits intoairbnb:masterfrom
sarahwada:swada--trebuchet_force_deployment
Open

[trebuchet] force deployment of trebuchets via admin console#45
sarahwada wants to merge 5 commits intoairbnb:masterfrom
sarahwada:swada--trebuchet_force_deployment

Conversation

@sarahwada
Copy link

@sarahwada sarahwada commented May 12, 2018

This change adds a method to apply a force field to a trebuchet deployment. This can be handled differently depending on the backend. For the existing backend implementations included in this library, there is no handling of a force deployment.

@sarahwada sarahwada changed the title Swada trebuchet force deployment [trebuchet] allow force deployment of trebuchets via admin console May 14, 2018
@sarahwada sarahwada changed the title [trebuchet] allow force deployment of trebuchets via admin console [trebuchet] force deployment of trebuchets via admin console May 14, 2018
CHANGELOG.md Outdated
@@ -1,3 +1,6 @@
## 0.10.0 (May 11, 2018)
Copy link

Choose a reason for hiding this comment

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

0.10.1?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

end

def aim(strategy_name, options = nil)
def aim(strategy_name, options = nil, force = false)
Copy link

Choose a reason for hiding this comment

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

This PR seems to suggest the force boolean flag is associated with each individual strategy inside a feature.
However, shouldn't such flag be associated with a feature rather than strategies in a feature?

I was under the impression this boolean flag would be implemented in similar ways as comment and expiration_date.
See https://github.com/wang103/trebuchet/blob/f92d20d7a653ae86a4dd944e8a34db9119d82d6f/lib/trebuchet/feature.rb#L117-L121
https://github.com/wang103/trebuchet/blob/f92d20d7a653ae86a4dd944e8a34db9119d82d6f/lib/trebuchet/feature.rb#L117-L121

In other words, just add a setter method named something like def set_force_deploy(force_deploy) and a getter method named something like def force_deploy() in feature.rb?

Choose a reason for hiding this comment

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

ugh, default positional arguments after an options hash is a pretty ugly pattern and we should avoid it.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, ideally I would like this force boolean flag to be associated with a specific deployment (a deployment containing multiple strategies or an expiration date).

The problem I was running into is that for each individual component of a deployment is saved as a separate sitar configuration in the backend--one new deployment per strategy changed and expiration date. A force deployment should be associated with a specific configuration, but that information is lost once implementing a force deployment becomes its a separate configuration.

Copy link
Author

Choose a reason for hiding this comment

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

Given that this entire change is just the added positional argument (which is not needed as Allen mentioned), I can abandon this change. @wang103 let me know if you want to chat more about the implementation of force.

Copy link
Author

Choose a reason for hiding this comment

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

Ok--looking once again, from my understanding it seems that the options hash isn't actually treated as a free-form options hash, and instead is expected to be a single value containing the strategy (e.g.: https://github.com/airbnb/trebuchet/blob/master/lib/trebuchet/backend/redis.rb#L56). Given this, I'm not sure what the ruby-esque way of implementing the api change. What about changing the optionsparam name to strategy_content for clarity, and then adding a true options hash as the last parameter?

end

def set_strategy(feature, strategy, options = nil)
def set_strategy(feature, strategy, options = nil, force = false)

Choose a reason for hiding this comment

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

❌ don't use default positional arguments for this. https://github.com/airbnb/ruby#no-default-args

Copy link
Author

Choose a reason for hiding this comment

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

Ah didn't realize that's what options = nil was. Will remove the force parameter and look for the value in the options hash instead.

Copy link

@wang103 wang103 left a comment

Choose a reason for hiding this comment

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

LGTM

Sarah Wada added 3 commits July 13, 2018 15:32
  rather than embedding in the methods itself. this is due to the
  fact that the options hash actually just contains the strategy, and
  as such an optional force parameter cannot be easily added to the
  hash.
@sarahwada sarahwada force-pushed the swada--trebuchet_force_deployment branch from 4b3da38 to a81497f Compare July 13, 2018 22:34
end

# Set the feature to be force depoyed.
def set_force()
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

thanks, done

end

def aim(strategy_name, options = nil)

Copy link
Contributor

Choose a reason for hiding this comment

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

why the new line?

Copy link
Author

Choose a reason for hiding this comment

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

removed

Trebuchet.backend.set_expiration_date(self.name, expiration_date)
end

# Set the feature to be force depoyed.
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think this comment adds value (this is what i'd expect from a function called "set force") as is ... but what does it actually mean to be force deployed? would you be able to capture that in a 1-2 line comment?

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.

4 participants