Skip to content

x509 error with certificate-authority-data: pin mergo dependency against kubernetes/client-go compatible version#3497

Merged
istio-merge-robot merged 1 commit intoistio:masterfrom
steffengy:master
Feb 15, 2018
Merged

x509 error with certificate-authority-data: pin mergo dependency against kubernetes/client-go compatible version#3497
istio-merge-robot merged 1 commit intoistio:masterfrom
steffengy:master

Conversation

@steffengy
Copy link
Copy Markdown
Contributor

@steffengy steffengy commented Feb 14, 2018

This issue was noticed when istioctl returned
"x509: certificate signed by unknown authority"
in combination with a cluster in ~/.kube/config that
specifies its cluster certificate using certificate-authority-data.

The merging in
https://github.com/kubernetes/client-go/blob/b6a34c5a002893138005771f76480e7166da9310/tools/clientcmd/loader.go#L225-L227
results in CertificateAuthorityData containing the base64-decoded
certificate twice, which results in the x509 error.

Potentially related to https://github.com/kubernetes/client-go/blob/7cd1d3291b7d9b1e2d54d4b69eb65995eaf8888e/tools/clientcmd/client_config.go#L160-L162.
Not sure if that's the right way to fix that issue, I'd also appreciate
some pointers on the best approach to add tests for this.

This issue was noticed when istioctl returned
"x509: certificate signed by unknown authority"
in combination with a cluster in ~/.kube/config that
specifies its certificate using certificate-authority-data.

The merging in
https://github.com/kubernetes/client-go/blob/b6a34c5a002893138005771f76480e7166da9310/tools/clientcmd/loader.go#L225-L227
results in `CertificateAuthorityData` containing the base64-decoded
certificate twice, which results in the x509 error.
@steffengy steffengy requested a review from a team February 14, 2018 19:25
@istio-testing
Copy link
Copy Markdown
Collaborator

Hi @steffengy. Thanks for your PR.

I'm waiting for a istio 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.

I understand the commands that are listed here.

Details

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/test-infra repository. I understand the commands that are listed here.

Copy link
Copy Markdown
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

/lgtm

@istio-merge-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: costinm

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@istio-merge-robot
Copy link
Copy Markdown

/test all [submit-queue is verifying that this PR is safe to merge]

@istio-merge-robot
Copy link
Copy Markdown

Automatic merge from submit-queue.

@istio-merge-robot istio-merge-robot merged commit 55449bd into istio:master Feb 15, 2018
ldemailly added a commit to istio-releases/vendor that referenced this pull request Feb 15, 2018
ldemailly added a commit that referenced this pull request Feb 15, 2018
Merge branch 'master' into vendor-sub
ldemailly added a commit that referenced this pull request Feb 15, 2018
matches master ed69c3a and
#3497
@ldemailly
Copy link
Copy Markdown
Member

ldemailly commented Feb 15, 2018

the changes from this pr btw are:
istio-releases/vendor@fb63920

curious which line in that diff is the bug we are fixing ?

@steffengy
Copy link
Copy Markdown
Contributor Author

@ldemailly
darccio/mergo@0b8c27e
breaks this.

In hindsight that's quite logical that it's that commit, but bisecting works too:

package main

import (
	"bytes"
	"fmt"
	"github.com/imdario/mergo"
	clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)

func main() {
	mapConfig := clientcmdapi.NewConfig()
	cluster := clientcmdapi.NewCluster()
	cluster.CertificateAuthorityData = []byte("testdata")
	mapConfig.Clusters["test"] = cluster

	nonMapConfig := clientcmdapi.NewConfig()
	cluster = clientcmdapi.NewCluster()
	cluster.CertificateAuthorityData = []byte("testdata")
	nonMapConfig.Clusters["test"] = cluster

	config := clientcmdapi.NewConfig()
	mergo.Merge(config, mapConfig)
	mergo.Merge(config, nonMapConfig)

	fmt.Println(string(config.Clusters["test"].CertificateAuthorityData))
	authority := config.Clusters["test"].CertificateAuthorityData
	if bytes.Compare(authority, []byte("testdata")) != 0 {
		panic("CertificateAuthorityData does not match")
	}
}

@ldemailly
Copy link
Copy Markdown
Member

ic, thanks a lot, I would report the bug in client go, as mergo quite clearly document their intent?

@steffengy
Copy link
Copy Markdown
Contributor Author

@ldemailly
The people on client-go are quite likely aware of this, since there seems to be quite a bit of behavior that changed in mergo.
https://github.com/kubernetes/client-go/blob/7cd1d3291b7d9b1e2d54d4b69eb65995eaf8888e/tools/clientcmd/client_config.go#L160-L162
is a good indicator for that, where they note that they explicitly for that reason use an old version
of mergo (tagging against it in godeps).

A comment at https://github.com/kubernetes/client-go/blob/b6a34c5a002893138005771f76480e7166da9310/tools/clientcmd/loader.go#L225-L227
to indicate this breaks with darccio/mergo@0b8c27e might make sense though.
Maybe even in the readme, indicating that one should make sure to respect the
dependency versions client-go requires (since the godep tagging will be ignored when using dep).

@ldemailly
Copy link
Copy Markdown
Member

mergo should probably have bumped major or at least minor on that change
instead of a sha can we put an = constraint?

@ldemailly
Copy link
Copy Markdown
Member

not sure what you mean by ignore by go dep btw

@steffengy
Copy link
Copy Markdown
Contributor Author

@ldemailly
I'd advise against that since mergo can cause issues at places where it obviously won't immediately be noticable.
The reason for tagging against that sha-hash is that it's surely known to work and consistent with what client-go does/expects: https://github.com/kubernetes/client-go/blob/35d357565b16ae43c8366248258d910df7c70841/Godeps/Godeps.json#L179.
With ignore godep I mean, that dep in istio doesn't pickup this tagging specified in the file linked above.

ldemailly added a commit that referenced this pull request Feb 15, 2018
* (Rfc) adding vendor as submodule

Receiving objects: 100% (4145/4145), 8.26 MiB | 930.00 KiB/s, done.

Note: adding pruning instruction to Gopkg.toml makes vendor be 54Mb
instead of 407Mb

* Example of rebase, matching master's change to .lock

* Adding submodule target to init + example of update flow

Ran
dep ensure --update istio.io/fortio
To pick up 0.6.8 from 0.6.7
Checked in vendor/ submodule first and now this commit

* No need to cache vendor with this setup

* No cache needed/used

* Added make targets like fortio's for submodule

+ Fun of touching dozens of circleci builds...

* Removed unnecessary .lock copy

* Merge and dip ensure

* Fix for #3483

* Update from master

matches master ed69c3a and
#3497
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.

7 participants