-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] add port for client status #311
Conversation
montaguelhz
commented
Sep 16, 2023
•
edited by Wine93
Loading
edited by Wine93
@Wine93 @caoxianfei1 PTAL~ |
t.AddStep(&step.ListContainers{ | ||
ShowAll: true, | ||
Format: `"{{.Status}}"`, | ||
Filter: fmt.Sprintf("id=%s", containerId), | ||
Out: &status, | ||
ExecOptions: curveadm.ExecOptions(), | ||
}) | ||
t.AddStep(&step2Port{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe step2GetPort
is more meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
show ip:port is better?just look like: Get Client Status: [OK]
Id Kind Host Container Id Status Adrress Aux Info
-- ---- ---- ------------ ------ ---- --------
2ae7016a1160 curvebs client-host 8b484fb2ed8a Up 2 weeks xxx.xxx.xxx.xxx:9002 {"user":"curve","volume":"/test2"}
15ea0603042d curvebs server-host 0af4ecea35b7 Up 2 weeks xxx.xxx.xxx.xxx:9001 {"user":"curve","volume":"/test1"} @Wine93 |
f9f925c
to
6e765b8
Compare
done |
@montaguelhz Have you passed the test |
The six ci tests are passed. |
I test it but address part is nil. |
cmd := ctx.Module().DockerCli().TopContainer(s.containerId) | ||
out, err := cmd.Execute(s.execOptions) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, I haven't tested the situation that top command goes wrong, but why it throw error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don‘t know why commmand error, but
if err != nil {
return err
}
we should throw the error?
if len(pid) == 0 { | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a error occur? handle it.
if err != nil { | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
|
||
// execute "ss" command in container | ||
cli := ctx.Module().Shell().SocketStatistics("") | ||
cli.AddOption("--no-header") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #295
51ce4e2
to
086cd94
Compare
@caoxianfei1 The cause of the problem is that I executed |
The result is 2ae7016a1160 curvebs client-host 8b484fb2ed8a Up 2 months *:9002 {"user":"curve","volume":"/test2"} |
@caoxianfei1 PTAL~ |
func (s *step2GetAddress) extractAddress(line, pid string) string { | ||
|
||
regex, err := regexp.Compile(`^.* ((\d+\.\d+\.\d+\.\d+)|\*:\d+).*pid=` + pid + ".*$") | ||
if err == nil { | ||
mu := regex.FindStringSubmatch(line) | ||
if len(mu) > 1 { | ||
return mu[1] | ||
} | ||
} | ||
return "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newer version ss command will answer RTNETLINK answers: Invalid argument
. See the pr 5adc604
Signed-off-by: montaguelhz <[email protected]>