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

Add probe triggered log and shift the periodics timer after manual run #119089

Merged
merged 3 commits into from
Oct 23, 2024

Conversation

mochizuki875
Copy link
Member

@mochizuki875 mochizuki875 commented Jul 5, 2023

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Output a log when probe is triggered.
Especially readinessProbe, it will be executed by two triggers:

However, there are no means to know which executed readinessProbe, and it may make confusion like #118815.
In addition, shift the periodic timer of ReadinessProbe after manual run.

Which issue(s) this PR fixes:

Fixes #118815

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Output a log as v4-level when probe is triggered and shift the periodic timer of ReadinessProbe after manual run.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 5, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @mochizuki875. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 5, 2023
@k8s-ci-robot k8s-ci-robot requested review from dchen1107 and mtaufen July 5, 2023 06:25
@mochizuki875
Copy link
Member Author

/sig node
/area kubelet

@aimuz
Copy link
Contributor

aimuz commented Jul 7, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 7, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Jul 24, 2023

/triage accepted
/priority important-longterm
/cc @SergeyKanzhelev

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 24, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Aug 30, 2023

/assign
@mochizuki875 Would it be enough to only log manually triggered probes to reduce amount of logging?

@mochizuki875
Copy link
Member Author

@bart0sh
I think so because if we remove it, the probe's regular log emitted by periodSeconds will not be output.

case <-probeTicker.C:
klog.V(3).InfoS("Triggerd Probe by periodSeconds", "probeType", w.probeType, "pod", klog.KObj(w.pod), "podUID", w.pod.UID, "containerName", w.container.Name)

Should I remove regular log?

@SergeyKanzhelev
Copy link
Member

the right fix will be to shift the periodics timer after the manual run. Also maybe update docs for probes

/lgtm cancel
/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Aug 9, 2024
@mochizuki875
Copy link
Member Author

mochizuki875 commented Aug 28, 2024

@SergeyKanzhelev
Thank you for your comment.

the right fix will be to shift the periodics timer after the manual run.

How about updating the periodic timer to run the probe again at intervals of probeTickerPeriod starting from the moment a manual run occurs?
(Also I agree updating docs)

e.g. Assume that probeTickerPeriod=30 and first periodic run occurs at 15:00:00, and manual run occurs at 15:00:10.
Then, the next periodic run is scheduled for 15:00:40(instead of the current 15:00:30).

@mochizuki875 mochizuki875 force-pushed the add_probe_triggered_log branch from 2f90380 to b3f9f16 Compare August 30, 2024 06:51
@mochizuki875 mochizuki875 changed the title Add probe triggered log Add probe triggered log and shift the periodics timer after manual run Aug 30, 2024
@mochizuki875
Copy link
Member Author

@SergeyKanzhelev

I've fix as below:

In addition, I've create PR which update docs.
kubernetes/website#47727

Best regards.

@mochizuki875
Copy link
Member Author

/retest

@@ -178,7 +178,13 @@ probeLoop:
case <-w.stopCh:
break probeLoop
case <-probeTicker.C:
klog.V(4).InfoS("Triggerd Probe by periodSeconds", "probeType", w.probeType, "pod", klog.KObj(w.pod), "podUID", w.pod.UID, "containerName", w.container.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this message is necessary because every probe emits a level 4 log when it runs:

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) {
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))
case p.HTTPGet != nil:
req, err := httpprobe.NewRequestForHTTPGetAction(p.HTTPGet, &container, status.PodIP, "probe")
if err != nil {
return probe.Unknown, "", err
}
if klogV4 := klog.V(4); klogV4.Enabled() {
port := req.URL.Port()
host := req.URL.Hostname()
path := req.URL.Path
scheme := req.URL.Scheme
headers := p.HTTPGet.HTTPHeaders
klogV4.InfoS("HTTP-Probe", "scheme", scheme, "host", host, "port", port, "path", path, "timeout", timeout, "headers", headers)
}
return pb.http.Probe(req, timeout)
case p.TCPSocket != nil:
port, err := probe.ResolveContainerPort(p.TCPSocket.Port, &container)
if err != nil {
return probe.Unknown, "", err
}
host := p.TCPSocket.Host
if host == "" {
host = status.PodIP
}
klog.V(4).InfoS("TCP-Probe", "host", host, "port", port, "timeout", timeout)
return pb.tcp.Probe(host, port, timeout)
case p.GRPC != nil:
host := status.PodIP
service := ""
if p.GRPC.Service != nil {
service = *p.GRPC.Service
}
klog.V(4).InfoS("GRPC-Probe", "host", host, "service", service, "port", p.GRPC.Port, "timeout", timeout)
return pb.grpc.Probe(host, service, int(p.GRPC.Port), timeout)

So, we can distinguish whether a probe is periodical or manual by searching the message for manual run added below.

In addition, this message looks noisy because this is emitted even while the probe in on hold. It means this message is logged for a startup probe while the container is running.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hshiina
Indeed, you are right.
I've removed the periodical log.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3194f64f70f439205c9021bd1b57ec52312dc6fd

@thockin
Copy link
Member

thockin commented Oct 22, 2024

ping for approval!

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mochizuki875, SergeyKanzhelev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2024
@SergeyKanzhelev
Copy link
Member

this will be tricky to test, merging as-is is fine. Thanks

@mochizuki875
Copy link
Member Author

@SergeyKanzhelev
Thank you!

/remove-hold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 23, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5fa794d into kubernetes:master Oct 23, 2024
13 of 14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.32 milestone Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

readiness probe is not scheduled as configured periodSeconds