Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

pkg/pod: add WaitReady, dry Sandbox methods - #3462

#3462
Merged
s-urbaniak merged 6 commits into
rkt:masterrkt/rkt:masterfrom
s-urbaniak:waitReadys-urbaniak/rkt:waitReadyCopy head branch name to clipboard
Dec 14, 2016
Merged

pkg/pod: add WaitReady, dry Sandbox methods#3462
s-urbaniak merged 6 commits into
rkt:masterrkt/rkt:masterfrom
s-urbaniak:waitReadys-urbaniak/rkt:waitReadyCopy head branch name to clipboard

Conversation

@s-urbaniak

Copy link
Copy Markdown
Contributor

This adds a WaitReady method to be able to wait for pod readiness on the
command line.

It also reduces reduntant implementations in stage1 for checking mutable pods
and pod manifest update logic.

Fixes #3461

@s-urbaniak
s-urbaniak force-pushed the waitReady branch 2 times, most recently from 7b8898d to 8e4e579 Compare December 8, 2016 16:22
@s-urbaniak

Copy link
Copy Markdown
Contributor Author

/cc @euank

@s-urbaniak s-urbaniak added this to the v1.22.0 milestone Dec 8, 2016
@lucab

lucab commented Dec 8, 2016

Copy link
Copy Markdown
Member

It looks like there is a deadlock race.

@s-urbaniak

Copy link
Copy Markdown
Contributor Author

ack :-/

@s-urbaniak

Copy link
Copy Markdown
Contributor Author

I think I have to do refreshState in IsSupervisorReady and check if the pod is actually running.

@s-urbaniak

Copy link
Copy Markdown
Contributor Author

instead of refreshing the state in IsSupervisorReady I refresh in WaitReady (as WaitExited does) in order to keep the current semantics that most of the state query methods do not synchronize the actual pod's filesystem state.

However I added some more documentation to the existing methods and the Pod struct itself to make it more explicit which methods (i.e. the state transitioning ones) and some query methods (ContainerPid1, Wait*) refresh the actual pod state.

@s-urbaniak
s-urbaniak force-pushed the waitReady branch 2 times, most recently from aaff747 to e69031b Compare December 9, 2016 14:15
Comment thread pkg/pod/sandbox.go Outdated
if err != nil {
return err
}
defer f.Close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From here on we have the file and we defer-closing on success; instead, on error, should we try to rm it?

Comment thread pkg/pod/sandbox.go Outdated
if err != nil {
return err
}
defer tmpf.Close()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment related to file removal.

Comment thread pkg/pod/wait.go Outdated
// This method blocks indefinitely and refreshes the pod state.
func (p *Pod) WaitExited() error {
// isExited implies isExitedGarbage.
for !p.isExited && !p.isAbortedPrepare && !p.isGarbage && !p.isGone {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

similar to p.AfterRun, a helper of p.TerminalState could make this clearer..

Also, technically this isn't technically a "wait exited" because isAbortedPrepare is a pre-run, but terminal, state, so this is really WaitFinished or WaitTerminal

Comment thread pkg/pod/wait.go Outdated
}
}

// TODO(vc): return error or let caller detect the !p.isExited possibilities?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would rather nix this TODO and just document in the function comment that the pod will be in a terminal state if there is no error, but it's up to the caller to determine what that state is.

Comment thread rkt/status.go Outdated
@@ -46,6 +48,7 @@ const (
func init() {
cmdRkt.AddCommand(cmdStatus)
cmdStatus.Flags().BoolVar(&flagWait, "wait", false, "toggle waiting for the pod to exit")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"for the pod to reach a terminal state" is technically more correct; the caller should still ask status afterwards.

I'm not sure if there's a reason not to include a timeout here. I expect to kill the rkt process after a timeout if one isn't provided here regardless.

Comment thread rkt/status.go Outdated
func init() {
cmdRkt.AddCommand(cmdStatus)
cmdStatus.Flags().BoolVar(&flagWait, "wait", false, "toggle waiting for the pod to exit")
cmdStatus.Flags().DurationVar(&flagWaitReady, "wait-ready", time.Duration(0), "time to wait until the pod is ready. If time is less or equal zero it doesn't wait at all.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect '-1' to mean 'wait forever'.

@euank

euank commented Dec 9, 2016

Copy link
Copy Markdown
Member

I realize I mostly commented on code that was just being moved, not written anew. This looks okay to me on a first pass.

s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 12, 2016
This changes the rkt status --wait to accept a timeout rather than a
boolean value.

Addresses rkt#3462 (comment)
s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 12, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)
s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 12, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)
s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 12, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)
s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 12, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)

@lucab lucab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only some typos and missing docs. Code and UX looks good.

Comment thread pkg/pod/pods.go Outdated
return p.isExitedDeleting || p.isDeleting || p.isExited || p.isGarbage
}

// IsFinshed returns true if the pod is in a terminal state, else false.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IsFinished (typo: a missing "i")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread rkt/status.go Outdated
stderr.PrintE("unable to wait for pod", err)
if dReady != 0 {
if err := p.WaitReady(newContext(dReady)); err != nil {
stderr.PrintE("error waiting for pod readyiness", err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Spelling should be fixed in the whole PR, it is written "readiness".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread rkt/status.go
var (
cmdStatus = &cobra.Command{
Use: "status [--wait] UUID",
Use: "status [--wait=bool|timeout] [--wait-ready=bool|timeout] UUID",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

status.md should be updated with these changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 12, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)
@s-urbaniak

Copy link
Copy Markdown
Contributor Author

@lucab addressed review comments, PTAL

Comment thread tests/rkt_app_sandbox_test.go Outdated
cmd = strings.Fields(fmt.Sprintf("%s app add --debug %s %s --name=%s", ctx.Cmd(), podUUID, imageName, appName))
addCmd := exec.Command(cmd[0], cmd[1:]...)
addCmd.Env = append(addCmd.Env, "RKT_EXPERIMENT_APP=true")
fmt.Printf("Running command: %v\n", cmd)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: all these fmt.Printfs should be removed or changed to t.Logf

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah, I left it there, because this output is unbuffered, but I'll change it back to t.Logf.

Comment thread tests/rkt_tests.go Outdated
// wait up to one minute for the pod supervisor to be ready
cmd := strings.Fields(fmt.Sprintf("%s status --wait-ready=%s %s", ctx.Cmd(), timeout, podUUID))
statusCmd := exec.Command(cmd[0], cmd[1:]...)
fmt.Printf("Running command: %v\n", cmd)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same for this file

@euank

euank commented Dec 12, 2016

Copy link
Copy Markdown
Member

LGTM apart from the presumably leftover printfs

s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 13, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)
s-urbaniak added a commit to s-urbaniak/rkt that referenced this pull request Dec 14, 2016
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)

@lucab lucab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

This reduces reduntant implementations for checking mutable pod
manifests and pod manifest update logic.
Currently it is unclear which methods in pkg/pod refresh the pod
state and which don't. This fixes it by documenting it.
This adds a WaitReady method to be able to wait for pod readiness on the
command line.

Fixes rkt#3461
This is a minor cleanup in pkg/pod.
This changes the rkt status --wait to accept a timeout in addition to a
boolean value.

Addresses rkt#3462 (comment)
@s-urbaniak

Copy link
Copy Markdown
Contributor Author

Merging, as the the rawhide failure seems to be a flake.

@s-urbaniak
s-urbaniak merged commit 8fd6c41 into rkt:master Dec 14, 2016
@lucab lucab mentioned this pull request Jan 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.