-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix status taking a long time on docker driver #15077
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
Changes from 1 commit
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 |
---|---|---|
|
@@ -174,15 +174,15 @@ func APIServerStatus(cr command.Runner, hostname string, port int) (state.State, | |
rr, err := cr.RunCmd(exec.Command("sudo", "egrep", "^[0-9]+:freezer:", fmt.Sprintf("/proc/%d/cgroup", pid))) | ||
if err != nil { | ||
klog.Warningf("unable to find freezer cgroup: %v", err) | ||
return apiServerHealthz(hostname, port) | ||
return nonFreezerServerStatus(cr, hostname, port) | ||
|
||
} | ||
freezer := strings.TrimSpace(rr.Stdout.String()) | ||
klog.Infof("apiserver freezer: %q", freezer) | ||
fparts := strings.Split(freezer, ":") | ||
if len(fparts) != 3 { | ||
klog.Warningf("unable to parse freezer - found %d parts: %s", len(fparts), freezer) | ||
return apiServerHealthz(hostname, port) | ||
return nonFreezerServerStatus(cr, hostname, port) | ||
} | ||
|
||
rr, err = cr.RunCmd(exec.Command("sudo", "cat", path.Join("/sys/fs/cgroup/freezer", fparts[2], "freezer.state"))) | ||
|
@@ -196,7 +196,7 @@ func APIServerStatus(cr command.Runner, hostname string, port int) (state.State, | |
klog.Warningf("unable to get freezer state: %s", rr.Stderr.String()) | ||
} | ||
|
||
return apiServerHealthz(hostname, port) | ||
return nonFreezerServerStatus(cr, hostname, port) | ||
} | ||
|
||
fs := strings.TrimSpace(rr.Stdout.String()) | ||
|
@@ -207,6 +207,17 @@ func APIServerStatus(cr command.Runner, hostname string, port int) (state.State, | |
return apiServerHealthz(hostname, port) | ||
} | ||
|
||
func nonFreezerServerStatus(cr command.Runner, hostname string, port int) (state.State, error) { | ||
rr, err := cr.RunCmd(exec.Command("ls")) | ||
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. is this running in home folder? 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. Correct |
||
if err != nil { | ||
return state.None, err | ||
} | ||
if strings.Contains(rr.Stdout.String(), "paused") { | ||
return state.Paused, nil | ||
} | ||
return apiServerHealthz(hostname, port) | ||
} | ||
|
||
// apiServerHealthz checks apiserver in a patient and tolerant manner | ||
func apiServerHealthz(hostname string, port int) (state.State, error) { | ||
var st state.State | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ limitations under the License. | |
package cluster | ||
|
||
import ( | ||
"os/exec" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
|
@@ -63,7 +64,17 @@ func pause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]string | |
return ids, nil | ||
} | ||
|
||
return ids, cr.PauseContainers(ids) | ||
if err := cr.PauseContainers(ids); err != nil { | ||
return ids, errors.Wrap(err, "pausing containers") | ||
} | ||
|
||
if isTouchingKubeSystem(namespaces) { | ||
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. I am curious if it is better to have the "paused" file to be in the /tmp ? in case minikube VM gets restarted to be auto-cleaned ? the question is, when minikube is paused, and user restarts minikube VM (not through minikube interface but by shutting down the laptop) would minikube still be paused ? 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. I tried moving the file to When the user manually restarts the container (as this only affects kicbase, not ISO) the kubelet and apiserver are stopped and a |
||
if _, err := r.RunCmd(exec.Command("touch", "paused")); err != nil { | ||
klog.Errorf("failed to create paused file, apiserver may display incorrect status") | ||
} | ||
} | ||
|
||
return ids, nil | ||
} | ||
|
||
// Unpause unpauses a Kubernetes cluster, retrying if necessary | ||
|
@@ -99,6 +110,12 @@ func unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]stri | |
return ids, errors.Wrap(err, "kubelet start") | ||
} | ||
|
||
if isTouchingKubeSystem(namespaces) { | ||
if _, err := r.RunCmd(exec.Command("rm", "-f", "paused")); err != nil { | ||
klog.Errorf("failed to remove paused file, apiserver may display incorrect status") | ||
} | ||
} | ||
|
||
return ids, nil | ||
} | ||
|
||
|
@@ -115,3 +132,16 @@ func CheckIfPaused(cr cruntime.Manager, namespaces []string) (bool, error) { | |
|
||
return false, nil | ||
} | ||
|
||
// isTouchingKubeSystem returns if the user is pausing or unpausing the kube-system namespace | ||
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. does this function return "-ing" state ? does it mean if it returns true then another function is Touch-ing the file ? 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. Function name was vague, renamed and improved the comment |
||
func isTouchingKubeSystem(namespaces []string) bool { | ||
if namespaces == nil { | ||
return true | ||
} | ||
for _, ns := range namespaces { | ||
if ns == "kube-system" { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
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.
please add detailed comment for this function. the name is not self-explantory
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.
Added a comment