Skip to content

helm list performance, 1k+ release secrets cost 50s #8008

Closed

Description

@liuming-dev

Output of helm version:
version.BuildInfo{Version:"v3.2.0", GitCommit:"e11b7ce3b12db2941e90399e874513fbd24bcb71", GitTreeState:"clean", GoVersion:"go1.13.10"}

Output of kubectl version:
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T23:35:15Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):

Situation

~/.kube » helm list --kubeconfig ~/.kube/pre -n bizqa|wc -l 
     257

~/.kube » kubectl --kubeconfig ~/.kube/pre -n bizqa get secret|grep sh.helm.release.v1|wc -l
    1176

~/.kube » ./helm list  --kubeconfig ~/.kube/pre -n bizqa --debug
secrets.go:85: [debug] secret list begin 2020-04-27 23:13:23.452096 +0800 CST m=+0.171505153
secrets.go:87: [debug] secret list end 2020-04-27 23:14:09.381549 +0800 CST m=+46.102320791
secrets.go:96: [debug] secret decode begin 2020-04-27 23:14:09.381579 +0800 CST m=+46.102350108
secrets.go:107: [debug] secret decode end 2020-04-27 23:14:11.643692 +0800 CST m=+48.364530799
NAME                            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                    APP VERSION
2060-biz-janus-admin            bizqa           1               2020-04-21 20:03:49.104460438 +0800 CST deployed        thanos-deployment-1.0.0  1.16.0     
...

pkg/storage/driver/secrets.go

func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) {
	lsel := kblabels.Set{"owner": "helm"}.AsSelector()
	opts := metav1.ListOptions{LabelSelector: lsel.String()}

	secrets.Log("secret list begin %v", time.Now())
	list, err := secrets.impl.List(context.Background(), opts)
	secrets.Log("secret list end %v",time.Now())
	if err != nil {
		return nil, errors.Wrap(err, "list: failed to list")
	}

	var results []*rspb.Release

	// iterate over the secrets object list
	// and decode each release
	secrets.Log("secret decode begin %v",time.Now())
	for _, item := range list.Items {
		rls, err := decodeRelease(string(item.Data["release"]))
		if err != nil {
			secrets.Log("list: failed to decode release: %v: %s", item, err)
			continue
		}
		if filter(rls) {
			results = append(results, rls)
		}
	}
	secrets.Log("secret decode end %v",time.Now())
	return results, nil
}

The query time cost is really too high, especially we adopt the helm pkg as go sdk module in our projects, it's intolerable。

the following code runs costing too much time, which is a implementation in client-go module

list, err := secrets.impl.List(context.Background(), opts)

Activity

  1. technosophos commented on Apr 27, 2020

    @technosophos
    Member

    You left your cloud provider blank. What Kubernetes provider are you using? Querying is a server-side (Kubernetes API) operation. Helm merely sends the request and gets the response back. So you might be able to tune your Kubernetes API server.

    You can also test with kubectl by passing the same list of filters.

  2. liuming-dev commented on Apr 28, 2020

    @liuming-dev
    ContributorAuthor

    You left your cloud provider blank. What Kubernetes provider are you using? Querying is a server-side (Kubernetes API) operation. Helm merely sends the request and gets the response back. So you might be able to tune your Kubernetes API server.

    You can also test with kubectl by passing the same list of filters.

    it's my company's private cloud infrastructure, and kubectl costs about 2~3s

    ~/.kube » kubectl --kubeconfig ~/.kube/pre -n bizqa get secret
    
  3. github-actions commented on Aug 21, 2020

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  4. bridgetkromhout commented on Sep 19, 2020

    @bridgetkromhout
    Member

    Hi, @liuming-dev - as mentioned above, querying is a server-side (Kubernetes API) operation; Helm sends the request and gets the response back. We suggest opening an issue with your Kubernetes service provider's infrastructure team, as they may be able to offer ideas for tuning. We'll resolve this issue at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions