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

Implement initialization of piped service client in k8s plugin #5387

Merged
merged 6 commits into from
Dec 4, 2024

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Dec 3, 2024

What this PR does:

as title

Why we need it:

We need the piped's plugin service client to call the APIs.

Which issue(s) this PR fixes:

Part of #4980

Does this PR introduce a user-facing change?: No

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 33 lines in your changes missing coverage. Please review.

Project coverage is 25.84%. Comparing base (77b999c) to head (2d1da06).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/plugin/pipedapi/client.go 0.00% 20 Missing ⚠️
pkg/app/pipedv1/plugin/kubernetes/server.go 0.00% 9 Missing ⚠️
...kg/app/pipedv1/plugin/toolregistry/toolregistry.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5387      +/-   ##
==========================================
- Coverage   25.85%   25.84%   -0.02%     
==========================================
  Files         447      448       +1     
  Lines       48233    48261      +28     
==========================================
  Hits        12472    12472              
- Misses      34790    34818      +28     
  Partials      971      971              

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

ffjlabo
ffjlabo previously approved these changes Dec 3, 2024
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@t-kikuc t-kikuc left a comment

Choose a reason for hiding this comment

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

I wanna ask one point

apiPort: 10000,
gracePeriod: 30 * time.Second,
apiPort: 10000,
pipedPluginServicePort: 9087,
Copy link
Member

Choose a reason for hiding this comment

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

[ASK] Where does 9087 come from?

Do other plugins need to avoid using 9087?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for not commenting about this.
This comes from the default of pipedv1's plugin service port.

pluginServicePort: 9087,

Copy link
Member

Choose a reason for hiding this comment

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

I got it, thank you.
I think it'd be better to avoid hard coding (e.g., by using const) because all plugins need to specify 9087 directly.

If it's not easy now, let's do it in another PR later.

Copy link
Contributor Author

@Warashi Warashi Dec 3, 2024

Choose a reason for hiding this comment

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

I came to one idea.
The piped will always specify the port when invoking the plugin.
Then, making the default -1 and the plugin raises the error if the piped doesn't specify the port.
WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

It seems good!

You mean a piped passes the piped's port to each plugin, right? If not passed, an error will occur by -1

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 👍🏻
I realized the way to pass this port must be the same across all the plugins.
We have to discuss how to pass it (e.g., as a command option or an environment variable, and these names, too).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@t-kikuc
I changed the default to -1 and added validation.
In this PR, I want to merge it with this implementation.

81bef18

Copy link
Member

Choose a reason for hiding this comment

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

@Warashi Thank you!

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
t-kikuc
t-kikuc previously approved these changes Dec 3, 2024
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

Thanks! Left a commet.

Comment on lines 80 to 83
if s.pipedPluginServicePort == -1 {
input.Logger.Error("piped-plugin-service-port is required")
return errors.New("piped-plugin-service-port is required")
}
Copy link
Member

Choose a reason for hiding this comment

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

We can use MarkFlagRequired to require the flag 👀
https://pkg.go.dev/github.com/spf13/cobra#MarkFlagRequired

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ffjlabo
Thank you for notifying me 👍🏻
Fixed on this commit
b66474b

Copy link
Member

Choose a reason for hiding this comment

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

@Warashi

Then the following line is unnecessary, right?

		pipedPluginServicePort: -1, // default as error value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, that's right. I'll change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. fixed on this commit
2d1da06

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

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

🚀

@Warashi Warashi merged commit 40dae44 into master Dec 4, 2024
14 of 18 checks passed
@Warashi Warashi deleted the k8s-plugin-initialize-piped-service-client branch December 4, 2024 02:17
@github-actions github-actions bot mentioned this pull request Jan 21, 2025
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.

3 participants