Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Xavier Thompson
slapos
Commits
47bb7e5a
Commit
47bb7e5a
authored
Oct 04, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/html5as-base: Add custom promise demo
parent
de45e89a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
2 deletions
+73
-2
software/html5as-base/buildout.hash.cfg
software/html5as-base/buildout.hash.cfg
+6
-2
software/html5as-base/instance.cfg.in
software/html5as-base/instance.cfg.in
+1
-0
software/html5as-base/instance_html5as.cfg.in
software/html5as-base/instance_html5as.cfg.in
+9
-0
software/html5as-base/promise/check_index_exists.py
software/html5as-base/promise/check_index_exists.py
+52
-0
software/html5as-base/software.cfg
software/html5as-base/software.cfg
+5
-0
No files found.
software/html5as-base/buildout.hash.cfg
View file @
47bb7e5a
...
...
@@ -17,11 +17,11 @@
[template-cfg]
filename = instance.cfg.in
md5sum =
9e486efe4ab1aba8cb72b04f6c6da8ad
md5sum =
51292164b96db5889010e0962c96ee96
[instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in
md5sum =
f8d1777c43b173a900cfbdf104dec990
md5sum =
98b880debb61556066c5d720c1cb86e3
[template_nginx_conf]
_update_hash_filename_ = templates/nginx_conf.in
...
...
@@ -46,3 +46,7 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2
[template_instance_replicate]
_update_hash_filename_ = instance_replicate.cfg.in
md5sum = 7ff7e11d05145115f53564ec1af205ef
[custom-promise]
_update_hash_filename_ = promise/check_index_exists.py
md5sum = a98d598136629e667e7e43e1d3746b53
software/html5as-base/instance.cfg.in
View file @
47bb7e5a
...
...
@@ -15,6 +15,7 @@ template_launcher = {{ template_launcher_target }}
template_index_html = {{ template_index_html_target }}
template_graceful = {{ template_graceful_target }}
template_monitor = {{ template_monitor }}
custom_promise = {{ custom_promise }}
[instance-html5as]
recipe = slapos.recipe.template:jinja2
...
...
software/html5as-base/instance_html5as.cfg.in
View file @
47bb7e5a
...
...
@@ -14,6 +14,7 @@ parts =
launcher
nginx-graceful
port-listening-promise
index-exists-promise
logrotate-entry-nginx
publish-connection-information
...
...
@@ -240,3 +241,11 @@ name = html5as-http-frontend.py
url = ${html5as-frontend:connection-secure_access}
config-url = ${:url}
config-check-secure = 1
# Add the custom promise to check that the index file exists
[index-exists-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ parameter_list['custom_promise'] }}
output = ${directory:plugins}/check-index-exists.py
config-filepath = ${html5as:default_index}
software/html5as-base/promise/check_index_exists.py
0 → 100644
View file @
47bb7e5a
import
os
from
zope.interface
import
implementer
from
slapos.grid.promise
import
interface
from
slapos.grid.promise.generic
import
GenericPromise
@
implementer
(
interface
.
IPromise
)
class
RunPromise
(
GenericPromise
):
def
__init__
(
self
,
config
):
"""
Called when initialising the promise before testing.
Sets the configuration and the periodicity.
"""
super
(
RunPromise
,
self
).
__init__
(
config
)
self
.
setPeriodicity
(
minute
=
2
)
def
sense
(
self
):
"""
Called every time the promise is tested.
Signals a positive or negative result.
In this case, check whether the file exists.
"""
path
=
self
.
getConfig
(
'filepath'
)
if
os
.
path
.
isfile
(
path
):
self
.
logger
.
info
(
"filepath %s exists and is a file"
,
path
)
else
:
self
.
logger
.
error
(
"filepath %s does not exist or is not a file"
,
path
)
def
test
(
self
):
"""
Called after sense() if the instance is still converging.
Returns success or failure based on sense results.
In this case, fail if the previous sensor result is negative.
"""
return
self
.
_test
(
result_count
=
1
,
failure_amount
=
1
)
def
anomaly
(
self
):
"""
Called after sense() if the instance has finished converging.
Returns success or failure based on sense results.
Failure signals the instance has diverged.
In this case, fail if two out of the last three results are negative.
"""
return
self
.
_anomaly
(
result_count
=
3
,
failure_amount
=
2
)
software/html5as-base/software.cfg
View file @
47bb7e5a
...
...
@@ -44,6 +44,7 @@ context =
key template_graceful_target template_graceful:target
key template_instance_replicate template_instance_replicate:target
key template_monitor monitor2-template:rendered
key custom_promise custom-promise:target
[download-base]
recipe = slapos.recipe.build:download
...
...
@@ -77,3 +78,7 @@ mode = 0644
recipe = zc.recipe.egg
eggs =
plone.recipe.command
# Download the custom promise
[custom-promise]
<= download-base
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