From 7fc9648bcc01284715876e815d04fcf9f63ca0d9 Mon Sep 17 00:00:00 2001 From: mromaszewicz Date: Tue, 19 Nov 2019 20:51:27 -0800 Subject: [PATCH] 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. --- stacker/stack.py | 6 ------ stacker/tests/test_plan.py | 24 ++++++++++++++++++++++++ stacker/tests/test_stack.py | 26 -------------------------- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/stacker/stack.py b/stacker/stack.py index aa5ab81b4..950fcd548 100644 --- a/stacker/stack.py +++ b/stacker/stack.py @@ -85,12 +85,6 @@ def required_by(self): @property def requires(self): - # By definition, a locked stack has no dependencies, because we won't - # be performing an update operation on the stack. This means, resolving - # outputs from dependencies is unnecessary. - if self.locked and not self.force: - return [] - requires = set(self.definition.requires or []) # Add any dependencies based on output lookups diff --git a/stacker/tests/test_plan.py b/stacker/tests/test_plan.py index a88c5e460..dda72569b 100644 --- a/stacker/tests/test_plan.py +++ b/stacker/tests/test_plan.py @@ -115,6 +115,30 @@ def fn(stack, status=None): self.assertEquals(calls, ['namespace-vpc.1', 'namespace-bastion.1']) + def test_execute_plan_locked(self): + # Locked stacks still need to have their requires evaluated when + # they're being created. + vpc = Stack( + definition=generate_definition('vpc', 1), + context=self.context) + bastion = Stack( + definition=generate_definition('bastion', 1, requires=[vpc.name]), + locked=True, + context=self.context) + + calls = [] + + def fn(stack, status=None): + calls.append(stack.fqn) + return COMPLETE + + graph = build_graph([Step(vpc, fn), Step(bastion, fn)]) + plan = build_plan( + description="Test", graph=graph) + plan.execute(walk) + + self.assertEquals(calls, ['namespace-vpc.1', 'namespace-bastion.1']) + def test_execute_plan_filtered(self): vpc = Stack( definition=generate_definition('vpc', 1), diff --git a/stacker/tests/test_stack.py b/stacker/tests/test_stack.py index c1bba0156..ccdab6622 100644 --- a/stacker/tests/test_stack.py +++ b/stacker/tests/test_stack.py @@ -49,32 +49,6 @@ def test_stack_requires(self): stack.requires, ) - def test_stack_requires_when_locked(self): - definition = generate_definition( - base_name="vpc", - stack_id=1, - variables={ - "Var1": "${noop fakeStack3::FakeOutput}", - "Var2": ( - "some.template.value:${output fakeStack2::FakeOutput}:" - "${output fakeStack::FakeOutput}" - ), - "Var3": "${output fakeStack::FakeOutput}," - "${output fakeStack2::FakeOutput}", - }, - requires=["fakeStack"], - ) - stack = Stack(definition=definition, context=self.context) - - stack.locked = True - self.assertEqual(len(stack.requires), 0) - - # TODO(ejholmes): When the stack is in `--force`, it's not really - # locked. Maybe it would be better if `stack.locked` were false when - # the stack is in `--force`. - stack.force = True - self.assertEqual(len(stack.requires), 2) - def test_stack_requires_circular_ref(self): definition = generate_definition( base_name="vpc",