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

klippy: a controller that auto-instantiates packages #3575

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

justinsb
Copy link
Contributor

@justinsb justinsb commented Sep 22, 2022

This controller will automatically create draft package instances where the bindings are satisfied. If the bindings are sufficiently constraining, this can act as a guided workflow to help users do the next right thing.

@justinsb justinsb changed the title WIP: klippy WIP: klippy: a controller that auto-instantiates packages Oct 19, 2022
@justinsb justinsb force-pushed the klippy branch 2 times, most recently from 57cf6d1 to bf15db3 Compare October 19, 2022 20:16
Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

some drive by comments.

parentObjects, err := parseObjects(ctx, parentResources)
if err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

parseObjects and parseBlueprints seems like functions could be useful in other places (porchclient++).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes - I feel like we should have them somewhere already. I just don't know where...


var allProposals []*api.PackageRevision
for _, blueprint := range blueprints {
proposals, err := r.buildProposals(ctx, parent, parentObjects, blueprint)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like this is the part we would like to externalize (delegate to proposal makers).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - as we build more of these, we can refactor to share code. I would hope that anyone building the second proposal controller would refactor to reuse some of this code - hopefully making it a bit better along the way :-) cc @yuwenma

}

proposals = append(proposals, proposal)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

lots of binding stuff that I skipped over. I am curious, where is bind function used that was taken as input ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops - I forgot to do that - fixed in the latest update!

@johnbelamaric
Copy link
Contributor

This is quite similar to what I am looking for with #3448. The idea is that a local-config resource will describe the "my package requires", and another one in other packages will describe the "my package provides". I want a dependency resolution controller that sees these in Draft package revisions and resolves them. Dependencies themselves are also surfaced as conditions, so that we can identify when all dependencies have been satisfied.

@justinsb
Copy link
Contributor Author

This is quite similar to what I am looking for with #3448. The idea is that a local-config resource will describe the "my package requires", and another one in other packages will describe the "my package provides". I want a dependency resolution controller that sees these in Draft package revisions and resolves them. Dependencies themselves are also surfaced as conditions, so that we can identify when all dependencies have been satisfied.

That's great news, thank @johnbelamaric . I do expect we'll have multiple controllers making proposals. I think it would be great if @yuwenma (or @natasha41575 ) tackled updating-the-container-image next. I don't know whether your needs are close enough that we should extend this controller, or whether we should build a second controller - generally I think we'll evolve our understanding as we build out this functionality (better to have many specialized controllers, or fewer more generic ones?)

@justinsb justinsb force-pushed the klippy branch 5 times, most recently from 02932f8 to f8b5ae1 Compare October 21, 2022 18:26
@justinsb justinsb changed the title WIP: klippy: a controller that auto-instantiates packages klippy: a controller that auto-instantiates packages Oct 21, 2022
@justinsb justinsb force-pushed the klippy branch 2 times, most recently from ca3ded7 to 9287d91 Compare October 21, 2022 19:45
Copy link
Contributor

@mortent mortent 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 to me, but can we add a README file that describes what it does and includes a simple example for testing it? I've found that pretty useful in the other controllers when I need to make changes. So something like this: https://github.com/GoogleContainerTools/kpt/tree/main/porch/controllers/workloadidentitybindings/config/samples


package klippy

//+kubebuilder:rbac:groups=porch.kpt.dev,resources=packagerevisionresources,verbs=get;list;watch;create;update;patch;delete
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for putting the rbac directives here instead of in the controller.go file itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was mostly just trying it out to see how I/we felt about it. The RBAC generated is the same either way. I'll move it into the main controller, to follow the existing patterns.

packageRevision := &packageRevisions.Items[i]

if !strings.HasPrefix(packageRevision.Spec.PackageName, "infra/") {
log.Info("HACK: ignoring non-infra package", "package", packageRevision.Spec.PackageName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we document the convention used here?

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 call, I removed the hack. Instead we only apply this where packages actually have bindings, which achieves much the same thing (scoping just to the packages that are using bindings).

This controller will automatically create draft package instances
where the bindings are satisfied.  If the bindings are sufficiently
constraining, this can act as a guided workflow to help users do the
next right thing.
@justinsb
Copy link
Contributor Author

Thanks @mortent - I added a README and was able to remove the hack.

@justinsb justinsb merged commit cd2ec9d into kptdev:main Nov 2, 2022
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.

None yet

4 participants