Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
power-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
power-node
Commits
d3452f73
Commit
d3452f73
authored
1 year ago
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update check container healthy
parent
5a300b51
master
dev
master-aon
master_v2
master_v2_test
test
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
task_handler.go
nm/task_handler.go
+11
-9
No files found.
nm/task_handler.go
View file @
d3452f73
...
...
@@ -431,28 +431,28 @@ func (op *TaskOp) getFileCache(respStr string, dockerOp *operate.DockerOp) (stri
return
""
,
nil
}
func
(
op
*
TaskOp
)
checkContainerHealthy
(
internalIp
string
,
internalPort
uint16
)
error
{
func
(
op
*
TaskOp
)
checkContainerHealthy
(
internalIp
string
,
internalPort
uint16
)
(
bool
,
error
)
{
healthCheckUrl
:=
fmt
.
Sprintf
(
"http://%s:%d%s"
,
internalIp
,
internalPort
,
models
.
HealthCheckAPI
)
healthyCheckResp
,
err
:=
op
.
httpClient
.
Get
(
healthCheckUrl
)
if
err
!=
nil
{
log
.
Errorf
(
"Request container healthy failed: %s"
,
err
.
Error
())
return
f
mt
.
Errorf
(
"%s-%s"
,
"The container is not ready"
,
err
)
log
.
Warn
(
"Request container healthy failed: %s"
,
err
.
Error
())
return
f
alse
,
nil
}
if
healthyCheckResp
.
StatusCode
==
http
.
StatusNotFound
{
return
nil
return
true
,
nil
}
body
,
err
:=
io
.
ReadAll
(
healthyCheckResp
.
Body
)
m
:=
&
models
.
HealthyCheck
{}
err
=
json
.
Unmarshal
(
body
,
m
)
if
err
!=
nil
{
log
.
Errorf
(
"Json unmarshal container healthy body failed: %s"
,
err
.
Error
())
return
fmt
.
Errorf
(
"%s,%s"
,
"Json unmarshal container healthy body failed"
,
err
.
Error
())
return
f
alse
,
f
mt
.
Errorf
(
"%s,%s"
,
"Json unmarshal container healthy body failed"
,
err
.
Error
())
}
if
m
.
Status
!=
models
.
READY
{
log
.
Errorf
(
"The container is not ready"
)
return
f
mt
.
Errorf
(
"%s"
,
"The container is not ready"
)
log
.
Warn
(
"The container is not ready"
)
return
f
alse
,
nil
}
return
nil
return
true
,
nil
}
func
(
op
*
TaskOp
)
waitContainerRunning
(
handler
*
TaskWorker
,
imageId
string
)
error
{
...
...
@@ -476,9 +476,11 @@ func (op *TaskOp) waitContainerRunning(handler *TaskWorker, imageId string) erro
continue
}
if
isMatch
:=
strings
.
HasPrefix
(
op
.
taskCmd
.
ImageName
,
models
.
ReplicateImageNameSuffix
);
isMatch
{
if
err
:=
op
.
checkContainerHealthy
(
internalIp
,
internalPort
);
err
!=
nil
{
if
isReqSuccess
,
err
:=
op
.
checkContainerHealthy
(
internalIp
,
internalPort
);
err
!=
nil
{
log
.
WithField
(
"err"
,
err
)
.
Errorf
(
"check container healthy failed"
)
return
fmt
.
Errorf
(
"%s-%s"
,
"check container healthy failed"
,
err
.
Error
())
}
else
if
!
isReqSuccess
{
continue
}
}
op
.
taskCmd
.
ApiUrl
=
fmt
.
Sprintf
(
"http://%s:%d%s"
,
internalIp
,
internalPort
,
op
.
taskCmd
.
ApiUrl
)
...
...
This diff is collapsed.
Click to expand it.
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