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

while installing kube-prometheus-stack helmchart on k8s, for loop in the RESTMappings method seems to run indefinitely #12957

Open
Fenil-Patelll opened this issue Apr 17, 2024 · 4 comments

Comments

@Fenil-Patelll
Copy link

Fenil-Patelll commented Apr 17, 2024

I am using Helm APIs to install helm charts on the Kubernetes cluster. while installing kube-Prometheus-stack, I found out that the RESTMappings method ran indefinitely even though there were a fixed amount of array elements inside it.

RESTMapper Source Code :- https://github.com/kubernetes/apimachinery/blob/e696ec55a32e2177cd5f2fe1ded91d9485aa5c64/pkg/api/meta/multirestmapper.go#L191

Note:- the issue only occurs when we don't have the required credentials(secrets)[I doubt it is due to missing kube-Prometheus-admission credentials ] available on the cluster and installing the kube-Prometheus-stack chart for the first time.

If we have the credentials(secrets) the RESTMappings method does not run indefinitely & installation works without any error.

Screenshot 2024-04-17 at 12 46 15 PM

Output of helm version:
Could not see any logs in helm, as the loop runs indefinitely

Cloud Provider/Platform (AKS, GKE, Minikube etc.):
Local Kubernetes cluster running

Some Related thread for this error
prometheus-community/helm-charts#3187
prometheus-community/helm-charts#3370
https://stackoverflow.com/questions/75890673/helm-kube-prometheus-stack-stuck-in-pending-install

@fyrnaga
Copy link

fyrnaga commented Apr 17, 2024

From what we gather it seems to happen when only there is a helm chart using Kubernetes CRDs which are not installed. It keeps looping without any error being returned

@gjenkins8
Copy link
Contributor

can you please repeat with --debug flag, and see if anything useful is returned. And for brevity, provide commands how to replicate

@Fenil-Patelll
Copy link
Author

@fyrnaga

@fyrnaga
Copy link

fyrnaga commented May 1, 2024

@gjenkins8 To explain a bit more, we have a client app called helmet to wrap helm calls over http. This allows use to do helm installation on Kubernetes cluster through our app using that client.

Right now, the problem occurs if we have an empty kubernetes cluster (like a docker one locally) without anything. When we try to install either

  • traefik/traefik
    or
  • prometheus-community/kube-Prometheus-stack
    it is hanging in the Run command.

We did a debugging session in visual studio and it is looping almost infinitely when the custom CRDs are not installed.

There is the code sample. It is hanging in the Run command.

type installRequest struct {
	baseRequest
	DryRun      bool                   `json:"dryRun,omitempty"`
	Chart       string                 `json:"chart"`
	Version     string                 `json:"version"`
	RepoURL     string                 `json:"repositoryUrl"`
	ReleaseName string                 `json:"releaseName"`
	Values      map[string]interface{} `json:"values,omitempty"`
}

// InstallChart attempts to execute a Helm release on the target
// Kubernetes server with the values supplied in the request body
func InstallChart(r *http.Request) response.APIResponse {

	req := new(installRequest)
	if validateReq := validateRequest(r, req); validateReq != nil {
		return validateReq
	}

	namespace := mux.Vars(r)["namespace"]
	actionConfig, apiErr := req.InitActionConfig(namespace)
	if apiErr != nil {
		return apiErr
	}

	installClient := action.NewInstall(actionConfig)
	installClient.DryRun = req.DryRun
	installClient.ReleaseName = req.ReleaseName
	installClient.Namespace = namespace

	// creates new environmentSettings objects, if no environment
	// variables are found it pre-populates with defaults
	settings := cli.New()
	installClient.ChartPathOptions.RepoURL = req.RepoURL
	installClient.ChartPathOptions.Version = req.Version

	cp, err := installClient.ChartPathOptions.LocateChart(req.Chart, settings)
	if err != nil {
		return response.FailureResponseWithContext(404, response.ErrNotFound, map[string]string{"chart": req.Chart}, err)
	}

	loadedChart, err := loader.Load(cp)
	if err != nil {
		return response.FailureResponse(500, response.ErrUnexpected, err)

	}
	rel, err := installClient.Run(loadedChart, req.Values)
	if err != nil {
		// In the event of an error during the install step we return the error message in the context map as is, this is a because
		// these are always printed in the CLI tool and give the user important feedback about why the failure occured
		return response.FailureResponseWithContext(500, response.ErrUnexpected, map[string]string{"message": err.Error()}, err)
	}
	return response.SuccessResponse(200, rel)
}

There are the http call values received. We are using for either chart the default value file that is provided.
image

I tried to have the debug flag enabled but it didn't added anything.

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

No branches or pull requests

3 participants