Report hardware config errors to PtpConfig status conditions #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
hardwareSpecificDefinitionsvalue is detected (e.g., a typo likeintel/e81instead ofintel/e810), the daemon now sets aHardwareConfigurationWarningcondition on the related PtpConfig.Motivation
Previously, when a user configured a
HardwareConfigwith an invalidhardwareSpecificDefinitionsvalue, 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: ModifiedresolveSubsystemStructureto return an error when an unknownhardwareSpecificDefinitionsvalue is provided, instead of silently skippingController Updates
pkg/controller/hardwareconfig_controller.go:setHardwareConfigWarning()function that updates the related PtpConfig status with a warning conditionptpv1,metav1, andstringsTests
pkg/hardwareconfig/hardwareconfig_test.go: AddedTestResolveSubsystemStructure_UnknownHardwareDefinitionunit test covering various invalid inputsTest Data
pkg/hardwareconfig/testdata/hwconfig-typo-test.yaml: HardwareConfig with intentional typo for manual testingpkg/hardwareconfig/testdata/ptpconfig-for-hwconfig-test.yaml: Matching PtpConfig for manual testingExample
When a hardware configuration error occurs, the PtpConfig status will show:
How to Test
Apply a PtpConfig with a profile:
Apply a HardwareConfig with a typo:
Check the PtpConfig status:
kubectl get ptpconfig test-ptpconfig-for-hwtest -n openshift-ptp -o yaml | grep -A10 conditionsRelated PRs
Conditionsfield toPtpConfigStatusstruct and CRD schemaUnit Tests
go test -v ./pkg/hardwareconfig/... -run TestResolveSubsystemStructure_UnknownHardwareDefinition