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
Bollard is reading partial json data in create_image
#190
Comments
Thanks for reporting, we added the |
@fussybeaver, to be clear, the chunks that were read were the following:
and
If you take the first chunk and run But the next chunk was failed to be read with not EOF, but syntax error. This means the first chunk was just skipped, but the rest of the object caused a hard error |
Improves the json parser to handler scenarios: - the buffer ends in a '}' and is not a parseable json - newlines inside the json payload Closes #190
Improves the json parser to handler scenarios: - the buffer ends in a '}' and is not a parseable json - newlines inside the json payload Closes #190
Improves the json parser to handler scenarios: - the buffer ends in a '}' and is not a parseable json - newlines inside the json payload Closes #190
Hi @Veetaha can you check if this is now fixed ? |
@fussybeaver great, thank you! |
@fussybeaver I would be greatful if you could make a patch release for this, and I'll be able to upgrade us to the new version |
Since this is a change in some 'hot' code, I'd like get this tested perhaps also in some upstream projects that are used more heavily, before releasing a new version. |
@fussybeaver I don't think that we will be able to debug it on our CI, taking into account how much flaky CI costs to us. We've already added retries for errors from use futures::prelude::*;
#[tokio::test]
async fn luck_testing() {
env_logger::init();
let docker = bollard::Docker::connect_with_local_defaults().unwrap();
let image = "amazon/dynamodb-local:1.18.0";
let timeout = std::time::Duration::from_secs(6 * 60 * 60);
let start = std::time::Instant::now();
for i in 0.. {
eprintln!("[#{i}] Pulling image...");
docker
.create_image(
Some(bollard::image::CreateImageOptions {
from_image: image,
..Default::default()
}),
/* root_fs */ None,
/* credentials */ None,
)
.for_each(|info| {
if let Err(err) = info {
eprintln!("[#{i}]: Pulling failed! {err:#?}");
}
future::ready(())
})
.await;
docker.remove_image(image, None, None).await.unwrap();
if start.elapsed() >= timeout {
eprintln!("[#{i}] Timeout reached, exitting...");
break;
}
}
} It failed on an unrelated error in [2022-02-14T06:50:11Z DEBUG bollard::read] Decoding JSON line from stream: {"errorDetail":{"message":"error pulling image configuration: Get \"https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/39/39d290d0ed044e20481d8a02dfb84509e48426e99a7175d1412299db837818eb/data?verify=1644824401-2%2BNoBGk55KVtN7yebBVVT%2B%2Fmd1A%3D\": dial tcp: lookup production.cloudflare.docker.com: Temporary failure in name resolution"},"error":"error pulling image configuration: Get \"https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/39/39d290d0ed044e20481d8a02dfb84509e48426e99a7175d1412299db837818eb/data?verify=1644824401-2%2BNoBGk55KVtN7yebBVVT%2B%2Fmd1A%3D\": dial tcp: lookup production.cloudflare.docker.com: Temporary failure in name resolution"}
[2022-02-14T06:50:11Z DEBUG bollard::uri] Parsing uri: unix://2f7661722f72756e2f646f636b65722e736f636b/images/amazon/dynamodb-local:1.18.0, client_type: Unix, socket: /var/run/docker.sock
[2022-02-14T06:50:11Z DEBUG bollard::docker] unix://2f7661722f72756e2f646f636b65722e736f636b/images/amazon/dynamodb-local:1.18.0
[2022-02-14T06:50:11Z DEBUG bollard::docker] request: Request { method: DELETE, uri: unix://2f7661722f72756e2f646f636b65722e736f636b/images/amazon/dynamodb-local:1.18.0, version: HTTP/1.1, headers: {"x-registry-auth": "eyJ1c2VybmFtZSI6bnVsbCwicGFzc3dvcmQiOm51bGwsImF1dGgiOm51bGwsImVtYWlsIjpudWxsLCJzZXJ2ZXJhZGRyZXNzIjpudWxsLCJpZGVudGl0eXRva2VuIjpudWxsLCJyZWdpc3RyeXRva2VuIjpudWxsfQ==", "content-type": "application/json"}, body: Body(Empty) }
thread 'bollard::luck_testing' panicked at 'called `Result::unwrap()` on an `Err` value: DockerResponseNotFoundError { message: "{\"message\":\"No such image: amazon/dynamodb-local:1.18.0\"}\n" }', crates/foo/src/bollard.rs:32:54 This looks like an unrelated error, so I'm going to open a separate issue. |
Thanks for your efforts.. |
@fussybeaver Today I've corrected that test not to exit early in
I ran the test with ~/junk/rust-sandbox $ RUST_LOG=debug cargo test --release --lib -- luck_testing --nocapture 2>&1 | dd bs=1 count=40000000000 > log.log
63910839+0 records in
63910839+0 records out
63910839 bytes (64 MB, 61 MiB) copied, 21610.1 s, 3.0 kB/s
Took 6h 0m 10s
~/junk/rust-sandbox $ cat log.log | grep fail
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out; finished in 21605.39s
~/junk/rust-sandbox $ du -h log.log
61M log.log This makes me more confident that the bug should've been fixed |
Excellent. That sounds promising. |
Improves the json parser to handler scenarios: - the buffer ends in a '}' and is not a parseable json - newlines inside the json payload Closes fussybeaver#190 master (fussybeaver#196) v0.13.0 v0.12.0
Improves the json parser to handler scenarios: - the buffer ends in a '}' and is not a parseable json - newlines inside the json payload Closes fussybeaver#190 master (fussybeaver#196) v0.13.0 v0.12.0
When using
create_image
we've stumbled with the following error on our CI. It appears randomly just due to the nature of this bug. Looks like the response stream thatbollard
receives from docker may be read in chunks that are not aligned with the JSON data.Here is the log from our test that failed due to this bug:
The first read ended up with a chunk in the middle of the JSON object, so
is_eof()
returnedtrue
here:bollard/src/read.rs
Line 118 in a457b0f
But the next line resulted in a JSON parsing error right at the start, so the error was returned.
The invocation of
create_image()
in our test looks like this:The text was updated successfully, but these errors were encountered: