Skip to content

Split ping probe into ping4 and ping6 for dual-stack support - #1498

Open
mkowalski wants to merge 1 commit into
nmstate:mainfrom
mkowalski:split-ping-probe-dual-stack-2
Open

Split ping probe into ping4 and ping6 for dual-stack support#1498
mkowalski wants to merge 1 commit into
nmstate:mainfrom
mkowalski:split-ping-probe-dual-stack-2

Conversation

@mkowalski

Copy link
Copy Markdown
Member

The single "ping" connectivity probe checked only one default gateway (whichever appeared first), making it impossible to detect when only one IP stack broke after applying an NNCP on dual-stack systems.

Split into separate "ping4" (0.0.0.0/0) and "ping6" (::/0) probes that track each IP stack independently. To avoid a 120s timeout penalty on single-stack clusters, Select() now pre-checks which address families have a default gateway and only includes the applicable ping probes.

Both hasGw4 and hasGw6 default to false so that a transient pre-check failure skips ping probes entirely rather than adding a probe whose trial would time out for 120s on clusters lacking that address family.

Fixes: #1411

Is this a BUG FIX or a FEATURE ?:

Uncomment only one, leave it on its own line:

/kind bug
/kind enhancement

What this PR does / why we need it:

Special notes for your reviewer:

Release note:

Ping probe becomes now Ping4 and Ping6 for supporting dual-stack environments

@kubevirt-bot kubevirt-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 16, 2026
@kubevirt-bot
kubevirt-bot requested review from emy and qinqon April 16, 2026 15:15
@kubevirt-bot kubevirt-bot added the dco-signoff: yes Indicates the PR's author has DCO signed all their commits. label Apr 16, 2026
@kubevirt-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mkowalski for approval. For more information see the Code Review Process.

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

Details 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

The single "ping" connectivity probe checked only one default gateway
(whichever appeared first), making it impossible to detect when only
one IP stack broke after applying an NNCP on dual-stack systems.

Split into separate "ping4" (0.0.0.0/0) and "ping6" (::/0) probes
that track each IP stack independently. To avoid a 120s timeout
penalty on single-stack clusters, Select() now pre-checks which
address families have a default gateway and only includes the
applicable ping probes.

Both hasGw4 and hasGw6 default to false so that a transient
pre-check failure skips ping probes entirely rather than adding a
probe whose trial would time out for 120s on clusters lacking that
address family.

Fixes: nmstate#1411
Signed-off-by: Mat Kowalski <mkowalski@redhat.com>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mkowalski
mkowalski force-pushed the split-ping-probe-dual-stack-2 branch from 233afb8 to af3cae9 Compare April 16, 2026 15:16

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces dual-stack support for connectivity probes by refactoring gateway detection and ping logic into IPv4 and IPv6 specific implementations. It also optimizes the probe selection process by pre-checking for available gateways, which prevents unnecessary timeouts on single-stack clusters. The review feedback suggests simplifying the calculation of ProbesTotalTimeout to avoid over-estimation and removing redundant logging within the ping polling loop to reduce log noise.

Comment thread pkg/probe/probes.go
Comment on lines +70 to +77
ProbesTotalTimeout = defaultGwProbeTimeout + // Select: ping4
defaultGwProbeTimeout + // Select: ping6
defaultDNSProbeTimeout + // Select: dns
defaultGwProbeTimeout + // Run: ping4
defaultGwProbeTimeout + // Run: ping6
defaultDNSProbeTimeout + // Run: dns
apiServerProbeTimeout + // Run: api-server
nodeReadinessProbeTimeout // Run: node-readiness

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The ProbesTotalTimeout is over-calculated. A probe is only included in the Run() phase if it successfully passes the Select() phase. If a probe fails in Select(), it consumes its timeout there but is not executed in Run(). If it succeeds in Select(), it consumes negligible time there and may consume its full timeout in Run(). Thus, each probe (ping4, ping6, dns, api-server, node-readiness) contributes at most once to the total worst-case timeout. The total should be the sum of the timeouts for these 5 distinct probes. This aligns with the preference for simpler implementations that cover known requirements without unnecessary complexity.

ProbesTotalTimeout = defaultGwProbeTimeout + // ping4
	defaultGwProbeTimeout + // ping6
	defaultDNSProbeTimeout + // dns
	apiServerProbeTimeout + // api-server
	nodeReadinessProbeTimeout // node-readiness
References
  1. Changes that add complexity to 'future-proof' the code against hypothetical scenarios require strong justification. Without it, prefer the simpler implementation that covers known requirements.

Comment thread pkg/probe/probes.go
Comment on lines 206 to 209
if err != nil {
log.Error(err, "failed to retrieve default gw")
return false, nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Logging an error here is redundant because defaultGwByDestination already logs (at debug level) when a gateway is missing. Furthermore, since this is called within a poll loop, it will log an error every second for 120 seconds if the gateway is not found, which is excessively noisy. Returning false, nil is sufficient for the poll to continue.

Suggested change
if err != nil {
log.Error(err, "failed to retrieve default gw")
return false, nil
}
gw, err := gwFunc(gjsonCurrentState)
if err != nil {
return false, nil
}

@kubevirt-bot

Copy link
Copy Markdown
Collaborator

@mkowalski: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-nmstate-e2e-handler-k8s af3cae9 link true /test pull-kubernetes-nmstate-e2e-handler-k8s
Details

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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has DCO signed all their commits. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve connectivity probe for dual-stack systems

2 participants