Skip to content

Conversation

@gtannous-spec
Copy link
Collaborator

Description

This PR adds the ability for the linuxptp-daemon to report hardware configuration errors directly to the PtpConfig CR status using Kubernetes conditions. When an invalid hardwareSpecificDefinitions value is detected (e.g., a typo like intel/e81 instead of intel/e810), the daemon now sets a HardwareConfigurationWarning condition on the related PtpConfig.

Motivation

Previously, when a user configured a HardwareConfig with an invalid hardwareSpecificDefinitions value, the daemon would silently skip the hardware configuration without any feedback. This made it difficult for users to diagnose why their hardware wasn't being configured properly.

With this change, users get clear feedback about configuration errors directly in the PtpConfig status.

Changes

Core Logic

  • pkg/hardwareconfig/hardwareconfig.go: Modified resolveSubsystemStructure to return an error when an unknown hardwareSpecificDefinitions value is provided, instead of silently skipping

Controller Updates

  • pkg/controller/hardwareconfig_controller.go:
    • Added setHardwareConfigWarning() function that updates the related PtpConfig status with a warning condition
    • Only updates the PtpConfig that is specifically related to the failing HardwareConfig (not all PtpConfigs)
    • Added imports for ptpv1, metav1, and strings

Tests

  • pkg/hardwareconfig/hardwareconfig_test.go: Added TestResolveSubsystemStructure_UnknownHardwareDefinition unit test covering various invalid inputs

Test Data

  • pkg/hardwareconfig/testdata/hwconfig-typo-test.yaml: HardwareConfig with intentional typo for manual testing
  • pkg/hardwareconfig/testdata/ptpconfig-for-hwconfig-test.yaml: Matching PtpConfig for manual testing

Example

When a hardware configuration error occurs, the PtpConfig status will show:

status:
  conditions:
  - type: HardwareConfigurationWarning
    status: "True"
    reason: InvalidHardwareSpecificDefinitions
    message: "unknown hardwareSpecificDefinitions 'intel/e81' for subsystem test-subsystem: valid options are 'intel/e810'"
    lastTransitionTime: "2025-12-28T22:56:00Z"
  matchList:
    - nodeName: worker-1
      profile: grandmaster-profile

How to Test

  1. Apply a PtpConfig with a profile:

    kubectl apply -f pkg/hardwareconfig/testdata/ptpconfig-for-hwconfig-test.yaml
  2. Apply a HardwareConfig with a typo:

    kubectl apply -f pkg/hardwareconfig/testdata/hwconfig-typo-test.yaml
  3. Check the PtpConfig status:

    kubectl get ptpconfig test-ptpconfig-for-hwtest -n openshift-ptp -o yaml | grep -A10 conditions

Related PRs

  • ptp-operator: Companion PR adds Conditions field to PtpConfigStatus struct and CRD schema

Unit Tests

go test -v ./pkg/hardwareconfig/... -run TestResolveSubsystemStructure_UnknownHardwareDefinition

@gtannous-spec gtannous-spec added the ok-to-test ok to test label Dec 29, 2025
@github-actions
Copy link

Thanks for your PR,
Best regards.

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

Labels

ok-to-test ok to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant