Skip to content
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

Refactoring unused parameter #124033

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/kubelet/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (pb *prober) probe(ctx context.Context, probeType probeType, pod *v1.Pod, s
return results.Success, nil
}

result, output, err := pb.runProbeWithRetries(ctx, probeType, probeSpec, pod, status, container, containerID, maxProbeRetries)
result, output, err := pb.runProbeWithRetries(ctx, probeSpec, pod, status, container, containerID, maxProbeRetries)
if err != nil || (result != probe.Success && result != probe.Warning) {
// Probe failed in one way or another.
if err != nil {
Expand All @@ -120,26 +120,26 @@ func (pb *prober) probe(ctx context.Context, probeType probeType, pod *v1.Pod, s

// runProbeWithRetries tries to probe the container in a finite loop, it returns the last result
// if it never succeeds.
func (pb *prober) runProbeWithRetries(ctx context.Context, probeType probeType, p *v1.Probe, pod *v1.Pod, status v1.PodStatus, container v1.Container, containerID kubecontainer.ContainerID, retries int) (probe.Result, string, error) {
func (pb *prober) runProbeWithRetries(ctx context.Context, p *v1.Probe, pod *v1.Pod, status v1.PodStatus, container v1.Container, containerID kubecontainer.ContainerID, retries int) (probe.Result, string, error) {
var err error
var result probe.Result
var output string
for i := 0; i < retries; i++ {
result, output, err = pb.runProbe(ctx, probeType, p, pod, status, container, containerID)
result, output, err = pb.runProbe(ctx, p, pod, status, container, containerID)
if err == nil {
return result, output, nil
}
}
return result, output, err
}

func (pb *prober) runProbe(ctx context.Context, probeType probeType, p *v1.Probe, pod *v1.Pod, status v1.PodStatus, container v1.Container, containerID kubecontainer.ContainerID) (probe.Result, string, error) {
func (pb *prober) runProbe(ctx context.Context, p *v1.Probe, pod *v1.Pod, status v1.PodStatus, container v1.Container, containerID kubecontainer.ContainerID) (probe.Result, string, error) {
timeout := time.Duration(p.TimeoutSeconds) * time.Second
switch {
case p.Exec != nil:
klog.V(4).InfoS("Exec-Probe runProbe", "pod", klog.KObj(pod), "containerName", container.Name, "execCommand", p.Exec.Command)
command := kubecontainer.ExpandContainerCommandOnlyStatic(p.Exec.Command, container.Env)
return pb.exec.Probe(pb.newExecInContainer(ctx, container, containerID, command, timeout))
return pb.exec.Probe(pb.newExecInContainer(ctx, containerID, command, timeout))

case p.HTTPGet != nil:
req, err := httpprobe.NewRequestForHTTPGetAction(p.HTTPGet, &container, status.PodIP, "probe")
Expand Down Expand Up @@ -190,7 +190,7 @@ type execInContainer struct {
writer io.Writer
}

func (pb *prober) newExecInContainer(ctx context.Context, container v1.Container, containerID kubecontainer.ContainerID, cmd []string, timeout time.Duration) exec.Cmd {
func (pb *prober) newExecInContainer(ctx context.Context, containerID kubecontainer.ContainerID, cmd []string, timeout time.Duration) exec.Cmd {
return &execInContainer{run: func() ([]byte, error) {
return pb.runner.RunInContainer(ctx, containerID, cmd, timeout)
}}
Expand Down
3 changes: 1 addition & 2 deletions pkg/kubelet/prober/prober_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,9 @@ func TestNewExecInContainer(t *testing.T) {
runner: runner,
}

container := v1.Container{}
containerID := kubecontainer.ContainerID{Type: "docker", ID: "containerID"}
cmd := []string{"/foo", "bar"}
exec := prober.newExecInContainer(ctx, container, containerID, cmd, 0)
exec := prober.newExecInContainer(ctx, containerID, cmd, 0)

var dataBuffer bytes.Buffer
writer := ioutils.LimitWriter(&dataBuffer, int64(limit))
Expand Down