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

Deploy method override annotation #753

Merged
merged 9 commits into from
Oct 6, 2020

Conversation

timothysmith0609
Copy link
Contributor

@timothysmith0609 timothysmith0609 commented Oct 1, 2020

Concerns https://github.com/Shopify/shopify-core-redis-proxy/pull/170

What are you trying to accomplish with this PR?
We are reaching the annotation size limit for certain ConfigMap resources. Note, this is not the 1MiB limit of the ConfigMap data, itself, but simply the annotation. One possible strategy to get around this is to preclude the use of the last-applied-annotation (which is causing the bloat in size). To do this, we need to stop using apply when deploying this resource and instead use replace.

To that end, this PR introduces an annotation-driven feature, krane.shopify.io/alpha/deploy-method-override. This override accepts one of apply, create, replace, replace-force and is used to control the deploy method at the individual resource level. I chose this approach because:

  • There is already a Krane convention of describing custom behaviour via the use of resource-level annotations (e.g. timeout override, required-rollout).
  • The actual code changes are quite light and easily removed should we decide to remove this feature in the future and/or when a more long-term solution to the underlying problem becomes available.

@timothysmith0609 timothysmith0609 marked this pull request as ready for review October 1, 2020 18:59
@timothysmith0609 timothysmith0609 requested a review from a team as a code owner October 1, 2020 18:59
Copy link

@tanner-bruce tanner-bruce left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -95,11 +95,10 @@ def deploy_resources(resources, prune: false, verify:, record_summary: true)
applyables, individuals = resources.partition { |r| r.deploy_method == :apply }
# Prunable resources should also applied so that they can be pruned
pruneable_types = @prune_whitelist.map { |t| t.split("/").last }
applyables += individuals.select { |r| pruneable_types.include?(r.type) }
applyables += individuals.select { |r| pruneable_types.include?(r.type) && !r.deploy_method_override }
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 need to fight against default behaviour, which makes me loath to ever merge this into master. Previously, we would run apply here to enforce pruning, but since the goal right now is to avoid pruning, we need to add this workaround.

The good news is that this only affects resources that are purposefully overridden, but I think it's enough of a landmine to give me some pause

Copy link
Contributor

Choose a reason for hiding this comment

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

Would It be helpful to ever see a log warning when a pruneable resource is being overridden? I think if it's purposely overridden, then they know they're fighting the default. but wondering if it would give less pause and help to debug if that knowledge assumption is wrong.

@@ -35,6 +35,8 @@ class KubernetesResource
If you have reason to believe it will succeed, retry the deploy to continue to monitor the rollout.
MSG

ALLOWED_DEPLOY_METHOD_OVERRIDES = %w(create replace replace-force)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed to get rid of apply here because

Note that the latter point means overriding will prevent default pruning behaviour for the resource(s) whose deploy methods are being overridden. This isn't bad, in and of itself, but it's worth pointing out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that the latter point means overriding will prevent default pruning behaviour for the resource(s) whose deploy methods are being overridden. This isn't bad, in and of itself, but it's worth pointing out.

Worth making a note about this in a readme somewhere or nah?

@timothysmith0609 timothysmith0609 requested review from RyanBrushett and removed request for manuelfelipe October 2, 2020 16:55
Copy link
Contributor

@beckygowland beckygowland left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

@@ -95,11 +95,10 @@ def deploy_resources(resources, prune: false, verify:, record_summary: true)
applyables, individuals = resources.partition { |r| r.deploy_method == :apply }
# Prunable resources should also applied so that they can be pruned
pruneable_types = @prune_whitelist.map { |t| t.split("/").last }
applyables += individuals.select { |r| pruneable_types.include?(r.type) }
applyables += individuals.select { |r| pruneable_types.include?(r.type) && !r.deploy_method_override }
Copy link
Contributor

Choose a reason for hiding this comment

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

Would It be helpful to ever see a log warning when a pruneable resource is being overridden? I think if it's purposely overridden, then they know they're fighting the default. but wondering if it would give less pause and help to debug if that knowledge assumption is wrong.

@@ -35,6 +35,8 @@ class KubernetesResource
If you have reason to believe it will succeed, retry the deploy to continue to monitor the rollout.
MSG

ALLOWED_DEPLOY_METHOD_OVERRIDES = %w(create replace replace-force)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that the latter point means overriding will prevent default pruning behaviour for the resource(s) whose deploy methods are being overridden. This isn't bad, in and of itself, but it's worth pointing out.

Worth making a note about this in a readme somewhere or nah?

@timothysmith0609
Copy link
Contributor Author

Worth making a note about this in a readme somewhere or nah?

Added a note to the changelog, which should be sufficient until we decide whether to keep/toss this feature longterm

@RyanBrushett
Copy link
Contributor

Thanks Tim. ⛵

@dturn
Copy link
Contributor

dturn commented Oct 5, 2020

Code looks reasonable and on a positive note this will get resolved with server side apply (kubernetes/kubectl#712). I definitely think we need to leave a warning somewhere (possibly in the readme / changelog) that this disables pruning. A different approach would be to automatically detect large objects instead of using an annotation, that would make it clear this is a workaround for large objects not an generic annotation to chagne the deploy method.

@timothysmith0609 timothysmith0609 merged commit 50d76cf into master Oct 6, 2020
@timothysmith0609 timothysmith0609 deleted the deploy_method_annotation_alpha branch October 6, 2020 16:58
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.

5 participants