Fix for Heat Salt Formula
Add correct stack_absent delete handling to prevent playing
in russian roulette. Now if stack is deleted before it's polled,
_poll_for_complete handle it correctly, without raising incorrect
exception.
Also dirty hack with sys.path.insert is removed.
Related-Issue: PROD-22102
Change-Id: I7f994c26304069052344c881b34e540e49fd5a32
diff --git a/_modules/heatv1/__init__.py b/_modules/heatv1/__init__.py
index 51d90b4..45c5cdb 100644
--- a/_modules/heatv1/__init__.py
+++ b/_modules/heatv1/__init__.py
@@ -11,14 +11,8 @@
except ImportError:
REQUIREMENTS_MET = False
-import os
-import sys
-# i failed to load module witjout this
-# seems bugs in salt or it is only me
-sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
-
-import stack
+from heatv1 import stack
stack_create = stack.stack_create
stack_delete = stack.stack_delete
diff --git a/_modules/heatv1/stack.py b/_modules/heatv1/stack.py
index ace3db0..001dc1d 100644
--- a/_modules/heatv1/stack.py
+++ b/_modules/heatv1/stack.py
@@ -1,6 +1,6 @@
from yaml import safe_load
import json
-import common
+from heatv1 import common
try:
from urllib.parse import urlencode
except ImportError:
diff --git a/_states/heatv1.py b/_states/heatv1.py
index 4ee8cf5..45cff84 100644
--- a/_states/heatv1.py
+++ b/_states/heatv1.py
@@ -28,6 +28,10 @@
name=stack_name,
cloud_name=cloud_name)
if not stack["result"]:
+ if action == "DELETE" and stack['status_code'] == 404:
+ stack_status = 'DELETE COMPLETE'
+ msg = msg_template % dict(name=stack_name, status=stack_status)
+ return 'DELETE_COMPLETE', msg
raise Exception("request for stack failed")
stack = stack["body"]["stack"]