Add revert_previous_change_set method to the Stack class#67
Add revert_previous_change_set method to the Stack class#67PiotrKozlowski wants to merge 3 commits intomainfrom
Conversation
|
Can someone look into this test case error? from but then, for the second call, It seems to be some kind of cached pointer, but I can't find a way this behaves that way and how to solve this. |
|
Re recording the requests seems to fix it @PiotrKozlowski |
| logger.info("Applying previous parameters...") | ||
| apply_change_set(params: @previous_parameters, wait: wait) | ||
| @previous_parameters = nil | ||
| else |
There was a problem hiding this comment.
The previous change set could also have had a different stack template. So we'd need to use that too? (the change set we are trying to revert could be using both new parameter values and a new template). Code like https://github.com/openstax/aws-ruby/blob/master/lib/openstax/aws/stack.rb#L59-L60 is maybe helpful.
There was a problem hiding this comment.
Is this something which may happen only when we code this directly, like in the test: it "can be updated with a new template" where we create a new stack and then create new stack class and instead of calling create we just call apply_change_set?
In this case, it seems like it would be not possible to retrieve the first template data using cached @previous_template because it would be a new class.
It seems like this case for creating a new stack class and calling apply_change_set instead of create is something which would be outside of the current concept of reverting changes using @previous_parameters to store the previous values.
I was thinking about passing template_s3_url to the revert_to_previous_change_set and apply_change_set methods which would work but it would not update response for stack.template method
What do you think would be the best option to allow reverting templates?
There was a problem hiding this comment.
Looks good, I've added some fixes and updated cassettes: #71
| logger.info("**** DRY RUN ****") if dry_run | ||
|
|
||
| if @previous_parameters | ||
| logger.info("Applying previous parameters...") |
There was a problem hiding this comment.
"Reverting to previous change set..." is probably more appropriate given the comment below about templates changing too
| apply_change_set(params: @previous_parameters, wait: wait) | ||
| @previous_parameters = nil | ||
| else | ||
| logger.info("There are no saved previous parameters for #{name} stack.") |
There was a problem hiding this comment.
Should this be an error? logger.error? And if an error should we exit or raise?
There was a problem hiding this comment.
I would not call an error here and just let the user know that he called a method on a stack which does not have a previous version
If you want me to change that, please let me know what should happen in that case
| def apply_change_set(params: {}, wait: false) | ||
| logger.info("**** DRY RUN ****") if dry_run | ||
|
|
||
| @previous_parameters = deployed_parameters |
There was a problem hiding this comment.
Do we need to persist the previous parameters or template somewhere? If the process dies, these instance variables will be lost and we will no longer be able to revert.
There was a problem hiding this comment.
Hmm, that's a good question. I'm not sure if this should be done in this or a in a separate issue. I also don't know what would be the best way to achive this - some temp file?
cc @TomWoodward
for: https://app.zenhub.com/workspaces/openstax-unified-5b71aabe3815ff014b102258/issues/openstax/unified/972
Used in https://github.com/openstax/unified-deployment/pull/97
I don't know why the test is failing, so I still need to fix it, butplease let me know what do you think of this approachI've based my test on the previous test. Just added 3 lines for reverting and checking if changes were applied.