Skip to content

✨ Add ability to drop-into a shell at any moment of the CI process #2197

Closed

Description

@marcosnils

What are you trying to do?

Early versions of Docker allowed execing into intermediate build steps since intermediate images were generated and spawning a container with any of these images was extremely useful for troubleshooting productivity. Since docker (and also dagger) are using buildkit, this UX has been lost and the current way people are working around this now is commenting out part of their build pipeline only export the end result into an image and then execing into that.

It'd be awesome if Dagger could bring this UX back and allow users to drop-into a shell with the corresponding mounts and FS before or after an action execution.

cc @sipsma

Why is this important to you?

It'll improve the CI troubleshooting experience drastically to understand why some actions sometimes fail due to missing files or confusions about filesystem and mounts locations.

How are you currently working around this?

By manually commenting out part of the plan execution and exporting the resulting output to a docker image that I can exec afterwards. In some cases, I have to additionally add a step to install a shell since some Dagger plans don't have one.

Activity

  1. jpadams commented on Apr 14, 2022

    @jpadams
    Contributor
  2. sipsma commented on Apr 14, 2022

    @sipsma
    Contributor

    There's a lot of features in Buildkit that will make the implementation for this much more tractable:

    1. You can start ephemeral containers with the NewContainer API in Buildkit that support the same basic features of any ExecOp but also things like hooking up a TTY from the client
    2. Though not well documented, if an Exec fails partway through running, you can grab the changed filesystem state and open a shell up to look around and try commands: https://gist.github.com/hinshun/e72f509121e022bc81ebba03fc2851c6

    The only issue I can think of is that the ability to inspect failed exec fs state only lasts for the duration of the current client session; after the client session is closed that fs state is thrown away. This means you couldn't open a shell using the failed state from like 3 runs ago in your CI as @aluzzardi mentioned. However, if we wanted that ability I don't think it's a huge project to add to Buildkit.


    In terms of how Dagger exposes this to users, the first thought off the top of my head is that we could add two flags to dagger do that support:

    1. The ability to just open a shell at whatever your action is targeting (--shell?).
    2. The ability to open a debug shell if there is a failure at an Exec (--shell-on-failure?).

    One issue is that not all Execs actually have a shell present (i.e. distroless-like images), so an additional feature we could consider layering on top of the more basic ones is the ability to mount the fs state you want to inspect somewhere on a "debug fs state" that has a shell (and maybe other debugging tools). This would require the ability to specify what the debug state should be, would have to think about clean ways of approaching that. This is more advanced though obviously, not P0.

  3. sipsma commented on Apr 14, 2022

    @sipsma
    Contributor

    Also, in terms of implementation, this issue is related to a few others that involve long-running async tasks (a category that debug shells fall under I think):

  4. marcosnils commented on Jan 3, 2023

    @marcosnils
    ContributorAuthor

    closing in favor of #3024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions