Skip to content

Commit

Permalink
Merge pull request #267 from openvstorage/issue-266
Browse files Browse the repository at this point in the history
test and fix for #266
  • Loading branch information
domsj authored Jun 28, 2016
2 parents 7cee7e1 + 5f9b178 commit 899c906
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ocaml/src/alba_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,17 @@ let test_clean_obsolete_keys () =

assert_fragment ((=) None) >>= fun () ->

client # with_nsm_client'
~namespace_id
(fun nsm ->
nsm # list_device_keys_to_be_deleted
~first:"" ~finc:true
~last:None
~max:100 ~reverse:false
~osd_id:osd_id_first_fragment) >>= fun r ->
Lwt_log.debug_f "%s" ([%show : string list] (r |> fst |> snd)) >>= fun () ->
assert (r = ((0, []), false));

Lwt.return ()))

let test_garbage_collect () =
Expand Down
61 changes: 61 additions & 0 deletions ocaml/src/cli_nsm_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,69 @@ let list_device_objects_cmd =
Term.info "dev-list-device-objects"
~doc:"objects from the namespace that have fragments on this device"


let list_osd_keys_to_be_deleted
cfg_file tls_config
osd_id namespace_id
first finc max
reverse verbose
=
let t () =
with_alba_client
cfg_file
tls_config
(fun alba_client ->
alba_client # with_nsm_client'
~namespace_id
(fun nsm_client ->
nsm_client # list_device_keys_to_be_deleted
~osd_id
~first ~finc ~last:None
~max ~reverse
>>= fun ((cnt,xs), more) ->
Lwt_io.printlf "found %i items:" cnt >>= fun () ->
Lwt_list.iter_s
(Lwt_io.printlf "%s")
xs
>>= fun () ->
Lwt.return ()
))
in
lwt_cmd_line ~to_json:false ~verbose t

let list_osd_keys_to_be_deleted_cmd =
let osd_id default =
let doc = "osd's short id" in
Arg.(value
& opt int32 default
& info ["osd_id"] ~docv:"OSD_ID" ~doc)
in
let namespace_id default =
let doc = "namespace id" in
Arg.(value
& opt int32 default
& info ["namespace_id"] ~docv:"NAMESPACE_ID" ~doc)
in
let make_opt_bool name = Arg.(value & opt bool false & info [name]) in
let reverse = make_opt_bool "reverse" in
Term.(pure list_osd_keys_to_be_deleted
$ alba_cfg_url
$ tls_config
$ osd_id 0l
$ namespace_id 0l
$ first $ finc
$ max
$ reverse
$ verbose
),
Term.info "dev-list-osd-keys-to-be-deleted"
~doc:"list keys that have to be deleted"



let cmds =
[
nsm_host_statistics_cmd;
list_device_objects_cmd;
list_osd_keys_to_be_deleted_cmd;
]
2 changes: 1 addition & 1 deletion ocaml/src/nsm_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class client (nsm_host_client : Nsm_host_client.basic_client) namespace_id =
[(osd_id,
List.map
(fun key ->
Osd_keys.AlbaInstance.to_global_key namespace_id (key, 0, 0))
Osd_keys.AlbaInstance.to_global_key namespace_id (key, 0, String.length key))
keys)]

method get_gc_epochs =
Expand Down

0 comments on commit 899c906

Please sign in to comment.