@@ -803,7 +803,13 @@ handle_bucket_update_inner(BucketId, Req, Params, Limit) ->
803803 {false , _ , {ok , ParsedProps , _ }} ->
804804 BucketType = proplists :get_value (bucketType , ParsedProps ),
805805 UpdatedProps = ns_bucket :extract_bucket_props (ParsedProps ),
806- case update_bucket (Ctx , BucketId , BucketType , UpdatedProps , Req ) of
806+ Options =
807+ case proplists :get_value (no_restart , ParsedProps , false ) of
808+ true -> [no_restart ];
809+ false -> []
810+ end ,
811+ case update_bucket (Ctx , BucketId , BucketType , UpdatedProps ,
812+ Options , Req ) of
807813 retry ->
808814 handle_bucket_update_inner (BucketId , Req , Params ,
809815 Limit - 1 );
@@ -849,6 +855,10 @@ storage_mode_migration_error(history_retention_enabled_on_bucket) ->
849855 {" Cannot migrate storage mode. history_retention enabled on bucket." , 400 };
850856storage_mode_migration_error (history_retention_enabled_on_collections ) ->
851857 {" Cannot migrate storage mode. history_retention enabled on collections." ,
858+ 400 };
859+ storage_mode_migration_error (eviction_policy_no_restart_required ) ->
860+ {" Eviction policy changes during storage mode migration require "
861+ " --no-restart option." ,
852862 400 }.
853863
854864reply_storage_mode_migration_error (Req , Error ) ->
@@ -875,14 +885,10 @@ maybe_update_cas_props(BucketId, BucketConfig, UpdatedProps, true = _CcvEn) ->
875885maybe_update_cas_props (_ , _ , UpdatedProps , false = _CcEn ) ->
876886 {ok , UpdatedProps }.
877887
878- update_via_orchestrator (Req , BucketId , StorageMode , BucketType , UpdatedProps ) ->
879- update_via_orchestrator (Req , BucketId , StorageMode , BucketType ,
880- UpdatedProps , true ).
881-
882888update_via_orchestrator (Req , BucketId , StorageMode , BucketType , UpdatedProps ,
883- CanRetry ) ->
889+ CanRetry , Options ) ->
884890 case ns_orchestrator :update_bucket (BucketType , StorageMode ,
885- BucketId , UpdatedProps ) of
891+ BucketId , UpdatedProps , Options ) of
886892 ok ->
887893 ns_audit :modify_bucket (Req , BucketId , BucketType , UpdatedProps ),
888894 DisplayBucketType = ns_bucket :display_type (BucketType ,
@@ -911,7 +917,11 @@ update_via_orchestrator(Req, BucketId, StorageMode, BucketType, UpdatedProps,
911917 {error , {storage_mode_migration , janitor_not_run }} when CanRetry ->
912918 ns_orchestrator :ensure_janitor_run ({bucket , BucketId }, 5000 ),
913919 update_via_orchestrator (Req , BucketId , StorageMode , BucketType ,
914- UpdatedProps , false );
920+ UpdatedProps , false , Options );
921+ {error , {eviction_policy_change , janitor_not_run }} when CanRetry ->
922+ ns_orchestrator :ensure_janitor_run ({bucket , BucketId }, 5000 ),
923+ update_via_orchestrator (Req , BucketId , StorageMode , BucketType ,
924+ UpdatedProps , false , Options );
915925 {error , {storage_mode_migration , Error }} ->
916926 reply_storage_mode_migration_error (Req , Error );
917927 {error , secret_not_found } ->
@@ -930,7 +940,7 @@ update_via_orchestrator(Req, BucketId, StorageMode, BucketType, UpdatedProps,
930940 end
931941 end .
932942
933- update_bucket (Ctx , BucketId , BucketType , UpdatedProps , Req ) ->
943+ update_bucket (Ctx , BucketId , BucketType , UpdatedProps , Options , Req ) ->
934944 # bv_ctx {bucket_config = BucketConfig } = Ctx ,
935945 StorageMode = ns_bucket :storage_mode (BucketConfig ),
936946 CcvEn = proplists :get_value (cross_cluster_versioning_enabled ,
@@ -939,7 +949,7 @@ update_bucket(Ctx, BucketId, BucketType, UpdatedProps, Req) ->
939949 case maybe_update_cas_props (BucketId , BucketConfig , UpdatedProps , CcvEn ) of
940950 {ok , UpdateProps1 } ->
941951 update_via_orchestrator (Req , BucketId , StorageMode , BucketType ,
942- UpdateProps1 );
952+ UpdateProps1 , true , Options );
943953 {error , max_cas_vbucket_retrieval_no_map } ->
944954 reply_text (Req , " Unable to retrieve max_cas due to no vBucket map" ,
945955 503 );
@@ -1625,7 +1635,8 @@ basic_bucket_params_screening(Ctx, Params) ->
16251635 CommonParams = validate_common_params (Ctx , Params ),
16261636 TypeSpecificParams =
16271637 validate_bucket_type_specific_params (CommonParams , Params , Ctx ),
1628- Candidates = CommonParams ++ TypeSpecificParams ,
1638+ NoRestartParam = parse_validate_no_restart (Params ),
1639+ Candidates = CommonParams ++ TypeSpecificParams ++ [NoRestartParam ],
16291640 assert_candidates (Candidates ),
16301641 % % Basic parameter checking has been done. Take the non-error key/values
16311642 % % and do additional checking (e.g. relationships between different
@@ -3730,6 +3741,38 @@ parse_validate_workload_pattern_default(Params) ->
37303741 " 'mixed'" >>}
37313742 end .
37323743
3744+ parse_validate_no_restart (Params ) ->
3745+ case proplists :get_value (" noRestart" , Params ) of
3746+ undefined ->
3747+ ignore ;
3748+ Value ->
3749+ case ns_config :read_key_fast (allow_online_eviction_policy_change ,
3750+ false ) of
3751+ true ->
3752+ case menelaus_util :parse_validate_boolean (Value ) of
3753+ {ok , BoolValue } ->
3754+ case proplists :get_value (" evictionPolicy" ,
3755+ Params ) of
3756+ undefined ->
3757+ {error , no_restart ,
3758+ <<" noRestart option has no effect unless "
3759+ " evictionPolicy is being changed" >>};
3760+ _ ->
3761+ {ok , no_restart , BoolValue }
3762+ end ;
3763+ _Error ->
3764+ {error , no_restart ,
3765+ <<" noRestart must be a boolean (true/false)" >>}
3766+ end ;
3767+ false ->
3768+ {error , no_restart ,
3769+ <<" noRestart option is not supported. Enable "
3770+ " allow_online_eviction_policy_change to use this "
3771+ " feature" >>}
3772+ end
3773+ end .
3774+
3775+
37333776handle_compact_bucket (_PoolId , Bucket , Req ) ->
37343777 ok = compaction_api :force_compact_bucket (Bucket ),
37353778 reply (Req , 200 ).
0 commit comments