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

Imports from Jsonnet library paths are broken #8719

Closed
3 tasks done
maxbrunet opened this issue Mar 8, 2022 · 1 comment · Fixed by #8721
Closed
3 tasks done

Imports from Jsonnet library paths are broken #8719

maxbrunet opened this issue Mar 8, 2022 · 1 comment · Fixed by #8721
Labels
bug Something isn't working cherry-pick/2.2 Candidate for cherry picking into the 2.2 release branch cherry-pick/2.3 Candidate for cherry picking into the 2.3 release branch regression Bug is a regression, should be handled with high priority
Milestone

Comments

@maxbrunet
Copy link
Contributor

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

Imports from Jsonnet library paths have stopped working since version 2.2.6

Manifest generation error (cached): rpc error: code = FailedPrecondition desc = Failed to evaluate jsonnet "main.jsonnet": RUNTIME ERROR: couldn't open import "grafana.libsonnet": no match locally or in the Jsonnet library paths
        .grafana/environments/staging/main.jsonnet:1:11-37      thunk <g> from <$>
        .grafana/environments/staging/main.jsonnet:3:17-18      thunk <grafana> from <$>
        .grafana/environments/staging/main.jsonnet:48:36-43     thunk from <object <anonymous>>
        <std>:1501:24-25        thunk from <function <anonymous>>
        <std>:1501:5-33 function <anonymous>
        .grafana/environments/staging/main.jsonnet:48:19-44     object <anonymous>
        .grafana/environments/staging/main.jsonnet:(46:5)-(51:6)
        Field "items"
        During manifestation

All our Jsonnet-based applications follow a Ksonnet/Tanka-like structure:

.
└── grafana/
    ├── environments/           # Environment-specific resources and overrides
    │   └── staging/
    │       └── main.libsonnet
    ├── lib/                    # Jsonnet libraries
    │   └── grafana.libsonnet
    └── vendor/                 # Third-party libraries
        └── github.com/brancz/kubernetes-grafana/grafana/
            └── grafana.libsonnet

I suspect it to be caused by #8606

To Reproduce

  • Write some Jsonnet with imports from JPath:
mkdir -p jsonnet-imports/environments/staging jsonnet-imports/lib
cat > jsonnet-imports/lib/mylib.libsonnet <<EOF
{
  apiVersion: 'v1',
  kind: 'ConfigMap',
  metadata: {
    name: 'my-config-map',
  },
  data: {},
}
EOF
echo "(import 'mylib.libsonnet')" > jsonnet-imports/environments/staging/main.jsonnet
  • Optionally, test generating with the Jsonnet CLI:
jsonnet -J jsonnet-imports/lib jsonnet-imports/environments/staging/main.jsonnet
  • Create the Application:
REPO_URL='git@bitbucket.org:myworkspace/myrepo.git'
kubectl apply -f - <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: jsonnet-imports
spec:
  destination:
    namespace: default
    server: https://kubernetes.default.svc
  project: default
  source:
    directory:
      jsonnet:
        libs:
        - jsonnet-imports/lib
    path: jsonnet-imports/environments/staging
    repoURL: ${REPO_URL}
    targetRevision: HEAD
EOF

Expected behavior

Jsonnet imports from JPath work and the manifest is generated

Screenshots

Version

v2.2.6+2e550c3

Also affects v2.3.0

Logs

time="2022-03-08T02:28:53Z" level=info msg="manifest error cache hit: &ApplicationSource{RepoURL:git@bitbucket.org:myworkspace/myrepo.git,Path:grafana/environments/staging,TargetRevision:HEAD,Helm:nil,Kustomize:nil,Ksonnet:nil,Directory:&ApplicationSourceDirectory{Recurse:false,Jsonnet:ApplicationSourceJsonnet{ExtVars:[]JsonnetVar{},TLAs:[]JsonnetVar{},Libs:[grafana/vendor grafana/lib],},Exclude:,Include:,},Plugin:nil,Chart:,}/3b76739906d9dc4b7853af361891ec8e5b36b9a3"
time="2022-03-08T02:28:53Z" level=error msg="finished unary call with code Unknown" error="Manifest generation error (cached): rpc error: code = FailedPrecondition desc = Failed to evaluate jsonnet \"main.jsonnet\": RUNTIME ERROR: couldn't open import \"grafana.libsonnet\": no match locally or in the Jsonnet library paths\n\t.grafana/environments/staging/main.jsonnet:1:11-37\tthunk <g> from <$>\n\t.grafana/environments/staging/main.jsonnet:3:17-18\tthunk <grafana> from <$>\n\t.grafana/environments/staging/main.jsonnet:48:36-43\tthunk from <object <anonymous>>\n\t<std>:1501:24-25\tthunk from <function <anonymous>>\n\t<std>:1501:5-33\tfunction <anonymous>\n\t.grafana/environments/staging/main.jsonnet:48:19-44\tobject <anonymous>\n\t.grafana/environments/staging/main.jsonnet:(46:5)-(51:6)\t\n\tField \"items\"\t\n\tDuring manifestation\t\n" grpc.code=Unknown grpc.method=GenerateManifest grpc.request.deadline="2022-03-08T02:30:51Z" grpc.service=repository.RepoServerService grpc.start_time="2022-03-08T02:28:51Z" grpc.time_ms=2419.792 span.kind=server system=grpc
@maxbrunet maxbrunet added the bug Something isn't working label Mar 8, 2022
@alexmt alexmt added this to the v2.3 milestone Mar 8, 2022
@alexmt alexmt added cherry-pick/2.3 Candidate for cherry picking into the 2.3 release branch regression Bug is a regression, should be handled with high priority cherry-pick/2.2 Candidate for cherry picking into the 2.2 release branch labels Mar 8, 2022
@alexmt
Copy link
Collaborator

alexmt commented Mar 8, 2022

Thanks for providing the sample app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cherry-pick/2.2 Candidate for cherry picking into the 2.2 release branch cherry-pick/2.3 Candidate for cherry picking into the 2.3 release branch regression Bug is a regression, should be handled with high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants