https://pantsbuild.org/ logo
n

narrow-judge-15725

08/11/2022, 12:24 PM
hi everyone. i have a question about the helm backend and dependency inference. 🧵
in the documentation it states for it to work one just needs to add a
source_root
. my setup is something like: pants.toml
Copy code
...
[source]
root_patterns = [
    "src/infrastructure/helm-charts/*"
]
...
src/infrastructure/helm-charts/base/Chart.yaml
Copy code
apiVersion: v2
description: Common utilities for helm charts
name: base
version: 1.0.0
src/infrastructure/helm=charts/core/Chart.yaml
Copy code
apiVersion: v2
description: Core dependencies for any kubernetes cluster
name: core
version: 1.0.0

dependencies:
- name: base
Each folder has the build file which tailor generated correctly. As per the documentation this should be sufficient for the base dependency to be discovered from core. But:
Copy code
./pants dependencies src/infrastructure/helm-charts/core
Returns nothing
What am i missing? Thanks in advance!
h

happy-kitchen-89482

08/11/2022, 1:29 PM
Just a guess, but what happens if you make your source root
src/infrastructure/helm-charts
(without the
*
)?
Setting the root to
src/infrastructure/helm-charts/*
means that every folder under
helm-charts
is a separate root, which is probably not what you intended?
👍 1
n

narrow-judge-15725

08/11/2022, 3:30 PM
oh, i see. then i got confused by the documentation
unfortunately i get the same result after changing this 😞
Copy code
[source]
root_patterns = [
  "pants-plugins",
  "src/infrastructure/helm-charts"
]
Screenshot 2022-08-11 at 17.35.41.png
that’s my folder structure. service should depend on base.
Copy code
apiVersion: v2
name: service
description: Deploys a microservice application
version: 1.0.0
dependencies:
  - name: base
i was trying to follow this part.
h

happy-kitchen-89482

08/11/2022, 5:08 PM
cc @witty-family-13337 - I think you’re best placed to help out here?
w

witty-family-13337

08/11/2022, 5:10 PM
your source root pattern should be,
src/infrastructure/helm-charts/*
h

hundreds-father-404

08/11/2022, 5:11 PM
It sounds like that was their original setting in the top of the thread
w

witty-family-13337

08/11/2022, 5:13 PM
right, sorry, I think I know what is happening
what version of Pants are you using? any chance you could test this with latest SHA from pants’ repo?
the was an oversight issue with previous release in which the dependency inference rules where not registered when enabling the backend
👍 1
it's fixed in
main
and could backport it into 2.13
h

happy-kitchen-89482

08/11/2022, 5:19 PM
So every dir under
src/infrastructure/helm-charts/
should be a root for them? That went against my intuition, so good thing I cc’d you… 🙂
w

witty-family-13337

08/11/2022, 5:20 PM
yeah that's right, in essence, the location of the
Chart.yaml
is the root
👍 1
h

hundreds-father-404

08/11/2022, 5:20 PM
it's fixed in main and could backport it into 2.13
Yeah, I think that'd be helpful given that 2.14 is a few weeks out at lesat
👍 1
w

witty-family-13337

08/11/2022, 5:21 PM
it's a very small fix, so I will get a PR ready
❤️ 1
n

narrow-judge-15725

08/11/2022, 5:38 PM
thanks for the help! this is a fresh repo:
Copy code
pants_version = "2.12.0"
w

witty-family-13337

08/11/2022, 5:39 PM
oh, I see, would need to backport it to 2.12 too
n

narrow-judge-15725

08/11/2022, 5:39 PM
i can try what you need, but 2.12 is what the quickstart script is generating 🙂
i tried with
2.14.0.dev5
and
/*
and it works
Copy code
./pants dependencies src/infrastructure/helm-charts/service
19:42:07.55 [INFO] Initializing scheduler...
19:42:07.86 [INFO] Scheduler initialized.
src/infrastructure/helm-charts/base:base
w

witty-family-13337

08/11/2022, 5:43 PM
great, so it is what I suspected
n

narrow-judge-15725

08/11/2022, 5:43 PM
it also works with
src/infrastructure/helm-charts
as root through 🤔
should there be a difference?
w

witty-family-13337

08/11/2022, 5:43 PM
to resolve dependency it works regardless
n

narrow-judge-15725

08/11/2022, 5:43 PM
if you need a playground i can just share the full thing, it is a fresh repo just with this helm stuff
w

witty-family-13337

08/11/2022, 5:44 PM
but if you don't include the /* then the final chart package will include the root folder inside the tarball
n

narrow-judge-15725

08/11/2022, 5:44 PM
oh, understood 👍
w

witty-family-13337

08/11/2022, 5:44 PM
and that's going to cause issues with other Helm operations
👍 1
I’ll try to get a backport asap, as soon as I get home, I’m at my phone right now, in the middle of a training session 😅
n

narrow-judge-15725

08/11/2022, 5:46 PM
no rush! so then the docs are correct, it was an actual bug correct?
w

witty-family-13337

08/11/2022, 5:47 PM
yup! it's a bug
n

narrow-judge-15725

08/11/2022, 5:47 PM
dope! thanks for the quick help. do you need me to test in other versions or anything else or you already have all you need?
w

witty-family-13337

08/11/2022, 5:48 PM
no worries, it's a 1 line change that I totally overlooked
n

narrow-judge-15725

08/11/2022, 5:48 PM
unrelated question, how would i be able to do
helm template
? i should write my own goal for this or there is already a way?
w

witty-family-13337

08/11/2022, 5:49 PM
no any actual way right now, that would come with 2.14 as it adds support for deployments
if you could describe your use case I can try to make it available
n

narrow-judge-15725

08/11/2022, 5:51 PM
just printing the result, or writing it to a file. might be helpful for debugging
w

witty-family-13337

08/11/2022, 5:51 PM
I was thinking of adding it as part of the
export-codegen
goal
but it may take a while as I stabilise the implementation for supporting deployments
n

narrow-judge-15725

08/11/2022, 5:52 PM
hm, sorry i’m not familiar enough with pants in general. sort of started today.. but maybe it makes sense 😁
w

witty-family-13337

08/11/2022, 5:53 PM
this is because rendering a chart requires some of the machinery that is used in the deployments implementation
n

narrow-judge-15725

08/11/2022, 5:54 PM
is this
deployments
something with the helm implementation or something intended to become some kind of pants primitive? where can i read more about it?
w

witty-family-13337

08/11/2022, 5:56 PM
yeah, that's it
n

narrow-judge-15725

08/11/2022, 5:57 PM
ah i see the doc, so deployment will be a way of grouping templates to values… to do env specific stuff etc no?
then yes, i think some dry run or knowing what might get deployed if you do trigger the new
deploy
goal would be beneficial.
w

witty-family-13337

08/11/2022, 5:58 PM
dry run was another option
I’ll get the backport first, then continue on polishing this deployment support for 2.14
n

narrow-judge-15725

08/11/2022, 6:02 PM
i was somewhat coming from bazel and read this back in the day. i think it is a sensible way of doing things and may serve as inspiration. in short: • rule for rendering. input: chart + values, output: rendered.yaml • rule for deploying. input: the yaml i liked this approach because one can plumb whatever in between. for example the deploy rule could take my own yaml, or one generated by helm, or kustomize, or whatever.
w

witty-family-13337

08/11/2022, 6:07 PM
deployments will come as an experimental feature in 2.14, happy to gather feedback as we roll it out
the implementation right now is based on helm install though
n

narrow-judge-15725

08/11/2022, 6:10 PM
amazing!
w

witty-family-13337

08/12/2022, 7:49 AM
Backports of the fix for chart dependency inference for Pants 2.12 and Pants 2.13: • https://github.com/pantsbuild/pants/pull/16490https://github.com/pantsbuild/pants/pull/16491
n

narrow-judge-15725

08/12/2022, 12:58 PM
thanks for working on this!
👍 1
should this work on
pants_version = "2.12.0"
or not yet?
oh i see GH actions is still working on it
w

witty-family-13337

08/12/2022, 1:16 PM
I guess it will be part of 2.12.1 release
h

happy-kitchen-89482

08/12/2022, 2:10 PM
Yep, we’ll do some point releases soon
maybe even today
For Slack historians, this fix from Alonso gets rid of source root configuration entirely for Helm: https://github.com/pantsbuild/pants/pull/16531
Since we know what the source root has to be (the dir of the Chart.yaml), why force you to configure it? Great work @witty-family-13337!
🙂 2
🙌 2