From b3fbd490d63db21a04d344612cbc1d8044c643b8 Mon Sep 17 00:00:00 2001 From: Guillaume Genestier Date: Fri, 6 Dec 2024 16:32:07 +0100 Subject: [PATCH 1/3] Tezt/Cloud: Add a --no-docker-push CLI option --- tezt/lib_cloud/cli.ml | 11 +++++++++++ tezt/lib_cloud/cli.mli | 4 ++++ tezt/lib_cloud/cloud.ml | 4 ++-- tezt/lib_cloud/deployement.ml | 2 +- tezt/lib_cloud/env.ml | 2 ++ tezt/lib_cloud/env.mli | 17 ++++++++++------- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/tezt/lib_cloud/cli.ml b/tezt/lib_cloud/cli.ml index 1c4ee03eb26c..0ace75a0fc84 100644 --- a/tezt/lib_cloud/cli.ml +++ b/tezt/lib_cloud/cli.ml @@ -263,3 +263,14 @@ let check_file_consistency = Although a scenario can opt in or opt out, this flag sets the default \ behavior. Its default value is [true] unless [--macosx] is used." (not macosx) + +let push_docker = + Clap.flag + ~section + ~unset_long:"no-docker-push" + ~description: + "When used with a remote machine, by default, `tezt-cloud` pushes the \ + Docker container to the created VM. When one tries to reuse an existing \ + VM, and do not use the updated content of the Docker container, pushing \ + this container takes a significant time for no purpose." + true diff --git a/tezt/lib_cloud/cli.mli b/tezt/lib_cloud/cli.mli index b98f947c9b88..9434b77b2166 100644 --- a/tezt/lib_cloud/cli.mli +++ b/tezt/lib_cloud/cli.mli @@ -112,3 +112,7 @@ val macosx : bool (** Check for file consistency. *) val check_file_consistency : bool + +(** Specify if the docker container should be pushed. + Only considered for remote mode. *) +val push_docker : bool diff --git a/tezt/lib_cloud/cloud.ml b/tezt/lib_cloud/cloud.ml index dffd8918d10c..48292b10c186 100644 --- a/tezt/lib_cloud/cloud.ml +++ b/tezt/lib_cloud/cloud.ml @@ -569,7 +569,7 @@ let register ?proxy_files ?proxy_args ?vms ~__FILE__ ~title ~tags ?seed | `Cloud -> (* The scenario is executed locally and the VMs are on the cloud. *) let* () = Jobs.deploy_docker_registry () in - let* () = Jobs.docker_build ~push:true () in + let* () = Jobs.docker_build ~push:Env.push_docker () in let* deployement = Deployement.deploy ~configurations in let* () = Deployement.agents deployement @@ -582,7 +582,7 @@ let register ?proxy_files ?proxy_args ?vms ~__FILE__ ~title ~tags ?seed let* proxy_running = try_reattach () in if not proxy_running then let* () = Jobs.deploy_docker_registry () in - let* () = Jobs.docker_build ~push:true () in + let* () = Jobs.docker_build ~push:Env.push_docker () in let* deployement = Deployement.deploy ~configurations in let* () = Deployement.agents deployement diff --git a/tezt/lib_cloud/deployement.ml b/tezt/lib_cloud/deployement.ml index 93b09de8a804..68f28d5577e7 100644 --- a/tezt/lib_cloud/deployement.ml +++ b/tezt/lib_cloud/deployement.ml @@ -189,7 +189,7 @@ module Remote = struct let* () = Jobs.docker_build ~docker_image:configuration.Configuration.docker_image - ~push:true + ~push:Env.push_docker () in let* () = Terraform.VM.Workspace.select workspace_name in diff --git a/tezt/lib_cloud/env.ml b/tezt/lib_cloud/env.ml index 8f2e9f5bb324..7ecffac7d953 100644 --- a/tezt/lib_cloud/env.ml +++ b/tezt/lib_cloud/env.ml @@ -83,6 +83,8 @@ let macosx = Cli.macosx let check_file_consistency = Cli.check_file_consistency +let push_docker = Cli.push_docker + let project_id = Gcloud.project_id let init () = diff --git a/tezt/lib_cloud/env.mli b/tezt/lib_cloud/env.mli index 9ae789f6cff7..2ace4f4fab29 100644 --- a/tezt/lib_cloud/env.mli +++ b/tezt/lib_cloud/env.mli @@ -10,11 +10,11 @@ type docker_image = Gcp of {alias : string} | Octez_release of {tag : string} -(** Equivalent to [Cli.tezt_cloud], but if not present, checks if `TEZT_CLOUD` +(** Equivalent to [Cli.tezt_cloud], but if not present, checks if `TEZT_CLOUD` is provided. *) val tezt_cloud : string -(** [ssh_private_key_filename ?home ()] returns the private key path associated to +(** [ssh_private_key_filename ?home ()] returns the private key path associated to the [?home] path and the [tezt_cloud] argument. *) val ssh_private_key_filename : ?home:string -> unit -> string @@ -114,10 +114,13 @@ val macosx : bool (** Equivalent to [Cli.check_file_consistency]. *) val check_file_consistency : bool +(** Equivalent to [Cli.push_docker]. *) +val push_docker : bool + (** Equivalent to [Gcloud.project_id]. *) val project_id : unit -> string Lwt.t -(** [init ()] initialises and deploys a Docker registry using Terraform, only when the +(** [init ()] initialises and deploys a Docker registry using Terraform, only when the [mode] is either [`Host] or [`Cloud]. *) val init : unit -> unit Lwt.t @@ -132,8 +135,8 @@ val registry_uri : unit -> string Lwt.t [docker_image]'s type. *) val uri_of_docker_image : docker_image -> string Lwt.t -(** [wait_process ?sleep ~is_ready ~run ()] recursively waits for [~run] process to be ready. - When the process is successful, but no [~is_ready], it loops after [?sleep] seconds. If +(** [wait_process ?sleep ~is_ready ~run ()] recursively waits for [~run] process to be ready. + When the process is successful, but no [~is_ready], it loops after [?sleep] seconds. If it is ready, it returns the read output. If it fails, this gets logged. *) val wait_process : ?sleep:int -> @@ -142,11 +145,11 @@ val wait_process : unit -> string Lwt.t -(** [run_command ?cmd_wrapper cmd args] can wrap the command given by [cmd] and [args] with +(** [run_command ?cmd_wrapper cmd args] can wrap the command given by [cmd] and [args] with a [Gcloud] wrapper, depending on the value of [?cmd_wrapper]. *) val run_command : ?cmd_wrapper:Gcloud.cmd_wrapper -> string -> string list -> Process.t -(** [dns_domains ()] returns a list of fully qualified domain names (FQDNs) based on current +(** [dns_domains ()] returns a list of fully qualified domain names (FQDNs) based on current configuration (given by [Cli.dns_domains]) and [mode] of operation. *) val dns_domains : unit -> string list Lwt.t -- GitLab From 2610ab35d3209662393c1eca1ab5962d4d11f778 Mon Sep 17 00:00:00 2001 From: Guillaume Genestier Date: Fri, 6 Dec 2024 17:30:00 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Fran=C3=A7ois's=20remarks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tezt/lib_cloud/cli.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tezt/lib_cloud/cli.ml b/tezt/lib_cloud/cli.ml index 0ace75a0fc84..d14e4286d7d2 100644 --- a/tezt/lib_cloud/cli.ml +++ b/tezt/lib_cloud/cli.ml @@ -269,8 +269,10 @@ let push_docker = ~section ~unset_long:"no-docker-push" ~description: - "When used with a remote machine, by default, `tezt-cloud` pushes the \ - Docker container to the created VM. When one tries to reuse an existing \ - VM, and do not use the updated content of the Docker container, pushing \ - this container takes a significant time for no purpose." + "When used in cloud mode (--cloud) or proxy mode (--proxy), by default, \ + `tezt-cloud` pushes the Docker container n GCP. This is useful to save \ + some bandwidth or some times during a redeployment that won't \ + add/remove VMs that are already running. VM, and do not use the updated \ + content of the Docker container, pushing this container takes a \ + significant time for no purpose." true -- GitLab From 4c74cd67ed1cfb09a74de6ef37dae322feb0186a Mon Sep 17 00:00:00 2001 From: Guillaume Genestier Date: Mon, 9 Dec 2024 16:15:44 +0100 Subject: [PATCH 3/3] Paul's comments --- tezt/lib_cloud/cli.ml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tezt/lib_cloud/cli.ml b/tezt/lib_cloud/cli.ml index d14e4286d7d2..ab63df141f16 100644 --- a/tezt/lib_cloud/cli.ml +++ b/tezt/lib_cloud/cli.ml @@ -270,9 +270,8 @@ let push_docker = ~unset_long:"no-docker-push" ~description: "When used in cloud mode (--cloud) or proxy mode (--proxy), by default, \ - `tezt-cloud` pushes the Docker container n GCP. This is useful to save \ - some bandwidth or some times during a redeployment that won't \ - add/remove VMs that are already running. VM, and do not use the updated \ - content of the Docker container, pushing this container takes a \ - significant time for no purpose." + `tezt-cloud` pushes the Docker containers on GCP. To save some \ + bandwidth or some time during a redeployment that won't add or remove \ + VMs that are already running, it is useful to prevent those containers \ + to be pushed." true -- GitLab