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

Input packages for oci_image_build are not included as dependencies for the target #79

Open
jgranstrom opened this issue May 11, 2024 · 3 comments
Labels
t: bug Something isn't working

Comments

@jgranstrom
Copy link

oci_image_build targets do not include their input/packages targets as dependencies.

Example:

oci_image_build(
    name="image",
    args=[
        "-jar",
        "/src.app1/app1Jar.jar",
    ],
    base=[":arm64"],
    entrypoint="java",
    packages=[":app1Jar"],
    tag="latest",
)
❯ pants dependencies src/app1:image
src/app1:arm64

They are only visible in packages_raw. Only base images are part of dependencies.

❯ pants peek src/app1:image
[
  {
    "address": "src/app1:image",
    "target_type": "oci_image_build",
    "args": [
      "-jar",
      "/src.app1/app1Jar.jar"
    ],
    "base": [
      ":arm64"
    ],
    "commands": null,
    "dependencies": [
      "src/app1:arm64"
    ],
    "description": null,
    "entrypoint": "java",
    "env": null,
    "layers_raw": null,
    "output_path": null,
    "packages_raw": [
      ":app1Jar"
    ],
    "repository": null,
    "tag": "latest",
    "tags": null,
    "terminal": false
  }
]

Is this intended? It makes it difficult for anything targeting the oci_image to know when it needs to run.

@jgranstrom jgranstrom added the t: bug Something isn't working label May 11, 2024
@jgranstrom
Copy link
Author

jgranstrom commented May 11, 2024

It's the same in the examples in this repo:

pants-backends main
 ❯ pants dependencies //examples/oci:oci
examples/oci:python3-d11#latest

 ❯ pants peek //examples/oci:oci
[
  {
    "address": "examples/oci:oci",
    "target_type": "oci_image_build",
    "args": null,
    "base": [
      ":python3-d11#latest"
    ],
    "commands": null,
    "dependencies": [
      "examples/oci:python3-d11#latest"
    ],
    "description": null,
    "entrypoint": null,
    "env": null,
    "layers_raw": null,
    "output_path": null,
    "packages_raw": [
      ":example"
    ],
    "repository": "harbor.sbg.dev/test/pants-plugin-oci-example",
    "tag": "latest",
    "tags": null,
    "terminal": false
  }
]

How does it know when it needs to rebuild the image when the pex is rebuilt? Do you pick that out manually, or just run everything?

@tgolsson
Copy link
Owner

Hmm, interesting! I think this is mostly a display issue, will have to look more closely. Pants makes some assumptions about fields being (somewhat) unique -- in particular, that there is only one Dependencies field etc. Some of my targets have two, because I think the UX of a separate field for the "base" image is preferrable. I've not noticed any adverse effects in practice, but I hadn't considered this aspect.

@jgranstrom
Copy link
Author

Hmm, interesting! I think this is mostly a display issue, will have to look more closely. Pants makes some assumptions about fields being (somewhat) unique -- in particular, that there is only one Dependencies field etc. Some of my targets have two, because I think the UX of a separate field for the "base" image is preferrable. I've not noticed any adverse effects in practice, but I hadn't considered this aspect.

FYI I worked around this for my case by using oci_layer, putting the packages in there and adding that instead to oci_image_build, then everything behaves as expected with dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants