Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
containers
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
containers
Commits
baf8d886
Commit
baf8d886
authored
Oct 08, 2018
by
Kamil Iskra
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fail-empty-sets' into 'master'
Strengthen tests for invalid input Closes
#2
See merge request
!5
parents
a09400ed
a22998a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
17 deletions
+35
-17
src/container_manager.cpp
src/container_manager.cpp
+35
-17
No files found.
src/container_manager.cpp
View file @
baf8d886
...
...
@@ -454,17 +454,22 @@ bool Container_manager::is_legal_create_command(String_parser& sp)
if
(
sp
.
get_string
(
"name"
,
name
))
HANDLE_CM_ERROR_IF
(
!
is_name_available
(
name
),
this
,
string
(
"Another container already has the name "
)
+
strval
);
else
THROW_ON_BAD_INPUT
(
"name is missing"
);
bval
=
fals
e
;
bval
=
tru
e
;
sp
.
get_bool
(
"cpu_exclusive"
,
bval
);
if
(
sp
.
get_int_list
(
"cpus"
,
intvect
))
{
HANDLE_CM_ERROR_IF
(
!
are_resources_available
<
int
>
(
_cpu_ownerships
,
intvect
,
bval
),
this
,
string
(
"At least part of the requested CPU cores is unavailable"
)
+
(
bval
?
string
(
" exclusively."
)
:
string
(
"."
)));
HANDLE_CM_ERROR_IF
(
intvect
.
size
()
==
0
,
this
,
"cpu list is empty"
);
}
else
THROW_ON_BAD_INPUT
(
"cpu list is missing"
);
bval
=
false
;
sp
.
get_bool
(
"cpu_exclusive"
,
bval
);
if
(
sp
.
get_added_int_list
(
"cpus"
,
intvect
))
HANDLE_CM_ERROR_IF
(
!
are_resources_available
<
int
>
(
_cpu_ownerships
,
intvect
,
bval
),
this
,
...
...
@@ -474,13 +479,16 @@ bool Container_manager::is_legal_create_command(String_parser& sp)
bval
=
false
;
sp
.
get_bool
(
"mem_exclusive"
,
bval
);
if
(
sp
.
get_int_list
(
"mems"
,
intvect
))
{
HANDLE_CM_ERROR_IF
(
!
are_resources_available
<
int
>
(
_mem_ownerships
,
intvect
,
bval
),
this
,
string
(
"At least part of the requested memory nodes is unavailable"
)
+
(
bval
?
string
(
" exclusively."
)
:
string
(
"."
)));
HANDLE_CM_ERROR_IF
(
intvect
.
size
()
==
0
,
this
,
"memory list is empty"
);
}
else
THROW_ON_BAD_INPUT
(
"memory list is missing"
);
bval
=
false
;
sp
.
get_bool
(
"mem_exclusive"
,
bval
);
if
(
sp
.
get_added_int_list
(
"mems"
,
intvect
))
HANDLE_CM_ERROR_IF
(
!
are_resources_available
<
int
>
(
_mem_ownerships
,
intvect
,
bval
),
this
,
...
...
@@ -778,19 +786,29 @@ void Container_manager::create_service_os(string command)
vector
<
int
>
cpus
;
sp
.
get_int_list
(
"cpus"
,
cpus
);
THROW_ON_FORBIDDEN_ACTION_IF
(
!
are_resources_available
<
int
>
(
_cpu_ownerships
,
cpus
,
true
),
string
(
"At least part of the requested CPU cores is unavailable"
));
THROW_ON_FORBIDDEN_ACTION_IF
(
!
_cpu_ownerships
.
are_unused
(
cpus
),
"Some of the CPU cores requested are already in use"
);
if
(
sp
.
get_int_list
(
"cpus"
,
cpus
))
{
THROW_ON_FORBIDDEN_ACTION_IF
(
!
are_resources_available
<
int
>
(
_cpu_ownerships
,
cpus
,
true
),
string
(
"At least part of the requested CPU cores is unavailable"
));
THROW_ON_FORBIDDEN_ACTION_IF
(
!
_cpu_ownerships
.
are_unused
(
cpus
),
"Some of the CPU cores requested are already in use"
);
THROW_ON_FORBIDDEN_ACTION_IF
(
cpus
.
size
()
==
0
,
"cpu list is empty"
);
}
else
THROW_ON_FORBIDDEN_ACTION
(
"cpu list is missing"
);
vector
<
int
>
mems
;
sp
.
get_int_list
(
"mems"
,
mems
);
THROW_ON_FORBIDDEN_ACTION_IF
(
!
are_resources_available
<
int
>
(
_mem_ownerships
,
mems
,
true
),
string
(
"At least part of the requested memory nodes is unavailable"
));
THROW_ON_FORBIDDEN_ACTION_IF
(
!
_cpu_ownerships
.
are_unused
(
cpus
),
"Some of the CPU cores requested are already in use"
);
if
(
sp
.
get_int_list
(
"mems"
,
mems
))
{
THROW_ON_FORBIDDEN_ACTION_IF
(
!
are_resources_available
<
int
>
(
_mem_ownerships
,
mems
,
true
),
string
(
"At least part of the requested memory nodes is unavailable"
));
THROW_ON_FORBIDDEN_ACTION_IF
(
!
_mem_ownerships
.
are_unused
(
cpus
),
"Some of the memory nodes requested are already in use"
);
THROW_ON_FORBIDDEN_ACTION_IF
(
mems
.
size
()
==
0
,
"memory list is empty"
);
}
else
THROW_ON_FORBIDDEN_ACTION
(
"memory list is missing"
);
_cpu_ownerships
.
transfer_to
(
cpus
,
_sos_cpu_ownerships
);
_mem_ownerships
.
transfer_to
(
mems
,
_sos_mem_ownerships
);
_argo_containers_root
->
remove_cpus
(
cpus
);
...
...
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