Skip to content

Commit

Permalink
Handle error in cuttlefish leo-project/leofs#530
Browse files Browse the repository at this point in the history
  • Loading branch information
mocchira committed Dec 6, 2016
1 parent 23ad9c2 commit 719be53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions priv/leo_gateway.schema
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@
{default, 5242880}
]}.

{translation, "leo_gateway.large_object.reading_chunked_obj_len",
fun(Conf) ->
Len = cuttlefish_util:conf_get_value("large_object.chunked_obj_len", Conf),
ReadingLen = cuttlefish_util:conf_get_value("large_object.reading_chunked_obj_len", Conf),
case ReadingLen > Len of
true ->
Reason = lists:flatten(io_lib:format("reading_chunked_obj_len: ~w > chunked_obj_len: ~w", [ReadingLen, Len])),
{error, Reason};
false ->
ReadingLen
end
end}.

%% --------------------------------------------------------------------
%% GATEWAY - CACHE
Expand Down
8 changes: 8 additions & 0 deletions src/leo_gateway_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ get_options() ->
MaxChunkedObjs = leo_misc:get_value('max_chunked_objs', LargeObjectProp, ?DEF_LOBJ_MAX_CHUNKED_OBJS),
ChunkedObjLen = leo_misc:get_value('chunked_obj_len', LargeObjectProp, ?DEF_LOBJ_CHUNK_OBJ_LEN),
ReadingChunkedLen = leo_misc:get_value('reading_chunked_obj_len', LargeObjectProp, ?DEF_LOBJ_READING_CHUNK_OBJ_LEN),
case ReadingChunkedLen of
{error, Cause} ->
%% stop to handle
%% https://github.com/leo-project/leofs/issues/531
error({error, Cause});
_ ->
nop
end,
ThresholdChunkLen = leo_misc:get_value('threshold_of_chunk_len', LargeObjectProp, ?DEF_LOBJ_THRESHOLD_OF_CHUNK_LEN),
MaxObjLen = MaxChunkedObjs * ChunkedObjLen,

Expand Down

1 comment on commit 719be53

@yosukehara
Copy link
Member

Choose a reason for hiding this comment

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

@mocchira LGTM, thanks.

Please sign in to comment.