Skip to content
Open
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
24 changes: 24 additions & 0 deletions backend/dataall/core/stacks/aws/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ def _get_stack(**data) -> dict:
except ClientError as e:
raise e

@staticmethod
def describe_stack_status(engine, task: Task):
"""Light describe: only updates stack status (and stackid) from DescribeStacks. No resources, events, or outputs."""
try:
data = {
'accountid': task.payload['accountid'],
'region': task.payload['region'],
'stack_name': task.payload['stack_name'],
}
cfn_stack = CloudFormation._get_stack(**data)
stack_arn = cfn_stack['StackId']
status = cfn_stack['StackStatus']
with engine.scoped_session() as session:
stack: Stack = session.query(Stack).get(task.payload['stackUri'])
stack.status = status
stack.stackid = stack_arn
session.commit()
except ClientError as e:
with engine.scoped_session() as session:
stack: Stack = session.query(Stack).get(task.payload['stackUri'])
if not stack.error:
stack.error = {'error': json_utils.to_string(e.response['Error']['Message'])}
session.commit()

@staticmethod
def describe_stack_resources(engine, task: Task):
try:
Expand Down
5 changes: 5 additions & 0 deletions backend/dataall/core/stacks/handlers/stack_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def delete_stack(engine, task: Task):
raise e
return {'status': 200, 'stackDeleted': True}

@staticmethod
@Worker.handler(path='cloudformation.stack.describe_status')
def describe_stack_status(engine, task: Task):
CloudFormation.describe_stack_status(engine, task)

@staticmethod
@Worker.handler(path='cloudformation.stack.describe_resources')
def describe_stack_resources(engine, task: Task):
Expand Down
22 changes: 21 additions & 1 deletion backend/dataall/core/stacks/services/stack_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,32 @@ def resolve_parent_obj_stack(targetUri: str, targetType: str, environmentUri: st
)
return stack

cfn_task = StackService.save_describe_stack_task(session, env, stack, targetUri)
cfn_task = StackService.save_describe_stack_status_task(session, env, stack, targetUri)
Worker.queue(engine=context.db_engine, task_ids=[cfn_task.taskUri])
return stack

@staticmethod
def save_describe_stack_status_task(session, environment, stack, target_uri):
"""Light describe task for view path: only updates status (no resources, events, outputs)."""
cfn_task = Task(
targetUri=stack.stackUri,
action='cloudformation.stack.describe_status',
payload={
'accountid': environment.AwsAccountId,
'region': environment.region,
'role_arn': environment.CDKRoleArn,
'stack_name': stack.name,
'stackUri': stack.stackUri,
'targetUri': target_uri,
},
)
session.add(cfn_task)
session.commit()
return cfn_task

@staticmethod
def save_describe_stack_task(session, environment, stack, target_uri):
"""Full describe task: status, outputs, resources, events. Used when opening Stack tab."""
cfn_task = Task(
targetUri=stack.stackUri,
action='cloudformation.stack.describe_resources',
Expand Down
Loading