Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole
Commits
477897b7
Commit
477897b7
authored
Jan 31, 2020
by
Romain Reuillon
Browse files
[Plugin+lib] fix: update container lib and make sure all processes are killed of cancel
parent
55ca6d3f
Pipeline
#465
failed with stage
in 13 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
libraries/build.sbt
View file @
477897b7
...
...
@@ -235,7 +235,7 @@ lazy val mgo = OsgiProject(dir, "mgo", exports = Seq("mgo.*", "freestyle.*"), im
version
:=
mgoVersion
)
dependsOn
(
monocle
,
math
,
cats
,
squants
)
settings
(
settings
:
_
*
)
lazy
val
containerVersion
=
"1.
7
"
lazy
val
containerVersion
=
"1.
8
"
lazy
val
container
=
OsgiProject
(
dir
,
"container"
,
exports
=
Seq
(
"container.*"
),
imports
=
Seq
(
"!better.*"
,
"!javax.xml.*"
,
"!scala.meta.*"
,
"!sun.misc.*"
,
"!com.github.luben.*"
,
"!org.apache.avalon.*"
,
"!org.apache.log.*"
,
"!org.brotli.dec.*"
,
"!javax.*"
,
"*"
),
privatePackages
=
Seq
(
"!scala.*"
,
"!monocle.*"
,
"!org.apache.commons.math3.*"
,
"!cats.*"
,
"!squants.*"
,
"!scalaz.*"
,
"!io.circe.*"
,
"!shapeless.*"
,
"*"
))
settings
(
libraryDependencies
+=
"org.openmole"
%%
"container"
%
containerVersion
,
...
...
openmole/core/org.openmole.core.tools/src/main/scala/org/openmole/core/tools/service/ProcessUtil.scala
View file @
477897b7
...
...
@@ -36,7 +36,10 @@ object ProcessUtil {
try
process
.
waitFor
catch
{
case
e
:
Throwable
⇒
process.destroyForcibly
()
def
kill
(
p:
ProcessHandle
)
=
p
.
destroyForcibly
()
process
.
descendants
().
forEach
(
kill
)
kill
(
process
.
toHandle
)
throw
e
}
finally
{
...
...
openmole/plugins/org.openmole.plugin.task.container/src/main/scala/org/openmole/plugin/task/container/ContainerTask.scala
View file @
477897b7
...
...
@@ -17,6 +17,8 @@ package org.openmole.plugin.task.container
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
java.io.PrintStream
import
monocle.macros.Lenses
import
org.openmole.core.dsl._
import
org.openmole.core.dsl.extension._
...
...
@@ -101,10 +103,11 @@ object ContainerTask {
containerSystem
:
ContainerSystem
,
image
:
_
root_.container.FlatImage
,
commands
:
Seq
[
String
],
volumes
:
Seq
[(
String
,
String
)]
=
Seq
.
empty
,
environmentVariables
:
Seq
[(
String
,
String
)]
=
Seq
.
empty
,
workDirectory
:
Option
[
String
]
=
None
,
logger
:
scala.sys.process.ProcessLogger
)(
implicit
tmpDirectory
:
TmpDirectory
)
=
{
volumes
:
Seq
[(
String
,
String
)]
=
Seq
.
empty
,
environmentVariables
:
Seq
[(
String
,
String
)]
=
Seq
.
empty
,
workDirectory
:
Option
[
String
]
=
None
,
output
:
PrintStream
,
error
:
PrintStream
)(
implicit
tmpDirectory
:
TmpDirectory
)
=
{
val
retCode
=
containerSystem
match
{
case
Proot
(
noSeccomp
,
kernel
)
⇒
...
...
@@ -116,7 +119,8 @@ object ContainerTask {
directory
/
"tmp"
,
commands
=
commands
,
proot
=
proot
.
getAbsolutePath
,
logger
=
logger
,
output
=
output
,
error
=
error
,
kernel
=
Some
(
kernel
),
noSeccomp
=
noSeccomp
,
bind
=
volumes
,
...
...
@@ -130,7 +134,8 @@ object ContainerTask {
image
,
directory
/
"tmp"
,
commands
=
commands
,
logger
=
logger
,
output
=
output
,
error
=
error
,
bind
=
volumes
,
environmentVariables
=
environmentVariables
,
workDirectory
=
workDirectory
,
...
...
@@ -206,7 +211,7 @@ object ContainerTask {
def
executeInstall
(
containerSystem
:
ContainerSystem
,
image
:
_
root_.container.FlatImage
,
install
:
Seq
[
String
])(
implicit
tmpDirectory
:
TmpDirectory
,
outputRedirection
:
OutputRedirection
)
=
if
(
install
.
isEmpty
)
image
else
{
val
retCode
=
runCommandInContainer
(
containerSystem
,
image
,
install
,
logger
=
scala
.
sys
.
process
.
ProcessLogger
.
apply
(
s
⇒
outputRedirection
.
output
.
println
(
s
),
s
⇒
outputRedirection
.
error
.
println
(
s
))
)
val
retCode
=
runCommandInContainer
(
containerSystem
,
image
,
install
,
output
=
outputRedirection
.
output
,
error
=
outputRedirection
.
error
)
if
(
retCode
!=
0
)
throw
new
UserBadDataError
(
s
"Process exited a non 0 return code ($retCode)"
)
image
}
...
...
@@ -271,24 +276,16 @@ import ContainerTask._
val
pool
=
executionContext
.
cache
.
getOrElseUpdate
(
containerPoolKey
,
createPool
)
val
stdO
utBu
ff
er
=
new
String
Builder
()
val
stdE
rrBu
ff
er
=
new
String
Builder
()
val
o
utBu
ild
er
=
new
String
OutputStream
val
e
rrBu
ild
er
=
new
String
OutputStream
def
processOutput
(
s
:
String
)
=
{
executionContext
.
outputRedirection
.
output
.
println
(
s
)
if
(
stdOut
.
isDefined
)
{
stdOutBuffer
.
append
(
s
)
stdOutBuffer
.
append
(
'\n'
)
}
}
val
out
:
PrintStream
=
if
(
stdOut
.
isDefined
)
new
PrintStream
(
MultiplexedOutputStream
(
outBuilder
,
executionContext
.
outputRedirection
.
output
))
else
executionContext
.
outputRedirection
.
output
def
processErr
(
s
:
String
)
=
{
executionContext
.
outputRedirection
.
error
.
println
(
s
)
if
(
stdErr
.
isDefined
)
{
stdErrBuffer
.
append
(
s
)
stdErrBuffer
.
append
(
'\n'
)
}
}
val
err
=
if
(
stdErr
.
isDefined
)
new
PrintStream
(
MultiplexedOutputStream
(
errBuilder
,
executionContext
.
outputRedirection
.
error
))
else
executionContext
.
outputRedirection
.
error
def
prepareVolumes
(
preparedFilesInfo
:
Iterable
[
FileInfo
],
...
...
@@ -325,7 +322,8 @@ import ContainerTask._
image
=
container
,
commands
=
command
.
value
.
map
(
_
.
from
(
context
)),
workDirectory
=
Some
(
workDirectoryValue
),
logger
=
scala
.
sys
.
process
.
ProcessLogger
.
apply
(
processOutput
,
processErr
),
output
=
out
,
error
=
err
,
volumes
=
volumes
,
environmentVariables
=
containerEnvironmentVariables
)
...
...
@@ -352,8 +350,8 @@ import ContainerTask._
retContext
++
returnValue
.
map
(
v
⇒
Variable
(
v
,
retCode
))
++
stdOut
.
map
(
v
⇒
Variable
(
v
,
stdOutBuffer
.
toString
))
++
stdErr
.
map
(
v
⇒
Variable
(
v
,
stdErrBuff
er
.
toString
))
stdOut
.
map
(
v
⇒
Variable
(
v
,
out
.
toString
))
++
stdErr
.
map
(
v
⇒
Variable
(
v
,
e
r
r
.
toString
))
}
}
...
...
openmole/project/Libraries.scala
View file @
477897b7
...
...
@@ -8,7 +8,7 @@ object Libraries {
lazy
val
gridscaleVersion
=
"2.28"
lazy
val
sshjVersion
=
"0.27.0"
lazy
val
containerVersion
=
"1.
7
"
lazy
val
containerVersion
=
"1.
8
"
lazy
val
mgoVersion
=
"3.42"
lazy
val
bouncyCastleVersion
=
"1.64"
lazy
val
d3Version
=
"3.5.12"
...
...
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