-
Notifications
You must be signed in to change notification settings - Fork 950
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
feature: take over old containerd instance when pouchd restart #1275
feature: take over old containerd instance when pouchd restart #1275
Conversation
451686b
to
58c1400
Compare
@@ -166,3 +185,125 @@ func (c *Client) Version(ctx context.Context) (containerd.Version, error) { | |||
|
|||
return cli.client.Version(ctx) | |||
} | |||
|
|||
func (c *Client) runContainerdDaemon(homeDir string, copts clientOpts) error { | |||
if homeDir == "" { |
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.
Could we use os.Stat
to check homeDir here? If the homeDir doesn't exist, we should return error right away.
WDYT?
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.
the home-dir existence is checked in main.go, so we no need check here.
but we should check the stateDir
here, thanks for your reminder, :)
ctrd/client.go
Outdated
} | ||
logrus.Infof("ctrd: new containerd process, pid: %d", cmd.Process.Pid) | ||
|
||
if err := utils.SetOOMScore(cmd.Process.Pid, -17); err != 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.
I remember the containerd
has the OOM score settings in the configuration. In my opinion, it's better if we maintain configuration for the pouchd. The configuration can help us to locate the problem in the future. How do you think?
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.
Agree, reasonable !!!
58c1400
to
662553d
Compare
Codecov Report
@@ Coverage Diff @@
## master #1275 +/- ##
==========================================
- Coverage 15.52% 15.31% -0.21%
==========================================
Files 173 174 +1
Lines 10868 11014 +146
==========================================
Hits 1687 1687
- Misses 9062 9208 +146
Partials 119 119
|
662553d
to
d21aaf3
Compare
ctrd/client.go
Outdated
os.RemoveAll(c.socketPath) | ||
} | ||
|
||
// Start a new containerd instance |
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 think we can use a function to wrap the following functions
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.
+1
daemon/daemon.go
Outdated
errMsg = fmt.Sprintf("%s\n", err.Error()) | ||
} | ||
|
||
fmt.Println("Start cleanup containerd...") |
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 am afraid we should use logrus to catch this line of message.
Rather than fmt.Println
.
@@ -216,7 +225,23 @@ func (d *Daemon) Run() error { | |||
|
|||
// Shutdown stops daemon. | |||
func (d *Daemon) Shutdown() error { | |||
return d.server.Stop() | |||
var errMsg string |
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 am wondering if the variable errMsg
is redundant.
I think with the current implementation, we can just return the returned err, right?
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.
@allencloud i want to execute all stop
function even occurred an error when calling one of the stop
function
d21aaf3
to
cb430da
Compare
Updated! PTAL @allencloud @fuweid |
9588676
to
002d016
Compare
I am wondering if we could add an integration test to cover this case? @HusterWan We only have api and cli integration test and unit test, for other kinds of test, shall we include them in test code as well? |
Maybe we can add test case in daemon test, here is test steps in my compute:
@Letty5411 can we add test case as my described ? |
// Start a new containerd instance | ||
args := []string{ | ||
"-a", c.rpcAddr, | ||
"--root", path.Join(c.homeDir, "containerd/root"), |
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.
Sorry. I don't make my suggestion clear in the last comment.
The containerd has own the configuration. The link is here. Maybe we can marshal the settings in the file so that we can use the file to check the information about pouchd.
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.
actually, the containerd core Opts
have been in the poucd configuration file, and i think we no need keep much containerd configuration opts in pouchd code, if you want to add more configurations , use the containerd configuration file outside, DYA?
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
type clientOpts struct { | ||
startDaemon bool | ||
debugLog bool | ||
rpcAddr string |
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.
Should we have default value for the option? I'm wondering that the WithXXX
is not necessary for every time. WDYT?
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.
Not call WithXXX
will set the Opts
with default value.
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.
Hi @HusterWan
// set default value for parameters
if copts.rpcAddr == "" {
copts.rpcAddr = unixSocketPath
}
client.rpcAddr = copts.rpcAddr
if copts.grpcClientPoolCapacity <= 0 {
copts.grpcClientPoolCapacity = defaultGrpcClientPoolCapacity
}
if copts.maxStreamsClient <= 0 {
copts.maxStreamsClient = defaultMaxStreamsClient
}
For this part, I means we can use the following code to handle
var defaultClientOpts = clientOpts{
rpcAddr: unixSocketPath,
grpcClientPoolCapacity: defaultGrpcClientPoolCapacity,
maxStreamsClient: defaultMaxStreamsClient
}
With the default value, we don't need to have the if-else code. :)
Hope it can help
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 am afraid, i can not agree with you, default
value take effect when not specified or invalid params
Signed-off-by: Michael Wan <zirenwan@gmail.com>
002d016
to
7bf5abc
Compare
LGTM |
Signed-off-by: Michael Wan zirenwan@gmail.com
Ⅰ. Describe what this PR did
When
pouchd
restart, if oldcontainerd
is alive, we take it over.Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews