Skip to content

Commit

Permalink
Locked stacks still have requirements (#746)
Browse files Browse the repository at this point in the history
This fixes 745. Locked stacks still have dependencies, since there
is no difference between a locked stack and an unlocked stack at
creation time.
  • Loading branch information
mromaszewicz authored and phobologic committed Nov 20, 2019
1 parent 1c07ff2 commit 7fc9648
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
6 changes: 0 additions & 6 deletions stacker/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions stacker/tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
26 changes: 0 additions & 26 deletions stacker/tests/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7fc9648

Please sign in to comment.