Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
feudalBackend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
feudal
feudalBackend
Commits
f1054f5a
Commit
f1054f5a
authored
Dec 15, 2018
by
Lukas Burgey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change deployment state target updating
parent
34fb6521
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
5 deletions
+46
-5
feudal/backend/models/__init__.py
feudal/backend/models/__init__.py
+1
-3
feudal/backend/models/deployments.py
feudal/backend/models/deployments.py
+45
-2
No files found.
feudal/backend/models/__init__.py
View file @
f1054f5a
...
@@ -44,9 +44,7 @@ class Site(models.Model):
...
@@ -44,9 +44,7 @@ class Site(models.Model):
dep_states
=
[
dep_states
=
[
state
state
for
state
in
self
.
states
.
all
()
for
state
in
self
.
states
.
all
()
if
(
if
state
.
is_pending
and
state
.
deployments
.
exists
()
state
.
is_pending
or
state
.
is_credential_pending
)
and
state
.
deployments
.
exists
()
]
]
# make the deployments unique here
# make the deployments unique here
...
...
feudal/backend/models/deployments.py
View file @
f1054f5a
...
@@ -428,13 +428,20 @@ class DeploymentState(models.Model):
...
@@ -428,13 +428,20 @@ class DeploymentState(models.Model):
return
True
return
True
# pending because the state target is not reached
# pending because the state target is not reached
if
self
.
state
==
QUESTIONNAIRE
or
self
.
state
==
REJECTED
:
return
False
if
self
.
state_target
!=
self
.
state
:
if
self
.
state_target
!=
self
.
state
:
return
True
return
True
return
False
# passing through is_credential_pending here
return
self
.
is_credential_pending
@
property
@
property
def
is_credential_pending
(
self
):
def
is_credential_pending
(
self
):
# little hack to not confuse the user
if
self
.
state
==
QUESTIONNAIRE
or
self
.
state
==
REJECTED
:
return
False
for
credential_state
in
self
.
credential_states
.
all
():
for
credential_state
in
self
.
credential_states
.
all
():
if
credential_state
.
is_pending
:
if
credential_state
.
is_pending
:
return
True
return
True
...
@@ -496,6 +503,40 @@ class DeploymentState(models.Model):
...
@@ -496,6 +503,40 @@ class DeploymentState(models.Model):
# STATE TRANSITIONS
# STATE TRANSITIONS
# DeploymentState.dep_target_changed
# called when one of our deployment changes its state_target
def
dep_target_changed
(
self
):
LOGGER
.
debug
(
self
.
msg
(
'dep_target_changed'
))
self
.
_assure_credential_states_exist
()
for
cred_state
in
self
.
credential_states
.
all
():
cred_state
.
set_target
(
self
.
state_target
)
if
self
.
state_target
==
DEPLOYED
:
# handle the 7 states we can be in
if
self
.
state
==
NOT_DEPLOYED
or
self
.
state
==
REMOVAL_PENDING
:
self
.
_set_state
(
DEPLOYMENT_PENDING
)
elif
self
.
state
==
DEPLOYED
or
self
.
state
==
DEPLOYMENT_PENDING
:
LOGGER
.
debug
(
self
.
msg
(
'has already reached the correct state'
))
elif
self
.
state
==
QUESTIONNAIRE
:
LOGGER
.
debug
(
self
.
msg
(
'is questionnaire! Need answers first'
))
elif
self
.
state
==
REJECTED
:
LOGGER
.
debug
(
self
.
msg
(
'is rejected! The site will never execute this deployement'
))
elif
self
.
state
==
FAILED
:
LOGGER
.
debug
(
self
.
msg
(
'is failed! We will retry it'
))
elif
self
.
state_target
==
NOT_DEPLOYED
:
self
.
_reset
()
# handle the 7 states we can be in
if
self
.
state
==
DEPLOYED
or
self
.
state
==
DEPLOYMENT_PENDING
:
self
.
_set_state
(
REMOVAL_PENDING
)
elif
self
.
state
==
NOT_DEPLOYED
or
self
.
state
==
REMOVAL_PENDING
:
LOGGER
.
debug
(
self
.
msg
(
'has already reached the correct state'
))
elif
self
.
state
==
FAILED
or
self
.
state
==
REJECTED
or
self
.
state
==
QUESTIONNAIRE
:
self
.
_set_state
(
NOT_DEPLOYED
)
#
# DeploymentState.user_deploy
# DeploymentState.user_deploy
def
user_deploy
(
self
):
def
user_deploy
(
self
):
LOGGER
.
debug
(
self
.
msg
(
'user_deploy'
))
LOGGER
.
debug
(
self
.
msg
(
'user_deploy'
))
...
@@ -514,6 +555,7 @@ class DeploymentState(models.Model):
...
@@ -514,6 +555,7 @@ class DeploymentState(models.Model):
self
.
_set_state
(
DEPLOYMENT_PENDING
)
self
.
_set_state
(
DEPLOYMENT_PENDING
)
# deprecated
# DeploymentState.user_remove
# DeploymentState.user_remove
# returns True if no other deployment needs this state_item to be deployed
# returns True if no other deployment needs this state_item to be deployed
def
user_remove
(
self
):
def
user_remove
(
self
):
...
@@ -552,6 +594,7 @@ class DeploymentState(models.Model):
...
@@ -552,6 +594,7 @@ class DeploymentState(models.Model):
# True: signal the callee that a publish_to_client is permitted
# True: signal the callee that a publish_to_client is permitted
return
True
return
True
# deprecated
# user: questionnaire answered
# user: questionnaire answered
def
user_answers
(
self
,
answers
=
None
):
def
user_answers
(
self
,
answers
=
None
):
if
not
self
.
deployments
.
exists
():
if
not
self
.
deployments
.
exists
():
...
@@ -618,7 +661,7 @@ class DeploymentState(models.Model):
...
@@ -618,7 +661,7 @@ class DeploymentState(models.Model):
# publish after we updated the values of the response
# publish after we updated the values of the response
self
.
_set_state
(
state
,
publish
=
True
)
self
.
_set_state
(
state
,
publish
=
True
)
if
s
tate
==
FAILED
or
state
==
REJECTED
:
if
s
elf
.
state
==
FAILED
or
self
.
state
==
REJECTED
or
self
.
state
==
QUESTIONNAIRE
:
return
return
# is the target reached now?
# is the target reached now?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment