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

add pvc and emptyDir to function_volumes #1666

Merged
merged 10 commits into from
May 3, 2023

Conversation

zalsader
Copy link
Contributor

@zalsader zalsader commented Apr 4, 2023

Changes

  • add persistentVolumeClaim and emptyDir to the allowed function volumes
  • deploy persistentVolumeClaim and emptyDir volumes
  • add persistentVolumeClaim and emptyDir as options in config

/kind api-change

Fixes #1647

Release Note

Allow specifying `persistentVolumeClaim` and `emptyDir` as volumes in functions.

Docs

- [knative/docs]: TODO

@knative-prow knative-prow bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Apr 4, 2023
@knative-prow
Copy link

knative-prow bot commented Apr 4, 2023

Welcome @zalsader! It looks like this is your first PR to knative/func 🎉

@knative-prow knative-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 4, 2023
@knative-prow knative-prow bot requested review from maximilien and nainaz April 4, 2023 01:42
@matejvasek matejvasek requested review from lkingland, zroubalik and jrangelramos and removed request for maximilien and nainaz April 4, 2023 20:58
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Patch coverage: 43.67% and project coverage change: +13.12 🎉

Comparison is base (88b3634) 49.81% compared to head (f89e51c) 62.94%.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1666       +/-   ##
===========================================
+ Coverage   49.81%   62.94%   +13.12%     
===========================================
  Files          81       93       +12     
  Lines       11148    12183     +1035     
===========================================
+ Hits         5553     7668     +2115     
+ Misses       5111     3818     -1293     
- Partials      484      697      +213     
Flag Coverage Δ
e2e-test 39.01% <27.01%> (?)
e2e-test-oncluster 34.45% <3.44%> (?)
e2e-test-oncluster-runtime 29.35% <0.00%> (?)
e2e-test-runtime-go 28.09% <3.44%> (?)
e2e-test-runtime-node 29.20% <3.44%> (?)
e2e-test-runtime-python 29.20% <3.44%> (?)
e2e-test-runtime-quarkus 29.34% <3.44%> (?)
e2e-test-runtime-springboot 28.21% <3.44%> (?)
e2e-test-runtime-typescript 29.34% <3.44%> (?)
integration-tests 49.78% <16.09%> (?)
unit-tests-macos-latest 48.67% <19.54%> (?)
unit-tests-ubuntu-latest 49.55% <19.54%> (?)
unit-tests-windows-latest 48.73% <19.54%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/functions/function.go 77.92% <0.00%> (+0.51%) ⬆️
pkg/functions/invoke.go 55.39% <0.00%> (+7.19%) ⬆️
pkg/knative/deployer.go 64.47% <17.30%> (+58.52%) ⬆️
cmd/config_volumes.go 64.84% <32.55%> (+37.37%) ⬆️
pkg/k8s/persistent_volumes.go 71.79% <59.37%> (+71.79%) ⬆️
pkg/functions/function_volumes.go 78.18% <75.55%> (-5.82%) ⬇️

... and 59 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@matejvasek
Copy link
Contributor

@zalsader you need to re-generate schema make schema-generate and push it.

@zalsader
Copy link
Contributor Author

zalsader commented Apr 5, 2023

@zalsader you need to re-generate schema make schema-generate and push it.

I did that. The command for make schema-generate was broken, so I added a fix.

@zalsader
Copy link
Contributor Author

zalsader commented Apr 5, 2023

One thing is missing: We need to check that the features are enabled. Do you have suggestions on how to do that?

@matejvasek
Copy link
Contributor

One thing is missing: We need to check that the features are enabled. Do you have suggestions on how to do that?

@zalsader what features do you mean?

@zalsader
Copy link
Contributor Author

zalsader commented Apr 5, 2023

@zalsader what features do you mean?

Sorry I should have been more clear. The PVC and emptyDir are behind a feature flag.

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.

This looks very good

Just one small change: please move the validation logic func validateVolumes out of pkg/functions since in order to execute this (much appreciated) more advanced validation requires k8s.io/api/core/v1 and k8s.io/apimachinery/pkg/api/resource. We are keeping the core package functions dependency-free, so I think perhaps pkg/k8s would be the right place for this validator; taking its dependencies with it.

@lkingland
Copy link
Member

@zalsader what features do you mean?

Sorry I should have been more clear. The PVC and emptyDir are behind a feature flag.

This is a good point, and actually a larger question, because there are other things I would like the functions client library to be able to inspect about the state of the configuration of the cluster, and interact with the user appropriately (or at least generate helpful error messages).

For now, I am fine with this PR being as-is, leaning on documentation, and perhaps issuing a warning to the user in the CLI that if they receive error X they need to enable PVC support.

I am going to put this on our agenda for this weeks meeting, and probably open a discussion.

Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
it needs to be regenrated every time.

Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
@zalsader
Copy link
Contributor Author

For now, I am fine with this PR being as-is, leaning on documentation, and perhaps issuing a warning to the user in the CLI that if they receive error X they need to enable PVC support.

I am going to put this on our agenda for this weeks meeting, and probably open a discussion.

When is the meeting, and would I be able to join? Where would be an appropriate place to issue this warning or write that documentation?

@lkingland
Copy link
Member

lkingland commented Apr 28, 2023

For now, I am fine with this PR being as-is, leaning on documentation, and perhaps issuing a warning to the user in the CLI that if they receive error X they need to enable PVC support.
I am going to put this on our agenda for this weeks meeting, and probably open a discussion.

When is the meeting, and would I be able to join? Where would be an appropriate place to issue this warning or write that documentation?

We have a Knative Community Calendar which includes an open Functions Weekly Meeting on Tuesdays from 14:00-14:30 UTC, as well as many other meetings.

Until we have a way to query the connected platform to detect things like whether or not PVCs are enabled, I would issue this warning clearly from within the CLI package when a user successfully adds a PVC volume via the CLI; perhaps even with a link to the documentation of how to enable. Perhaps someone in the meeting will have a better suggestion as a stop-gap until we have a more permanent solution.

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.

Looks good to me @zalsader

I'll /lgtm this after giving you a chance to take a look at that .PHONY declaration, and perhaps add a helpful warning to the user about this feature requiring special features being installed in the cluster; if you can find a good spot to emit that from the cmd package.
👍🏻

Makefile Outdated
@@ -203,6 +203,7 @@ $(BIN_WINDOWS): generate/zz_filesystem_generated.go
##@ Schemas
######################
schema-generate: schema/func_yaml-schema.json ## Generate func.yaml schema
.PHONY: schema/func_yaml-schema.json
Copy link
Member

@lkingland lkingland Apr 28, 2023

Choose a reason for hiding this comment

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

I am pretty sure that this is not a .PHONY, because it is actually intended to create the file schema/func_yaml-schema.json. Did you mean to perhaps write .PHONY: schema-generate?

Copy link
Contributor Author

@zalsader zalsader Apr 29, 2023

Choose a reason for hiding this comment

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

make build depends on $(CODE) which includes schema/func_yaml-schema.json. Since the file exists, make does not attempt to regenerate that file. This caused an issue later in the CI pipeline which runs make schema-generate.
Since there was a .PHONY: generate/zz_filesystem_generated.go, I thought it would be ok to do the same for the schema file. What do you think we should do instead?

Copy link
Member

Choose a reason for hiding this comment

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

I think @lkingland is correct here. Modifying pkg/functions/function.go does indeed cause the schema to be regenerated via this make target:

func/Makefile

Lines 206 to 207 in d5b4a8d

schema/func_yaml-schema.json: pkg/functions/function.go
go run schema/generator/main.go

The schema-generate target should have been a no-op in CI unless the schema/func_yaml-schema.json changed during the build. This has not historically been a problem, so IMO this change is not needed. Otherwise all looks good!

Copy link
Member

@lkingland lkingland May 2, 2023

Choose a reason for hiding this comment

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

Since there was a .PHONY: generate/zz_filesystem_generated.go, I thought it would be ok to do the same for the schema file.

I see; thanks for noticing! I believe that .PHONY: generate/zz_filesystem_generated.go should actually be removed as well, but that's probably an update for another day/issue. The way it is being generated seems to me not entirely optimal, so it's probably not the best example.

Here's how I understand this rule to work:

schema/func_yaml-schema.json: pkg/functions/function.go 
        go run schema/generator/main.go

pkg/functions/function.go is the dependency. The rule will only execute if the target file either doesn't exist or is older than the dependency file. In this case, if function.go is newer than func_yaml-schema.json (has modifications), then the rule will be executed, generating the file again via go run.... This is the intended functionality.

I would like to know the problem you saw in CI. There actually might be something over there we need to fix or clean up! Other than this, this PR looks good to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know what the issue is now; I added a commit. schema/func_yaml-schema.json should also depend on function_*.go

Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
@zalsader zalsader requested a review from lkingland May 2, 2023 14:55
@lance
Copy link
Member

lance commented May 2, 2023

Assuming tests pass, this is good to go. Thanks for your contribution @zalsader!

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label May 2, 2023
@lance
Copy link
Member

lance commented May 2, 2023

@zalsader I neglected to notice that @lkingland had requested this change.

Just one small change: please move the validation logic func validateVolumes out of pkg/functions since in order to execute this (much appreciated) more advanced validation requires k8s.io/api/core/v1 and k8s.io/apimachinery/pkg/api/resource. We are keeping the core package functions dependency-free, so I think perhaps pkg/k8s would be the right place for this validator; taking its dependencies with it.

Would you mind please handling this as well? Thanks.

@zalsader
Copy link
Contributor Author

zalsader commented May 3, 2023

Would you mind please handling this as well? Thanks.

I think it is already done since I removed the extra dependencies.

@lance lance dismissed lkingland’s stale review May 3, 2023 13:57

The additional dependencies were removed as requested

@lance
Copy link
Member

lance commented May 3, 2023

/approve
/lgtm

@knative-prow
Copy link

knative-prow bot commented May 3, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance, zalsader

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 3, 2023
@knative-prow knative-prow bot merged commit 6558f96 into knative:main May 3, 2023
@zalsader zalsader deleted the feature/add-pvc-empty branch May 3, 2023 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/enhancement lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support PVC and emptyDir in run.volumes in func.yaml
4 participants