Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
delete Jobs with Background propagation policy
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Jul 5, 2024
1 parent 1b41fab commit 4ca5e82
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 12 additions & 0 deletions e2e/e2e.ml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ let check_pod_age ~component ~smaller_than =
in
assert b

let count_pods ~generate_name =
let stdout, _ =
kubectl
(Printf.sprintf
{|get pod -n e2e -o json | jq '[.items[] | select(.metadata.generateName == "%s")] | length'|}
generate_name)
in
stdout |> String.trim |> int_of_string

let setup () = ()

let () =
Expand All @@ -194,6 +203,9 @@ let () =
wait_deploy_available ~n:"e2e" "mastodon0-streaming";
wait_deploy_available ~n:"e2e" "mastodon0-web";

assert (count_pods ~generate_name:"mastodon0-pre-migration-" = 0);
assert (count_pods ~generate_name:"mastodon0-post-migration-" = 0);

check_deploy_resources ~n:"e2e" ~limits_cpu:"1" ~limits_memory:"1000Mi"
~requests_cpu:"100m" ~requests_memory:"100Mi" "mastodon0-web";
check_deploy_resources ~n:"e2e" ~limits_memory:"100Mi"
Expand Down
5 changes: 3 additions & 2 deletions lib/k.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,13 @@ module Make (B : Bare.S) = struct
B.list_for_all_namespaces ~sw client ()
|> expect_one |> Result.map B.to_list

let delete client ?uid ?namespace ~name () =
let delete client ?propagation_policy ?uid ?namespace ~name () =
let namespace = Option.value ~default:"" namespace in
Eio.Switch.run @@ fun sw ->
B.delete_namespaced ~sw client ~name ~namespace
B.delete_namespaced ~sw client ~name ~namespace ?propagation_policy
~body:
(Io_k8s_apimachinery_pkg_apis_meta_v1_delete_options.make
?propagation_policy
~preconditions:
(Io_k8s_apimachinery_pkg_apis_meta_v1_preconditions.make ?uid ())
())
Expand Down
3 changes: 2 additions & 1 deletion lib/mastodon_reconciler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ let delete_job client ~(mastodon : Mastodon.t) ~kind =
let name = Option.get (Option.get mastodon.metadata).name in
let namespace = Option.get (Option.get mastodon.metadata).namespace in
let job_name = get_job_name name kind in
K.Job.delete client ~name:job_name ~namespace ()
K.Job.delete client ~name:job_name ~namespace ~propagation_policy:"Background"
()
|> ignore_not_found_error
|> Result.map_error K.show_error

Expand Down

0 comments on commit 4ca5e82

Please sign in to comment.