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

Make sure FirstPartyHelmDeploymentMapping doesn't get calculated if disabled #21633

Merged
merged 6 commits into from
Nov 12, 2024

Conversation

grihabor
Copy link
Contributor

Option [helm-infer].deployment_dependencies was added in #21282. Unfortunately, I missed one place where FirstPartyHelmDeploymentMapping is requested:

@rule(desc="Prepare Helm deployment post-renderer", level=LogLevel.DEBUG)
async def prepare_post_renderer_for_helm_deployment(
    request: HelmDeploymentPostRendererRequest,
    union_membership: UnionMembership,
    docker_options: DockerOptions,
) -> SetupHelmPostRenderer:
    mapping = await Get(
        FirstPartyHelmDeploymentMapping, FirstPartyHelmDeploymentMappingRequest(request.field_set)
    )
    ...

Here I move this logic inside the rule, so that all consumers correctly handle the case when [helm-infer].deployment_dependencies is set to false

@grihabor grihabor changed the base branch from 2.23.x to main November 12, 2024 14:38
@grihabor grihabor force-pushed the fix-deployment_dependencies-logic branch from c5d97e9 to c11db1b Compare November 12, 2024 14:39
@tdyas tdyas added needs-cherrypick category:bugfix Bug fixes for released features labels Nov 12, 2024
@tdyas tdyas added this to the 2.23.x milestone Nov 12, 2024
Copy link
Contributor

@tdyas tdyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this option benefit from a test of any sort?

@grihabor
Copy link
Contributor Author

grihabor commented Nov 12, 2024

Would this option benefit from a test of any sort?

I'm not sure if there is a good test that can check that we're not doing inference, but I can add one if you suggest how it should work exactly

@tgolsson
Copy link
Contributor

I'm not sure if there is a good test that can check that we're not doing inference, but I can add one if you suggest how it should work exactly

Isn't this the exact same test as for doing inference, except that you the dependency shouldn't exist..?

@tdyas
Copy link
Contributor

tdyas commented Nov 12, 2024

The reason why I'm asking for a test is primarily because this PR fixes a regression. And I generally want tests for regressions since they are failure modes which actually occurred.

The operative question in my view: How do we know that this PR in fact fixed the regression?

How did you account for tracking down all relevant call sites?

A test can provide proof. Or some additional narrative context on testing methodology could be fine as well.

@benjyw
Copy link
Contributor

benjyw commented Nov 12, 2024

@grihabor Are you able to add a test and get this merged today? It is past time to get 2.23.0 out... :)

@grihabor
Copy link
Contributor Author

Isn't this the exact same test as for doing inference, except that you the dependency shouldn't exist..?

If this test existed, it wouldn't have caught this problem, because it wouldn't have tested that we don't calculate FirstPartyHelmDeploymentMapping

@grihabor
Copy link
Contributor Author

The operative question in my view: How do we know that this PR in fact fixed the regression?

I can explain how I noticed there is an issue. I ran this

$ pants experimental-deploy --no-experimental-deploy-publish-dependencies --dry-run :my-deployment

and got the error

UnownedDependencyError: Error resolving Docker image dependency of a Helm chart.
                `my-image:0.1.0` was supplied, but Pants cannot determine
                whether this should be a target's address or a 3rd-party dependency.
                If this should be an external image, add `my-image:0.1.0` to `[helm-infer].external_docker_images`
                If this should be a target address, use an absolute path instead (possibly `//my-image:0.1.0`).

This indirectly means that pants is trying to build FirstPartyHelmDeploymentMapping.

I could add the test that sets [helm-infer].unowned_dependency_behavior = "error" and [helm-infer].deployment_dependencies = false and makes sure there is no error, sounds good?

@tdyas
Copy link
Contributor

tdyas commented Nov 12, 2024

I could add the test that sets [helm-infer].unowned_dependency_behavior = "error" and [helm-infer].deployment_dependencies = false and makes sure there is no error, sounds good?

That works for me.

@grihabor
Copy link
Contributor Author

Done: b8b3d83

PS Notes are probably not required, because there is already a note about the option:

Added [option `[helm-infer].deployment_dependencies`](https://www.pantsbuild.org/2.23/reference/subsystems/helm-infer#deployment_dependencies) to disable costly parsing of k8s manifests.

@tdyas tdyas added the release-notes:not-required PR doesn't require mention in release notes label Nov 12, 2024
@tdyas tdyas merged commit 042cc0a into pantsbuild:main Nov 12, 2024
24 checks passed
@WorkerPants
Copy link
Member

I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants.

✔️ 2.23.x

Successfully opened #21635.


Thanks again for your contributions!

🤖 Beep Boop here's my run link

tdyas pushed a commit to tdyas/pants that referenced this pull request Nov 12, 2024
…isabled (pantsbuild#21633)

Option `[helm-infer].deployment_dependencies` was added in
pantsbuild#21282. Unfortunately, I missed
one place where `FirstPartyHelmDeploymentMapping` is requested:
```python
@rule(desc="Prepare Helm deployment post-renderer", level=LogLevel.DEBUG)
async def prepare_post_renderer_for_helm_deployment(
    request: HelmDeploymentPostRendererRequest,
    union_membership: UnionMembership,
    docker_options: DockerOptions,
) -> SetupHelmPostRenderer:
    mapping = await Get(
        FirstPartyHelmDeploymentMapping, FirstPartyHelmDeploymentMappingRequest(request.field_set)
    )
    ...
```
Here I move this logic inside the rule, so that all consumers correctly
handle the case when `[helm-infer].deployment_dependencies` is set to
`false`
benjyw pushed a commit that referenced this pull request Nov 12, 2024
…isabled (Cherry-pick of #21633) (#21635)

Option `[helm-infer].deployment_dependencies` was added in
#21282. Unfortunately, I missed
one place where `FirstPartyHelmDeploymentMapping` is requested:
```python
@rule(desc="Prepare Helm deployment post-renderer", level=LogLevel.DEBUG)
async def prepare_post_renderer_for_helm_deployment(
    request: HelmDeploymentPostRendererRequest,
    union_membership: UnionMembership,
    docker_options: DockerOptions,
) -> SetupHelmPostRenderer:
    mapping = await Get(
        FirstPartyHelmDeploymentMapping, FirstPartyHelmDeploymentMappingRequest(request.field_set)
    )
    ...
```
Here I move this logic inside the rule, so that all consumers correctly
handle the case when `[helm-infer].deployment_dependencies` is set to
`false`

Co-authored-by: Gregory Borodin <grihabor@gmail.com>
benjyw pushed a commit that referenced this pull request Nov 13, 2024
…isabled (Cherry-pick of #21633) (#21636)

Option `[helm-infer].deployment_dependencies` was added in
#21282. Unfortunately, I missed
one place where `FirstPartyHelmDeploymentMapping` is requested:
```python
@rule(desc="Prepare Helm deployment post-renderer", level=LogLevel.DEBUG)
async def prepare_post_renderer_for_helm_deployment(
    request: HelmDeploymentPostRendererRequest,
    union_membership: UnionMembership,
    docker_options: DockerOptions,
) -> SetupHelmPostRenderer:
    mapping = await Get(
        FirstPartyHelmDeploymentMapping, FirstPartyHelmDeploymentMappingRequest(request.field_set)
    )
    ...
```
Here I move this logic inside the rule, so that all consumers correctly
handle the case when `[helm-infer].deployment_dependencies` is set to
`false`

Co-authored-by: Gregory Borodin <grihabor@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features release-notes:not-required PR doesn't require mention in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants