Skip to content

Commit 49f8128

Browse files
authored
Merge master into feature/configure-ssh-phase2 (#6409)
2 parents 6e6c0ed + e21647c commit 49f8128

File tree

136 files changed

+1452
-813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1452
-813
lines changed

.github/workflows/docs.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,23 @@ jobs:
3131
- name: Update Ubuntu repositories
3232
run: sudo apt-get update
3333

34+
# We set DUNE_CACHE_STORAGE_MODE, it is required for dune cache to work inside opam for now,
35+
# otherwise it gets EXDEV and considers it a cache miss
3436
- name: Use ocaml
35-
uses: ocaml/setup-ocaml@v2
37+
uses: ocaml/setup-ocaml@v3
3638
with:
3739
ocaml-compiler: ${{ steps.dotenv.outputs.ocaml_version_full }}
3840
opam-repositories: |
3941
xs-opam: ${{ steps.dotenv.outputs.repository }}
42+
dune-cache: true
43+
opam-pin: false
44+
cache-prefix: v3-${{ steps.system-info.outputs.name }}-${{ steps.system-info.outputs.release }}
45+
env:
46+
DUNE_CACHE_STORAGE_MODE: copy
4047

4148
- name: Install dependencies
42-
run: opam pin list --short | xargs opam install --deps-only -v
49+
shell: bash
50+
run: opam install . --deps-only -v
4351

4452
- name: Generate xapi-storage docs
4553
run: |

dune-project

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
(formatting (enabled_for ocaml))
44
(using menhir 2.0)
55
(using directory-targets 0.1)
6+
(opam_file_location inside_opam_directory)
67

78
(cram enable)
89
(implicit_transitive_deps false)

ocaml/libs/xapi-rrd/lib/rrd.ml

+103-100
Original file line numberDiff line numberDiff line change
@@ -379,121 +379,124 @@ let process_ds_value ds value interval new_rrd =
379379
rate
380380

381381
let ds_update rrd timestamp valuesandtransforms new_rrd =
382-
(* Interval is the time between this and the last update
383-
384-
Currently ds_update is called with datasources that belong to a single
385-
plugin, correspondingly they all have the same timestamp.
386-
Further refactoring is needed if timestamps per measurement are to be
387-
introduced. *)
388-
let first_ds_index, _ = valuesandtransforms.(0) in
389-
let last_updated = rrd.rrd_dss.(first_ds_index).ds_last_updated in
390-
let interval = timestamp -. last_updated in
391-
(* Work around the clock going backwards *)
392-
let interval = if interval < 0. then 5. else interval in
393-
394-
(* start time (st) and age of the last processed pdp and the currently occupied one *)
395-
let proc_pdp_st, _proc_pdp_age = get_times last_updated rrd.timestep in
396-
let occu_pdp_st, occu_pdp_age = get_times timestamp rrd.timestep in
397-
398-
(* The number of pdps that should result from this update *)
399-
let elapsed_pdp_st =
400-
Int64.to_int ((occu_pdp_st --- proc_pdp_st) /// rrd.timestep)
401-
in
402-
403-
(* if we're due one or more PDPs, pre_int is the amount of the
404-
current update interval that will be used in calculating them, and
405-
post_int is the amount left over
406-
this step. If a PDP isn't post is what's left over *)
407-
let pre_int, post_int =
408-
if elapsed_pdp_st > 0 then
409-
let pre = interval -. occu_pdp_age in
410-
(pre, occu_pdp_age)
411-
else
412-
(interval, 0.0)
413-
in
414-
415-
(* We're now done with the last_updated value, so update it *)
416-
rrd.last_updated <- timestamp ;
382+
(* CA-408841 - don't update the rrd at all if list of datasources is empty *)
383+
if valuesandtransforms <> [||] then (
384+
(* Interval is the time between this and the last update
385+
386+
Currently ds_update is called with datasources that belong to a single
387+
plugin, correspondingly they all have the same timestamp.
388+
Further refactoring is needed if timestamps per measurement are to be
389+
introduced. *)
390+
let first_ds_index, _ = valuesandtransforms.(0) in
391+
let last_updated = rrd.rrd_dss.(first_ds_index).ds_last_updated in
392+
let interval = timestamp -. last_updated in
393+
(* Work around the clock going backwards *)
394+
let interval = if interval < 0. then 5. else interval in
395+
396+
(* start time (st) and age of the last processed pdp and the currently occupied one *)
397+
let proc_pdp_st, _proc_pdp_age = get_times last_updated rrd.timestep in
398+
let occu_pdp_st, occu_pdp_age = get_times timestamp rrd.timestep in
399+
400+
(* The number of pdps that should result from this update *)
401+
let elapsed_pdp_st =
402+
Int64.to_int ((occu_pdp_st --- proc_pdp_st) /// rrd.timestep)
403+
in
417404

418-
(* Calculate the values we're going to store based on the input data and the type of the DS *)
419-
let v2s =
420-
Array.map
421-
(fun (i, {value; _}) ->
422-
let v = process_ds_value rrd.rrd_dss.(i) value interval new_rrd in
423-
rrd.rrd_dss.(i).ds_last_updated <- timestamp ;
424-
(i, v)
425-
)
426-
valuesandtransforms
427-
in
428-
(* Update the PDP accumulators up until the most recent PDP *)
429-
Array.iter
430-
(fun (i, value) ->
431-
let ds = rrd.rrd_dss.(i) in
432-
if Utils.isnan value then
433-
ds.ds_unknown_sec <- pre_int
405+
(* if we're due one or more PDPs, pre_int is the amount of the
406+
current update interval that will be used in calculating them, and
407+
post_int is the amount left over
408+
this step. If a PDP isn't post is what's left over *)
409+
let pre_int, post_int =
410+
if elapsed_pdp_st > 0 then
411+
let pre = interval -. occu_pdp_age in
412+
(pre, occu_pdp_age)
434413
else
435-
(* CA-404597 - Gauge and Absolute values should be passed as-is,
436-
without being involved in time-based calculations at all.
437-
This applies to calculations below as well *)
438-
match ds.ds_ty with
439-
| Gauge | Absolute ->
440-
ds.ds_value <- value
441-
| Derive ->
442-
ds.ds_value <- ds.ds_value +. (pre_int *. value /. interval)
443-
)
444-
v2s ;
414+
(interval, 0.0)
415+
in
416+
417+
(* We're now done with the last_updated value, so update it *)
418+
rrd.last_updated <- timestamp ;
445419

446-
(* If we've passed a PDP point, we need to update the RRAs *)
447-
if elapsed_pdp_st > 0 then (
448-
(* Calculate the PDPs for each DS *)
449-
let pdps =
420+
(* Calculate the values we're going to store based on the input data and the type of the DS *)
421+
let v2s =
450422
Array.map
451-
(fun (i, {transform; _}) ->
452-
let ds = rrd.rrd_dss.(i) in
453-
if interval > ds.ds_mrhb then
454-
(i, nan)
455-
else
456-
let raw =
457-
let proc_pdp_st = get_float_time last_updated rrd.timestep in
458-
let occu_pdp_st = get_float_time timestamp rrd.timestep in
459-
460-
match ds.ds_ty with
461-
| Gauge | Absolute ->
462-
ds.ds_value
463-
| Derive ->
464-
ds.ds_value
465-
/. (occu_pdp_st -. proc_pdp_st -. ds.ds_unknown_sec)
466-
in
467-
(* Apply the transform after the raw value has been calculated *)
468-
let raw = apply_transform_function transform raw in
469-
(* Make sure the values are not out of bounds after all the processing *)
470-
if raw < ds.ds_min || raw > ds.ds_max then
471-
(i, nan)
472-
else
473-
(i, raw)
423+
(fun (i, {value; _}) ->
424+
let v = process_ds_value rrd.rrd_dss.(i) value interval new_rrd in
425+
rrd.rrd_dss.(i).ds_last_updated <- timestamp ;
426+
(i, v)
474427
)
475428
valuesandtransforms
476429
in
477-
478-
rra_update rrd proc_pdp_st elapsed_pdp_st pdps ;
479-
480-
(* Reset the PDP accumulators *)
430+
(* Update the PDP accumulators up until the most recent PDP *)
481431
Array.iter
482432
(fun (i, value) ->
483433
let ds = rrd.rrd_dss.(i) in
484-
if Utils.isnan value then (
485-
ds.ds_value <- 0.0 ;
486-
ds.ds_unknown_sec <- post_int
487-
) else (
488-
ds.ds_unknown_sec <- 0.0 ;
434+
if Utils.isnan value then
435+
ds.ds_unknown_sec <- pre_int
436+
else
437+
(* CA-404597 - Gauge and Absolute values should be passed as-is,
438+
without being involved in time-based calculations at all.
439+
This applies to calculations below as well *)
489440
match ds.ds_ty with
490441
| Gauge | Absolute ->
491442
ds.ds_value <- value
492443
| Derive ->
493-
ds.ds_value <- post_int *. value /. interval
494-
)
444+
ds.ds_value <- ds.ds_value +. (pre_int *. value /. interval)
495445
)
496-
v2s
446+
v2s ;
447+
448+
(* If we've passed a PDP point, we need to update the RRAs *)
449+
if elapsed_pdp_st > 0 then (
450+
(* Calculate the PDPs for each DS *)
451+
let pdps =
452+
Array.map
453+
(fun (i, {transform; _}) ->
454+
let ds = rrd.rrd_dss.(i) in
455+
if interval > ds.ds_mrhb then
456+
(i, nan)
457+
else
458+
let raw =
459+
let proc_pdp_st = get_float_time last_updated rrd.timestep in
460+
let occu_pdp_st = get_float_time timestamp rrd.timestep in
461+
462+
match ds.ds_ty with
463+
| Gauge | Absolute ->
464+
ds.ds_value
465+
| Derive ->
466+
ds.ds_value
467+
/. (occu_pdp_st -. proc_pdp_st -. ds.ds_unknown_sec)
468+
in
469+
(* Apply the transform after the raw value has been calculated *)
470+
let raw = apply_transform_function transform raw in
471+
(* Make sure the values are not out of bounds after all the processing *)
472+
if raw < ds.ds_min || raw > ds.ds_max then
473+
(i, nan)
474+
else
475+
(i, raw)
476+
)
477+
valuesandtransforms
478+
in
479+
480+
rra_update rrd proc_pdp_st elapsed_pdp_st pdps ;
481+
482+
(* Reset the PDP accumulators *)
483+
Array.iter
484+
(fun (i, value) ->
485+
let ds = rrd.rrd_dss.(i) in
486+
if Utils.isnan value then (
487+
ds.ds_value <- 0.0 ;
488+
ds.ds_unknown_sec <- post_int
489+
) else (
490+
ds.ds_unknown_sec <- 0.0 ;
491+
match ds.ds_ty with
492+
| Gauge | Absolute ->
493+
ds.ds_value <- value
494+
| Derive ->
495+
ds.ds_value <- post_int *. value /. interval
496+
)
497+
)
498+
v2s
499+
)
497500
)
498501

499502
(** Update the rrd with named values rather than just an ordered array

ocaml/tests/test_sm_features.ml

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ module CreateSMObject = Generic.MakeStateful (struct
249249
; features
250250
; configuration= []
251251
; required_cluster_stack= []
252+
; smapi_version= SMAPIv2
252253
}
253254

254255
let extract_output __context _ =

ocaml/tests/test_storage_migrate_state.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ open Test_highlevel
1717
module StorageMigrateState = struct
1818
type state_t = unit
1919

20-
let create_default_state () = Storage_migrate.State.clear ()
20+
let create_default_state () = Storage_migrate_helper.State.clear ()
2121
end
2222

2323
let sample_send_state =
24-
Storage_migrate.State.Send_state.
24+
Storage_migrate_helper.State.Send_state.
2525
{
2626
url= "url"
2727
; dest_sr= Storage_interface.Sr.of_string "dest_sr"
@@ -45,7 +45,7 @@ let sample_send_state =
4545

4646
let sample_receive_state =
4747
let open Storage_interface in
48-
Storage_migrate.State.Receive_state.
48+
Storage_migrate_helper.State.Receive_state.
4949
{
5050
sr= Sr.of_string "my_sr"
5151
; dummy_vdi= Vdi.of_string "dummy_vdi"
@@ -57,7 +57,7 @@ let sample_receive_state =
5757
}
5858

5959
let sample_copy_state =
60-
Storage_migrate.State.Copy_state.
60+
Storage_migrate_helper.State.Copy_state.
6161
{
6262
base_dp= "base_dp"
6363
; leaf_dp= "leaf_dp"
@@ -70,7 +70,7 @@ let sample_copy_state =
7070

7171
module MapOf = Generic.MakeStateful (struct
7272
module Io = struct
73-
open Storage_migrate.State
73+
open Storage_migrate_helper.State
7474

7575
type input_t =
7676
(string * osend operation) option
@@ -88,7 +88,7 @@ module MapOf = Generic.MakeStateful (struct
8888
end
8989

9090
module State = StorageMigrateState
91-
open Storage_migrate.State
91+
open Storage_migrate_helper.State
9292

9393
let load_input () (send, recv, copy) =
9494
Option.iter (fun (id, send) -> add id send) send ;
@@ -116,7 +116,7 @@ module MapOf = Generic.MakeStateful (struct
116116
end)
117117

118118
let test_clear () =
119-
let open Storage_migrate.State in
119+
let open Storage_migrate_helper.State in
120120
clear () ;
121121
add "foo" (Send_op sample_send_state) ;
122122
add "bar" (Recv_op sample_receive_state) ;
@@ -130,5 +130,5 @@ let test_clear () =
130130
let test = [("clear", `Quick, test_clear)]
131131

132132
let tests =
133-
Storage_migrate.State.persist_root := Test_common.working_area ;
133+
Storage_migrate_helper.State.persist_root := Test_common.working_area ;
134134
[("storage_migrate_state_map_of", MapOf.tests)]

ocaml/tests/test_vdi_cbt.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ let register_smapiv2_server (module S : Storage_interface.Server_impl) sr_ref =
3030
; features= []
3131
; configuration= []
3232
; required_cluster_stack= []
33+
; smapi_version= SMAPIv2
3334
}
3435
in
3536

36-
Storage_mux.register sr_ref rpc "" dummy_query_result
37+
Storage_mux_reg.register sr_ref rpc "" dummy_query_result
3738

3839
let make_smapiv2_storage_server ?vdi_enable_cbt ?vdi_disable_cbt
3940
?vdi_list_changed_blocks ?vdi_data_destroy ?vdi_snapshot ?vdi_clone:_ () =

0 commit comments

Comments
 (0)