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 file resource provider for EG standalone mode #3159

Merged
merged 23 commits into from
Sep 11, 2024

Conversation

shawnh2
Copy link
Contributor

@shawnh2 shawnh2 commented Apr 10, 2024

What type of PR is this?

What this PR does / why we need it:

This PR implement two component for file resource provider: Notifier and ResourceStore.

  • Notifier monitors paths(files or dirs) on host via fsnotify, and send Write/Remove event to ResourceStore
  • ResourceStore load and store resources according to the received event

Which issue(s) this PR fixes:

related #1393


There're some TODOs in this PR, tracked by #3213 #3207

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
… provider

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
@shawnh2 shawnh2 marked this pull request as ready for review April 18, 2024 07:09
@shawnh2 shawnh2 requested a review from a team as a code owner April 18, 2024 07:09
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

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

As discussed in today's meeting, I prefer to remove the EnvoyGatewayCustomProvider and add a flat EnvoyGatewayFileProvider(or a better name).

@arkodg
Copy link
Contributor

arkodg commented Apr 24, 2024

As discussed in today's meeting, I prefer to remove the EnvoyGatewayCustomProvider and add a flat EnvoyGatewayFileProvider(or a better name).

Custom is needed to allow for different resource and infra provider

@zhaohuabing
Copy link
Member

zhaohuabing commented Apr 24, 2024

As discussed in today's meeting, I prefer to remove the EnvoyGatewayCustomProvider and add a flat EnvoyGatewayFileProvider(or a better name).

Custom is needed to allow for different resource and infra provider

Add it later when a use case comes out? The File/Host Provider is not a custom provider, it's a known one.

@arkodg
Copy link
Contributor

arkodg commented Apr 24, 2024

As discussed in today's meeting, I prefer to remove the EnvoyGatewayCustomProvider and add a flat EnvoyGatewayFileProvider(or a better name).

Custom is needed to allow for different resource and infra provider

Add it later when a use case comes out? The File/Host Provider is not a custom provider, it's a known one.

use case exists today - file resource provider and host infra provider to implement standalone case, running EG in a docker container or bare metal directly w/o any API server

@Xunzhuo
Copy link
Member

Xunzhuo commented May 14, 2024

/retest

Copy link
Member

@Xunzhuo Xunzhuo left a comment

Choose a reason for hiding this comment

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

Do we plan on releasing this in v1.1.0 ?

cc @arkodg

@arkodg
Copy link
Contributor

arkodg commented May 15, 2024

Do we plan on releasing this in v1.1.0 ?

cc @arkodg

yeah I'm a +1 for this, prioritizing other PRs right now, will get to this one soon

@shawnh2
Copy link
Contributor Author

shawnh2 commented Jun 4, 2024

will split changes of api/v1alpha1/validation/envoygateway_validate.go into a separate PR, since it's only a refactor and very easily to conflict.

Copy link

github-actions bot commented Jul 4, 2024

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jul 4, 2024
@Xunzhuo Xunzhuo removed the stale label Jul 25, 2024
@sky92zwq
Copy link

Hi, does it set -c or --config-path to switch to file-mode? how to implement the config file?

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 7.87270% with 550 lines in your changes missing coverage. Please review.

Project coverage is 66.54%. Comparing base (c109131) to head (3c5d0f1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/provider/file/resources.go 0.00% 234 Missing ⚠️
internal/provider/file/notifier.go 0.00% 158 Missing ⚠️
internal/provider/file/file.go 0.00% 66 Missing ⚠️
internal/provider/runner/runner.go 0.00% 32 Missing ⚠️
internal/provider/file/store.go 0.00% 26 Missing ⚠️
internal/cmd/server.go 0.00% 15 Missing ⚠️
internal/infrastructure/manager.go 0.00% 9 Missing ⚠️
internal/infrastructure/runner/runner.go 0.00% 6 Missing ⚠️
internal/provider/file/path.go 88.88% 1 Missing and 1 partial ⚠️
internal/provider/kubernetes/kubernetes.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3159      +/-   ##
==========================================
- Coverage   67.99%   66.54%   -1.45%     
==========================================
  Files         190      195       +5     
  Lines       23130    23699     +569     
==========================================
+ Hits        15727    15771      +44     
- Misses       6284     6809     +525     
  Partials     1119     1119              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
@shawnh2 shawnh2 dismissed stale reviews from zhaohuabing and arkodg via 4052618 August 25, 2024 08:21
@shawnh2 shawnh2 removed the hold do not merge label Aug 25, 2024
@shawnh2 shawnh2 requested review from zhaohuabing, arkodg, cnvergence and a team August 25, 2024 08:24
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
// - This issue is tracked by https://github.com/envoyproxy/gateway/issues/3207
//
// convertKubernetesYAMLToResources converts a Kubernetes YAML string into GatewayAPI Resources.
func convertKubernetesYAMLToResources(str string) (*gatewayapi.Resources, error) {

Choose a reason for hiding this comment

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

should deal with ReferenceGrant type resource in this func?

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, it should. This PR only leverage the basic functionality for file-provider, as described in the comments here, this function will be revisited along with the one in egctl x translate.

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
@shawnh2 shawnh2 requested a review from arkodg September 8, 2024 09:09
@shawnh2
Copy link
Contributor Author

shawnh2 commented Sep 8, 2024

Hi, does it set -c or --config-path to switch to file-mode? how to implement the config file?

You can start file-provider mode like envoy-gateway server -c config.yaml, with config.yaml:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyGateway
gateway:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
provider:
  type: Custom
  custom:
    resource:
      type: File
      file:
        paths: ["test/"]
logging:
  level:
    default: info

@shawnh2
Copy link
Contributor Author

shawnh2 commented Sep 8, 2024

/retest

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

thanks !

@arkodg arkodg requested review from a team September 9, 2024 19:03
Copy link
Member

@Xunzhuo Xunzhuo left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

@Xunzhuo Xunzhuo merged commit f5693f6 into envoyproxy:main Sep 11, 2024
13 checks passed
@shawnh2 shawnh2 deleted the host-file-provider branch September 11, 2024 02:34
ncsham pushed a commit to ncsham/gateway that referenced this pull request Sep 11, 2024
)

* add validations for envoy-gateway file resource type

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* improve eg validation and add resource provider interface for various provider

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* extract common gatewayapi layer translate logic in egctl translate

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add notifier support

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix lint and move read yaml bytes function back to translate

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add resources store support

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix lint

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix ci

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* update infra provider api and address comments

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* update custom provider comments and validate method test

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* restore extension manager and add health probe server for file provider

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* update envoy gateway helper functions

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add some unit tests

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* properly handle the remove event for the file provider

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix lint

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* no default to k8s for infra provider

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix runner

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

---------

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Co-authored-by: Xunzhuo <bitliu@tencent.com>
Signed-off-by: NCSham <sudoer@ncsham.in>
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.

6 participants