Skip to content

Commit

Permalink
Merge pull request #2881 from DataDog/baptiste.foy/FA/keep-env
Browse files Browse the repository at this point in the history
upgrade(onboarding): Add option to keep VMs
  • Loading branch information
BaptisteFoy authored Aug 14, 2024
2 parents b7164df + 7166c02 commit 68a6376
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions utils/virtual_machine/aws_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,26 @@ def _start_vm(self, vm):
self.install_provision(vm, ec2_server, server_connection, create_cache=ami_id is None)

def stack_destroy(self):
logger.info(f"Destroying VMs: {self.vms}")
try:
self.stack.destroy(on_output=logger.info, debug=True)
self.datadog_event_sender.sendEventToDatadog(
f"[E2E] Stack {self.stack_name} : success on Pulumi stack destroy",
"",
["operation:destroy", "result:ok", f"stack:{self.stack_name}"],
)
except Exception as pulumi_exception:
logger.error("Exception destroying aws provision infraestructure")
logger.exception(pulumi_exception)
self.datadog_event_sender.sendEventToDatadog(
f"[E2E] Stack {self.stack_name} : error on Pulumi stack destroy",
repr(pulumi_exception),
["operation:destroy", "result:fail", f"stack:{self.stack_name}"],
if os.getenv("ONBOARDING_KEEP_VMS") is None:
logger.info(f"Destroying VMs: {self.vms}")
try:
self.stack.destroy(on_output=logger.info, debug=True)
self.datadog_event_sender.sendEventToDatadog(
f"[E2E] Stack {self.stack_name} : success on Pulumi stack destroy",
"",
["operation:destroy", "result:ok", f"stack:{self.stack_name}"],
)
except Exception as pulumi_exception:
logger.error("Exception destroying aws provision infraestructure")
logger.exception(pulumi_exception)
self.datadog_event_sender.sendEventToDatadog(
f"[E2E] Stack {self.stack_name} : error on Pulumi stack destroy",
repr(pulumi_exception),
["operation:destroy", "result:fail", f"stack:{self.stack_name}"],
)
else:
logger.info(
f"Did not destroy VMs as ONBOARDING_KEEP_VMS is set. To destroy them, re-run the test without this env var."
)

def _get_cached_ami(self, vm):
Expand Down

0 comments on commit 68a6376

Please sign in to comment.