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

adding support for publishing bundle to Minio Object Storage (#5395) #5757

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Dimss
Copy link

@Dimss Dimss commented Jan 3, 2025

As a part of #5395 this PR add support to Minio S3 storage.
The PR does not meant to be merge to main yet.
I do need someone look on the PR and provide initial feedback.
I wanna make sure this functionality is still needed and overall logic does make sense.
if all good, I'll continue to work on it, add tests, etc...

@sorindumitru
Copy link
Collaborator

Thanks for the contribution @Dimss! I'll try to take a look at it this week.

@sorindumitru
Copy link
Collaborator

@Dimss Minio is API compatible with AWS S3 API, so it should be possible to use the existing awss3 bundle publisher here. Have you tried using that? Are there any issues or missing functionality?

@Dimss
Copy link
Author

Dimss commented Jan 12, 2025

@sorindumitru awss3 might be working with Minio.
However, by default when user using awss3 bundle publisher he doesn't have an option to configure what's Minio calls Endpoint URL. We possibly can extend the awss3 configuration with Endpoint URL, but then perhaps it will be not awss3 but generic s3 bundle publisher.
In addition, Minio allow insecure connections to buckets (might be useful for dev/test envs)

I think the main question here, should it be a generic S3 publisher or publisher for each provider with it's backend implementation.

@kfox1111
Copy link
Contributor

Thank you so much for working on this! :)

Its using the minio client, but I think it could work against any s3 server as coded?

There are a lot of s3 compatible implementations out there (many storage vendors support it) and they all work with the aws s3 client I believe, or one of the implementations like minio's client.

Having one generic s3 driver I think would be preferable to one per storage implementation, as they all essentially work the same.

@sorindumitru
Copy link
Collaborator

Having separate implementations for different platforms may make sense eventually, but I feel that for now it only adds maintenance burden.

If someone does end up needing something from this plugin where it makes sense to have it use platform specific APIs, such as platform specific authentication methods, we should look into splitting off that part into a separate plugin. @Dimss, do you need anything from an S3 publisher that is Minio specific?

For now, it's probably easiest to just add support for specifying an optional endpoint to the awss3 plugin.

@Dimss
Copy link
Author

Dimss commented Jan 19, 2025

@sorindumitru ok by me.
So then I'll extend existing awss3 plugin with extra optional parameter endpoint and insecure.
Do you agree?

@kfox1111
Copy link
Contributor

Just endpoint for now I think? if you need to load in a custom ca for talking to minio, it can be done via the system trust bundle. If its actually insecure, not sure there is any advantage to funneling it through the s3 service rather then just using the agents insecure_bootstrap flag?

@Dimss
Copy link
Author

Dimss commented Jan 19, 2025

@kfox1111 agree. then I'll just add one optional endpoint param into existing awss3 plugin

@Dimss Dimss requested a review from sorindumitru as a code owner February 4, 2025 15:49
@Dimss
Copy link
Author

Dimss commented Feb 4, 2025

@kfox1111, @sorindumitru I applied required changes, pls review.

Copy link
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

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

Thank you @Dimss for this contribution!

We need to update the documentation of the aws_s3 bundle publisher plugin with the new Endpoint setting, indicating that's an optional setting (not required).

We should also add test coverage for this, making sure to check that the configuration has been properly wired up to the aws config.

@amartinezfayo
Copy link
Member

Hi @Dimss, I think we’re pretty close to having this merged. Have you had a chance to look at the latest small comments?

@Dimss
Copy link
Author

Dimss commented Feb 24, 2025

Hey @amartinezfayo yeah, I saw the comments, I'll make it done in coming days.

@Dimss
Copy link
Author

Dimss commented Mar 1, 2025

@amartinezfayo I've applied required changes, added tests and updated docs.
pls review.

kfox1111
kfox1111 previously approved these changes Mar 1, 2025
Copy link
Contributor

@kfox1111 kfox1111 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! :)

@kfox1111
Copy link
Contributor

kfox1111 commented Mar 1, 2025

Looks like the DCO needs fixing.

@Dimss Dimss force-pushed the s3-bundlePublisher-for-other-implementations-5395 branch 2 times, most recently from 67a371d to a4ad9d1 Compare March 2, 2025 09:21
@Dimss Dimss requested review from amartinezfayo and kfox1111 March 2, 2025 09:30
@Dimss
Copy link
Author

Dimss commented Mar 2, 2025

@kfox1111 DCO has been added.

@Dimss Dimss force-pushed the s3-bundlePublisher-for-other-implementations-5395 branch from 079304f to b4829a7 Compare March 2, 2025 16:30
@Dimss Dimss force-pushed the s3-bundlePublisher-for-other-implementations-5395 branch from b4829a7 to ca83e3f Compare March 2, 2025 16:33
options.BaseEndpoint = c.BaseEndpoint
}
}
return s3.NewFromConfig(c, options), nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think NewFromConfig would end up calling the nil options in the case that the BaseEndpoint is not configured. We could have the options have a default of an empty function.

Copy link
Author

Choose a reason for hiding this comment

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

@sorindumitru I do not understand what you mean.
can you pls provide an example.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The options variable defaults to the zero value of a function pointer, which is nil. NewFromConfig will then try to call that nil and get a segfault. See for example https://play.golang.com/p/SPZxT29tKjN

We can avoid this by initializing the variable to a function that doesn't do anything.

Copy link
Author

Choose a reason for hiding this comment

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

@sorindumitru, yes you are right.
@amartinezfayo suggested to change it var comment
I'll revert it back to options := func(options *s3.Options) {}, is that OK?

@@ -98,6 +110,20 @@ func TestConfigure(t *testing.T) {
expectMsg: "failed to create client: client creation error",
newClientErr: errors.New("client creation error"),
},
{
name: "wrong endpoint format",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find the format in the test name a bit confusing because there's a Format field in the config too. Maybe we can say:

Suggested change
name: "wrong endpoint format",
name: "invalid endpoint url",

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this change didn't get addressed.

go.mod Outdated
@@ -1,166 +1,161 @@
module github.com/spiffe/spire

go 1.23.4
go 1.24.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be some leftover from rebasing, could you clean it up?

Copy link
Author

Choose a reason for hiding this comment

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

@sorindumitru
this looks up to date.. not sure why github show this diff.
in PR, the go.mod have valid go version

@Dimss Dimss force-pushed the s3-bundlePublisher-for-other-implementations-5395 branch 2 times, most recently from 7689432 to 593c46a Compare March 2, 2025 17:38
@Dimss Dimss requested a review from sorindumitru March 2, 2025 17:41
@Dimss Dimss force-pushed the s3-bundlePublisher-for-other-implementations-5395 branch from 593c46a to cd225fd Compare March 2, 2025 20:00
@@ -2229,4 +2229,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
software.sslmate.com/src/go-pkcs12 v0.4.0 h1:H2g08FrTvSFKUj+D309j1DPfk5APnIdAQAB8aEykJ5k=
software.sslmate.com/src/go-pkcs12 v0.4.0/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI=
software.sslmate.com/src/go-pkcs12 v0.4.0/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we still have these new line changes, could you also remove this? The linter is also complaining about them.

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.

4 participants