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

feat: add support for annotations in func.yaml #314

Merged
merged 1 commit into from
Apr 28, 2021

Conversation

lance
Copy link
Member

@lance lance commented Apr 23, 2021

This commit adds limited support for annotations in the func.yaml
config file. The feature is limited, because it's only additive. A
user can add an annotation foo: bar in the config and deploy the
function, successfully setting that annotation on the Service.
However, if they subsequently remove foo: bar from the config
file, it will not be removed from the deployment. This is because
it's not possible to know, from the set of annotations that currently
exist on the deployment, which ones were set by us and which were not.
So, removing any annotations that are not in func.yaml is unsafe.

It may be possible to store in a hidden file somewhere all of the
user-supplied annotations, allowing us to diff func.yaml with that file,
but I'm not sure I want to go down that path. It might just be best to
document this limitation.

We may also want to document that annotations added through func.yaml
should be user supplied settings/values, and not annotations that are
managed by knative (e.g. the autoscaling annotations).

Fixes: #307

Signed-off-by: Lance Ball lball@redhat.com

@lance lance requested a review from a team April 23, 2021 13:47
@lance lance self-assigned this Apr 23, 2021
@zroubalik
Copy link
Contributor

zroubalik commented Apr 26, 2021

We may also want to document that annotations added through func.yaml
should be user supplied settings/values, and not annotations that are
managed by knative (e.g. the autoscaling annotations).

What is the reason behind this?

So you'd like to define knative annotations in another func.yaml property? Something like knativeAnnotations? So maybe we should rename annotations -> userAnnotations or something similar.

@lance
Copy link
Member Author

lance commented Apr 26, 2021

@zroubalik because when you try and set the scaling annotations manually, you get an error from Knative (or I am doing something wrong).

Error: knative deployer failed to deploy the service: admission webhook "validation.webhook.serving.knative.dev" denied the request: validation failed: invalid key name "autoscaling.knative.dev/target": metadata.annotations
autoscaling annotations must be put under "spec.template.metadata.annotations" to work
invalid key name "autoscaling.knative.dev/window": metadata.annotations
autoscaling annotations must be put under "spec.template.metadata.annotations" to work
Error: exit status 1

@lance lance force-pushed the lance/307-add-annotations branch from 1f4cae3 to d3cb765 Compare April 26, 2021 21:04
Copy link
Member

@lkingland lkingland left a comment

Choose a reason for hiding this comment

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

LGTM!

This commit adds limited support for annotations in the func.yaml
config file. The feature is limited, because it's only additive. A
user can add an annotation `foo: bar` in the config and deploy the
function, successfully setting that annotation on the Service.
However, if they subsequently remove `foo: bar` from the config
file, it will _not_ be removed from the deployment. This is because
it's not possible to know, from the set of annotations that currently
exist on the deployment, which ones were set by us and which were not.
So, removing any annotations that are not in func.yaml is unsafe.

It may be possible to store in a hidden file somewhere all of the
user-supplied annotations, allowing us to diff func.yaml with that file,
but I'm not sure I want to go down that path. It might just be best to
document this limitation.

We may also want to document that annotations added through func.yaml
should be user supplied settings/values, and not annotations that are
managed by knative (e.g. the autoscaling annotations).

Fixes: knative#307

Signed-off-by: Lance Ball <lball@redhat.com>
@lance lance force-pushed the lance/307-add-annotations branch from d3cb765 to 591f9a8 Compare April 28, 2021 13:24
@lance lance merged commit 5feb0e2 into knative:main Apr 28, 2021
@lance lance deleted the lance/307-add-annotations branch April 28, 2021 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for annotations in func.yaml
3 participants