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

Error in resolving Helm version #144

Closed
dnbstd opened this issue Aug 27, 2020 · 2 comments
Closed

Error in resolving Helm version #144

dnbstd opened this issue Aug 27, 2020 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@dnbstd
Copy link

dnbstd commented Aug 27, 2020

Hello Dev team!

Original Dockerfile from repository with changed kubectl and helm version:

 # build libjq
FROM ubuntu:18.04 AS libjq
ENV DEBIAN_FRONTEND=noninteractive \
    DEBCONF_NONINTERACTIVE_SEEN=true \
    LC_ALL=C.UTF-8 \
    LANG=C.UTF-8

RUN apt-get update && \
    apt-get install -y git ca-certificates && \
    git clone https://github.com/flant/libjq-go /libjq-go && \
    cd /libjq-go && \
    git submodule update --init --recursive && \
    /libjq-go/scripts/install-libjq-dependencies-ubuntu.sh && \
    /libjq-go/scripts/build-libjq-static.sh /libjq-go /libjq


# build addon-operator binary linked with libjq
FROM golang:1.14 AS addon-operator
ARG appVersion=latest

# Cache-friendly download of go dependencies.
ADD go.mod go.sum /addon-operator/
WORKDIR /addon-operator
RUN go mod download

COPY --from=libjq /libjq /libjq
ADD . /addon-operator
WORKDIR /addon-operator

RUN git submodule update --init --recursive && ./go-build.sh $appVersion

FROM krallin/ubuntu-tini:bionic AS tini

# build final image
FROM ubuntu:18.04
RUN apt-get update && \
    apt-get install -y ca-certificates wget jq && \
    rm -rf /var/lib/apt/lists && \
    wget https://storage.googleapis.com/kubernetes-release/release/v1.17.9/bin/linux/amd64/kubectl -O /bin/kubectl && \
    chmod +x /bin/kubectl && \
    wget https://storage.googleapis.com/kubernetes-helm/helm-v2.16.10-linux-amd64.tar.gz -O /helm.tgz && \
    tar -z -x -C /bin -f /helm.tgz --strip-components=1 linux-amd64/helm linux-amd64/tiller && \
    rm -f /helm.tgz && \
    helm init --client-only && \
    mkdir /hooks
COPY --from=tini /usr/local/bin/tini /sbin/tini
COPY --from=addon-operator /addon-operator/addon-operator /
WORKDIR /
ENV MODULES_DIR /modules
ENV GLOBAL_HOOKS_DIR /global-hooks

Addon-operator is recognize Helm version >2.16 as Helm 3

part of log with debug on:

[DEBUG] Executing command 'helm version --short' in '' dir
{INFO] Helm 3 version: Client: v2.16.10+gbceca24 Server: v2.16.10+gbceca24

With this issue we take such error because Addon-operator use module for helm3:

ModuleRun failed. Requeue task to retry after delay. Failed count is 117. Error: helm upgrade failed: exit status 1:
 Error: stat prometheus-operator: no such file or directory  binding=ReloadAllModules event.type=OperatorStartup module=prometheus-operator module.state=failed operator.component=taskRunner queue=main task.id=5c3f5e9b-62fb-4760-9b5b-7d6c4def1974

Resolve this issue by changes in code of module helm.go (hot solution,not better):

func Init(client kube.KubernetesClient) error {

	HelmVer := os.Getenv("HELM_CLIENT_VERSION")

	if HelmVer == "3" {
		// Try helm3 first
		err := helm3.Init(&helm3.Helm3Options{
			Namespace:  app.Namespace,
			HistoryMax: app.Helm3HistoryMax,
			Timeout:    app.Helm3Timeout,
			KubeClient: client,
		})
		if err == nil {
			NewClient = helm3.NewClient
			return nil
		}
	}
	// Fallback to helm2
	// TODO make tiller cancelable
	err := helm2.InitTillerProcess(helm2.TillerOptions{
		Namespace:          app.Namespace,
		HistoryMax:         app.TillerMaxHistory,
		ListenAddress:      app.TillerListenAddress,
		ListenPort:         app.TillerListenPort,
		ProbeListenAddress: app.TillerProbeListenAddress,
		ProbeListenPort:    app.TillerProbeListenPort,
	})
	if err != nil {
		return fmt.Errorf("init tiller: %s", err)
	}

	// Initialize helm2 client
	err = helm2.Init(&helm2.Helm2Options{
		Namespace:  app.Namespace,
		KubeClient: client,
	})
	if err != nil {
		return fmt.Errorf("init helm client: %s", err)
	}
	NewClient = helm2.NewClient
	HealthzHandler = helm2.TillerHealthHandler()
	return nil
}
@diafour diafour added the bug Something isn't working label Aug 28, 2020
@diafour diafour self-assigned this Aug 28, 2020
@diafour
Copy link
Contributor

diafour commented Aug 28, 2020

Thank you for the detailed bug report!
As I can see, the naive "autodetection" of the Helm version is totally broken, so the Addon-operator now works only with Helm3. I'll fix this next week.

@diafour diafour added this to the 1.0.0-beta.7 milestone Nov 27, 2020
@diafour
Copy link
Contributor

diafour commented Nov 27, 2020

Meanwhile, fixed in #147.

@shurup shurup closed this as completed Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants