Kaniko builds are slower in v0.20
We are running some performance test and we found the kaniko performance is worse than before: execution time increased from 70s -> 120s
@SaschaSchwarze0 did some investigation and found there are some code logic change in the recent kaniko release:
Analysis:
From Kaniko 0.19 to 0.20 there was commit https://github.com/GoogleContainerTools/kaniko/commit/7b51aec5d955e9bc642943a4b8672575600782e7. It changes the dependency on github.com/google/go-containerregistry from v0.0.0-20191218175032-34fb8ff33bed to v0.0.0-20200313165449-955bf358a3d8.
In go-containerregistry, there is commit https://github.com/google/go-containerregistry/commit/a1fca010ae9cbeb2132652e304335b04f3368455. In this commit, the dependency on k8s.io/kubernetes (includes k8s.io/kubernetes/pkg/credentialprovider) v1.11.10 was removed. Instead a dependency on github.com/vdemeester/k8s-pkg-credentialprovider v0.0.0-20200107171650-7c61ffa44238 was added.
The whole reason of this does not matter so much for us, but this change also updated the k8s code (in the fork that is now used). And in this code, there is commit https://github.com/kubernetes/kubernetes/commit/11efc013288a15322a6abc0852a4859f7b0785dc. This commit changes ecrProvider.Enabled() form simply returning true to this code:
func (p *ecrProvider) Enabled() bool {
sess, err := session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
})
if err != nil {
klog.Errorf("while validating AWS credentials %v", err)
return false
}
if _, err := sess.Config.Credentials.Get(); err != nil {
klog.Errorf("while getting AWS credentials %v", err)
return false
}
return true
}
This code needs 30 seconds. I tested this by adding more log statements there. The build run log then looks like this:
2020-05-15T11:29:29.222534132Z [37mDEBU[0m[0000] Copying file /workspace/source/Dockerfile to /kaniko/Dockerfile
2020-05-15T11:29:29.222590589Z [37mTRAC[0m[0000] Adding /var/run to initialWhitelist
2020-05-15T11:29:29.222943087Z I0515 11:29:29.222784 11 aws_credentials.go:69] aws_credentials.go Enabled >
2020-05-15T11:30:09.867137556Z E0515 11:30:09.866898 11 aws_credentials.go:79] while getting AWS credentials NoCredentialProviders: no valid providers in chain. Deprecated.
2020-05-15T11:30:09.867190538Z For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2020-05-15T11:30:09.867203442Z I0515 11:30:09.866945 11 aws_credentials.go:80] aws_credentials.go Enabled < false
2020-05-15T11:30:11.115727416Z [37mDEBU[0m[0041] Skip resolving path /kaniko/Dockerfile
[...]
I guess that this logic only runs in the k8s context but need to investigate further.
SO we still need more investigation or if need, we need to rollback to the previous 0.19 version.
Hi, you just mentioned me. Please be aware that I am on vacation and come back June 2nd.
This is the issue which we opened in kaniko community: https://github.com/GoogleContainerTools/kaniko/issues/1268
we will also keep investigating.
But before we fix or find the root cause, we decide to: Switch to use kaniko 0.19 release for better performance
Pls let us know if you have any comment. If no objection, we will provide PR to Switch to use kaniko 0.19 first.
PR to switch to kaniko v0.19 image: https://github.com/redhat-developer/build/pull/245
Also fix the delay problem for the newer version: https://github.com/redhat-developer/build/pull/267