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 authored Oct 18, 2022
1 parent 56e151d commit 1746bcf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
21 changes: 17 additions & 4 deletions skyplane/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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 @@ -469,7 +473,9 @@ def sync(


@app.command()
def deprovision():
def deprovision(
all: bool = typer.Option(False, "--all", "-a", help="Deprovision all resources including networks."),
):
"""Deprovision all resources created by skyplane."""
instances = query_instances()

Expand All @@ -479,9 +485,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 1746bcf

Please sign in to comment.