kube-prometheus icon indicating copy to clipboard operation
kube-prometheus copied to clipboard

RUNTIME ERROR: couldn't open import "kube-prometheus/main.libsonnet": no match locally or in the Jsonnet library path

Open rupang790 opened this issue 4 years ago • 8 comments

What happened? I was trying to install kube-prometheus with customizing about Thanos-sidecar. I followed docs https://github.com/prometheus-operator/kube-prometheus#customizing-kube-prometheus but there was some error when I execute build.sh with jsonnet.

I already searched closed issue about same as my error, but I could not find solutions. Do you have any idea about this to solve?

+ set -o pipefail
++ pwd
+ PATH=/root/my-kube-prometheus/tmp/bin:/opt/rh/devtoolset-7/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin:/usr/local/go/bin:/bin:/root/.krew/bin:/usr/lib64/python2.7/site-packages:/root/bin:/usr/local/bin:/usr/local/go/bin:/root/go/bin:/root/.krew/bin:/root/go/src/github.com/vcpkg:/root/bin:/usr/local/bin:/usr/local/go/bin:/root/go/bin:/root/.krew/bin:/root/bin:/usr/local/bin:/usr/local/go/bin:/root/go/bin:/root/.krew/bin::/root/bin:/usr/local/bin:/usr/local/go/bin:/root/go/bin:/root/.krew/bin:-/root/jsonnet:/root/bin:/usr/local/bin:/usr/local/go/bin:/root/go/bin:/root/.krew/bin:/root/jsonnet
+ rm -rf manifests
+ mkdir -p manifests/setup
+ jsonnet -J vendor -m manifests thanos-sidecar.jsonnet
+ xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml' -- '{}'
RUNTIME ERROR: couldn't open import "kube-prometheus/main.libsonnet": no match locally or in the Jsonnet library paths
	thanos-sidecar.jsonnet:2:4-43	thunk <kp> from <$>
	thanos-sidecar.jsonnet:21:86-88
	<std>:1293:24-25	thunk from <function <anonymous>>
	<std>:1293:5-33	function <anonymous>
	thanos-sidecar.jsonnet:21:69-104	$
	thanos-sidecar.jsonnet:21:1-106
	thanos-sidecar.jsonnet:21:1-106
	During evaluation

Did you expect to see some different?

How to reproduce it (as minimally and precisely as possible):

$ mkdir my-kube-prometheus
$ cd my-kube-prometheus

$ jb init
$ jb install github.com/prometheus-operator/kube-prometheus/jsonnet/[email protected]
$ wget https://raw.githubusercontent.com/prometheus-operator/kube-prometheus/release-0.7/build.sh -O build.sh
$ jb update

$ go get github.com/brancz/gojsontoyaml

Then I copied Thanos-sidecar.jsonnet from this git.

local kp =
  (import 'kube-prometheus/main.libsonnet') +
  {
    values+:: {
      common+: {
        namespace: 'monitoring',
      },
      prometheus+: {
        thanos: {
          version: '0.19.0',
          image: 'quay.io/thanos/thanos:v0.19.0',
          objectStorageConfig: {
            key: 'thanos.yaml',  // How the file inside the secret is called
            name: 'thanos-objectstorage',  // This is the name of your Kubernetes secret with the config
          },
        },
      },
    },
  };

{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{
  ['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
  for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) }

After that, execute ./build.sh thanos-sidecar.jsonnet

Environment

  • Prometheus Operator version:

    Insert image tag or Git SHA here

  • Kubernetes version information:

    Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.7", GitCommit:"132a687512d7fb058d0f5890f07d4121b3f0a2e2", GitTreeState:"clean", BuildDate:"2021-05-12T12:32:49Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}

  • Kubernetes cluster kind:

    kubeadm

  • Manifests:

insert manifests relevant to the issue
  • Prometheus Operator Logs:
Insert Prometheus Operator logs relevant to the issue here
  • Prometheus Logs:
Insert Prometheus logs relevant to the issue here

Anything else we need to know?:

rupang790 avatar Jul 05 '21 06:07 rupang790

thanos-sidecar.libsonnet is an example on release-0.8 branch and there is no such example for release-0.7. Those branches are incompatible with each other and we have migration guide in https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/migration-guide.md.

couldn't open import "kube-prometheus/main.libsonnet": no match locally or in the Jsonnet library path

release-0.7 do not have main.libsonnet. On that branch similar file is called kube-prometheus.libsonnet.

paulfantom avatar Jul 05 '21 06:07 paulfantom

@paulfantom , I will check again my branch and try again for it. Thanks for mentions.

rupang790 avatar Jul 05 '21 06:07 rupang790

I faced the same error using your examples https://github.com/prometheus-operator/kube-prometheus/blob/main/examples/additional-namespaces.jsonnet after executing ./build.sh additional-namespaces.jsonnet I got RUNTIME ERROR: couldn't open import "kube-prometheus/main.libsonnet": no match locally or in the Jsonnet library path

Also I have tried import "kube-prometheus.libsonnet" and import "kube-prometheus/kube-prometheus.libsonnet". But error still occurs. What's the solution?

Epimetheus84 avatar Jul 29 '21 08:07 Epimetheus84

It might be because you haven't downloaded the jsonnet dependencies. Could you try running make vendor before building the manifests?

Following the installation documentation should also help you: https://github.com/prometheus-operator/kube-prometheus#installing. Note that it is required to do the installation before compiling.

dgrisonnet avatar Jul 29 '21 09:07 dgrisonnet

@dgrisonnet, Yes, I dowloaded dependencies using jb init & jb install github.com/prometheus-operator/kube-prometheus/jsonnet/[email protected] I have this vendor structure

d-----        29.07.2021     12:22                github.com
-a---l        29.07.2021     12:22              0 alertmanager
-a---l        29.07.2021     12:22              0 grafana
-a---l        29.07.2021     12:22              0 grafana-builder
-a---l        29.07.2021     12:22              0 grafonnet
-a---l        29.07.2021     12:22              0 kube-prometheus
-a---l        29.07.2021     12:22              0 kube-state-metrics
-a---l        29.07.2021     12:22              0 kube-state-metrics-mixin
-a---l        29.07.2021     12:22              0 kubernetes-mixin
-a---l        29.07.2021     12:22              0 mixin
-a---l        29.07.2021     12:22              0 node-mixin
-a---l        29.07.2021     12:22              0 prometheus
-a---l        29.07.2021     12:22              0 prometheus-operator
-a---l        29.07.2021     12:22              0 promgrafonnet

make vendor says "make: Nothing to be done for 'vendor'."

Epimetheus84 avatar Jul 29 '21 09:07 Epimetheus84

Since your bug seems different than the original one reported in this issue, would you mind opening another bug?

dgrisonnet avatar Jul 29 '21 10:07 dgrisonnet

sure

Epimetheus84 avatar Jul 29 '21 12:07 Epimetheus84

This issue has been automatically marked as stale because it has not had any activity in the last 60 days. Thank you for your contributions.

github-actions[bot] avatar Nov 08 '21 02:11 github-actions[bot]

This issue was closed because it has not had any activity in the last 120 days. Please reopen if you feel this is still valid.

github-actions[bot] avatar Jan 14 '23 03:01 github-actions[bot]