Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openwhisk-runtime-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Groundhog
openwhisk-runtime-python
Commits
78945d9c
Commit
78945d9c
authored
8 years ago
by
Perry
Committed by
Rodric Rabbah
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add verbosity on availability and queue state when getting, returning, or waiting for container.
parent
9c14273b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/dispatcher/src/main/scala/whisk/core/container/ContainerPool.scala
+17
-8
17 additions, 8 deletions
...r/src/main/scala/whisk/core/container/ContainerPool.scala
with
17 additions
and
8 deletions
core/dispatcher/src/main/scala/whisk/core/container/ContainerPool.scala
+
17
−
8
View file @
78945d9c
...
...
@@ -154,10 +154,11 @@ class ContainerPool(
info
(
this
,
s
"Shutting down: Not getting container for ${action.fullyQualifiedName} with ${auth.uuid}"
)
None
}
else
{
info
(
this
,
s
"Getting container for ${action.fullyQualifiedName} with ${auth.uuid}"
)
val
key
=
ActionContainerId
(
auth
.
uuid
,
action
.
fullyQualifiedName
,
action
.
rev
)
try
{
getImpl
(
nextPosition
.
next
(),
key
,
()
=>
makeWhiskContainer
(
action
,
auth
))
map
{
val
myPos
=
nextPosition
.
next
()
info
(
this
,
s
"Getting container for ${action.fullyQualifiedName} with ${auth.uuid}. myPos = $myPos comp = ${completedPosition.cur} slack = ${slack()}"
)
val
key
=
ActionContainerId
(
auth
.
uuid
,
action
.
fullyQualifiedName
,
action
.
rev
)
getImpl
(
0
,
myPos
,
key
,
()
=>
makeWhiskContainer
(
action
,
auth
))
map
{
case
(
c
,
initResult
)
=>
val
cacheMsg
=
if
(!
initResult
.
isDefined
)
"(Cache Hit)"
else
"(Cache Miss)"
info
(
this
,
s
"getAction obtained container ${c.id} ${cacheMsg}"
)
...
...
@@ -175,7 +176,7 @@ class ContainerPool(
info
(
this
,
s
"Getting container for image $imageName with args "
+
args
.
mkString
(
" "
))
// Not a regular key. Doesn't matter in testing.
val
key
=
new
ActionContainerId
(
s
"instantiated."
+
imageName
+
args
.
mkString
(
"_"
))
getImpl
(
0
,
key
,
()
=>
makeContainer
(
key
,
imageName
,
args
))
map
{
_
.
_1
}
getImpl
(
0
,
0
,
key
,
()
=>
makeContainer
(
key
,
imageName
,
args
))
map
{
_
.
_1
}
}
/**
...
...
@@ -183,11 +184,20 @@ class ContainerPool(
* This method will apply retry so that the caller is blocked until retry succeeds.
*/
@tailrec
final
def
getImpl
(
position
:
Int
,
key
:
ActionContainerId
,
conMaker
:
()
=>
FinalContainerResult
)(
implicit
transid
:
TransactionId
)
:
Option
[(
Container
,
Option
[
RunResult
])]
=
{
final
def
getImpl
(
tryCount
:
Int
,
position
:
Int
,
key
:
ActionContainerId
,
conMaker
:
()
=>
FinalContainerResult
)(
implicit
transid
:
TransactionId
)
:
Option
[(
Container
,
Option
[
RunResult
])]
=
{
val
positionInLine
=
position
-
completedPosition
.
cur
// this will be 1 if at the front of the line
val
available
=
slack
()
if
(
positionInLine
>
available
)
{
// e.g. if there is 1 available, then I wait if I am second in line (positionInLine = 2)
Thread
.
sleep
(
50
)
// TODO: replace with wait/notify but tricky to get right because of desire for maximal concurrency
if
(
tryCount
==
200
)
{
warn
(
this
,
s
"""getImpl possibly stuck:
| position = $position
| completed = ${completedPosition.cur}")
| slack = $available
| maxActive = ${_maxActive}
| activeCount = ${activeCount()}
| startingCounter = ${startingCounter.cur}"""
.
stripMargin
)
}
}
else
getOrMake
(
key
,
conMaker
)
match
{
case
Success
(
con
,
initResult
)
=>
info
(
this
,
s
"Obtained container ${con.containerId.getOrElse("
unknown
")}"
)
...
...
@@ -198,7 +208,7 @@ class ContainerPool(
case
Busy
=>
// This will not cause a busy loop because only those that could be productive will get a chance
}
getImpl
(
position
,
key
,
conMaker
)
getImpl
(
tryCount
+
1
,
position
,
key
,
conMaker
)
}
def
getNumberOfIdleContainers
(
key
:
ActionContainerId
)(
implicit
transid
:
TransactionId
)
:
Int
=
{
...
...
@@ -310,8 +320,7 @@ class ContainerPool(
* This call can be slow but not while locking data structure so it does not interfere with other activations.
*/
def
putBack
(
container
:
Container
,
delete
:
Boolean
=
false
)(
implicit
transid
:
TransactionId
)
:
Unit
=
{
info
(
this
,
s
"putBack returning container ${container.id} delete = $delete"
)
info
(
this
,
s
"putBack returning container ${container.id} delete = $delete slack = ${slack()}"
)
// Docker operation outside sync block. Don't pause if we are deleting.
if
(!
delete
)
{
runDockerOp
{
container
.
pause
()
}
...
...
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