Skip to content

Commit ff207d6

Browse files
Merge pull request #45 from RelationalAI/ag-multipart-metrics-and-padding
Multipart PUT InvalidBlockList fix, new Rust metrics and padding behavior
2 parents c9f72d6 + 3fabc53 commit ff207d6

5 files changed

+76
-12
lines changed

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "RustyObjectStore"
22
uuid = "1b5eed3d-1f46-4baa-87f3-a4a892b23610"
3-
version = "0.9.1"
3+
version = "0.10.0"
44

55
[deps]
66
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -20,7 +20,7 @@ ReTestItems = "1"
2020
Sockets = "1"
2121
Test = "1"
2222
julia = "1.8"
23-
object_store_ffi_jll = "0.9.1"
23+
object_store_ffi_jll = "0.10.0"
2424

2525
[extras]
2626
CloudBase = "85eb1798-d7c4-4918-bb13-c944d38e27ed"

src/RustyObjectStore.jl

+9-7
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ function safe_message(e::Exception)
799799
if e isa RequestException
800800
msg = message(e)
801801
r = reason(e)
802-
if contains(msg, "<Error>") || contains(msg, "http")
803-
# Contains unreadacted payload from backend or urls, try extracting safe information
802+
if contains(msg, "<Error>")
803+
# Contains unreadacted payload from backend, try extracting safe information
804804
code, backend_msg, report = extract_safe_parts(message(e))
805805
reason_str = reason_description(r)
806806

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

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

2007-
struct Metrics
2008-
live_bytes::Int64
2009-
end
2010-
20112010
function current_metrics()
2012-
return @ccall rust_lib.current_metrics()::Metrics
2011+
metrics_ptr = @ccall rust_lib.current_metrics()::Ptr{Cchar}
2012+
metrics_string = unsafe_string(metrics_ptr)
2013+
metrics = JSON3.read(metrics_string)
2014+
return metrics
20132015
end
20142016

20152017
module Test

test/azure_blobs_exception_tests.jl

+62
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,63 @@ end # @testitem
594594
return nrequests[]
595595
end
596596

597+
function test_invalid_block_list()
598+
nrequests = Ref(0)
599+
uploadid = nothing
600+
(port, tcp_server) = Sockets.listenany(8081)
601+
http_server = HTTP.serve!(tcp_server) do request::HTTP.Request
602+
nrequests[] += 1
603+
if request.method == "PUT"
604+
if occursin("comp=blocklist", request.target)
605+
uploadid_value = HTTP.header(request, "x-ms-meta-uploadid")
606+
if !isnothing(uploadid_value)
607+
uploadid = "x-ms-meta-uploadid" => uploadid_value
608+
end
609+
return HTTP.Response(400, "InvalidBlockList")
610+
else
611+
return HTTP.Response(200, [
612+
"Content-Length" => "0",
613+
"Last-Modified" => "Tue, 15 Oct 2019 12:45:26 GMT",
614+
"ETag" => "123"
615+
], "")
616+
end
617+
elseif request.method == "HEAD"
618+
return HTTP.Response(200, [
619+
uploadid,
620+
"Content-Length" => "0",
621+
"Last-Modified" => "Tue, 15 Oct 2019 12:45:26 GMT",
622+
"ETag" => "123"
623+
], "")
624+
else
625+
return HTTP.Response(404, "Not Found")
626+
end
627+
end
628+
629+
baseurl = "http://127.0.0.1:$port/$account/$container/"
630+
conf = AzureConfig(;
631+
storage_account_name=account,
632+
container_name=container,
633+
storage_account_key=shared_key_from_azurite,
634+
host=baseurl,
635+
opts=ClientOptions(;
636+
max_retries=max_retries,
637+
retry_timeout_secs=retry_timeout_secs,
638+
request_timeout_secs
639+
)
640+
)
641+
642+
try
643+
put_object(zeros(UInt8, 11 * 1024 * 1024), "blob", conf)
644+
@test true
645+
catch e
646+
@test false
647+
finally
648+
Threads.@spawn HTTP.forceclose(http_server)
649+
end
650+
# wait(http_server)
651+
return nrequests[]
652+
end
653+
597654
@testset "400: Bad Request" begin
598655
# Returned when there's an error in the request URI, headers, or body. The response body
599656
# contains an error message explaining what the specific problem is.
@@ -762,4 +819,9 @@ end # @testitem
762819
nrequests = test_cancellation()
763820
@test nrequests == 1
764821
end
822+
823+
@testset "InvalidBlockList" begin
824+
nrequests = test_invalid_block_list()
825+
@test nrequests == 4
826+
end
765827
end

test/basic_unified_tests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ function run_list_test_cases(config::AbstractConfig; strict_entry_size=true)
589589

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

test/snowflake_stage_exception_tests.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@
8989
@test false # Should have thrown an error
9090
catch e
9191
@test e isa RustyObjectStore.PutException
92-
@test occursin("Connection refused", e.msg)
92+
@test occursin("Connection refused", e.msg) || occursin("Unable to access master token file", e.msg)
9393
end
9494

9595
try
9696
get_object!(buffer, "still_doesnt_exist.csv", _stale_config)
9797
@test false # Should have thrown an error
9898
catch e
9999
@test e isa RustyObjectStore.GetException
100-
@test occursin("Connection refused", e.msg)
100+
@test occursin("Connection refused", e.msg) || occursin("Unable to access master token file", e.msg)
101101
end
102102
end
103103

0 commit comments

Comments
 (0)