Merge "Environment in delete failed state was in progress forever"
This commit is contained in:
commit
238e3a60e5
@ -20,10 +20,10 @@ from murano.db import models
|
||||
from murano.db.services import environments as envs
|
||||
from murano.db.services import sessions
|
||||
from murano.db import session as db_session
|
||||
|
||||
from murano.openstack.common.gettextutils import _ # noqa
|
||||
from murano.openstack.common import log as logging
|
||||
from murano.services import actions
|
||||
from murano.services import states
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -50,8 +50,8 @@ class Controller(object):
|
||||
|
||||
# no new session can be opened if environment has deploying status
|
||||
env_status = envs.EnvironmentServices.get_status(environment_id)
|
||||
if env_status in (envs.EnvironmentStatus.DEPLOYING,
|
||||
envs.EnvironmentStatus.DELETING):
|
||||
if env_status in (states.EnvironmentStatus.DEPLOYING,
|
||||
states.EnvironmentStatus.DELETING):
|
||||
LOG.info(_('Could not open session for environment <EnvId: {0}>,'
|
||||
'environment has deploying '
|
||||
'status.').format(environment_id))
|
||||
|
@ -20,9 +20,9 @@ from murano.db import models
|
||||
from murano.db.services import environments as envs
|
||||
from murano.db.services import sessions
|
||||
from murano.db import session as db_session
|
||||
|
||||
from murano.openstack.common.gettextutils import _ # noqa
|
||||
from murano.openstack.common import log as logging
|
||||
from murano.services import states
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
API_NAME = 'Sessions'
|
||||
@ -62,8 +62,8 @@ class Controller(object):
|
||||
|
||||
# no new session can be opened if environment has deploying status
|
||||
env_status = envs.EnvironmentServices.get_status(environment_id)
|
||||
if env_status in (envs.EnvironmentStatus.DEPLOYING,
|
||||
envs.EnvironmentStatus.DELETING):
|
||||
if env_status in (states.EnvironmentStatus.DEPLOYING,
|
||||
states.EnvironmentStatus.DELETING):
|
||||
msg = _('Could not open session for environment <EnvId: {0}>,'
|
||||
'environment has deploying status.').format(environment_id)
|
||||
LOG.error(msg)
|
||||
@ -113,7 +113,7 @@ class Controller(object):
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPUnauthorized(explanation=msg)
|
||||
|
||||
if session.state == sessions.SessionState.DEPLOYING:
|
||||
if session.state == states.SessionState.DEPLOYING:
|
||||
msg = _('Session <SessionId: {0}> is in deploying state and '
|
||||
'could not be deleted').format(session_id)
|
||||
LOG.error(msg)
|
||||
@ -138,7 +138,7 @@ class Controller(object):
|
||||
LOG.error(msg)
|
||||
raise exc.HTTPForbidden(explanation=msg)
|
||||
|
||||
if session.state != sessions.SessionState.OPENED:
|
||||
if session.state != states.SessionState.OPENED:
|
||||
msg = _('Session <SessionId {0}> is already deployed or '
|
||||
'deployment is in progress').format(session_id)
|
||||
LOG.error(msg)
|
||||
|
@ -25,11 +25,11 @@ from murano.common.helpers import token_sanitizer
|
||||
from murano.db import models
|
||||
from murano.db.services import environments
|
||||
from murano.db.services import instances
|
||||
from murano.db.services import sessions
|
||||
from murano.db import session
|
||||
from murano.openstack.common.gettextutils import _ # noqa
|
||||
from murano.openstack.common import log as logging
|
||||
from murano.openstack.common import timeutils
|
||||
from murano.services import states
|
||||
|
||||
|
||||
RPC_SERVICE = None
|
||||
@ -96,13 +96,14 @@ class ResultEndpoint(object):
|
||||
#close session
|
||||
conf_session = unit.query(models.Session).filter_by(
|
||||
**{'environment_id': environment.id,
|
||||
'state': 'deploying' if not deleted else 'deleting'}).first()
|
||||
'state': states.SessionState.DEPLOYING if not deleted
|
||||
else states.SessionState.DELETING}).first()
|
||||
if num_errors > 0:
|
||||
conf_session.state = \
|
||||
sessions.SessionState.DELETE_FAILURE if deleted else \
|
||||
sessions.SessionState.DEPLOY_FAILURE
|
||||
states.SessionState.DELETE_FAILURE if deleted else \
|
||||
states.SessionState.DEPLOY_FAILURE
|
||||
else:
|
||||
conf_session.state = sessions.SessionState.DEPLOYED
|
||||
conf_session.state = states.SessionState.DEPLOYED
|
||||
conf_session.save(unit)
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
from murano.common.helpers import token_sanitizer
|
||||
from murano.db import models
|
||||
from murano.services import state
|
||||
from murano.services import states
|
||||
|
||||
|
||||
def get_environment(session, unit):
|
||||
@ -22,10 +22,11 @@ def get_environment(session, unit):
|
||||
|
||||
|
||||
def update_task(action, session, task, unit):
|
||||
session.state = state.SessionState.deploying
|
||||
objects = session.description.get('Objects', None)
|
||||
session.state = states.SessionState.DELETING if objects is None \
|
||||
else states.SessionState.DEPLOYING
|
||||
task_info = models.Task()
|
||||
task_info.environment_id = session.environment_id
|
||||
objects = session.description.get('Objects', None)
|
||||
if objects:
|
||||
task_info.description = token_sanitizer.TokenSanitizer().sanitize(
|
||||
dict(session.description.get('Objects')))
|
||||
|
@ -12,28 +12,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
|
||||
from murano.common import uuidutils
|
||||
|
||||
from murano.db import models
|
||||
from murano.db.services import sessions
|
||||
from murano.db import session as db_session
|
||||
from murano.services import states
|
||||
|
||||
|
||||
EnvironmentStatus = collections.namedtuple('EnvironmentStatus', [
|
||||
'READY', 'PENDING', 'DEPLOYING', 'DEPLOY_FAILURE', 'DELETING',
|
||||
'DELETE_FAILURE'
|
||||
])(
|
||||
READY='ready',
|
||||
PENDING='pending',
|
||||
DEPLOYING='deploying',
|
||||
DEPLOY_FAILURE='deploy failure',
|
||||
DELETING='deleting',
|
||||
DELETE_FAILURE='delete failure'
|
||||
|
||||
)
|
||||
|
||||
DEFAULT_NETWORKS = {
|
||||
'environment': 'io.murano.resources.NeutronNetwork',
|
||||
# 'flat': 'io.murano.resources.ExistingNetworkConnector'
|
||||
@ -75,20 +60,20 @@ class EnvironmentServices(object):
|
||||
session_list = sessions.SessionServices.get_sessions(environment_id)
|
||||
has_opened = False
|
||||
for session in session_list:
|
||||
if session.state == sessions.SessionState.DEPLOYING:
|
||||
return EnvironmentStatus.DEPLOYING
|
||||
elif session.state == sessions.SessionState.DELETING:
|
||||
return EnvironmentStatus.DELETING
|
||||
elif session.state == sessions.SessionState.DEPLOY_FAILURE:
|
||||
return EnvironmentStatus.DEPLOY_FAILURE
|
||||
elif session.state == sessions.SessionState.DELETE_FAILURE:
|
||||
return EnvironmentStatus.DELETE_FAILURE
|
||||
elif session.state == sessions.SessionState.OPENED:
|
||||
if session.state == states.SessionState.DEPLOYING:
|
||||
return states.EnvironmentStatus.DEPLOYING
|
||||
elif session.state == states.SessionState.DELETING:
|
||||
return states.EnvironmentStatus.DELETING
|
||||
elif session.state == states.SessionState.DEPLOY_FAILURE:
|
||||
return states.EnvironmentStatus.DEPLOY_FAILURE
|
||||
elif session.state == states.SessionState.DELETE_FAILURE:
|
||||
return states.EnvironmentStatus.DELETE_FAILURE
|
||||
elif session.state == states.SessionState.OPENED:
|
||||
has_opened = True
|
||||
if has_opened:
|
||||
return EnvironmentStatus.PENDING
|
||||
return states.EnvironmentStatus.PENDING
|
||||
|
||||
return EnvironmentStatus.READY
|
||||
return states.EnvironmentStatus.READY
|
||||
|
||||
@staticmethod
|
||||
def create(environment_params, tenant_id):
|
||||
@ -169,7 +154,7 @@ class EnvironmentServices(object):
|
||||
if session_id:
|
||||
session = unit.query(models.Session).get(session_id)
|
||||
if sessions.SessionServices.validate(session):
|
||||
if session.state != sessions.SessionState.DEPLOYED:
|
||||
if session.state != states.SessionState.DEPLOYED:
|
||||
env_description = session.description
|
||||
else:
|
||||
env = unit.query(models.Environment) \
|
||||
|
@ -12,24 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
|
||||
from murano.db import models
|
||||
from murano.db import session as db_session
|
||||
from murano.services import actions
|
||||
|
||||
|
||||
SessionState = collections.namedtuple('SessionState', [
|
||||
'OPENED', 'DEPLOYING', 'DEPLOYED', 'DEPLOY_FAILURE', 'DELETING',
|
||||
'DELETE_FAILURE'
|
||||
])(
|
||||
OPENED='opened',
|
||||
DEPLOYING='deploying',
|
||||
DEPLOYED='deployed',
|
||||
DEPLOY_FAILURE='deploy failure',
|
||||
DELETING='deleting',
|
||||
DELETE_FAILURE='delete failure'
|
||||
)
|
||||
from murano.services import states
|
||||
|
||||
|
||||
class SessionServices(object):
|
||||
@ -38,7 +24,7 @@ class SessionServices(object):
|
||||
"""Get list of sessions for specified environment.
|
||||
|
||||
:param environment_id: Environment Id
|
||||
:param state: glazierapi.db.services.environments.EnvironmentStatus
|
||||
:param state: murano.services.states.EnvironmentStatus
|
||||
:return: Sessions for specified Environment, if SessionState is
|
||||
not defined all sessions for specified environment is returned.
|
||||
"""
|
||||
@ -73,7 +59,7 @@ class SessionServices(object):
|
||||
session = models.Session()
|
||||
session.environment_id = environment.id
|
||||
session.user_id = user_id
|
||||
session.state = SessionState.OPENED
|
||||
session.state = states.SessionState.OPENED
|
||||
# used for checking if other sessions was deployed before this one
|
||||
session.version = environment.version
|
||||
# all changes to environment is stored here, and translated to
|
||||
@ -105,9 +91,10 @@ class SessionServices(object):
|
||||
|
||||
#if other session is deploying now current session is invalid
|
||||
other_is_deploying = unit.query(models.Session).filter_by(
|
||||
environment_id=session.environment_id, state=SessionState.DEPLOYING
|
||||
environment_id=session.environment_id,
|
||||
state=states.SessionState.DEPLOYING
|
||||
).count() > 0
|
||||
if session.state == SessionState.OPENED and other_is_deploying:
|
||||
if session.state == states.SessionState.OPENED and other_is_deploying:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -13,7 +13,7 @@
|
||||
from murano.common import rpc
|
||||
from murano.db import models
|
||||
from murano.db.services import actions as actions_db
|
||||
from murano.services import state as states
|
||||
from murano.services import states
|
||||
|
||||
|
||||
class ActionServices(object):
|
||||
|
@ -14,7 +14,26 @@
|
||||
import collections
|
||||
|
||||
SessionState = collections.namedtuple('SessionState', [
|
||||
'open', 'deploying', 'deployed'
|
||||
'OPENED', 'DEPLOYING', 'DEPLOYED', 'DEPLOY_FAILURE', 'DELETING',
|
||||
'DELETE_FAILURE'
|
||||
])(
|
||||
open='open', deploying='deploying', deployed='deployed'
|
||||
OPENED='opened',
|
||||
DEPLOYING='deploying',
|
||||
DEPLOYED='deployed',
|
||||
DEPLOY_FAILURE='deploy failure',
|
||||
DELETING='deleting',
|
||||
DELETE_FAILURE='delete failure'
|
||||
)
|
||||
|
||||
EnvironmentStatus = collections.namedtuple('EnvironmentStatus', [
|
||||
'READY', 'PENDING', 'DEPLOYING', 'DEPLOY_FAILURE', 'DELETING',
|
||||
'DELETE_FAILURE'
|
||||
])(
|
||||
READY='ready',
|
||||
PENDING='pending',
|
||||
DEPLOYING='deploying',
|
||||
DEPLOY_FAILURE='deploy failure',
|
||||
DELETING='deleting',
|
||||
DELETE_FAILURE='delete failure'
|
||||
|
||||
)
|
@ -21,6 +21,7 @@ from murano.db.services import sessions
|
||||
from murano.db import session as db_session
|
||||
from murano.openstack.common.gettextutils import _ # noqa
|
||||
from murano.openstack.common import log as logging
|
||||
from murano.services import states
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -67,7 +68,7 @@ def verify_session(func):
|
||||
'is invalid').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
||||
if session.state == sessions.SessionState.DEPLOYING:
|
||||
if session.state == states.SessionState.DEPLOYING:
|
||||
LOG.info(_('Session <SessionId {0}> is already in '
|
||||
'deployment state').format(session_id))
|
||||
raise exc.HTTPForbidden()
|
||||
|
Loading…
Reference in New Issue
Block a user