Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Allow retention duration empty to default #954

Conversation

eric-sap
Copy link
Contributor

@eric-sap eric-sap commented Oct 26, 2021

Fixes #952

Proposed Changes

  • 🐛 Allow RetentionDuration to be mutable in specific circumstances - empty string to either "P0D" or "PT168H"

Without this change, running the channel-post-install.yaml for eventing-kafka v0.26.3 can crash if there are kafkachannel resources from a previous version that don't have the RetentionDuration field in the spec.

I am sure that this change "fixes the issue" ... however, I am not sure that "allowing exceptions to immutability" is an okay thing to be doing (However, I also don't know any other way to fix this, so comments are very welcome please).

Release Note

KafkaChannel "RetentionDuration" now permitted to change from empty to a proper value (immutability exception).  This allows the v0.26 post-install upgrade to run properly (must be using v0.26.4+ before running channel-post-install.yaml)

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Oct 26, 2021
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 26, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eric-sap

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 26, 2021
@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #954 (827d657) into main (8b3f08b) will increase coverage by 0.00%.
The diff coverage is 75.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #954   +/-   ##
=======================================
  Coverage   75.64%   75.65%           
=======================================
  Files         137      137           
  Lines        6545     6547    +2     
=======================================
+ Hits         4951     4953    +2     
  Misses       1311     1311           
  Partials      283      283           
Impacted Files Coverage Δ
...apis/messaging/v1beta1/kafka_channel_validation.go 81.39% <75.00%> (+0.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b3f08b...827d657. Read the comment docs.

Comment on lines 97 to 100
// or to the explicit canonical zero, "P0D" (which is an empty Period struct).
// This particular change needs to be allowed, otherwise upgrading old channels will fail.
if original.Spec.RetentionDuration == "" {
if kc.Spec.RetentionDuration == constants.DefaultRetentionISO8601Duration ||
Copy link
Contributor

Choose a reason for hiding this comment

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

should we release note this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, definitely - this was my fault - two successive changes to the same area - thanks eric.

@eric-sap
Copy link
Contributor Author

I've simplified it to a simple empty string check and a large comment about the reasoning. If this is okay to merge the I will do that and then port it back to the release-0.26 branch. I do think this should be left in main as well, since despite it being "required" to run the post-install job after installing v0.26, this is inevitably going to be neglected by some users and it would be better if the empty field were still able to be set to a proper value in v0.27+

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 27, 2021
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-sandbox-eventing-kafka-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/messaging/v1beta1/kafka_channel_validation.go 94.4% 94.7% 0.3

@travis-minke-sap
Copy link
Contributor

Thanks for fixing - sorry for the trouble!

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 27, 2021
@knative-prow-robot knative-prow-robot merged commit 90e6e62 into knative-extensions:main Oct 27, 2021
eric-sap added a commit to eric-sap/eventing-kafka that referenced this pull request Oct 27, 2021
* Allow the retentionDuration to be changed from empty to the default

* Also allow empty string to P0D

* imports

* imports

* imports

* imports

* Simplify to allow any change from empty-string

* Don't allow other immutable changes just because retentionDuration is changing

* style

* Linter doesn't care for passing nil contexts

* Skip the recursion and just alter the ignoreArguments

* imports
knative-prow-robot pushed a commit that referenced this pull request Oct 27, 2021
* Allow the retentionDuration to be changed from empty to the default

* Also allow empty string to P0D

* imports

* imports

* imports

* imports

* Simplify to allow any change from empty-string

* Don't allow other immutable changes just because retentionDuration is changing

* style

* Linter doesn't care for passing nil contexts

* Skip the recursion and just alter the ignoreArguments

* imports
pierDipi pushed a commit to pierDipi/eventing-kafka that referenced this pull request Oct 28, 2021
…native-extensions#957)

* Allow the retentionDuration to be changed from empty to the default

* Also allow empty string to P0D

* imports

* imports

* imports

* imports

* Simplify to allow any change from empty-string

* Don't allow other immutable changes just because retentionDuration is changing

* style

* Linter doesn't care for passing nil contexts

* Skip the recursion and just alter the ignoreArguments

* imports
openshift-merge-robot pushed a commit to openshift-knative/eventing-kafka that referenced this pull request Oct 28, 2021
…native-extensions#957) (#413)

* Allow the retentionDuration to be changed from empty to the default

* Also allow empty string to P0D

* imports

* imports

* imports

* imports

* Simplify to allow any change from empty-string

* Don't allow other immutable changes just because retentionDuration is changing

* style

* Linter doesn't care for passing nil contexts

* Skip the recursion and just alter the ignoreArguments

* imports

Co-authored-by: eric-sap <eric.van.heest@sap.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Distributed channel upgrade from v0.25.5 to v0.26.3 fails during retentionDuration update
5 participants