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

fix(server): enforce listen-metrics-urls client TLS info when its scheme is https/unixs #18186

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Jun 17, 2024

Otherwise, it will fail with

cannot listen on TLS for 127.0.0.1:8080: KeyFile and CertFile are not presented

We should instead explicitly fail fast, with a clear error message.

Also, adding some documentation how to configure TLS for metrics URLs.

c.f., #8060

@k8s-ci-robot
Copy link

Hi @gyuho. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 46.15385% with 7 lines in your changes missing coverage. Please review.

Project coverage is 68.86%. Comparing base (debc8fb) to head (0734121).

Current head 0734121 differs from pull request most recent head 22f20a8

Please upload reports for the commit 22f20a8 to get more accurate results.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
Files Coverage Δ
server/embed/etcd.go 75.77% <46.15%> (+0.25%) ⬆️

... and 21 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #18186      +/-   ##
==========================================
- Coverage   68.89%   68.86%   -0.04%     
==========================================
  Files         416      416              
  Lines       35151    35157       +6     
==========================================
- Hits        24218    24211       -7     
- Misses       9521     9541      +20     
+ Partials     1412     1405       -7     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update debc8fb...22f20a8. Read the comment docs.

@gyuho gyuho changed the title fix(server/embed): enforce non-empty client TLS if scheme is https/unixs fix(server/embed): enforce listen-metrics-urls non-empty client TLS for https/unixs Jun 17, 2024
@gyuho gyuho changed the title fix(server/embed): enforce listen-metrics-urls non-empty client TLS for https/unixs fix(server): enforce listen-metrics-urls non-empty client TLS for https/unixs Jun 17, 2024
@gyuho gyuho changed the title fix(server): enforce listen-metrics-urls non-empty client TLS for https/unixs fix(server): enforce listen-metrics-urls non-empty client TLS info when its scheme is https/unixs Jun 17, 2024
@gyuho
Copy link
Contributor Author

gyuho commented Jun 17, 2024

/retest

@k8s-ci-robot
Copy link

@gyuho: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@gyuho gyuho changed the title fix(server): enforce listen-metrics-urls non-empty client TLS info when its scheme is https/unixs fix(server): enforce listen-metrics-urls client TLS info when its scheme is https/unixs Jun 17, 2024
@ivanvc
Copy link
Member

ivanvc commented Jun 17, 2024

/ok-to-test

Signed-off-by: Gyuho Lee <[email protected]>
@gyuho
Copy link
Contributor Author

gyuho commented Jun 18, 2024

/retest

_ = proc.Close()
}()

if err := e2e.WaitReadyExpectProc(context.TODO(), proc, []string{embed.ErrMissingClientTLSInfoForMetricsURL.Error()}); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

No need to fix it now as there are more config e2e tests with this problem, but it would be a nice followup.

In case that etcd doesn't produce the log, would be nice to test to exit after couple of seconds instead of waiting infinitely.

if err := proc.Stop(); err != nil {
t.Error(err)
}
proc.Wait() // ensure the port has been released
Copy link
Member

Choose a reason for hiding this comment

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

Looked at other test, not all of them do this. Would be nice to have a consistent approach to shutting down proc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, yes. Some archaic code base here :)

Copy link
Member

Choose a reason for hiding this comment

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

Heh, we have been trying to clean it slowly up but we run out of steam.

#13637

@serathius
Copy link
Member

cc @ahrtr

Comment on lines 169 to 170
proc.Wait() // ensure the port has been released
_ = proc.Close()
Copy link
Member

Choose a reason for hiding this comment

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

Minor comment: proc.Wait() seems to be unnecessary, proc.Close() already calls ep.wg.Wait().

etcd/pkg/expect/expect.go

Lines 356 to 362 in c70e0e4

func (ep *ExpectProcess) Wait() {
ep.wg.Wait()
}
// Close waits for the expect process to exit and return its error.
func (ep *ExpectProcess) Close() error {
ep.wg.Wait()

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM with a minor comment.

You might want to backport the change to 3.5.

@serathius
Copy link
Member

/retest

@gyuho
Copy link
Contributor Author

gyuho commented Jun 18, 2024

/retest

1 similar comment
@gyuho
Copy link
Contributor Author

gyuho commented Jun 18, 2024

/retest

server/embed/etcd.go Show resolved Hide resolved
@ahrtr ahrtr merged commit 9c59b28 into etcd-io:main Jun 18, 2024
48 checks passed
@gyuho gyuho deleted the enforce-non-empty-client-tls-if-metrics-url-scheme-is-https branch June 20, 2024 05:33
@ivanvc ivanvc mentioned this pull request Jun 28, 2024
4 tasks
@jmhbnz
Copy link
Member

jmhbnz commented Jul 6, 2024

/cherrypick release-3.5

@k8s-infra-cherrypick-robot

@jmhbnz: #18186 failed to apply on top of branch "release-3.5":

Applying: fix(server/embed): enforce non-empty client TLS if scheme is https/unixs
Applying: test(e2e): add a case where client tls is missing for https metrics url
Using index info to reconstruct a base tree...
M	server/embed/etcd.go
M	tests/e2e/etcd_config_test.go
Falling back to patching base and 3-way merge...
Auto-merging tests/e2e/etcd_config_test.go
CONFLICT (content): Merge conflict in tests/e2e/etcd_config_test.go
Auto-merging server/embed/etcd.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 test(e2e): add a case where client tls is missing for https metrics url
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick release-3.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

jmhbnz added a commit to jmhbnz/etcd that referenced this pull request Jul 6, 2024
…s https/unixs

Backports a657f06, 22f20a8, 497f1a4 and 3e86af6 from etcd-io#18186.

Also backports required test util elements of 4c77726 from etcd-io#17661.

Signed-off-by: James Blair <[email protected]>
jmhbnz added a commit to jmhbnz/etcd that referenced this pull request Jul 9, 2024
…s https/unixs

Backports a657f06, 22f20a8, 497f1a4 and 3e86af6 from etcd-io#18186.

Also backports required test util elements of 4c77726 from etcd-io#17661.

Signed-off-by: James Blair <[email protected]>
hswong3i pushed a commit to alvistack/etcd-io-etcd that referenced this pull request Jul 20, 2024
…s https/unixs

Backports a657f06, 22f20a8, 497f1a4 and 3e86af6 from etcd-io#18186.

Also backports required test util elements of 4c77726 from etcd-io#17661.

Signed-off-by: James Blair <[email protected]>
aneesh1 pushed a commit to DataDog/etcd that referenced this pull request Sep 24, 2024
…s https/unixs

Backports a657f06, 22f20a8, 497f1a4 and 3e86af6 from etcd-io#18186.

Also backports required test util elements of 4c77726 from etcd-io#17661.

Signed-off-by: James Blair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

9 participants