Hi Everyone ! How can I configure Pants to use my ...
# general
f
Hi Everyone ! How can I configure Pants to use my private helm registry on Gitlab ? I haven't been able to make it work yet. I've got the following
helm_artifact
and
helm_deployment
defined:
Copy code
helm_artifact(
    name="myapp",
    artifact="myapp",
    version="0.1.3",
    repository="<https://gitlab.com/api/v4/projects/{REDACTED_PROJECT_ID}/packages/helm/stable>"
)

helm_deployment(
    name="staging",
    chart=":myapp",
    values={
        "image.tag": "xxxx-mytag",
        "postgres.password": f"{env('RDS_PASSWORD')}",
    },
    release_name="myapp",
    namespace="default",
)
But I can't get past this error when running
pants package ::
in Gitlab CI:
Copy code
Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/bin/pants", line 8, in <module>
    sys.exit(main())
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 112, in main
    PantsLoader.main()
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 108, in main
    cls.run_default_entrypoint()
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/bin/pants_loader.py", line 91, in run_default_entrypoint
    exit_code = runner.run(start_time)
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/bin/pants_runner.py", line 142, in run
    runner = LocalPantsRunner.create(
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 153, in create
    specs = calculate_specs(
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/init/specs_calculator.py", line 75, in calculate_specs
    (changed_addresses,) = session.product_request(
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 582, in product_request
    return self.execute(request)
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 523, in execute
    self._raise_on_error([t for _, t in throws])
  File "/root/.cache/nce/f60c448851c3b3112b179a56f168ee90d8597297cfc45d3ca7178c6715f6cba8/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 507, in _raise_on_error
    raise ExecutionError(
Exception message: 1 Exception encountered:
ProcessExecutionFailure: Process 'Pulling Helm Chart 'myapp' with version 0.1.3.' failed with exit code 1.
stdout:
stderr:
Error: looks like "<https://gitlab.com/api/v4/projects/{REDACTED_PROJECT_ID}/packages/helm/stable>" is not a valid chart repository or cannot be reached: failed to fetch <https://gitlab.com/api/v4/projects/{REDACTED_PROJECT_ID}/packages/helm/stable/index.yaml> : 401 Unauthorized
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
NoneType: None
FATAL: exception not rethrown
I tried to login using
helm repo add
(which is working), but still can't get pants to use credentials. What am I missing ?
c
Hi! you likely need to explicitly tell pants which env vars to use. prob using this setting: https://www.pantsbuild.org/2.19/reference/subsystems/helm#extra_env_vars
f
Well, after you message I tried but with no success. I even made sure to run
export $(helm env)
to make sure variables where set (path to conf etc.)
c
usually playing with the commands directly, and comparing that to what pants does may be helpful. If run with
pants --keep-sandboxes=always
it logs all sandboxes used, and in there is a
__run.sh
which you can run to emulate what pants does. Comparing that to running the commands directly in your own env and narrowing down what the differences are..
f
Thanks for the info Andreas, I'll have a look !