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

buildkit "no active sessions" #280

Open
JakeCooper opened this issue Dec 13, 2022 · 13 comments
Open

buildkit "no active sessions" #280

JakeCooper opened this issue Dec 13, 2022 · 13 comments

Comments

@JakeCooper
Copy link

Added the Bollard to Nixpacks (railwayapp/nixpacks#709) and having the "no active sessions error"

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

@fussybeaver
Copy link
Owner

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
	}
}

@JakeCooper
Copy link
Author

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
Copy link
Author

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

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

@fussybeaver
Copy link
Owner

fussybeaver commented Dec 14, 2022

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
Copy link
Owner

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.

@JakeCooper
Copy link
Author

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

@fussybeaver
Copy link
Owner

fussybeaver commented Dec 16, 2022

I've merged the Display impl for StatusResponse in #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..

@JakeCooper
Copy link
Author

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

@fussybeaver
Copy link
Owner

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
Copy link
Owner

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

@JakeCooper
Copy link
Author

Yea I meant something with progress

@fussybeaver
Copy link
Owner

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

int64 current = 4;
int64 total = 5;

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

@JakeCooper
Copy link
Author

JakeCooper commented Jan 26, 2023

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

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

No branches or pull requests

2 participants