Skip to content

Commit ccf7aed

Browse files
committed
Add light stack describe task
1 parent 509ebf1 commit ccf7aed

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

backend/dataall/core/stacks/aws/cloudformation.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ def _get_stack(**data) -> dict:
7070
except ClientError as e:
7171
raise e
7272

73+
@staticmethod
74+
def describe_stack_status(engine, task: Task):
75+
"""Light describe: only updates stack status (and stackid) from DescribeStacks. No resources, events, or outputs."""
76+
try:
77+
data = {
78+
'accountid': task.payload['accountid'],
79+
'region': task.payload['region'],
80+
'stack_name': task.payload['stack_name'],
81+
}
82+
cfn_stack = CloudFormation._get_stack(**data)
83+
stack_arn = cfn_stack['StackId']
84+
status = cfn_stack['StackStatus']
85+
with engine.scoped_session() as session:
86+
stack: Stack = session.query(Stack).get(task.payload['stackUri'])
87+
stack.status = status
88+
stack.stackid = stack_arn
89+
session.commit()
90+
except ClientError as e:
91+
with engine.scoped_session() as session:
92+
stack: Stack = session.query(Stack).get(task.payload['stackUri'])
93+
if not stack.error:
94+
stack.error = {'error': json_utils.to_string(e.response['Error']['Message'])}
95+
session.commit()
96+
7397
@staticmethod
7498
def describe_stack_resources(engine, task: Task):
7599
try:

backend/dataall/core/stacks/handlers/stack_handlers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ def delete_stack(engine, task: Task):
3131
raise e
3232
return {'status': 200, 'stackDeleted': True}
3333

34+
@staticmethod
35+
@Worker.handler(path='cloudformation.stack.describe_status')
36+
def describe_stack_status(engine, task: Task):
37+
CloudFormation.describe_stack_status(engine, task)
38+
3439
@staticmethod
3540
@Worker.handler(path='cloudformation.stack.describe_resources')
3641
def describe_stack_resources(engine, task: Task):

backend/dataall/core/stacks/services/stack_service.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,32 @@ def resolve_parent_obj_stack(targetUri: str, targetType: str, environmentUri: st
9090
)
9191
return stack
9292

93-
cfn_task = StackService.save_describe_stack_task(session, env, stack, targetUri)
93+
cfn_task = StackService.save_describe_stack_status_task(session, env, stack, targetUri)
9494
Worker.queue(engine=context.db_engine, task_ids=[cfn_task.taskUri])
9595
return stack
9696

97+
@staticmethod
98+
def save_describe_stack_status_task(session, environment, stack, target_uri):
99+
"""Light describe task for view path: only updates status (no resources, events, outputs)."""
100+
cfn_task = Task(
101+
targetUri=stack.stackUri,
102+
action='cloudformation.stack.describe_status',
103+
payload={
104+
'accountid': environment.AwsAccountId,
105+
'region': environment.region,
106+
'role_arn': environment.CDKRoleArn,
107+
'stack_name': stack.name,
108+
'stackUri': stack.stackUri,
109+
'targetUri': target_uri,
110+
},
111+
)
112+
session.add(cfn_task)
113+
session.commit()
114+
return cfn_task
115+
97116
@staticmethod
98117
def save_describe_stack_task(session, environment, stack, target_uri):
118+
"""Full describe task: status, outputs, resources, events. Used when opening Stack tab."""
99119
cfn_task = Task(
100120
targetUri=stack.stackUri,
101121
action='cloudformation.stack.describe_resources',

0 commit comments

Comments
 (0)