Skip to content

Commit

Permalink
feat: allow for custom cloud-build timeout (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsilva authored Dec 20, 2022
1 parent 8402ffe commit 2be0c0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/wanna/core/models/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DockerModel(BaseModel, extra=Extra.forbid, validate_assignment=True):
- `repository` - [str] (optional) GCP Artifact Registry repository for pushing images
- `registry` - [str] (optional) GCP Artifact Registry, when not set it defaults
to `{gcp_profile.region}-docker.pkg.dev`
- `cloud_build_timeout` - [int] `12000` how many seconds before cloud build timeout
- `cloud_build` - [str] (optional) `false` (default) to build locally, `true` to use GCP Cloud Build
- `cloud_build_workerpool` - [str] (optional) Name of the GCP Cloud Build workerpool if you want to use one
- `cloud_build_workerpool_location` - [str] (optional) Location of the GCP Cloud Build workerpool. Must be specified
Expand All @@ -95,6 +96,7 @@ class DockerModel(BaseModel, extra=Extra.forbid, validate_assignment=True):
images: List[DockerImageModel] = []
repository: Optional[str]
registry: Optional[str]
cloud_build_timeout: int = 12000
cloud_build: bool = False
cloud_build_workerpool: Optional[str]
cloud_build_workerpool_location: Optional[str]
Expand Down
3 changes: 2 additions & 1 deletion src/wanna/core/services/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(
self.location = gcp_profile.region
self.docker_build_config_path = os.getenv("WANNA_DOCKER_BUILD_CONFIG", self.work_dir / "dockerbuild.yaml")
self.build_config = self._read_build_config(self.docker_build_config_path)
self.cloud_build_timeout = docker_model.cloud_build_timeout
self.cloud_build = gcp_access_allowed and docker_model.cloud_build
self.cloud_build_workerpool = docker_model.cloud_build_workerpool
self.cloud_build_workerpool_location = docker_model.cloud_build_workerpool_location or self.location
Expand Down Expand Up @@ -297,7 +298,7 @@ def _build_image_on_gcp_cloud_build(
steps = BuildStep(name="gcr.io/cloud-builders/docker", args=["build", ".", "-f", dockerfile] + tags_args)

timeout = Duration()
timeout.seconds = 7200
timeout.seconds = self.cloud_build_timeout
if self.cloud_build_workerpool:
project_number = convert_project_id_to_project_number(self.project_id)
options = BuildOptions(
Expand Down

0 comments on commit 2be0c0d

Please sign in to comment.