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

Implement configuration injection in PackageVariant #3939

Merged
merged 10 commits into from
May 10, 2023

Conversation

johnbelamaric
Copy link
Contributor

@johnbelamaric johnbelamaric requested a review from a team as a code owner May 2, 2023 20:43
@johnbelamaric johnbelamaric self-assigned this May 2, 2023
@johnbelamaric johnbelamaric requested a review from droot May 2, 2023 20:43
@johnbelamaric johnbelamaric marked this pull request as draft May 2, 2023 20:44
@johnbelamaric johnbelamaric changed the title Add injection API Implement configuration injection in PackageVariant May 2, 2023
Note that ensurePackageVariant needed some fixes. When I introduced
applyMutations, I didn't properly update it to account for subsequent
reconciliations; if an error happened in the first reconciation, it was
never retried and rectified in later reconciliations. So, this change
also includes that fix.

Still more tests to do.
@johnbelamaric johnbelamaric marked this pull request as ready for review May 8, 2023 20:50
Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

General code structure and logic makes sense to me. Some drive-by comments

Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

A nit and a minor discussion point that I could go either way on, but looks good to me other than that.

if err := r.Client.Update(ctx, downstream); err != nil {
klog.Errorf("error updating package revision lifecycle: %v", err)
}
if downstream.Spec.Lifecycle == porchapi.PackageRevisionLifecycleDeletionProposed {
Copy link
Contributor

@natasha41575 natasha41575 May 9, 2023

Choose a reason for hiding this comment

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

Was there a reason to move this and the next few lines out of the isUpToDate condition? If the package revision with lifecycle DeletionProposed is not up to date and needs updating, then we are going to make and update a new draft, so I don't think it's needed to update the lifecycle of the old existing package revision?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I meant to ask you to give the changes in this method particular attention.

I was working with the understanding that LifecycleIsPublished would return false for those with deletion proposed, but now that you ask it, maybe that's not true? I was concerned that we would end up cloning a deletion proposed package, and that the published version would then remain in deletion proposed even though it's not supposed to.

My thinking was that we needed to clear this state since it's no longer proposed for deletion, regardless of what else needs to be done to it, and that it was safe to do that even if it's not up to date. That did require saving it before the clone.

Probably we should have some sort of e2e test or something to see if this works the way we think? Do we have an easy way to do this sort of complex test?

Copy link
Contributor

@natasha41575 natasha41575 May 10, 2023

Choose a reason for hiding this comment

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

Yeah, LifecycleIsPublished returns true for Published or DeletionProposed. Those two lifecycles are treated pretty much the same everywhere, with the only exception being the package revision deletion webhook that disallows Published packages to be deleted. Draft and Proposed package revisions don't need to be proposed for deletion - they can just be deleted at any time.

I was concerned that we would end up cloning a deletion proposed package, and that the published version would then remain in deletion proposed even though it's not supposed to.

The previous logic did copy a deletion proposed package, but the copied version will start out in draft state and will move through the normal package revision lifecycles of Draft -> Proposed -> Published -> DeletionProposed, requiring a client to move it to the next lifecycle at each step, so the copied version shouldn't get to the deletionProposed stage unless someone explicitly changed it to that.

My thinking was that we needed to clear this state since it's no longer proposed for deletion, regardless of what else needs to be done to it, and that it was safe to do that even if it's not up to date. That did require saving it before the clone.

Got it. So we are thinking of the proposedDeletion package revision as the target, and therefore we don't want it to be deleted anymore. Copying it later is just part of updating it. I agree that it is safe and I think your reasoning is correct, so your changes make sense.

Probably we should have some sort of e2e test or something to see if this works the way we think? Do we have an easy way to do this sort of complex test?

Unfortunately we don't have e2e tests set up for these controllers. We should try to set something up at some point rather than relying on developers to do a bunch of manual testing, but we don't have a concrete plan for that. We do have complex tests for the experimental rollouts controllers, so we might be able to draw some inspiration from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Natasha, that explanation helps a lot.

@johnbelamaric johnbelamaric merged commit 190dc23 into kptdev:main May 10, 2023
johnbelamaric added a commit to mortent/kpt that referenced this pull request Sep 18, 2023
* Add injection API

* Add validation for config injectors

* Add updated CRD

* Partial implementation of config injection

* Test and fix setInjectionPointConditionsAndGates

* Fix PVS test due to changed hash

* Initial complete injection implementation

Note that ensurePackageVariant needed some fixes. When I introduced
applyMutations, I didn't properly update it to account for subsequent
reconciliations; if an error happened in the first reconciation, it was
never retried and rectified in later reconciliations. So, this change
also includes that fix.

Still more tests to do.

* Additional tests, cleanup, bug fixes

* Address review comments

* Add TODO about watches for injected objects, fix nit
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.

Porch PackageVariant configuration injection feature
2 participants