Skip to content

Log intermediate errors in applyBackendSwitchRule API fallback chain #6

Description

@devin-ai-integration

Summary

applyBackendSwitchRule in internal/haproxy/dataplane_client.go tries up to 4 different Dataplane API paths (nested PUT → nested POST → legacy PUT → legacy POST) to handle v2/v3 endpoint layout differences. However, intermediate errors are silently discarded, making it very difficult to debug API compatibility issues.

Current behavior

When the preferred nested PUT fails, the code falls through to nested POST, then legacy PUT, then legacy POST. Only the final error (if all 4 fail) is returned. Errors from the first 3 attempts are lost.

Proposed fix

Log intermediate errors at debug level so operators can trace which API paths were attempted and why they failed:

log.V(1).Info("nested PUT failed, trying nested POST", "error", err)
// ... try nested POST
log.V(1).Info("nested POST failed, trying legacy PUT", "error", err2)
// ... etc

Alternatively, wrap all errors into the final error using errors.Join or fmt.Errorf so the full chain is available to callers.

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions