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

Support parallel BUILD within a FOR loop #4138

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexcb
Copy link
Contributor

@alexcb alexcb commented May 21, 2024

No description provided.

@alexcb alexcb force-pushed the acb/parallel-build-within-for-loop branch from 2890f2d to 19f81f7 Compare May 21, 2024 20:20
@alexcb
Copy link
Contributor Author

alexcb commented May 21, 2024

One thing that's off with this PR is the final output shows some duplicate BUILD +test-executor output at the end of the build. Here's a complete example:

consider the Earthfile:

VERSION 0.8

FROM earthly/dind:alpine

# this sequentially
test-parallel-for:
     BUILD +parallel

parallel:
    FOR num IN $(seq 5)
        BUILD +test-executor --PROJECT=$num
    END

test-executor:
    ARG PROJECT

    WITH DOCKER
        RUN --no-cache for i in 1 2 3 4; do echo "i=$i PROJECT=$PROJECT" && sleep 1; done; echo bye
    END

example run:

$ ./build/linux/amd64/earthly -P ~/test/with-docker-parallel+test-parallel-for 
 Init 🚀
————————————————————————————————————————————————————————————————————————————————

           buildkitd | Found buildkit daemon as docker container (earthly-dev-buildkitd)

Streaming logs to https://cloud.earthly.dev/builds/b8f686f5-2b5f-4321-a962-ed3fa813fd5d

 Build 🔧
————————————————————————————————————————————————————————————————————————————————

              logbus | Setting organization "" and project ""
/h/a/t/with-docker-parallel+test-parallel-for | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+test-parallel-for | --> FROM +base
 earthly/dind:alpine | --> Load metadata earthly/dind:alpine linux/amd64
/h/a/t/with-docker-parallel+test-parallel-for | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+test-parallel-for | --> BUILD +parallel
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> FROM +base
/h/a/t/with-docker-parallel+base | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+base | --> FROM earthly/dind:alpine
/h/a/t/with-docker-parallel+base | [----------] 100% FROM earthly/dind:alpine
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | *cached* --> mkdir /run/buildargs
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | *cached* --> FOR $(seq 5)
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=1
/h/a/t/with-docker-parallel+test-executor | --> FROM +base
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> BUILD +test-executor
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=3
/h/a/t/with-docker-parallel+test-executor | --> FROM +base
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=2
/h/a/t/with-docker-parallel+test-executor | --> FROM +base
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=4
/h/a/t/with-docker-parallel+test-executor | --> FROM +base
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=5
/h/a/t/with-docker-parallel+test-executor | --> FROM +base
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=1
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=4
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=2
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=3
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=5
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=1
/h/a/t/with-docker-parallel+test-executor | *cached* --> WITH DOCKER (install deps)
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=2
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN --privileged --no-cache for i in 1 2 3 4; do echo "i=$i PROJECT=$PROJECT" && sleep 1; done; echo bye
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=1
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN --privileged --no-cache for i in 1 2 3 4; do echo "i=$i PROJECT=$PROJECT" && sleep 1; done; echo bye
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=4
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN --privileged --no-cache for i in 1 2 3 4; do echo "i=$i PROJECT=$PROJECT" && sleep 1; done; echo bye
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=5
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN --privileged --no-cache for i in 1 2 3 4; do echo "i=$i PROJECT=$PROJECT" && sleep 1; done; echo bye
/h/a/t/with-docker-parallel+test-executor | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true PROJECT=3
/h/a/t/with-docker-parallel+test-executor | --> WITH DOCKER RUN --privileged --no-cache for i in 1 2 3 4; do echo "i=$i PROJECT=$PROJECT" && sleep 1; done; echo bye
/h/a/t/with-docker-parallel+test-executor | Starting dockerd with data root /var/earthly/dind/71f91fed70b5fcc883572f7a61778b00c4ea0cb762f6fd2eefaf6e311b855616/tmp.BeNehE
/h/a/t/with-docker-parallel+test-executor | Starting dockerd with data root /var/earthly/dind/00186b06f9bab75d529909a03ad99a1a343aa955300fb563ea3919b283121dbc/tmp.nomckE
/h/a/t/with-docker-parallel+test-executor | Starting dockerd with data root /var/earthly/dind/e17b17d9bce2adbb5776039189bcfb0ec34a7d98d5bffbe4fa7ba1f32b0f5fe7/tmp.mGFhnE
/h/a/t/with-docker-parallel+test-executor | Starting dockerd with data root /var/earthly/dind/f778f165beb24e8f619f110cee7ce43ed9560292abd77f93f96d8539590a605a/tmp.MlajBF
/h/a/t/with-docker-parallel+test-executor | Starting dockerd with data root /var/earthly/dind/2f06b21ab2493864900561183fa9f0eaaf20a9bc8df777d7ca9d5eaa7932e3f8/tmp.iNFIKF
/h/a/t/with-docker-parallel+test-executor | i=1 PROJECT=4
/h/a/t/with-docker-parallel+test-executor | i=1 PROJECT=3
/h/a/t/with-docker-parallel+test-executor | i=1 PROJECT=1
/h/a/t/with-docker-parallel+test-executor | i=1 PROJECT=2
/h/a/t/with-docker-parallel+test-executor | i=1 PROJECT=5
/h/a/t/with-docker-parallel+test-executor | i=2 PROJECT=4
/h/a/t/with-docker-parallel+test-executor | i=2 PROJECT=3
/h/a/t/with-docker-parallel+test-executor | i=2 PROJECT=1
/h/a/t/with-docker-parallel+test-executor | i=2 PROJECT=2
/h/a/t/with-docker-parallel+test-executor | i=2 PROJECT=5
/h/a/t/with-docker-parallel+test-executor | i=3 PROJECT=4
/h/a/t/with-docker-parallel+test-executor | i=3 PROJECT=3
/h/a/t/with-docker-parallel+test-executor | i=3 PROJECT=1
/h/a/t/with-docker-parallel+test-executor | i=3 PROJECT=2
/h/a/t/with-docker-parallel+test-executor | i=3 PROJECT=5
/h/a/t/with-docker-parallel+test-executor | i=4 PROJECT=4
/h/a/t/with-docker-parallel+test-executor | i=4 PROJECT=3
/h/a/t/with-docker-parallel+test-executor | i=4 PROJECT=1
/h/a/t/with-docker-parallel+test-executor | i=4 PROJECT=2
/h/a/t/with-docker-parallel+test-executor | i=4 PROJECT=5
/h/a/t/with-docker-parallel+test-executor | bye
/h/a/t/with-docker-parallel+test-executor | bye
/h/a/t/with-docker-parallel+test-executor | bye
/h/a/t/with-docker-parallel+test-executor | bye
/h/a/t/with-docker-parallel+test-executor | bye
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> BUILD +test-executor
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> BUILD +test-executor
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> BUILD +test-executor
/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> BUILD +test-executor

What's with the final

/h/a/t/with-docker-parallel+parallel | DOCKERHUB_MIRROR_AUTH_FROM_CLOUD_SECRETS=true
/h/a/t/with-docker-parallel+parallel | --> BUILD +test-executor

that's repeated 5 times -- I suspect it's related to the way the for _, async, in range []{true, false} causes a duplicate build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant