pkg/pod: add WaitReady, dry Sandbox methods - #3462
#3462pkg/pod: add WaitReady, dry Sandbox methods#3462
Conversation
7b8898d to
8e4e579
Compare
|
/cc @euank |
|
It looks like there is a deadlock race. |
|
ack :-/ |
|
I think I have to do |
|
instead of refreshing the state in However I added some more documentation to the existing methods and the |
aaff747 to
e69031b
Compare
| if err != nil { | ||
| return err | ||
| } | ||
| defer f.Close() |
There was a problem hiding this comment.
From here on we have the file and we defer-closing on success; instead, on error, should we try to rm it?
| if err != nil { | ||
| return err | ||
| } | ||
| defer tmpf.Close() |
There was a problem hiding this comment.
Same comment related to file removal.
| // 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 { |
There was a problem hiding this comment.
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
| } | ||
| } | ||
|
|
||
| // TODO(vc): return error or let caller detect the !p.isExited possibilities? |
There was a problem hiding this comment.
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.
| @@ -46,6 +48,7 @@ const ( | ||
| func init() { | ||
| cmdRkt.AddCommand(cmdStatus) | ||
| cmdStatus.Flags().BoolVar(&flagWait, "wait", false, "toggle waiting for the pod to exit") |
There was a problem hiding this comment.
"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.
| 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.") |
There was a problem hiding this comment.
I would expect '-1' to mean 'wait forever'.
|
I realize I mostly commented on code that was just being moved, not written anew. This looks okay to me on a first pass. |
e69031b to
56ee19a
Compare
This changes the rkt status --wait to accept a timeout rather than a boolean value. Addresses rkt#3462 (comment)
56ee19a to
863db9c
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
863db9c to
ac2930f
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
ac2930f to
6f0509a
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
6f0509a to
2a2383e
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
lucab
left a comment
There was a problem hiding this comment.
Only some typos and missing docs. Code and UX looks good.
| return p.isExitedDeleting || p.isDeleting || p.isExited || p.isGarbage | ||
| } | ||
|
|
||
| // IsFinshed returns true if the pod is in a terminal state, else false. |
| 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) |
There was a problem hiding this comment.
Spelling should be fixed in the whole PR, it is written "readiness".
| var ( | ||
| cmdStatus = &cobra.Command{ | ||
| Use: "status [--wait] UUID", | ||
| Use: "status [--wait=bool|timeout] [--wait-ready=bool|timeout] UUID", |
There was a problem hiding this comment.
status.md should be updated with these changes.
2a2383e to
ad210f2
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
|
@lucab addressed review comments, PTAL |
| 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) |
There was a problem hiding this comment.
nit: all these fmt.Printfs should be removed or changed to t.Logf
There was a problem hiding this comment.
ah, I left it there, because this output is unbuffered, but I'll change it back to t.Logf.
| // 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) |
|
LGTM apart from the presumably leftover |
ad210f2 to
d19da4a
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
d19da4a to
2e0f80a
Compare
This changes the rkt status --wait to accept a timeout in addition to a boolean value. Addresses rkt#3462 (comment)
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)
2e0f80a to
aaef5e3
Compare
|
Merging, as the the rawhide failure seems to be a flake. |
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