-
Notifications
You must be signed in to change notification settings - Fork 907
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
Instance: Set receive timeout for LXC command client sock #11293
Conversation
We may want to use |
lxd/instance/drivers/driver_lxc.go
Outdated
@@ -632,6 +632,12 @@ func (d *lxc) initLXC(config bool) error { | |||
return err | |||
} | |||
|
|||
// To discuss: take defalt timeout value from some global config? | |||
err = liblxc.SetTimeout(time.Duration(10) * time.Second) |
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 think we need to make it configurable.
However what happens if we, say, set a 10s timeout by default on init, as you're doing here, will this affect a longer timeout passed to d.c.Shutdown()?
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.
Also, can se set the timeout on the cc
returned from liblxc.NewContainer
rather than on the library as a whole?
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.
Also, can se set the timeout on the
cc
returned fromliblxc.NewContainer
rather than on the library as a whole?
sure, it's just mistake. Thanks!
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 think we need to make it configurable. However what happens if we, say, set a 10s timeout by default on init, as you're doing here, will this affect a longer timeout passed to d.c.Shutdown()?
Yep, that's what I've said in the original issue. That's why right now this timeout is not applied to all commands. We will need to extend liblxc and each command one by one to support this timeout. [like this commit ] And I'm not sure that we really need that. So, it's thing to discuss.
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.
OK so right now this would just record the timeout value but not use it, and then you would extend each underlying call to use it. And we wouldn't need to update d.c.Shutdown() to use it because it already has its own timeout support?
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.
Right now, for Shutdown
this container-wide timeout will be ignored at all.
You want to propose to take this "container-wide timeout" as a default value for Shutdown
call (if timeout specified as -1
)?
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.
well in Go at least we cannot specify -1, but we could have it use the container wide timeout if the timeout passed was zero perhaps?
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.
That's an interesting point.
What we have in the liblxc
:
/*!
* \brief Request the container shutdown by sending it \c
* SIGPWR.
*
* \param c Container.
* \param timeout Seconds to wait before returning false.
* (-1 to wait forever, 0 to avoid waiting).
*
* \return \c true if the container was shutdown successfully, else \c false.
*/
bool (*shutdown)(struct lxc_container *c, int timeout);
In the go-lxc
:
// Shutdown shuts down the container.
func (c *Container) Shutdown(timeout time.Duration) error {
c.mu.Lock()
defer c.mu.Unlock()
if c.container == nil {
return ErrNotDefined
}
if err := c.makeSure(isRunning); err != nil {
return err
}
if !bool(C.go_lxc_shutdown(c.container, C.int(timeout.Seconds()))) {
return ErrShutdownFailed
}
return nil
}
I don't think that it would be correct to change semantics of liblxc
shutdown
call. But we can change go-lxc
's Shutdown
implementation to take the "container-wide timeout" as a default in case when timeout
is 0. Or, better, to add another method like ShutdownWithTimeout
.
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.
We don't need ShutdownWithTimeout
as we already have Shutdown(timeout time.Duration)
.
I propose we just ignore the container wide timeout for the Shutdown(timeout time.Duration)
function then.
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 propose we just ignore the container wide timeout for the
Shutdown(timeout time.Duration)
function then.
It's just the current implementation behavior.
Issue canonical#4257 Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
4f07113
to
5846137
Compare
@mihalicyn happy to close this for now? |
why close? We don't want to take it? |
Oh right, you never requested a subsequent review on it and the RFC subject suggested this was just a design proposal. So does liblxc support this now? |
static analysis tests are failing, suggesting not.
|
And jenkins is red across the board with compile errors: https://jenkins.linuxcontainers.org/job/lxd-github-pull-test/8656/
|
I thought you would open a working PR once the changes had been made to liblxc itself. |
I've posted PRs to all projects https://github.com/lxc/lxd/pull/11293#issuecomment-1385870390 |
OK I missed that. The "RFC" in the title has really confused me as thought it was just a proposal and not ready yet. |
That's it. But I've started from implementing that in liblxc, go-lxc, lxd. It's easier to discuss when everything is almost ready :)
|
This helps with the weekly news letter too as the PR titles show up in there. |
On this point, what happens in go-lxc if we call the timeout and the underlying liblxc doesn't support the extension? What do you think? Or are you thinking that an error should be returned if liblxc doesn't support it and thus we should check |
@@ -632,6 +632,12 @@ func (d *lxc) initLXC(config bool) error { | |||
return err | |||
} | |||
|
|||
// To discuss: take defalt timeout value from some global config? |
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.
Lets take this comment out now the PR is ready for review.
Right now,
Yep, we can just use error code to detect that operation is not supported |
I see. I'm happy with either, but detecting the error seems simpler. Thanks |
Moving to Draft until the liblxc and go-lxc side of this is finalized. |
@mihalicyn happy to close this until its ready? |
Issue #4257
Signed-off-by: Alexander Mikhalitsyn aleksandr.mikhalitsyn@canonical.com
Please see lxc/lxc#4257