Skip to content
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

sceptre validate fails with obsolete stack config of which the template has already been deleted #1491

Closed
mvanholsteijn opened this issue Jul 31, 2024 · 7 comments
Assignees

Comments

@mvanholsteijn
Copy link

Subject of the issue

When running sceptre validate, the validate will fail on an obsolete stack config of which the template has already been deleted.

Your environment

  • 4.4.2
  • 3.9.11
  • MacOS/Linux

Steps to reproduce

  • add an the property obsolete: true to a stack config
  • delete the corresponding template file
  • sceptre validate will error FileNotFoundError: [Errno 2] No such file or directory:

Expected behaviour

  • that it either ignores the obsolete stack, ignores the error or that you can tell sceptre to ignore obsolete stack on validate (like launch --prune)

Actual behaviour

-- sceptre validate errors with error FileNotFoundError: [Errno 2] No such file or directory:

@alex-harvey-z3q
Copy link
Contributor

Much the same as with the other issue you have raised #1492, my initial feeling is that this is working by design. Since the intent and purpose of sceptre validate is to validate templates, its use on stacks whose templates have been deleted does not make sense to me.

I would be happy to offer advice on what I would do instead, but firstly you might have to explain why you would delete the template in the first place? Why is marking it as obsolete not sufficient? Apologies if this is a silly question, because I don't use this obsolete feature.

@mvanholsteijn
Copy link
Author

We run sceptre launch --prune which will delete stacks which have the property obsolete set to true. For this operation, it does not use the template any more. So, when we set the property to true we also delete the template as it is no longer required and we want it deleted.

Sceptre provides the obsolete property by design too and works on launch without template. Is it strange that I expect it to not break the validate run of 230 stack configs?

@zaro0508
Copy link
Contributor

zaro0508 commented Aug 2, 2024

@mvanholsteijn I would expect that sceptre validate should ignore sceptre configs that contain obsolete:true. Do you know if this is a regression? Does your sceptre config have dependencies? Anyways, it would be very helpful if you can attach your scpetre config to this issue.

@alex-harvey-z3q
Copy link
Contributor

@zaro0508 It does not appear to be a regression; I can reproduce the same behaviour using the commit where the feature was added, v3.2.0 and v3.2.2. The feature was added by @jfalkenstein and I wonder if he is around to offer any insights on whether this observed behaviour is a bug or intentional?

@alex-harvey-z3q
Copy link
Contributor

alex-harvey-z3q commented Aug 3, 2024

I notice that this Pruner has been implemented as a class in the CLI and contains this private method:

    def _plan_has_obsolete_stacks(self, plan: SceptrePlan):
        return len(plan.command_stacks) > 0

Perhaps with some refactoring we could move some of that to helpers and something like this could work?

--- a/sceptre/cli/template.py
+++ b/sceptre/cli/template.py
@@ -11,6 +11,9 @@ from sceptre.resolvers.placeholders import use_resolver_placeholders_on_error
 
 logger = logging.getLogger(__name__)
 
+def plan_has_obsolete_stacks(plan: SceptrePlan):
+    return len(plan.command_stacks) > 0
+
 
 @click.command(name="validate", short_help="Validates the template.")
 @click.option(
@@ -45,6 +48,10 @@ def validate_command(ctx, no_placeholders, path):
     execution_context = (
         null_context() if no_placeholders else use_resolver_placeholders_on_error()
     )
+
+    if plan_has_obsolete_stacks(plan):
+        return
+
     with execution_context:
         responses = plan.validate()

@alex-harvey-z3q
Copy link
Contributor

@mvanholsteijn What is your reason for deleting the templates after marking stacks as obsolete? Although I have never used this feature, it would be my expectation that validate would fail if you deleted the template from a stack but left the config that referred to it behind. If you do not want the template any more, why would you want the config to be there?

Again it could be my ignorance, as I have never used this feature.

@alex-harvey-z3q alex-harvey-z3q self-assigned this Aug 9, 2024
@alex-harvey-z3q
Copy link
Contributor

Having heard no response, closing this. I believe this is working as designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants