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

Allow customising which CRs are pre-deployed #505

Merged
merged 4 commits into from
Jul 3, 2019

Conversation

benlangfeld
Copy link
Contributor

What are you trying to accomplish with this PR?

Allow users to determine that certain CRDs should not be considered for pre-deploy. Our specific use-case is a variation on CronJob which we want to deploy only once our bare Pod deployment tasks (Rails migrations) have run.

How is this accomplished?

CRDs support an annotation which when set to any value other than true causes custom resources of that type not to be selected for pre-deploy.

What could go wrong?

Not sure.

@ghost ghost added the cla-needed label Jul 2, 2019
@benlangfeld
Copy link
Contributor Author

A corporate CLA was just signed to cover this.

Copy link
Contributor

@dturn dturn left a comment

Choose a reason for hiding this comment

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

A few minor things, but this looks good.

@@ -56,6 +56,11 @@ def prunable?
prunable == "true"
end

def predeployed?
predeployed = @definition.dig("metadata", "annotations", "kubernetes-deploy.shopify.io/predeployed")
predeployed.nil? || predeployed == "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

predeployed.downcase

Should we raise if the value isn't in nil, 'false', 'true' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't do any of that for prunable. Do you need those things implemented there too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Its probably a good idea to do it in both places, but I won't make it a blocker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prunable is explicitly documented as "any other value means false"; restricting to only nil, 'false', 'true' would be BC-breaking. I'm also not sure why we would want to be case insensitive.

test/integration-serial/serial_deploy_test.rb Outdated Show resolved Hide resolved
@ghost ghost removed the cla-needed label Jul 2, 2019
@dturn
Copy link
Contributor

dturn commented Jul 2, 2019

The CI failure is because the lint step can't check out code from remote repos, I'll need to dig into that. For now you can run bundle exec rubocop.

@benlangfeld
Copy link
Contributor Author

@dturn Resolved.

Copy link
Contributor

@timothysmith0609 timothysmith0609 left a comment

Choose a reason for hiding this comment

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

Looks good

CHANGELOG.md Outdated Show resolved Hide resolved
@benlangfeld
Copy link
Contributor Author

Could someone maybe trigger another CI run on this?

@timothysmith0609
Copy link
Contributor

CI on updated commit is all green (except for lint, as above)

@benlangfeld
Copy link
Contributor Author

@timothysmith0609 What lint issue?

{12:49}~/code/kubernetes-deploy:crd-select-predeploy ✓ [2.5.0]
➭ be rubocop
.rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml: Style/RedundantSortBy has the wrong namespace - should be Performance
.rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml: Style/Sample has the wrong namespace - should be Performance
Warning: unrecognized cop Layout/IndentFirstArgument found in .rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml
Warning: unrecognized cop Layout/IndentFirstArrayElement found in .rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml
Warning: unrecognized cop Layout/IndentFirstHashElement found in .rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml
Warning: unrecognized cop Style/Strip found in .rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml
Warning: unrecognized cop Sorbet/ConstantsFromStrings found in .rubocop.yml
Warning: unrecognized cop Layout/IndentFirstArgument found in .rubocop.yml
Warning: unrecognized cop Layout/IndentFirstArrayElement found in .rubocop.yml
Warning: unrecognized cop Layout/IndentFirstHashElement found in .rubocop.yml
Warning: unrecognized cop Style/Strip found in .rubocop.yml
Inspecting 112 files
................................................................................................................

112 files inspected, no offenses detected

@dturn dturn merged commit b37982f into Shopify:master Jul 3, 2019
@benlangfeld benlangfeld deleted the crd-select-predeploy branch July 3, 2019 16:02
@benlangfeld
Copy link
Contributor Author

Thank you @dturn ! Do you have an estimate for when this might make it into a release?

@timothysmith0609
Copy link
Contributor

@timothysmith0609 What lint issue?

Just the fact that lint for external contrib is broken in our CI, not that there was an actual lint error in the code

@dturn
Copy link
Contributor

dturn commented Jul 3, 2019

Do you have an estimate for when this might make it into a release?

We're going to try and release 0.26.5 today.

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