Skip to content

Duplicate log messages #449

Closed
Closed

Description

@dubo-dubon-duponey

This will naturally run only once ("echo LOL" one time):

foo: #up: [
    op.#DockerBuild & {
        dockerfile: """
            FROM dubodubonduponey/debian
            ARG TARGETPLATFORM
            RUN echo LOL $TARGETPLATFORM
        """
    },
]

This will run twice (echo LOL multiple times):

foo: #up: [
    op.#DockerBuild & {
        dockerfile: """
            FROM dubodubonduponey/debian
            ARG TARGETPLATFORM
            RUN echo LOL $TARGETPLATFORM
        """
    },
    op.#PushContainer & {
        ref: "push-registry.local/dagger/test:1"
    },
]

If you add DockerLogin before, it runs once more.

Activity

  1. aluzzardi commented on Jun 7, 2021

    @aluzzardi
    Contributor

    Possibly (hopefully) a duplicate of #495

    Assigning to @samalba for triaging

  2. added this to the beta milestone on Jun 7, 2021
  3. added
    kind/bug
    on Jun 7, 2021
  4. modified the milestones: v0.1.0, on Jun 8, 2021
  5. samalba commented on Jun 22, 2021

    @samalba
    Contributor

    I confirm this is still open

  6. modified the milestones: , v0.1.0 on Jun 22, 2021
  7. modified the milestones: v0.1.0, on Jan 7, 2022
  8. 13 remaining items

  9. grouville commented on Feb 4, 2022

    @grouville
    Member

    Ok, so after narrowing down the issue. I think that the deduplication issue is fixed. In a sense that this is not the case anymore when building such definition.

    Below, I dagger query the last action in my pipeline.
    It only shows this cue subtree, no other part of the DAG has been copied inside.

    debug-449 dagger query |jq .actions.pushedImage
    {
      "$dagger": {
        "task": {}
      },
      "auth": {
        "username": "guilaume1234"
      },
      "config": {},
      "dest": "guilaume1234/test:toto",
      "input": {
        "$dagger": {
          "fs": {}
        }
      }
    }
    

    However, this error is still present: It seems to come from the engine.#Push instruction, which seems to rerun all always: true steps in the constructed fs.

    Here is the gist repo case: https://gist.github.com/grouville/cd313727e6a5a581206af4b2d7ef932b

  10. aluzzardi commented on Feb 24, 2022

    @aluzzardi
    Contributor

    This is because always: true is backed by llb.IgnoreCache(), which only works through a single Build() session (dagger.#Push uses its separate Build() session).

    llb.IgnoreCache() is also breaking #CacheDir when using --no-cache: #1357

    One solution would be to revert #331 (/cc @samalba) and go back to the DAGGER_CACHEBUSTER method. I think since we're not embedding CUE anymore, this will work.

    The problem we had before was this:

    foo: #up: [
      op.Exec & { always: true }
    ]
    
    bar: #up [
      op.Exec & { mount: "/xxx": foo }
    ]
    
    • foo.#up[0] would inject DAGGER_CACHEBUSTER with value YYY
    • bar.#up[0].mount["/foo"].#up[0] would appear as a new "task", and inject DAGGER_CACHEBUSTER with value ZZZ

    Therefore the always: true would run twice.

    AFAIK, with Europa and the lack of embedding, this problem won't happen anymore (e.g. we'd mount the foo.output dagger.#FS into bar, and therefore won't be duplicating the task)

    /cc @shykes

  11. grouville commented on Mar 2, 2022

    @grouville
    Member

    This is because always: true is backed by llb.IgnoreCache(), which only works through a single Build() session (dagger.#Push uses its separate Build() session).

    llb.IgnoreCache() is also breaking #CacheDir when using --no-cache: #1357

    One solution would be to revert #331 (/cc @samalba) and go back to the DAGGER_CACHEBUSTER method. I think since we're not embedding CUE anymore, this will work.

    The problem we had before was this:

    foo: #up: [
      op.Exec & { always: true }
    ]
    
    bar: #up [
      op.Exec & { mount: "/xxx": foo }
    ]
    
    • foo.#up[0] would inject DAGGER_CACHEBUSTER with value YYY
    • bar.#up[0].mount["/foo"].#up[0] would appear as a new "task", and inject DAGGER_CACHEBUSTER with value ZZZ

    Therefore the always: true would run twice.

    AFAIK, with Europa and the lack of embedding, this problem won't happen anymore (e.g. we'd mount the foo.output dagger.#FS into bar, and therefore won't be duplicating the task)

    /cc @shykes

    It doesn't seem to work 😢 Here is my repro: https://gist.github.com/grouville/3cea54be3551aa99a229d9fbeed24527
    Test branch: https://github.com/grouville/dagger/tree/always-true

  12. grouville commented on Mar 4, 2022

    @grouville
    Member

    @aluzzardi, I tested with llb.ignoreCache. Exactly the same behavior as with DAGGER_CACHEBUSTER method: https://gist.github.com/grouville/f86244771969f3428a077b7a9eff562d

    Next steps
    With @TomChv's advice. I will try to separate the main build logs from the sub build [== dagger.#Push] logs.
    Guessed root cause: we s.opts.Control.Build with a new session. Buildkit triggers the cache, but with another session and print the corresponding cached output without re-executing. Weird, but highly probable.
    I don't know wether a repro in pure buildkit is an obligation atm. wdyt ?

    There is still < 0.5% of chance that the new session actually runs the print and the duplicate in parallel because echoed commands are not logged as CACHED but DONE.
    I highly doubt it is currently the case, as I ran hundreds of tests and the timing was always similar between first run and followings

  13. grouville commented on Mar 7, 2022

    @grouville
    Member

    I confirm once again that this is just a log issue. It works as expected, apart from that reprinting.
    I don't know the root cause yet (wether it's related to us or to buildkit, currently implenting a more in-depth repro case). At least, it's a contained issue @aluzzardi, and Europa did solve the previous related ones.

    Repro: https://gist.github.com/grouville/a9133208c9851932a4c2e1d6de72a748
    Basically, we see that the random waits are the same, even in the dagger.#Push step (which is a new Build). If I was being re-executed, it would be a different one + the sleep time are coherent with the expected behavior

  14. modified the milestones: v0.2.0-beta.1, on Mar 24, 2022
  15. changed the title [-]DockerBuild runs many times when it should run once[/-] [+]Duplicate log messages[/+] on Apr 8, 2022
  16. shykes commented on Apr 8, 2022

    @shykes
    Contributor

    I renamed the issue to reflect your latest findings @grouville . Does this duplicate logging occur for any core actions, or only a subset?

    Also: perhaps we should close this and create a new issue for the narrower scope you understood. There is a lot of discussion from last year in this issue, that is obsolete.

  17. sipsma commented on Apr 20, 2022

    @sipsma
    Contributor

    Took a look and believe I figured out what was going on. I think this is actually intentional behavior on Buildkit's part.

    We open a separate session in order to Export results (as a workaround for the lack of Export in the Gateway API), but as far as Buildkit knows that's the same as a totally separate client connecting and requesting a build that happens to overlap with an existing on-going build. Buildkit thus tries to be helpful and "backfill" the new client on all the progress so far. That's nice of it but in this case we are actually the same client, so we just end up with a bunch of duplicate progress events.

    I opened an issue w/ Buildkit that has some more details and proposed fixes here. For now, I think the solution of tracking which vertex digests have been completed and skipping logs for those ones is probably the best bet. It's more complicated for us and less performant than the other options, but has the large advantage of not needing upstream changes (and thus waiting for a new Buildkit release).

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

Metadata

Metadata

Assignees

Labels

kind/bugkind/user-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions