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

PTFE-1402 enable or disable external IP GCP runner #523

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions runner_manager/backend/gcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ def disks(self) -> List[AttachedDisk]:

@property
def network_interfaces(self) -> List[NetworkInterface]:
return [
NetworkInterface(
network=self.instance_config.network,
access_configs=[
AccessConfig(
name="External NAT",
)
],
)
]
network_interface: NetworkInterface = NetworkInterface(
network=self.instance_config.network,
)
if self.instance_config.enable_external_ip:
network_interface.access_configs = [
AccessConfig(
name="External NAT",
)
]
return [network_interface]

@property
def scheduling(self) -> Scheduling:
Expand Down
1 change: 1 addition & 0 deletions runner_manager/models/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class GCPInstanceConfig(InstanceConfig):
machine_type: str = "e2-small"
network: str = "global/networks/default"
enable_nested_virtualization: bool = True
enable_external_ip: bool = True
spot: bool = False
disk_size_gb: int = 20
disk_type: Literal["pd-ssd", "pd-standard"] = "pd-ssd"
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/backend/test_gcp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import List

from google.cloud.compute import Image
from google.cloud.compute import Image, NetworkInterface
from pytest import fixture, mark, raises
from redis_om import NotFoundError

Expand Down Expand Up @@ -57,6 +57,12 @@ def gcp_runner(runner: Runner, gcp_group: RunnerGroup) -> Runner:
def test_gcp_network_interfaces(gcp_group: RunnerGroup):
interfaces = gcp_group.backend.network_interfaces
assert len(interfaces) == 1
assert interfaces[0].access_configs[0].name == "External NAT"
# Test disabling external IP
gcp_group.backend.instance_config.enable_external_ip = False
interfaces: List[NetworkInterface] = gcp_group.backend.network_interfaces
assert len(interfaces) == 1
assert len(interfaces[0].access_configs) == 0


def test_gcp_group(gcp_group: RunnerGroup):
Expand Down
Loading