Skip to content

Add exec probe handler support to probes API#696

Open
zzzeek wants to merge 1 commit into
openstack-k8s-operators:mainfrom
zzzeek:OSPRH-30190
Open

Add exec probe handler support to probes API#696
zzzeek wants to merge 1 commit into
openstack-k8s-operators:mainfrom
zzzeek:OSPRH-30190

Conversation

@zzzeek
Copy link
Copy Markdown

@zzzeek zzzeek commented May 18, 2026

Add ProbeHandlerType (HTTP/Exec) and Command/Port/Scheme fields to ProbeConf. Introduce SetProbeConfV2 and CreateProbeSetV2 with a self-contained ProbeConf signature that switches on handler type. Export Merge for downstream use. Existing SetProbeConf/CreateProbeSet delegate to V2 for full backward compatibility.

References: OSPRH-30190

Add ProbeHandlerType (HTTP/Exec) and Command/Port/Scheme fields to
ProbeConf. Introduce SetProbeConfV2 and CreateProbeSetV2 with a
self-contained ProbeConf signature that switches on handler type.
Export Merge for downstream use. Existing SetProbeConf/CreateProbeSet
delegate to V2 for full backward compatibility.

References: OSPRH-30190

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
"path must start with '/' if specified")
errorList = append(errorList, err)

switch config.Type {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@zzzeek not sure about your thoughts but I'd like to consolidate these two switch-case(s) into a single one.
e.g.

switch config.Type {
case ProbeHandlerExec:
    if len(config.Command) == 0 {
        errorList = append(errorList, field.Required(basePath.Child("command"),
            "command is required for exec probe type"))
    }
case "", ProbeHandlerHTTP:
    if config.Path != "" && !strings.HasPrefix(config.Path, "/") {
        errorList = append(errorList, field.Invalid(basePath.Child("path"), config.Path,
            "path must start with '/' if specified"))
    }
default:
    errorList = append(errorList, field.Invalid(basePath.Child("type"), config.Type,
        "type must be one of: HTTP, Exec, or unset"))
}

This default should address the invalid type which is the entrypoint for our check, while the "valid" use cases can check other parameters and eventually raise a specific error.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yeah sorry looks like the robot was getting creative here, I spent most of my time fixing up the tests it generated.

probe.HTTPGet.Scheme = *scheme

switch config.Type {
case ProbeHandlerExec:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we really need a config.Type. While I understand the purpose and makes things readable, technically you can infer the type from the len(config.Command): if it is > 0 it implies you asked for an Exec Handler type, otherwise http, no other potential choices or extension are allowed AFAIK in k8s.
@zzzeek wdyt?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

still a python dev I think of "explicit is better than implicit". We discussed supporting other kinds of probes in the future (e.g. expanding the enum to include TCP, GRPC), which means for validation we need a way to validate the mutual exclusiveness of the different handler types and up front we need to know which ProbeHandler sub-field we are looking at. If we support Exec, HTTP, TCP and GRPC all at the same time, it seems like it would be uncomfortable defining a hierarchy of which field sets we look at first to determine the intent, which we then validate on once we've decided on which handler type we think this is. plus as you mention it makes things readable.

in the Probe struct, this mutual exclusiveness is determined by which of the sub-actions inside of ProbeHandler are set. so they dont have quite the same problem since we're working with a flat namespace.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fair enough, it's eventually just a string so it shouldn't impact on the CRD size. let's keep it explicit if the idea is to extend it more over the time.

// PeriodSeconds - How often (in seconds) to perform the probe
type ProbeConf struct {
// +kubebuilder:validation:Optional
Type ProbeHandlerType `json:"type,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is connected to my other comment. In other words I'm wondering if we should infer the ProbeHandlerType from the Command (it must be passed in that case) and default to HTTP (the only other choice) when a command is not passed. The other checks might remain unchanged or enhanced.

@fmount fmount requested review from abays and stuggi May 19, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants