basho/riak_cs — pull request #761 by shino (2013-12-27 08:22:44+00:00)
Title: Refactor/bucket object in state

Some independent logics fetch bucket object from Riak, bucket policy, bucket ACL
and bucket owner retrieval. In object access, e.g. GET Object, we can/should suppress
extra bucket object fetch.

Refactoring plan is simple. Let object-related webmachine callback
resources keep bucket objects (riak objects) in their state.

This PR is motivated mainly by https://github.com/basho/riak_cs/issues/701 .
Also this will be the basis for https://github.com/basho/riak_cs/issues/723 .

In testing this PR, two things found, both are reproduced at current develop branch.
1. Dialyzer outputs some warnings:
2. make test fails at `riak_cs_get_fsm_eqc`
These may/should be treated separated issues.

1 Dialyzer
```
riak_cs_gc.erl:187: The pattern [{UUID, _} | _] can never match the type []
riak_cs_gc_d.erl:173: The call riak_cs_gc_d:fetch_eligible_manifest_keys(RiakPid::'undefined' | pid(),BatchStart::non_neg_integer(),'undefined') will never return since it differs in the 3rd argument from the success typing arguments: (pid(),non_neg_integer(),binary())
riak_cs_gc_d.erl:608: Record construction #state{interval::'undefined' | non_neg_integer(),last::'undefined' | non_neg_integer(),next::{{non_neg_integer(),1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12,1..255},{byte(),byte(),byte()}},current_files::'undefined' | [#lfs_manifest_v3{version::integer(),block_size::'undefined' | integer(),bkey::'undefined' | {binary(),binary()},metadata::'undefined' | [{_,_}],uuid::'undefined' | binary(),content_length::'undefined' | non_neg_integer(),content_type::'undefined' | binary(),state::'active' | 'deleted' | 'pending_delete' | 'scheduled_delete' | 'undefined' | 'writing',write_blocks_remaining::'undefined' | [integer()],delete_blocks_remaining::'undefined' | [integer()],acl::'no_acl_yet' | 'undefined' | #acl_v1{owner::{string(),string()} | {string(),string(),string()},grants::[{'AllUsers' | 'AuthUsers' | {string(),string()},['FULL_CONTROL' | 'READ' | 'READ_ACP' | 'WRITE' | 'WRITE_ACP']}],creation_time::{non_neg_integer(),non_neg_integer(),non_neg_integer()}} | #acl_v2{owner::{string(),string()} | {string(),string(),string()},grants::[{'AllUsers' | 'AuthUsers' | {string(),string()},['FULL_CONTROL' | 'READ' | 'READ_ACP' | 'WRITE' | 'WRITE_ACP']}],creation_time::{non_neg_integer(),non_neg_integer(),non_neg_integer()}},props::'undefined' | [atom() | tuple()],cluster_id::'undefined' | binary()}],current_fileset::'undefined' | {set(),set()},current_riak_object::'undefined' | {'riakc_obj','undefined' | binary(),'undefined' | binary(),'undefined' | binary(),'undefined' | [{dict(),binary()}],'undefined' | dict(),'undefined' | binary()},batch_count::non_neg_integer(),batch_skips::non_neg_integer(),batch::'undefined' | [binary()],manif_count::non_neg_integer(),block_count::non_neg_integer(),pause_state::atom(),interval_remaining::'undefined' | non_neg_integer(),timer_ref::reference(),delete_fsm_pid::'undefined' | pid(),continuation::'undefined' | binary()} violates the declared type of field next::'undefined' | non_neg_integer()
Unknown functions:
riak_object:bucket/1
Unknown types:
riakc_pb_socket:index_results/0
done in 0m28.78s
done (warnings were emitted)
```

2 make test (sudden death, almost no output but failed)
```
$ make test
(SNIP)
.......................
[test] Killed
```