bollard icon indicating copy to clipboard operation
bollard copied to clipboard

buildkit "no active sessions"

Open JakeCooper opened this issue 2 years ago • 13 comments

Added the Bollard to Nixpacks (https://github.com/railwayapp/nixpacks/pull/709) and having the "no active sessions error"

To test, pull down that branch and run cargo run build ./examples/node

JakeCooper avatar Dec 13 '22 04:12 JakeCooper

Hi... I ran the example and it seemed to build correctly on my machine. The output was:

╔═════════ Nixpacks v0.16.0 ════════╗
║ setup      │ nodejs-16_x, npm-8_x ║
║───────────────────────────────────║
║ install    │ npm ci               ║
║───────────────────────────────────║
║ start      │ npm run start        ║
╚═══════════════════════════════════╝

[+] Building 41.5s (13/13) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                     0.1s
 => => transferring dockerfile: 853B                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                        0.1s
 => => transferring context: 2B                                                                                                                                                          0.0s
 => [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-1670889918                                                                                                           1.6s
 => [internal] load build context                                                                                                                                                        0.1s
 => => transferring context: 2.24kB                                                                                                                                                      0.0s
 => [stage-0 1/8] FROM ghcr.io/railwayapp/nixpacks:debian-1670889918@sha256:fbf7a5f8b650f25fbcbdf5253f90ad4c619616e2e82de15fd17ddac86cd8adf5                                             4.9s
 => => resolve ghcr.io/railwayapp/nixpacks:debian-1670889918@sha256:fbf7a5f8b650f25fbcbdf5253f90ad4c619616e2e82de15fd17ddac86cd8adf5                                                     0.0s
 => => sha256:45a1dbdafa9e87a62f79c9d5c07b671b3d44f3c0875b55188e947cdf48cc3749 953B / 953B                                                                                               0.0s
 => => sha256:2f7aec1d65c4af5c890942e0eb024512c0a24ce07c6dd86b4e7cb8faf75ffcae 3.88kB / 3.88kB                                                                                           0.0s
 => => sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7 31.37MB / 31.37MB                                                                                         1.4s
 => => sha256:a7171fa0f47838ada1b19a4a8e5d943bee420bfd931ff5db29957eb0a508ab36 43.97MB / 43.97MB                                                                                         2.0s
 => => sha256:07da0b6169e483784c1c21705125983a7a018d7bc2fb6319b6e5346b52b56a64 31.52MB / 31.52MB                                                                                         1.9s
 => => sha256:fbf7a5f8b650f25fbcbdf5253f90ad4c619616e2e82de15fd17ddac86cd8adf5 1.05kB / 1.05kB                                                                                           0.0s
 => => extracting sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7                                                                                                0.6s
 => => extracting sha256:a7171fa0f47838ada1b19a4a8e5d943bee420bfd931ff5db29957eb0a508ab36                                                                                                0.9s
 => => extracting sha256:07da0b6169e483784c1c21705125983a7a018d7bc2fb6319b6e5346b52b56a64                                                                                                0.5s
 => [stage-0 2/8] WORKDIR /app/                                                                                                                                                          0.1s
 => [stage-0 3/8] COPY .nixpacks/nixpkgs-a0b7e70db7a55088d3de0cc370a59f9fbcc906c3.nix .nixpacks/nixpkgs-a0b7e70db7a55088d3de0cc370a59f9fbcc906c3.nix                                     0.1s
 => [stage-0 4/8] RUN nix-env -if .nixpacks/nixpkgs-a0b7e70db7a55088d3de0cc370a59f9fbcc906c3.nix && nix-collect-garbage -d                                                              30.1s
 => [stage-0 5/8] RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile                                                                                                     0.4s
 => [stage-0 6/8] COPY . /app/.                                                                                                                                                          0.1s
 => [stage-0 7/8] RUN --mount=type=cache,id=SeR0PZFmMH0-/root/npm,target=/root/.npm npm ci                                                                                               0.7s
 => [stage-0 8/8] COPY . /app                                                                                                                                                            0.1s
 => exporting to image                                                                                                                                                                   3.1s
 => => exporting layers                                                                                                                                                                  3.0s
 => => writing image sha256:681a4bebc8405aa73085a7f4403a54087a9185d7f44826718a6447c5f4766ccc                                                                                             0.0s
 => => naming to docker.io/library/e466e936-1f16-494e-ae53-a84457686406                                                                                                                  0.0s
=== Successfully Built! ===

Run:
  docker run -it e466e936-1f16-494e-ae53-a84457686406

I'm running Docker 20.10.19 with the following config:

{
	"debug": true,
	"features": {
		"buildkit": true
	}
}

fussybeaver avatar Dec 13 '22 12:12 fussybeaver

Hmm that's quite odd. The output on the branch is spewing the raw Aux/VertexLog stuff. Did you run it on the correct branch (cooper/bollard)?

I was able to get it working, but I had to basically cram a "dummy option" (in this case, pull: true) right below the #[cfg(feature...)] line. Previously, it was session, which meant I guess that wasn't passed?

CleanShot 2022-12-14 at 11 01 59@2x

JakeCooper avatar Dec 14 '22 19:12 JakeCooper

Additionally, any tips on consuming these Vertex logs to make it human readable?

CleanShot 2022-12-14 at 11 03 16@2x

JakeCooper avatar Dec 14 '22 19:12 JakeCooper

Yes, you're right I was not on the right branch. Interesting that you need the pull option to be enabled, I'll double check that, possibly we should default that to being true and/or emit a warning if not.

Re: the spurious logs - ~maybe these are base64 encoded messages again?~ Edit: still checking (no idea yet what that field is)

fussybeaver avatar Dec 14 '22 21:12 fussybeaver

Yes this looks like you can just string utf8 encode that field, and you get a log output. I think I'll add a Display implementation to the StatusResponse type, as I can't really modify the protobuf output.

fussybeaver avatar Dec 15 '22 18:12 fussybeaver

I think I'll add a Display implementation to the StatusResponse type, as I can't really modify the protobuf output.

That would be amazing! If you could let me know when that's merge, I can go ahead and finish up the Bollard PR

The only other thing that's quite odd is, for this ticket, if you pull in the git hash, even if you enable buildkit in the Cargo toml, it does this odd thing where I need to declare a "filler" line right below cfg

This is where the original issue came with the "No session found". Basically, it was swallowing whatever property was being passed right below it. To get around this, I had to add a redundant pull line

CleanShot 2022-12-15 at 11 42 36@2x

Cargo.toml CleanShot 2022-12-15 at 11 42 51@2x

JakeCooper avatar Dec 15 '22 19:12 JakeCooper

I've merged the Display impl for StatusResponse in https://github.com/fussybeaver/bollard/pull/281

I did manage to eventually reproduce the "no active session" problem above, and I think it's because the nixpacks crate doesn't actually have a buildkit feature defined in its own Cargo.toml, so when you copy the example in bollard, it'll skip the session parameter that you passed, which is used to communicate with the buildkit server.

image

In those situations the Bollard codebase should be injecting a dummy id as replacement, but I guess that doesn't work for some reason.. Something to look into in future..

fussybeaver avatar Dec 16 '22 17:12 fussybeaver

Apologies to be a bother. I might have messed it up but it seems that simply calling print on the inner (as you did in your #281 PR isn't sufficient to produce the progress?

CleanShot 2022-12-16 at 11 06 21@2x

Much appreciated and sorry if this is a trivial Rust thing I'm messing up

JakeCooper avatar Dec 16 '22 19:12 JakeCooper

I think you need to clear the docker cache - I always had to run docker system prune -a -f between runs to see any vertexlogs in buildkit.

fussybeaver avatar Dec 16 '22 19:12 fussybeaver

Or... did you mean something else with progress?

fussybeaver avatar Dec 19 '22 10:12 fussybeaver

Yea I meant something with progress

JakeCooper avatar Jan 09 '23 22:01 JakeCooper

I'm seeing a progress from the returned statuses field.

https://github.com/fussybeaver/bollard/blob/8d5306da900a496ea9cfcf3a5559a5605fef8bbb/codegen/proto/resources/moby/buildkit/v1/control.proto#L125-L126

For example, while running cargo run build ./examples/node in the above linked Nixpacks PR, you'll get some statuses during the downloading of docker layers:

Response: StatusResponse: { vertexes: [], statuses: [VertexStatus { id: "sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7", vertex: "sha256:773df267af7ef14ed67bfe5d8c29de3a17fc2d893be1f19c063e0fd9428334be", name: "downloading", current: 2097152, total: 31366757, timestamp: Some(Timestamp { seconds: 1673356490, nanos: 794371167 }), started: Some(Timestamp { seconds: 1673356490, nanos: 199287990 }), completed: None }, VertexStatus { id: "sha256:e72f099327f43149c6c4333a04dbfd47f131ab4188dbf671a5557b406971bc63", vertex: "sha256:773df267af7ef14ed67bfe5d8c29de3a17fc2d893be1f19c063e0fd9428334be", name: "downloading", current: 6291456, total: 43966889, timestamp: Some(Timestamp { seconds: 1673356490, nanos: 794376579 }), started: Some(Timestamp { seconds: 1673356490, nanos: 199289658 }), completed: None }, VertexStatus { id: "sha256:3214eb2c3488498931fcaf4f4d8697b8c754f429d1cbf8a9d85700dcf33fce5d", vertex: "sha256:773df267af7ef14ed67bfe5d8c29de3a17fc2d893be1f19c063e0fd9428334be", name: "downloading", current: 3145728, total: 31321155, timestamp: Some(Timestamp { seconds: 1673356490, nanos: 794377685 }), started: Some(Timestamp { seconds: 1673356490, nanos: 199290974 }), completed: None }], logs: [], warnings: [] }
Response: StatusResponse: { vertexes: [], statuses: [VertexStatus { id: "sha256:1efc276f4ff952c055dea726cfc96ec6a4fdb8b62d9eed816bd2b788f2860ad7", vertex: "sha256:773df267af7ef14ed67bfe5d8c29de3a17fc2d893be1f19c063e0fd9428334be", name: "downloading", current: 4194304, total: 31366757, timestamp: Some(Timestamp { seconds: 1673356490, nanos: 894708253 }), started: Some(Timestamp { seconds: 1673356490, nanos: 199287990 }), completed: None }, VertexStatus { id: "sha256:e72f099327f43149c6c4333a04dbfd47f131ab4188dbf671a5557b406971bc63", vertex: "sha256:773df267af7ef14ed67bfe5d8c29de3a17fc2d893be1f19c063e0fd9428334be", name: "downloading", current: 10485760, total: 43966889, timestamp: Some(Timestamp { seconds: 1673356490, nanos: 894714079 }), started: Some(Timestamp { seconds: 1673356490, nanos: 199289658 }), completed: None }, VertexStatus { id: "sha256:3214eb2c3488498931fcaf4f4d8697b8c754f429d1cbf8a9d85700dcf33fce5d", vertex: "sha256:773df267af7ef14ed67bfe5d8c29de3a17fc2d893be1f19c063e0fd9428334be", name: "downloading", current: 5242880, total: 31321155, timestamp: Some(Timestamp { seconds: 1673356490, nanos: 894715124 }), started: Some(Timestamp { seconds: 1673356490, nanos: 199290974 }), completed: None }], logs: [], warnings: [] }

... where you can just divide the current from the total

fussybeaver avatar Jan 10 '23 13:01 fussybeaver

Oh right. Sorry, I should clarify; that part is indeed working

It's literally rendering the vertex logs to something like we currently have in the output in your original post

JakeCooper avatar Jan 26 '23 20:01 JakeCooper