Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure call to GCP only happens when cloud build is enabled #125

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/wanna/core/services/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def __init__(
self.build_dir = self.work_dir / "build" / "docker"
self.wanna_project_name = wanna_project_name
self.project_id = gcp_profile.project_id
self.project_number = convert_project_id_to_project_number(self.project_id)
self.location = gcp_profile.region
self.docker_build_config_path = os.getenv(
"WANNA_DOCKER_BUILD_CONFIG", self.work_dir / "dockerbuild.yaml"
Expand Down Expand Up @@ -454,6 +453,7 @@ def _build_image_on_gcp_cloud_build(
timeout = Duration()
timeout.seconds = self.cloud_build_timeout
DEFAULT_POLLING._timeout = self.cloud_build_timeout
project_number = convert_project_id_to_project_number(self.project_id)

dockerfile = os.path.relpath(file_path, context_dir)
blob = self._upload_context_dir_to_gcs(
Expand All @@ -473,7 +473,7 @@ def _build_image_on_gcp_cloud_build(
else (
BuildOptions(
pool=BuildOptions.PoolOption(
name=f"projects/{self.project_number}/locations/{self.cloud_build_workerpool_location}/workerPools/{self.cloud_build_workerpool}"
name=f"projects/{project_number}/locations/{self.cloud_build_workerpool_location}/workerPools/{self.cloud_build_workerpool}"
)
),
f"{self.cloud_build_workerpool_location}-cloudbuild.googleapis.com",
Expand Down Expand Up @@ -505,9 +505,9 @@ def _build_image_on_gcp_cloud_build(
build_id = op.metadata.build.id
base = "https://console.cloud.google.com/cloud-build/builds"
link = base + (
f";region={self.cloud_build_workerpool_location}/{build_id}?project={self.project_number}"
f";region={self.cloud_build_workerpool_location}/{build_id}?project={project_number}"
if self.cloud_build_workerpool
else f"/{build_id}?project={self.project_number}"
else f"/{build_id}?project={project_number}"
)

logger.user_info(text=f"Build started {link}")
Expand Down
Loading