Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
20
Merge Requests
20
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
f384b432
Commit
f384b432
authored
Jan 14, 2025
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.grid.promise: fixup! prevent json file corruption while updating data
parent
8e0ca4c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
slapos/grid/promise/__init__.py
slapos/grid/promise/__init__.py
+2
-2
slapos/tests/test_promise.py
slapos/tests/test_promise.py
+9
-2
No files found.
slapos/grid/promise/__init__.py
View file @
f384b432
...
...
@@ -474,7 +474,7 @@ class PromiseLauncher(object):
try
:
with
open
(
history_file
)
as
f
:
history_dict
=
json
.
load
(
f
)
except
OSError
as
e
:
except
(
IOError
,
OSError
)
as
e
:
if
e
.
errno
!=
errno
.
ENOENT
:
raise
except
ValueError
:
...
...
@@ -507,7 +507,7 @@ class PromiseLauncher(object):
try
:
with
open
(
stat_file_path
)
as
f
:
stat_dict
=
json
.
load
(
f
)
except
OSError
as
e
:
except
(
IOError
,
OSError
)
as
e
:
if
e
.
errno
!=
errno
.
ENOENT
:
raise
except
ValueError
:
...
...
slapos/tests/test_promise.py
View file @
f384b432
...
...
@@ -569,7 +569,7 @@ class RunPromise(GenericPromise):
def
test_runpromise_with_currupted_history
(
self
):
promise_name
=
'my_promise'
self
.
configureLauncher
()
self
.
generatePromiseScript
(
'my_promise.py'
,
success
=
True
,
periodicity
=
0.0
3
)
self
.
generatePromiseScript
(
'my_promise.py'
,
success
=
True
,
periodicity
=
0.0
2
)
self
.
launcher
.
run
()
self
.
assertSuccessResult
(
promise_name
)
...
...
@@ -598,7 +598,7 @@ class RunPromise(GenericPromise):
f
.
write
(
"""{
"data": ["Date, Success,
"""
)
time
.
sleep
(
4
)
time
.
sleep
(
3
)
with
self
.
assertRaises
(
ValueError
):
self
.
assertSuccessHistoryResult
(
promise_name
)
...
...
@@ -612,6 +612,13 @@ class RunPromise(GenericPromise):
# Statistics data file is not broken anymore
self
.
assertSuccessStatsResult
(
1
)
# make sure all works after history_file not exists
os
.
unlink
(
history_file
)
time
.
sleep
(
3
)
self
.
launcher
.
run
()
self
.
assertSuccessHistoryResult
(
promise_name
)
def
test_runpromise_no_logdir
(
self
):
promise_name
=
'my_promise.py'
# no promise log output dir
...
...
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