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

Allow to overwrite default ExternalTrafficPolicy for the service #1136

Merged

Conversation

yanchenko-igor
Copy link
Contributor

We would like to use Local ExternalTrafficPolicy for the services, so we can properly see the source IP of the clients connecting to the database, for this reason we would like to overwrite detault ExternalTraffixPolicy for the services created by postgres-operator.

@Jan-M
Copy link
Member

Jan-M commented Sep 10, 2020

Since you want to overwrite, should this not be in config map / crd config vs in the Postgres manifest?

@Jan-M
Copy link
Member

Jan-M commented Sep 10, 2020

It could just come with "cluster" from config map as default and allow overwrite in manifest like we do with other properties and then this sounds good.

// if spec.externalTrafficPolicy is not defined default value is "Cluster"
if spec.ExternalTrafficPolicy != nil {
serviceSpec.ExternalTrafficPolicy = *spec.ExternalTrafficPolicy
if c.OpConfig.ExternalTrafficPolicy == "" {
Copy link
Member

Choose a reason for hiding this comment

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

With the absence of any kind of error handling just dealing with the empty case does not make sense or? it is already set to default to "Cluster" if not set. so just line 1625 is good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if I am doing anything wrong, but I don't get default values in the test.

Copy link
Member

Choose a reason for hiding this comment

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

Yes but in no case is c.opconfig.externaltrafficpolicy "", which is fine. I would just argue this whole if statement can just be

serviceSpec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyType(c.OpConfig.ExternalTrafficPolicy)

You have the default properly set, so it should be cluster for everyone.

Everyone else switches it to Local.

And everyone else using something invalid gets an error.

So why deal/cover """ case extra?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean, if I run tests and I don't define c.opConfig.ExternalTrafficPolicy, then I get "" here. Not the default "Cluster" that I expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it's just because the way how the config is defined in tests.

@Jan-M
Copy link
Member

Jan-M commented Sep 10, 2020

Looks good to me, thanks for the fixes.

@Jan-M
Copy link
Member

Jan-M commented Sep 10, 2020

👍

1 similar comment
@sdudoladov
Copy link
Member

👍

@sdudoladov sdudoladov merged commit d8884a4 into zalando:master Sep 15, 2020
@sdudoladov
Copy link
Member

@yanchenko-igor thanks for a yet another contribution !

@FxKu FxKu mentioned this pull request Sep 29, 2020
@FxKu FxKu added this to the 1.6 milestone Oct 16, 2020
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