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

Use the public transport CA as remote CA if the remote CA list is empty #3993

Merged
merged 5 commits into from Dec 3, 2020

Conversation

idanmo
Copy link
Collaborator

@idanmo idanmo commented Nov 30, 2020

If remote clusters are not set for an ES cluster, the remote CA ca.crt mounted on the ES container is empty, which causes the _ssl/certificates ES REST API call to fail. In this PR, if remote clusters are not set for an ES cluster, the remote CA is populated with the public transport CA as a "dummy" CA.
This fix preserves the behavior where adding/setting remote clusters for ES does not require restarting the ES cluster.

Fixes #3881

@idanmo idanmo added the >bug Something isn't working label Nov 30, 2020
Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

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

LGTM. I did a quick test and seems to work. The only thing I noticed is that the remote connection is initially disconnected because the CA certificate was not available yet when the remote cluster was set up in ES via the API, but I believe the same could happen before if the CA propagation was too slow.

@@ -101,14 +104,24 @@ func TestReconcile(t *testing.T) {
Data: map[string][]byte{certificates.CAFileName: []byte("cert2\n")},
},
},
ca: 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 we should pass in the testCA here and on L64 as well to make sure it does not get included when there are remote CA certs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that makes sense.

Copy link
Contributor

@sebgl sebgl left a comment

Choose a reason for hiding this comment

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

LGTM, I also did a few tests 👍

@@ -36,6 +36,7 @@ func Labels(esName string) client.MatchingLabels {
func Reconcile(
c k8s.Client,
es esv1.Elasticsearch,
ca certificates.CA,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: transportCA would make things even more explicit

@@ -24,7 +24,9 @@ func TestReconcile(t *testing.T) {
type args struct {
es esv1.Elasticsearch
secrets []runtime.Object
ca *certificates.CA
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't be a pointer

@idanmo
Copy link
Collaborator Author

idanmo commented Dec 3, 2020

run full pr build

@idanmo idanmo merged commit 5bf2d24 into elastic:master Dec 3, 2020
idanmo added a commit to idanmo/cloud-on-k8s that referenced this pull request Dec 3, 2020
…ty (elastic#3993)

* Addresses an issue where remote transport ca.crt is empty if remote clusters are not set for an ES cluster
* Preserves the behavior where it is not needed to restart ES when configuring remote clusters, post the initial deployment of the cluster
david-kow pushed a commit that referenced this pull request Dec 4, 2020
…ty (#3993) (#4007)

* Addresses an issue where remote transport ca.crt is empty if remote clusters are not set for an ES cluster
* Preserves the behavior where it is not needed to restart ES when configuring remote clusters, post the initial deployment of the cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working v1.3.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote CA cert is created empty when remote clusters are not configured for an ES cluster
3 participants