def destroy(plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any]) -> None: _logger.debug("Running emr_on_eks destroy!") sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'") virtual_cluster_name = f"orbit-{context.name}-{team_context.name}" emr = boto3.client("emr-containers") response = emr.list_virtual_clusters( containerProviderId=f"orbit-{context.name}", containerProviderType="EKS", maxResults=500) if "virtualClusters" in response: for c in response["virtualClusters"]: if c["name"] == virtual_cluster_name: try: delete_response = emr.delete_virtual_cluster(id=c["id"]) _logger.debug("delete_virtual_cluster:", delete_response) except Exception as e: _logger.warning(e) pass cdk_destroy( stack_name=f"orbit-{context.name}-{team_context.name}-emr-on-eks", app_filename=os.path.join(ORBIT_EMR_ON_EKS_ROOT, "cdk.py"), context=context, team_context=team_context, parameters=parameters, )
def destroy(plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any]) -> None: _logger.debug("Destroying Redshift plugin resources for team %s", team_context.name) sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'") cdk_destroy( stack_name=f"orbit-{context.name}-{team_context.name}-{plugin_id}-redshift", app_filename=os.path.join(PLUGIN_ROOT_PATH, "orbit_redshift_stack.py"), context=context, team_context=team_context, parameters=parameters, )
def destroy(plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any]) -> None: _logger.debug("Running hello_world destroy!") sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'") cdk_destroy( stack_name=f"orbit-{context.name}-{team_context.name}-hello", app_filename=os.path.join(PLUGIN_ROOT_PATH, "hello_cdk.py"), context=context, team_context=team_context, parameters=parameters, )
def destroy(plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any]) -> None: _logger.debug("Destroying CodeCommit plugin resources for team %s", team_context.name) cdk_destroy( stack_name=f"orbit-{context.name}-{team_context.name}-codecommit", app_filename=os.path.join(ORBIT_CODE_COMMIT_ROOT, "cdk.py"), context=context, team_context=team_context, parameters=parameters, )
def destroy( plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any], ) -> None: _logger.debug("Running emr_on_eks destroy!") sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'") cluster_name = f"orbit-{context.name}" virtual_cluster_name = f"orbit-{context.name}-{team_context.name}" delete_virtual_cluster(cluster_name, virtual_cluster_name) cdk_destroy( stack_name=f"orbit-{context.name}-{team_context.name}-emr-on-eks", app_filename=os.path.join(ORBIT_EMR_ON_EKS_ROOT, "cdk.py"), context=context, team_context=team_context, parameters=parameters, )
def destroy( plugin_id: str, context: "Context", team_context: "TeamContext", parameters: Dict[str, Any], ) -> None: _logger.debug("Destroying Redshift plugin resources for team %s", team_context.name) sh.run(f"echo 'Team name: {team_context.name} | Plugin ID: {plugin_id}'") # Delete left over redshift cluster(s) before deleting plugin resources try: pass redshift = boto3.client("redshift") clusters = redshift.describe_clusters(TagValues=[team_context.name])["Clusters"] namespace = "orbit-" + context.name + "-" + team_context.name + "-" # Deleting redshift clusters in parallel. for cluster in clusters: cluster_id = cluster["ClusterIdentifier"] _logger.debug(f"cluster_id={cluster_id}") _logger.debug(f"namespace={namespace}") if namespace in cluster_id: cluster_name = cluster_id redshift.delete_cluster(ClusterIdentifier=cluster_name, SkipFinalClusterSnapshot=True) _logger.debug(f"Delete redshift cluster_name={cluster_name}") # Hold before destroying the redshift plugin resource. time.sleep(180) _logger.debug(f"Deleted {team_context.name} team redshift clusters") except Exception as e: _logger.error("Error deleting team %s redshift cluster(s) : %s", team_context.name, e) raise e cdk_destroy( stack_name=f"orbit-{context.name}-{team_context.name}-{plugin_id}-redshift", app_filename=os.path.join(PLUGIN_ROOT_PATH, "orbit_redshift_stack.py"), context=context, team_context=team_context, parameters=parameters, )