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

[configtls] [config/configgrpc] Use configtls.NewDefaultClientConfig(), configtls.NewDefaultConfig() and configtls.NewDefaultServerConfig() #11638

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

Conversation

wasim-nihal
Copy link

@wasim-nihal wasim-nihal commented Nov 11, 2024

Description

[config/configgrpc] Changes to move away from manually creating configtls.ClientConfig, configtls.Config and configtls.ServerConfig in favor of using configtls.NewDefaultClientConfig, configtls.NewDefaultClientConfig(), configtls.NewDefaultConfig() and configtls.NewDefaultServerConfig() respectively.

Link to tracking issue

Fixes #11383

…instead of manually creating struct. See: open-telemetry#11383

Signed-off-by: wasim-nihal <[email protected]>
@@ -102,11 +102,10 @@ func TestDefaultGrpcClientSettings(t *testing.T) {
tt, err := componenttest.SetupTelemetry(componentID)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

clientConfig := configtls.NewDefaultClientConfig()
clientConfig.Insecure = true
gcs := &ClientConfig{
Copy link
Contributor

Choose a reason for hiding this comment

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

In most/all of these first cases, wouldn't you want to use the NewDefaultClientConfig at the outer level, rather than only on the inner TLSSetting?
i.e. using this function:
https://github.com/nokia/open-telemetry-opentelemetry-collector/blob/1703ce6df6979d84720b5826c97d579cf11a59bb/config/configgrpc/configgrpc.go#L111

Copy link
Author

Choose a reason for hiding this comment

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

In most/all of these first cases, wouldn't you want to use the NewDefaultClientConfig at the outer level, rather than only on the inner TLSSetting?

Thanks for taking a look! This suggested change should be done for all the test cases or only the initial ones? PR includes changes only to migrate to new configtls.NewDefaultClientConfig(). If the community is okay, I am willing to create an issue to track this and create separate PR addressing this.

Please share your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please ignore my comment if it doesn't match the requirements. I just thought it odd that we'd use one and not the other. I'm new here. :)

@@ -102,11 +102,10 @@ func TestDefaultGrpcClientSettings(t *testing.T) {
tt, err := componenttest.SetupTelemetry(componentID)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

clientConfig := configtls.NewDefaultClientConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The term "clientConfig" is highly overloaded in this context, I wonder if it would be better to rename this local "tlsSettings" or something similar.

@wasim-nihal wasim-nihal marked this pull request as ready for review November 12, 2024 11:09
@wasim-nihal wasim-nihal requested a review from a team as a code owner November 12, 2024 11:09
@wasim-nihal
Copy link
Author

@mackjmr can you please review this change?

@@ -139,7 +137,8 @@ func TestAllGrpcClientSettings(t *testing.T) {
tt, err := componenttest.SetupTelemetry(componentID)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

clientConfig := configtls.NewDefaultClientConfig()
clientConfig.Insecure = false
Copy link
Contributor

Choose a reason for hiding this comment

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

false by default

@@ -375,15 +368,15 @@ func TestGrpcServerAuthSettings(t *testing.T) {
}

func TestGrpcClientConfigInvalidBalancer(t *testing.T) {
clientConfig := configtls.NewDefaultClientConfig()
clientConfig.Insecure = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Insecure is false by default

…nd configtls.NewDefaultServerConfig()

Signed-off-by: wasim-nihal <[email protected]>
@wasim-nihal wasim-nihal changed the title [configtls] [config/configgrpc] Use configtls.NewDefaultClientConfig … [configtls] [config/configgrpc] Use configtls.NewDefaultClientConfig(), configtls.NewDefaultConfig() and configtls.NewDefaultServerConfig() Nov 13, 2024
Signed-off-by: wasim-nihal <[email protected]>
@wasim-nihal
Copy link
Author

@atoulme , thanks for your review. I have addressed the comments in the latest commit. Could you please check?

Copy link
Member

@mackjmr mackjmr left a comment

Choose a reason for hiding this comment

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

LGTM

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.

[configtls] Use configtls.NewDefaultClientConfig instead of manually creating struct
4 participants