-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix status taking a long time on docker driver #15077
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,18 @@ func APIServerStatus(cr command.Runner, hostname string, port int) (state.State, | |
return apiServerHealthz(hostname, port) | ||
} | ||
|
||
// nonFreezerServerStatus is the alternative flow if the guest does not have the freezer cgroup so different methods to detect the apiserver status are used | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright 2022 The Kubernetes Authors All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package pause | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"k8s.io/klog/v2" | ||
"k8s.io/minikube/pkg/minikube/command" | ||
) | ||
|
||
const pausedFile = "paused" | ||
|
||
// CreatePausedFile creates a file in the minikube cluster to indicate that the apiserver is paused | ||
func CreatePausedFile(r command.Runner) { | ||
if _, err := r.RunCmd(exec.Command("touch", pausedFile)); err != nil { | ||
klog.Errorf("failed to create paused file, apiserver may display incorrect status") | ||
} | ||
} | ||
|
||
// RemovePausedFile removes a file in minikube cluster to indicate that the apiserver is unpaused | ||
func RemovePausedFile(r command.Runner) { | ||
if _, err := r.RunCmd(exec.Command("rm", "-f", pausedFile)); err != nil { | ||
klog.Errorf("failed to remove paused file, apiserver may display incorrect status") | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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