-
Notifications
You must be signed in to change notification settings - Fork 810
[healthcheck] optimize: reduce unnecessary function calls #5048
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -459,11 +459,6 @@ func runAction(cmd *cobra.Command, args []string) error { | |
| return err | ||
| } | ||
|
|
||
| statusC, err := task.Wait(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if err := task.Start(ctx); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -480,12 +475,14 @@ func runAction(cmd *cobra.Command, args []string) error { | |
| return err | ||
| } | ||
|
|
||
| // Setup container healthchecks. | ||
| if err := healthcheck.CreateTimer(ctx, c, (*config.Config)(&createOpt.GOptions), createOpt.NerdctlCmd, createOpt.NerdctlArgs); err != nil { | ||
| return fmt.Errorf("failed to create healthcheck timer: %w", err) | ||
| } | ||
| if err := healthcheck.StartTimer(ctx, c, (*config.Config)(&createOpt.GOptions)); err != nil { | ||
| return fmt.Errorf("failed to start healthcheck timer: %w", err) | ||
| if hcStr, ok := lab[labels.HealthCheck]; ok && hcStr != "" { | ||
| // Setup container healthchecks. | ||
| if err := healthcheck.CreateTimer(ctx, c, (*config.Config)(&createOpt.GOptions), createOpt.NerdctlCmd, createOpt.NerdctlArgs, lab); err != nil { | ||
| return fmt.Errorf("failed to create healthcheck timer: %w", err) | ||
| } | ||
| if err := healthcheck.StartTimer(ctx, c, (*config.Config)(&createOpt.GOptions), lab); err != nil { | ||
| return fmt.Errorf("failed to start healthcheck timer: %w", err) | ||
| } | ||
| } | ||
|
|
||
| if createOpt.Detach { | ||
|
|
@@ -503,6 +500,11 @@ func runAction(cmd *cobra.Command, args []string) error { | |
| } | ||
| } | ||
|
|
||
| statusC, err := task.Wait(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
Comment on lines
+503
to
+506
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can see
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should move back the code before task.Start
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not necessary to move back, it's not a bug if user use -d we don't need to wait it. @ChengyuZhu6
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @haytok Was your concern resolved? |
||
|
|
||
| select { | ||
| // io.Wait() would return when either 1) the user detaches from the container OR 2) the container is about to exit. | ||
| // | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.