Skip to content

Commit

Permalink
Merge pull request #45 from RelationalAI/ag-multipart-metrics-and-pad…
Browse files Browse the repository at this point in the history
…ding

Multipart PUT InvalidBlockList fix, new Rust metrics and padding behavior
  • Loading branch information
andrebsguedes authored Oct 31, 2024
2 parents c9f72d6 + 3fabc53 commit ff207d6
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "RustyObjectStore"
uuid = "1b5eed3d-1f46-4baa-87f3-a4a892b23610"
version = "0.9.1"
version = "0.10.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand All @@ -20,7 +20,7 @@ ReTestItems = "1"
Sockets = "1"
Test = "1"
julia = "1.8"
object_store_ffi_jll = "0.9.1"
object_store_ffi_jll = "0.10.0"

[extras]
CloudBase = "85eb1798-d7c4-4918-bb13-c944d38e27ed"
Expand Down
16 changes: 9 additions & 7 deletions src/RustyObjectStore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@ function safe_message(e::Exception)
if e isa RequestException
msg = message(e)
r = reason(e)
if contains(msg, "<Error>") || contains(msg, "http")
# Contains unreadacted payload from backend or urls, try extracting safe information
if contains(msg, "<Error>")
# Contains unreadacted payload from backend, try extracting safe information
code, backend_msg, report = extract_safe_parts(message(e))
reason_str = reason_description(r)

Expand All @@ -809,6 +809,9 @@ function safe_message(e::Exception)
retry_report = isnothing(report) ? "" : "\n\n$(report)"

return "$(backend_msg) (code: $(code), reason: $(reason_str))$(retry_report)"
elseif contains(msg, "http")
# Contains urls, redact them
return replace(msg, r"https?://[^\n )]+" => "<redacted url>")
else
# Assuming it safe as it does not come from backend or has url, return message directly
return msg
Expand Down Expand Up @@ -2004,12 +2007,11 @@ function invalidate_config(conf::Option{AbstractConfig}=nothing)
end
end

struct Metrics
live_bytes::Int64
end

function current_metrics()
return @ccall rust_lib.current_metrics()::Metrics
metrics_ptr = @ccall rust_lib.current_metrics()::Ptr{Cchar}
metrics_string = unsafe_string(metrics_ptr)
metrics = JSON3.read(metrics_string)
return metrics
end

module Test
Expand Down
62 changes: 62 additions & 0 deletions test/azure_blobs_exception_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,63 @@ end # @testitem
return nrequests[]
end

function test_invalid_block_list()
nrequests = Ref(0)
uploadid = nothing
(port, tcp_server) = Sockets.listenany(8081)
http_server = HTTP.serve!(tcp_server) do request::HTTP.Request
nrequests[] += 1
if request.method == "PUT"
if occursin("comp=blocklist", request.target)
uploadid_value = HTTP.header(request, "x-ms-meta-uploadid")
if !isnothing(uploadid_value)
uploadid = "x-ms-meta-uploadid" => uploadid_value
end
return HTTP.Response(400, "InvalidBlockList")
else
return HTTP.Response(200, [
"Content-Length" => "0",
"Last-Modified" => "Tue, 15 Oct 2019 12:45:26 GMT",
"ETag" => "123"
], "")
end
elseif request.method == "HEAD"
return HTTP.Response(200, [
uploadid,
"Content-Length" => "0",
"Last-Modified" => "Tue, 15 Oct 2019 12:45:26 GMT",
"ETag" => "123"
], "")
else
return HTTP.Response(404, "Not Found")
end
end

baseurl = "http://127.0.0.1:$port/$account/$container/"
conf = AzureConfig(;
storage_account_name=account,
container_name=container,
storage_account_key=shared_key_from_azurite,
host=baseurl,
opts=ClientOptions(;
max_retries=max_retries,
retry_timeout_secs=retry_timeout_secs,
request_timeout_secs
)
)

try
put_object(zeros(UInt8, 11 * 1024 * 1024), "blob", conf)
@test true
catch e
@test false
finally
Threads.@spawn HTTP.forceclose(http_server)
end
# wait(http_server)
return nrequests[]
end

@testset "400: Bad Request" begin
# Returned when there's an error in the request URI, headers, or body. The response body
# contains an error message explaining what the specific problem is.
Expand Down Expand Up @@ -762,4 +819,9 @@ end # @testitem
nrequests = test_cancellation()
@test nrequests == 1
end

@testset "InvalidBlockList" begin
nrequests = test_invalid_block_list()
@test nrequests == 4
end
end
2 changes: 1 addition & 1 deletion test/basic_unified_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ function run_list_test_cases(config::AbstractConfig; strict_entry_size=true)

entries = list_objects("list_empty/", config)
@test length(entries) == 3
@test map(x -> x.size, entries) == [0, 0, 0]
@test within_margin(sort(map(x -> x.size, entries)), [0, 0, 0], margin)
@test map(x -> x.location, entries) == ["list_empty/10.csv", "list_empty/20.csv", "list_empty/30.csv"]
end

Expand Down
4 changes: 2 additions & 2 deletions test/snowflake_stage_exception_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@
@test false # Should have thrown an error
catch e
@test e isa RustyObjectStore.PutException
@test occursin("Connection refused", e.msg)
@test occursin("Connection refused", e.msg) || occursin("Unable to access master token file", e.msg)
end

try
get_object!(buffer, "still_doesnt_exist.csv", _stale_config)
@test false # Should have thrown an error
catch e
@test e isa RustyObjectStore.GetException
@test occursin("Connection refused", e.msg)
@test occursin("Connection refused", e.msg) || occursin("Unable to access master token file", e.msg)
end
end

Expand Down

2 comments on commit ff207d6

@andrebsguedes
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/118446

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.0 -m "<description of version>" ff207d61dcbb3c84eed1946eac4e208703611916
git push origin v0.10.0

Please sign in to comment.