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: metric plugin system based on hashicorp go-plugin #2514

Merged
merged 56 commits into from
Feb 7, 2023

Conversation

zachaller
Copy link
Collaborator

@zachaller zachaller commented Jan 11, 2023

This adds support for a plugin system for metric providers using go-pluing from hashicorp.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2023

Go Published Test Results

1 850 tests   1 850 ✔️  2m 31s ⏱️
   112 suites         0 💤
       1 files           0

Results for commit 2cb9a35.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Base: 81.66% // Head: 81.59% // Decreases project coverage by -0.07% ⚠️

Coverage data is based on head (2cb9a35) compared to base (b60f69d).
Patch coverage: 77.39% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2514      +/-   ##
==========================================
- Coverage   81.66%   81.59%   -0.07%     
==========================================
  Files         126      130       +4     
  Lines       19147    19469     +322     
==========================================
+ Hits        15636    15886     +250     
- Misses       2717     2766      +49     
- Partials      794      817      +23     
Impacted Files Coverage Δ
analysis/analysis.go 85.53% <0.00%> (ø)
analysis/controller.go 61.53% <ø> (ø)
utils/analysis/factory.go 92.41% <0.00%> (-1.79%) ⬇️
utils/defaults/defaults.go 89.10% <ø> (ø)
controller/controller.go 89.53% <33.33%> (-1.89%) ⬇️
utils/plugin/plugin.go 53.84% <53.84%> (ø)
utils/plugin/downloader.go 59.54% <59.54%> (ø)
...ricproviders/plugin/rpc/rpc_test_implementation.go 91.42% <91.42%> (ø)
metricproviders/plugin/rpc/rpc.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2023

E2E Tests Published Test Results

    2 files      2 suites   1h 40m 23s ⏱️
  95 tests   88 ✔️ 3 💤 4
194 runs  184 ✔️ 6 💤 4

For more details on these failures, see this check.

Results for commit 2cb9a35.

♻️ This comment has been updated with latest results.

@zachaller
Copy link
Collaborator Author

After talking with @jessesuen who brought up an idea to look into wasm for plugins. The findings of that research turned out to be that today wasm plugins are currently not an option for Rollouts they have some shortcomings such as no golang runtime currently support network requests or really any io syscalls. There are other maturity issues as well, so the plan is to continue with go-plugins and revisit wasm if/when it makes sense.

@skandragon
Copy link

Does this only support a single plugin at a time? It also requires admin-side config, where jobs did not, so perhaps that is also an issue.

Or do I misunderstand that only one plugin can be provided?

@zachaller
Copy link
Collaborator Author

zachaller commented Jan 25, 2023

Yes this is an admin level config due to the fact in order to set it up you need to add a flag to the controller with a path to the binary executable plugin. This limits it to one plugin per controller aka you have some custom metrics system you company uses but it is not supported by rollouts this gives you the option to add that. You could create a plugin though that supports multiple systems etc.

@zachaller
Copy link
Collaborator Author

I did think about possibly doing a multiple plugin system that would allow end users to install other plugins per analysis templates but then we need to figure out how to package those up and install them as well etc. On the flip side I could also see this plugin system having someone else just create say a multi end-user plugin system that deals with packaging downloading plugins etc etc if people think that is valuable but would be curious about use cases either way.

@zachaller zachaller marked this pull request as draft January 27, 2023 22:41
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
…plugin-system

Signed-off-by: zachaller <zachaller@users.noreply.github.com>
@zachaller zachaller marked this pull request as ready for review January 30, 2023 06:54
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

Please check my comments.
Thank you.

metricproviders/plugin/rpc/rpc.go Show resolved Hide resolved
utils/plugin/plugin.go Outdated Show resolved Hide resolved
utils/plugin/plugin.go Show resolved Hide resolved
utils/plugin/plugin.go Show resolved Hide resolved
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/client/client.go Outdated Show resolved Hide resolved
metricproviders/plugin/plugin.go Show resolved Hide resolved
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Signed-off-by: zachaller <zachaller@users.noreply.github.com>
Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

Looking good overall. I have added 2 more comments.

return fmt.Errorf("failed to parse plugin location: %w", err)
}

finalFileLocation := filepath.Join(absoluteFilepath, plugin.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

how are we going to handle 2 plugins with the same name? wouldn't it be better to have some sort of namespace for plugins as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

correct this does not support two plugins with the same name I am not sure of the value 100% with that and it is somewhat controlled via the plugin themself because it is the registration method as well, aka plugins need to know where to look for their config at. I think we could provide a best practice as a plugin author to namespace them. Do you have any thoughts on what would make sense for namespace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Talking with leo we will probably try to enforce a strict file naming convention based on git repo to allow multiple plugins.

"k8s.io/client-go/kubernetes/fake"
)

func TestGetPluginLocation(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We use mockery to auto generate mocks from interfaces in Argo CD. This is something that you can have taken advantage as well to implement more test cases. Not a blocker, mainly a suggestion to improve the coverage.

Signed-off-by: zachaller <zachaller@users.noreply.github.com>
assert.Error(t, err)
}

func TestInitPlugin(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Small suggestion but personally I prefer BDD style test for readability. Example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will move to this on the traffic router plugin branch

Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarcloud
Copy link

sonarcloud bot commented Feb 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

No Coverage information No Coverage information
1.8% 1.8% Duplication

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.

3 participants