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

Resolve functions using function objects registered in apiserver #3633

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

justinsb
Copy link
Contributor

The intent is that many users will run a function mirror or similar.

@justinsb justinsb changed the title Resolve functions using function objects registered in apiserver WIP: Resolve functions using function objects registered in apiserver Oct 21, 2022
@justinsb justinsb changed the title WIP: Resolve functions using function objects registered in apiserver Resolve functions using function objects registered in apiserver Oct 21, 2022
@justinsb justinsb requested a review from droot October 21, 2022 19:50
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.

Change is looking good. Some minor questions.

@@ -147,6 +148,13 @@ func (c completedConfig) getCoreClient() (client.WithWatch, error) {
if err := configapi.AddToScheme(scheme); err != nil {
return nil, fmt.Errorf("error building scheme: %w", err)
}

// We query the apiserver, even if we could query directly; this will then work with CRDs etc.
// TODO: We need to think about priority-and-fairness with loopback queries
Copy link
Contributor

Choose a reason for hiding this comment

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

This comments seems out of place. Registering porchapi to current scheme doesn't involve querying apiserver.
Perhaps, misplaced ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where we enable it, but fair point - I moved to the callsite!

Namespace: r.namespace,
Name: name,
}
if err := r.client.Get(ctx, key, &function); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some clarifications:
How's the functions registry API work today ?
I am assuming by default, functions won't be there in any porch installation, so this resolving should be opt-in. Simplify because it is now calling network call for every function with out /. WDYT ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How it works today: You can register an OCI Repository with spec.content: Function, and then any discovered images are registered as Functions.

Performance: Currently I don't think the client.Client is caching (but it's always hard to know with controller-runtime!), but we could make it caching if we're concerned about the performance.

Opt-in: I think this should be the default behaviour and the default way we use functions. It's somewhat akin to the Function Catalog idea from kustomize. That said, I expect it to evolve over time (not least because we want to do something on the client side as well). If we have a flag and we set it for users then everyone will be running with anyway :-) I think we have a degree of opt-in because the user has to register a Repository of spec.content=Function to activate the behaviour (otherwise we fall through).

I do think I should write a doc about how this works today, we can keep it updated even as it changes...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think function registry is not widely discussed or shown in any of the demos, so I always considered as aspirational :) but this discussion suggests it is not the case.

Re: performance, I think functions are always beaten for slow performance, so just being careful with adding new latencies :)

Yes, I think documentation will certainly help.

For now, let's go with this and see if it causes any trouble in the field.

@@ -225,5 +227,6 @@ func (o *PorchServerOptions) AddFlags(fs *pflag.FlagSet) {
}

fs.StringVar(&o.FunctionRunnerAddress, "function-runner", "", "Address of the function runner gRPC service.")
fs.StringVar(&o.DefaultImagePrefix, "default-image-prefix", "gcr.io/kpt-fn/", "Default prefix for unqualified function names")
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 make the API based function resolution opt-in ?

The intent is that many users will run a function mirror or similar.
@justinsb justinsb merged commit 0fca8a1 into kptdev:main Oct 28, 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.

2 participants