Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
93fec841
Commit
93fec841
authored
8 years ago
by
Danny Auble
Browse files
Options
Downloads
Patches
Plain Diff
Conversion functions needed to handle the transition of consumed_energy from
a SUM of the steps to the job table.
parent
25dfb3d8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/accounting_storage/mysql/as_mysql_convert.c
+60
-24
60 additions, 24 deletions
src/plugins/accounting_storage/mysql/as_mysql_convert.c
with
60 additions
and
24 deletions
src/plugins/accounting_storage/mysql/as_mysql_convert.c
+
60
−
24
View file @
93fec841
...
...
@@ -41,9 +41,23 @@
static
int
_convert_job_table
(
mysql_conn_t
*
mysql_conn
,
char
*
cluster_name
)
{
int
rc
=
SLURM_SUCCESS
;
char
*
query
=
xstrdup_printf
(
"update
\"
%s_%s
\"
set tres_alloc="
"concat(concat('%d=', cpus_alloc));"
,
cluster_name
,
job_table
,
TRES_CPU
);
char
*
query
=
xstrdup_printf
(
"update
\"
%s_%s
\"
as job "
"left outer join ( select job_db_inx, "
"SUM(consumed_energy) 'sum_energy' "
"from
\"
%s_%s
\"
where id_step >= 0 "
"and consumed_energy != %"
PRIu64
" group by job_db_inx ) step on "
"job.job_db_inx=step.job_db_inx "
"set job.tres_alloc=concat("
"job.tres_alloc, concat(',%d=', "
"case when step.sum_energy then "
"step.sum_energy else %"
PRIu64
" END)) "
"where job.tres_alloc != '' && "
"job.tres_alloc not like '%%,%d=%%';"
,
cluster_name
,
job_table
,
cluster_name
,
step_table
,
NO_VAL64
,
TRES_ENERGY
,
NO_VAL64
,
TRES_ENERGY
);
debug4
(
"(%s:%d) query
\n
%s"
,
THIS_FILE
,
__LINE__
,
query
);
if
((
rc
=
mysql_db_query
(
mysql_conn
,
query
))
!=
SLURM_SUCCESS
)
...
...
@@ -57,9 +71,10 @@ static int _convert_job_table(mysql_conn_t *mysql_conn, char *cluster_name)
static
int
_convert_step_table
(
mysql_conn_t
*
mysql_conn
,
char
*
cluster_name
)
{
int
rc
=
SLURM_SUCCESS
;
char
*
query
=
xstrdup_printf
(
"update
\"
%s_%s
\"
set tres_alloc=concat('%d=', cpus_alloc);"
,
cluster_name
,
step_table
,
TRES_CPU
);
char
*
query
=
xstrdup_printf
(
"update
\"
%s_%s
\"
set consumed_energy=%"
PRIu64
" where consumed_energy=%u;"
,
cluster_name
,
step_table
,
NO_VAL64
,
NO_VAL
);
debug4
(
"(%s:%d) query
\n
%s"
,
THIS_FILE
,
__LINE__
,
query
);
if
((
rc
=
mysql_db_query
(
mysql_conn
,
query
))
!=
SLURM_SUCCESS
)
...
...
@@ -85,12 +100,12 @@ extern int as_mysql_convert_tables(mysql_conn_t *mysql_conn)
return
SLURM_SUCCESS
;
/* See if the old table exist first. I
f already ran here
default_acct and default_wckey won't exist
.
/* See if the old table exist first. I
n this case we would had already
* have the energy tres in the tres_alloc
.
*/
query
=
xstrdup_printf
(
"s
how columns
from
\"
%s_%s
\"
where "
"
Field='cpu_count' || Field='count'
;"
,
cluster_name
,
event
_table
);
query
=
xstrdup_printf
(
"s
elect tres_alloc
from
\"
%s_%s
\"
where "
"
tres_alloc like '%%,%d=%%' limit 1
;"
,
cluster_name
,
job
_table
,
TRES_ENERGY
);
debug4
(
"(%s:%d) query
\n
%s"
,
THIS_FILE
,
__LINE__
,
query
);
if
(
!
(
result
=
mysql_db_query_ret
(
mysql_conn
,
query
,
0
)))
{
...
...
@@ -102,36 +117,57 @@ extern int as_mysql_convert_tables(mysql_conn_t *mysql_conn)
mysql_free_result
(
result
);
result
=
NULL
;
if
(
!
i
)
{
info
(
"Conversion done: success!"
);
if
(
i
)
{
debug2
(
"Conversion done: success!"
);
return
SLURM_SUCCESS
;
}
/* make it up to date */
itr
=
list_iterator_create
(
as_mysql_total_cluster_list
);
while
((
cluster_name
=
list_next
(
itr
)))
{
query
=
xstrdup_printf
(
"s
how columns
from
\"
%s_%s
\"
where "
"
Field='cpu_count' || Field='count'
;"
,
cluster_name
,
event
_table
);
query
=
xstrdup_printf
(
"s
elect tres_alloc
from
\"
%s_%s
\"
where "
"
tres_alloc like '%%,%d=%%' limit 1
;"
,
cluster_name
,
job
_table
,
TRES_ENERGY
);
debug4
(
"(%s:%d) query
\n
%s"
,
THIS_FILE
,
__LINE__
,
query
);
if
(
!
(
result
=
mysql_db_query_ret
(
mysql_conn
,
query
,
0
)))
{
xfree
(
query
);
error
(
"QUERY BAD: No count col name for cluster %s,
"
"this should never happen"
,
cluster_name
);
error
(
"QUERY BAD: No count col name for cluster %s,
this should never happen"
,
cluster_name
);
continue
;
}
xfree
(
query
);
if
(
!
mysql_num_rows
(
result
))
{
error
(
"No count col name for cluster %s, "
"this should never happen"
,
cluster_name
);
mysql_free_result
(
result
);
i
=
mysql_num_rows
(
result
);
mysql_free_result
(
result
);
result
=
NULL
;
if
(
i
)
{
debug2
(
"Conversion on cluster %s not needed"
,
cluster_name
);
continue
;
}
else
{
/* Need to check if the database is empty */
query
=
xstrdup_printf
(
"select tres_alloc from
\"
%s_%s
\"
limit 1;"
,
cluster_name
,
job_table
);
debug4
(
"(%s:%d) query
\n
%s"
,
THIS_FILE
,
__LINE__
,
query
);
if
(
!
(
result
=
mysql_db_query_ret
(
mysql_conn
,
query
,
0
)))
{
xfree
(
query
);
continue
;
}
xfree
(
query
);
i
=
mysql_num_rows
(
result
);
mysql_free_result
(
result
);
result
=
NULL
;
if
(
!
i
)
{
debug2
(
"Conversion on cluster %s not needed, it doesn't have any rows in the table"
,
cluster_name
);
continue
;
}
}
mysql_free_result
(
result
);
/* Now convert the cluster usage tables */
info
(
"converting step table for %s"
,
cluster_name
);
if
((
rc
=
_convert_step_table
(
mysql_conn
,
cluster_name
)
!=
SLURM_SUCCESS
))
...
...
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