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
Wait functions for state #6232
Wait functions for state #6232
Conversation
ping @unclejack @crosbymichael @vieux |
Also, may be consider |
rebased |
// FIXME: why are we serializing running state to disk in the first place? | ||
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err) | ||
if err := container.ToDisk(); err != nil { | ||
utils.Errorf("Error dumping container state to disk: %s\n", err) | ||
} | ||
} | ||
|
||
container.State.SetStopped(exitCode) |
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 you set the state to stop after you write to disk.
I guess it's an issue because the container will be saved with a running state, no ?
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.
You are right. By this I tried to fix race between two RUN commands in buildfile, because they share same runconfig. So image id can change before we call ToDisk
. But it seems that it must be fixed in buildfile.
@vieux fixed. I'll try to fix race in buildfile in other PR after discuss with you. |
// to return. | ||
// FIXME: why are we serializing running state to disk in the first place? | ||
//log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err) | ||
// FIXME: here is race condition between to RUN instructions in Dockerfile |
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.
"two" RUN instructions?
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.
yup
ping @crosbymichael @vieux |
@anandkumarpatel @ykumar6 can you please test this one ? |
@@ -499,6 +489,7 @@ func (container *Container) cleanup() { | |||
} | |||
|
|||
func (container *Container) KillSig(sig int) error { | |||
log.Printf("Send %d to %s", sig, container.ID) |
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.
can you switch to debugf here ?
Will check it out |
I still see a lot of these: |
but do you have any panic ? On Mon, Jun 16, 2014 at 7:37 PM, anandkumarpatel notifications@github.com
Victor VIEUX |
@vieux Done, and rebased. |
@LK4D4 I see this error message a tonne, even when running on |
@anandkumarpatel yes, but this PR touch the same code, I want to make sure we don't reintroduce the panic :) |
LGTM |
|
||
// WaitStop waits until state is stopped. If state already stopped it returns | ||
// immediatly. If you want wait forever you must supply negative timeout. | ||
// Returns exit code, that was passed to SetRunning |
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.
SetRunning
takes a pid, you mean SetStop
no ?
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.
Yeah, you are right.
Fixed docstring |
sorry to bother you @anandkumarpatel |
// WaitRunning waits until state is running. If state already running it returns | ||
// immediatly. If you want wait forever you must supply negative timeout. | ||
// Returns pid, that was passed to SetRunning | ||
func (s *State) WaitRunning(timeout time.Duration) (int, 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.
This seems kinda weird that we have WaitRunning and WaitStopped methods.
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 didn't get :) It is about naming or about existing?
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.
Why don't we just have one wait method?
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.
Hmm, for example:
s := NewState()
go func() {
SomethingBeforeStart()
s.SetRunning(1)
}()
go func() {
pid := s.WaitRunning()
SomethingAfterStart(pid)
}()
And same for stop.
How can I achieve this with one wait method?
ping @crosbymichael |
ping @crosbymichael , I have some race fixes, which depend on this |
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
rebased |
LGTM |
Wait functions for state
I added waiting functions for state and merged
waitLock
to state.I intentionally did
State.WaitLock
receivetimeout
always. Because if you want waiting something forever you must suffer and think twice about it.Also may be makes sense to embed *State to container - this is for discuss.