-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If apply fails, attempt to run destroy #58
Conversation
|
/easycla |
3487639
to
85c9323
Compare
85c9323
to
a78f465
Compare
@@ -12,7 +12,7 @@ classifiers=[ | |||
readme = "README.md" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependencies update is required for the current black hook to work.
# Try to destroy partially applied resources | ||
self.destroy() | ||
finally: | ||
raise e from None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally ignore any errors from Destroy. In the test case, Destroy happens to fail for the same reason as the apply fails. In production scenarios, Destroy will normally work and destroy anything partially created by the apply step.
@@ -266,7 +273,8 @@ def parse_state( | |||
|
|||
for r in data.get("resources", ()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If resources are not correctly applied, the list of instances may be empty.
local_file.foo | ||
] | ||
} | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simulate a partial apply:
1 TF apply creates some resources (the local file in this case)
2 TF apply fail on some unrelated resource
Unfortunately local_file
resource wont fail if the local file exists already, it just overwrites. So I couldn't use it for the second step.
Instead, we force a failure using a data element to read a non existent file. The side effect of this is the destroy step also fails. But I couldn't find another way to simulate a scenario where a partial apply happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kapilt ready for review |
thanks for the pull request and detailed commentary. |
Codecov ReportBase: 92.81% // Head: 92.90% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
==========================================
+ Coverage 92.81% 92.90% +0.09%
==========================================
Files 8 8
Lines 473 479 +6
==========================================
+ Hits 439 445 +6
Misses 34 34
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@kapilt CI done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, this looks great.
closes #59