Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
13b1215a
Commit
13b1215a
authored
1 year ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-2829
: fixed parsing of df results. start task anyway if df fails.
parent
f871b619
No related branches found
No related tags found
1 merge request
!1326
TMSS-2829
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/backend/services/copy_service/copy_service.py
+40
-37
40 additions, 37 deletions
SAS/TMSS/backend/services/copy_service/copy_service.py
with
40 additions
and
37 deletions
SAS/TMSS/backend/services/copy_service/copy_service.py
+
40
−
37
View file @
13b1215a
...
@@ -80,44 +80,47 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler):
...
@@ -80,44 +80,47 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler):
if
subtask
[
'
state_value
'
]
!=
'
queued
'
:
if
subtask
[
'
state_value
'
]
!=
'
queued
'
:
return
return
# determine destination host and root_dir
try
:
destination
=
subtask
[
'
specifications_doc
'
][
'
destination
'
]
# determine destination host and root_dir
dst_host
=
destination
[:
destination
.
find
(
'
:
'
)]
if
'
:
'
in
destination
else
'
'
destination
=
subtask
[
'
specifications_doc
'
][
'
destination
'
]
dst_root_dir
=
'
/
'
+
destination
.
lstrip
(
dst_host
+
'
:
'
).
split
(
'
/
'
)[
1
]
dst_host
=
destination
[:
destination
.
find
(
'
:
'
)]
if
'
:
'
in
destination
else
''
# strip unneeded localhost to prevent unneeded ssh calls
dst_root_dir
=
'
/
'
+
destination
.
lstrip
(
dst_host
+
'
:
'
).
split
(
'
/
'
)[
1
]
dst_host
=
dst_host
.
lstrip
(
'
localhost:
'
).
lstrip
(
'
127.0.0.1:
'
)
# strip unneeded localhost to prevent unneeded ssh calls
dst_host
=
dst_host
.
lstrip
(
'
localhost:
'
).
lstrip
(
'
127.0.0.1:
'
)
df_cmd
=
[
'
df
'
,
dst_root_dir
]
if
dst_host
:
df_cmd
=
[
'
df
'
,
dst_root_dir
]
df_cmd
=
wrap_command_in_ssh_call
(
df_cmd
,
dst_host
)
if
dst_host
:
df_cmd
=
wrap_command_in_ssh_call
(
df_cmd
,
dst_host
)
logger
.
info
(
"
checking free disk space for copy-subtask id=%s, executing: %s
"
,
subtask
[
'
id
'
],
'
'
.
join
(
df_cmd
))
logger
.
info
(
"
checking free disk space for copy-subtask id=%s, executing: %s
"
,
subtask
[
'
id
'
],
'
'
.
join
(
df_cmd
))
# run df cmd, and parse output for total free disk space
df_result
=
check_output_returning_strings
(
df_cmd
)
# run df cmd, and parse output for total free disk space
logger
.
info
(
str
(
df_result
)
)
df_result
=
check_output_returning_strings
(
df_cmd
)
df_result_line
=
df_result
.
splitlines
()[
-
1
]
df_result_line
=
df_result
.
splitlines
()[
-
1
]
logger
.
info
(
str
(
df_result_line
)
)
df_result_line_parts
=
df_result_line
.
split
(
)
df_result_line_parts
=
df_result_line
.
split
(
'
'
)
df_bytes
=
int
(
df_result_line
_parts
[
3
]
)
logger
.
info
(
str
(
df_result_line_parts
)
)
input_dp_sizes
=
self
.
tmss_client
.
get_url_as_json_object
(
subtask
[
'
url
'
].
rstrip
(
'
/
'
)
+
'
/input_dataproducts?fields=size
'
)
df_bytes
=
int
(
df_result_line_parts
[
3
]
)
total_size
=
sum
(
x
[
'
size
'
]
for
x
in
input_dp_sizes
)
input_dp_sizes
=
self
.
tmss_client
.
get_url_as_json_object
(
subtask
[
'
url
'
].
rstrip
(
'
/
'
)
+
'
/input_dataproducts?fields=size
'
)
total_size
=
sum
(
x
[
'
size
'
]
for
x
in
input_dp
_size
s
)
if
df_bytes
>
total
_size
:
logger
.
info
(
"
enough free disk space available for copy-subtask id=%s destination=%s df=%d needed=%d
"
,
subtask
[
'
id
'
],
destination
,
df_bytes
,
total_size
)
if
df_bytes
>
total_size
:
logger
.
info
(
"
enough free disk space available for copy-subtask id=%s destination=%s df=%d needed=%d
"
,
subtask
[
'
id
'
],
destination
,
df_bytes
,
total_size
)
# clear previously set "not enough free disk space available" error_reason if set
if
subtask
.
get
(
'
error_reason
'
):
# clear previously set "not enough free disk space available"
error_reason
if set
self
.
tmss_client
.
do_request_and_get_result_as_string
(
'
PATCH
'
,
subtask
[
'
url
'
],
{
'
error_reason
'
:
None
})
if
subtask
.
get
(
'
error_reason
'
):
self
.
tmss_client
.
do_request_and_get_result_as_string
(
'
PATCH
'
,
subtask
[
'
url
'
],
{
'
error_reason
'
:
None
})
# run it
self
.
run_copy_subtask
(
subtask
)
# run it
else
:
self
.
run_
copy
_
subtask
(
subtask
)
msg
=
"
not enough free disk space available to start
copy
-
subtask
id=%s df=%d needed=%d
"
%
(
subtask
[
'
id
'
],
df_bytes
,
total_size
)
else
:
logger
.
info
(
msg
)
msg
=
"
not enough free disk space available to start copy-subtask id=%s df=%d needed=%d
"
%
(
subtask
[
'
id
'
],
df_bytes
,
total_size
)
self
.
tmss_client
.
do_request_and_get_result_as_string
(
'
PATCH
'
,
subtask
[
'
url
'
],
{
'
error_reason
'
:
msg
}
)
logger
.
info
(
msg
)
except
Exception
as
e
:
self
.
tmss_client
.
do_request_and_get_result_as_string
(
'
PATCH
'
,
subtask
[
'
url
'
],
{
'
error_reason
'
:
msg
}
)
logger
.
exception
(
str
(
e
)
)
# try to run it anyway, maybe it fails on not enough disk space.
# if it fails while running, then it results in an error status, and the user can take appropriate action.
self
.
run_copy_subtask
(
subtask
)
def
run_copy_subtask
(
self
,
subtask
):
def
run_copy_subtask
(
self
,
subtask
):
if
subtask
[
'
subtask_type
'
]
!=
'
copy
'
:
if
subtask
[
'
subtask_type
'
]
!=
'
copy
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment