Skip to content
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

Merged
merged 2 commits into from Jun 27, 2014
Merged

Wait functions for state #6232

merged 2 commits into from Jun 27, 2014

Conversation

LK4D4
Copy link
Contributor

@LK4D4 LK4D4 commented Jun 6, 2014

I added waiting functions for state and merged waitLock to state.
I intentionally did State.WaitLock receive timeout 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.

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 6, 2014

ping @unclejack @crosbymichael @vieux
I'll reping after dockercon, also)

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 10, 2014

Also, may be consider sync.Cond, but I'm not very excited about this idea.

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 11, 2014

rebased
ping @unclejack @crosbymichael @vieux

// 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)
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 13, 2014

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"two" RUN instructions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@unclejack
Copy link
Contributor

ping @crosbymichael @vieux

@vieux
Copy link
Contributor

vieux commented Jun 16, 2014

@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)
Copy link
Contributor

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 ?

@anandkumarpatel
Copy link
Contributor

Will check it out

@anandkumarpatel
Copy link
Contributor

I still see a lot of these:
out: [error] container.go:482 9756b99bef648af3d5435f12eaa676454e61185a98dd2030bf1d12cbc89ad3d3: Error closing terminal: invalid argument

@vieux
Copy link
Contributor

vieux commented Jun 17, 2014

but do you have any panic ?

On Mon, Jun 16, 2014 at 7:37 PM, anandkumarpatel notifications@github.com
wrote:

I still see a lot of these:
out: [error] container.go:482
9756b99bef648af3d5435f12eaa676454e61185a98dd2030bf1d12cbc89ad3d3: Error
closing terminal: invalid argument


Reply to this email directly or view it on GitHub
#6232 (comment).

Victor VIEUX
http://vvieux.com

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 17, 2014

@vieux Done, and rebased.
Also I saw Error closing terminal: invalid argument when using dirty btrfs filesystem. I think this error appears on any container start error.

@cyphar
Copy link
Contributor

cyphar commented Jun 17, 2014

@LK4D4 I see this error message a tonne, even when running on ext4.

@anandkumarpatel
Copy link
Contributor

@vieux the panic was fixed with #6065

@vieux
Copy link
Contributor

vieux commented Jun 17, 2014

@anandkumarpatel yes, but this PR touch the same code, I want to make sure we don't reintroduce the panic :)

@vieux
Copy link
Contributor

vieux commented Jun 17, 2014

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
Copy link
Contributor

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right.

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 17, 2014

Fixed docstring

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 17, 2014

@vieux Tried to fix #6259. Just moved SetStopped before cleanup.

@vieux
Copy link
Contributor

vieux commented Jun 17, 2014

sorry to bother you @anandkumarpatel
can you please retry to see if you get the panic back or not ?

// 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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?

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 20, 2014

ping @crosbymichael

@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 27, 2014

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)
@LK4D4
Copy link
Contributor Author

LK4D4 commented Jun 27, 2014

rebased

@crosbymichael
Copy link
Contributor

LGTM

crosbymichael pushed a commit that referenced this pull request Jun 27, 2014
@crosbymichael crosbymichael merged commit 680adb9 into moby:master Jun 27, 2014
@LK4D4 LK4D4 deleted the wait_functions_for_state branch June 28, 2014 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants