Skip to content

Commit 7fc9648

Browse files
mromaszewiczphobologic
authored andcommitted
Locked stacks still have requirements (#746)
This fixes 745. Locked stacks still have dependencies, since there is no difference between a locked stack and an unlocked stack at creation time.
1 parent 1c07ff2 commit 7fc9648

File tree

3 files changed

+24
-32
lines changed

3 files changed

+24
-32
lines changed

stacker/stack.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ def required_by(self):
8585

8686
@property
8787
def requires(self):
88-
# By definition, a locked stack has no dependencies, because we won't
89-
# be performing an update operation on the stack. This means, resolving
90-
# outputs from dependencies is unnecessary.
91-
if self.locked and not self.force:
92-
return []
93-
9488
requires = set(self.definition.requires or [])
9589

9690
# Add any dependencies based on output lookups

stacker/tests/test_plan.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,30 @@ def fn(stack, status=None):
115115

116116
self.assertEquals(calls, ['namespace-vpc.1', 'namespace-bastion.1'])
117117

118+
def test_execute_plan_locked(self):
119+
# Locked stacks still need to have their requires evaluated when
120+
# they're being created.
121+
vpc = Stack(
122+
definition=generate_definition('vpc', 1),
123+
context=self.context)
124+
bastion = Stack(
125+
definition=generate_definition('bastion', 1, requires=[vpc.name]),
126+
locked=True,
127+
context=self.context)
128+
129+
calls = []
130+
131+
def fn(stack, status=None):
132+
calls.append(stack.fqn)
133+
return COMPLETE
134+
135+
graph = build_graph([Step(vpc, fn), Step(bastion, fn)])
136+
plan = build_plan(
137+
description="Test", graph=graph)
138+
plan.execute(walk)
139+
140+
self.assertEquals(calls, ['namespace-vpc.1', 'namespace-bastion.1'])
141+
118142
def test_execute_plan_filtered(self):
119143
vpc = Stack(
120144
definition=generate_definition('vpc', 1),

stacker/tests/test_stack.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,6 @@ def test_stack_requires(self):
4949
stack.requires,
5050
)
5151

52-
def test_stack_requires_when_locked(self):
53-
definition = generate_definition(
54-
base_name="vpc",
55-
stack_id=1,
56-
variables={
57-
"Var1": "${noop fakeStack3::FakeOutput}",
58-
"Var2": (
59-
"some.template.value:${output fakeStack2::FakeOutput}:"
60-
"${output fakeStack::FakeOutput}"
61-
),
62-
"Var3": "${output fakeStack::FakeOutput},"
63-
"${output fakeStack2::FakeOutput}",
64-
},
65-
requires=["fakeStack"],
66-
)
67-
stack = Stack(definition=definition, context=self.context)
68-
69-
stack.locked = True
70-
self.assertEqual(len(stack.requires), 0)
71-
72-
# TODO(ejholmes): When the stack is in `--force`, it's not really
73-
# locked. Maybe it would be better if `stack.locked` were false when
74-
# the stack is in `--force`.
75-
stack.force = True
76-
self.assertEqual(len(stack.requires), 2)
77-
7852
def test_stack_requires_circular_ref(self):
7953
definition = generate_definition(
8054
base_name="vpc",

0 commit comments

Comments
 (0)