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

Use app label as app-change label for new apps #710

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

praveenrewar
Copy link
Member

@praveenrewar praveenrewar commented Feb 16, 2023

What this PR does / why we need it:

  • Introduce a new label kapp.k14s.io/app-change-app-label for app changes which uses the app label as value
  • Use the old label to list and delete app-changes created for exiting apps, but also add this new label to them.
  • Use the new label to list and delete app-changes created for new apps, but add the old label if length of app name is less than the maximum allowed length of a label key to keep the app-change backward compatible

Which issue(s) this PR fixes:

Fixes #646

Does this PR introduce a user-facing change?

Breaking change!!
App label generated by kapp will be used as app-change label instead of the app name for all the new apps.
- Using app name as a label value in app changes puts a limit on the number of characters a app name can have
- If an app deployed with new version of kapp (and having more than 63 characters) is used with an old version of kapp, then the old version won't be able to detect the app-changes created by the new version.

Additional Notes for your reviewer:

In future, after x number of releases, we can stop using the legacy label and start using the new label for existing apps as well. Since all the app-changes created for them would most probably have both the labels, it won't result in any loss of app-changes.

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


@praveenrewar praveenrewar changed the title Use app label as app-change label for all new apps Use app label as app-change label for new apps Feb 20, 2023
@praveenrewar praveenrewar marked this pull request as ready for review February 20, 2023 04:56
Copy link
Contributor

@100mik 100mik 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 thoughts and I am thinking about whether migrated apps that use the label name today is being considered.

pkg/kapp/app/recorded_app.go Outdated Show resolved Hide resolved
pkg/kapp/app/recorded_app.go Outdated Show resolved Hide resolved
pkg/kapp/app/recorded_app.go Outdated Show resolved Hide resolved
pkg/kapp/app/recorded_app.go Outdated Show resolved Hide resolved
pkg/kapp/app/recorded_app.go Outdated Show resolved Hide resolved
pkg/kapp/app/recorded_app.go Outdated Show resolved Hide resolved
@100mik
Copy link
Contributor

100mik commented Feb 21, 2023

I see that you called out that we won't be any change for existing + migrated apps. That checks out.
The only sore point I have is this means that we will never entirely stop using the old way.
The changes seem to be in line with the behaviour that you are calling out.

What I was wondering is, since app-changes are something we garbage collect. Would it make sense to do this at an app-change level?

  1. All new app-changes have app label
  2. We query for both labels, unless the app-changes-use-app-label annotation is set.
  3. We set the annotation when we get an empty list when looking for app-changes with the old label

So the huge downside is we make one more call till the app is migrated. And from a kapp-controller perspective. For stable packages that do not have diffs, this might be forever till they are reinstalled.

I am trying to figure out how we can potentially move to using just the new label. The path we are taking right now feels like we will be handling both cases for a long time since we cannot definitely said that no migrated or existing apps exist on the users cluster. And we end up leaving orphaned config maps when we do decide to move to the new one altogether.

Since, this is a case that is consciously not being handled in the PR. We can however track how we can "taper off" using old labels as a separate issue since this fix might be needed sooner rather than later.

TL;DR: The path to us not supporting the old label at all in the future is not clear. But we might track that separately and improve on the cases that we do not handle.
@praveenrewar thoughts?

@praveenrewar
Copy link
Member Author

@100mik Thanks for bringing this up. I was planning to take that up separately, but now I think that we should at least decide how we migrate the app-changes for existing apps before making this change.

How about we add one more label to app-changes (not label value, but new label itself). For new apps we will use the new label itself, for old apps we will use the old label but also add the new label to the app changes. After some releases we will switch to using the new label only.

New app-changes for existing apps:

labels:
    kapp.k14s.io/app-change-app: foo
    kapp.k14s.io/app-change-app-label: 101920101920
    kapp.k14s.io/is-app-change: ""

New app-changes for new apps:

labels:
    kapp.k14s.io/app-change-app-label: 101920101920
    kapp.k14s.io/is-app-change: ""

Does this make sense? I will see how these changes looks from code perspective.

@100mik
Copy link
Contributor

100mik commented Feb 22, 2023

Yeah, I think adding both labels now does give us a part forward. We should do that if it is feasible 🤔

@praveenrewar praveenrewar force-pushed the app-change-app branch 2 times, most recently from 1f1bd3f to 310fb85 Compare February 22, 2023 13:38
Copy link
Contributor

@100mik 100mik left a comment

Choose a reason for hiding this comment

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

The changes look good to me, adding both labels leave more room for us to plan out the migration!
I was wondering if there is a straightforward way of putting together tests for this, but I believe we do not have any form of tests involving older versions of kapp. So I am happy with these changes as long as we have verified the tabulated test cases. Let me know if you need a hand with the verification!

- Introduce a new label kapp.k14s.io/app-change-app-label for app changes which uses the app label as value
- Use the old label to list and delete app-changes created for exiting apps, but also add this new label to them.
- Use the new label to list and delete app-changes created for new apps, but add the old label if length of app name is less than the maximum allowed length of a label key

Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com>
Copy link
Contributor

@100mik 100mik left a comment

Choose a reason for hiding this comment

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

The additional condition makes sense!

@praveenrewar praveenrewar merged commit 2b2475b into develop Mar 6, 2023
@praveenrewar praveenrewar deleted the app-change-app branch March 6, 2023 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

App name cannot have more than 63 characters
3 participants