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

Add flag before deprovisioning networks #615

Merged
merged 2 commits into from
Oct 18, 2022
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
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