Skip to content

Commit

Permalink
Add flag before deprovisioning networks (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
parasj committed Oct 18, 2022
1 parent 961e64d commit 44eb38f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
18 changes: 15 additions & 3 deletions skyplane/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import skyplane.cli.usage.client
from skyplane import GB
from skyplane.cli.usage.client import UsageClient, UsageStatsStatus
from skyplane.compute.azure.azure_auth import AzureAuthentication
from skyplane.compute.azure.azure_cloud_provider import AzureCloudProvider
from skyplane.compute.gcp.gcp_auth import GCPAuthentication
from skyplane.compute.gcp.gcp_cloud_provider import GCPCloudProvider
from skyplane.replicate.replicator_client import ReplicatorClient, TransferStats

import typer
Expand Down Expand Up @@ -476,6 +480,7 @@ def deprovision(
filter_client_id: Optional[str] = typer.Option(
None, help="Only deprovision instances with this client ID under the skyplaneclientid instance tag."
),
all: bool = typer.Option(False, "--all", "-a", help="Deprovision all resources including networks."),
):
"""Deprovision all resources created by skyplane."""
instances = query_instances()
Expand All @@ -488,9 +493,16 @@ def deprovision(
else:
typer.secho("No instances to deprovision", fg="yellow", bold=True)

if AWSAuthentication().enabled():
aws = AWSCloudProvider()
aws.teardown_global()
if all:
if AWSAuthentication().enabled():
aws = AWSCloudProvider()
aws.teardown_global()
if GCPAuthentication().enabled():
gcp = GCPCloudProvider()
gcp.teardown_global()
if AzureAuthentication().enabled():
azure = AzureCloudProvider()
azure.teardown_global()


@app.command()
Expand Down
6 changes: 3 additions & 3 deletions skyplane/compute/cloud_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def provision_instance(
raise NotImplementedError

def setup_global(self, **kwargs):
raise NotImplementedError
pass

def setup_region(self, region: str):
raise NotImplementedError
pass

def teardown_global(self):
raise NotImplementedError
pass
7 changes: 4 additions & 3 deletions skyplane/compute/gcp/gcp_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ def get_adc_credential(google_auth, project_id=None):
logger.warning(f"Failed to load GCP credentials for project {project_id}: {e}")
inferred_cred, inferred_project = (None, None)
if project_id is not None and project_id != inferred_project:
logger.warning(
f"Google project ID error: Project ID from config {project_id} does not match inferred project from google.auth ADC {inferred_project}. Defaulting to config project."
)
if inferred_project is not None:
logger.warning(
f"Google project ID error: Project ID from config {project_id} does not match inferred project from google.auth ADC {inferred_project}. Defaulting to config project."
)
inferred_project = project_id
return inferred_cred, inferred_project

Expand Down

0 comments on commit 44eb38f

Please sign in to comment.