Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func main() {
daemon.PtpNamespace,
stdoutToSocket,
kubeClient,
cfg, // REST config for dynamic client to update PtpConfig status
ptpConfUpdate,
stopCh,
plugins,
Expand Down Expand Up @@ -219,7 +220,7 @@ func main() {
runHybridMode(cfg, cp, nodeName, ptpConfUpdate, daemonInstance, ptpClient, nodeName, &hwconfigs, &refreshNodePtpDevice, tickerPull, sigCh, closeProcessManager)
}
} else {
runLegacyMode(cp, nodeName, ptpConfUpdate, ptpClient, nodeName, &hwconfigs, &refreshNodePtpDevice, tickerPull, sigCh, closeProcessManager)
runLegacyMode(cp, nodeName, ptpConfUpdate, daemonInstance, ptpClient, nodeName, &hwconfigs, &refreshNodePtpDevice, tickerPull, sigCh, closeProcessManager)
}
}

Expand Down Expand Up @@ -397,7 +398,7 @@ func runHybridMode(cfg *rest.Config, cp *cliParams, nodeName string, ptpConfUpda
}

// runLegacyMode runs in legacy file-based mode without any controllers
func runLegacyMode(cp *cliParams, _ string, ptpConfUpdate *daemon.LinuxPTPConfUpdate, ptpClient *ptpclient.Clientset, nodeNameForDevice string, hwconfigs *[]ptpv1.HwConfig, refreshNodePtpDevice *bool, tickerPull *time.Ticker, sigCh chan os.Signal, closeProcessManager chan bool) {
func runLegacyMode(cp *cliParams, _ string, ptpConfUpdate *daemon.LinuxPTPConfUpdate, _ *daemon.Daemon, ptpClient *ptpclient.Clientset, nodeNameForDevice string, hwconfigs *[]ptpv1.HwConfig, refreshNodePtpDevice *bool, tickerPull *time.Ticker, sigCh chan os.Signal, closeProcessManager chan bool) {
glog.Info("Running in legacy file-based mode (no controllers)")

for {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
golang.org/x/sync v0.18.0
gonum.org/v1/gonum v0.16.0
k8s.io/api v0.28.3
k8s.io/apiextensions-apiserver v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
k8s.io/klog/v2 v2.130.1
Expand Down Expand Up @@ -86,7 +87,6 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v1.0.0 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
15 changes: 15 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

"github.com/golang/glog"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

ptpv1 "github.com/k8snetworkplumbingwg/ptp-operator/api/v1"
)
Expand Down Expand Up @@ -307,6 +308,10 @@ type Daemon struct {
// kubeClient allows interaction with Kubernetes, including the node we are running on.
kubeClient *kubernetes.Clientset

// restConfig is the Kubernetes REST config used to create dynamic clients
// for updating PtpConfig status when hardware plugin validation errors are found
restConfig *rest.Config

ptpUpdate *LinuxPTPConfUpdate

processManager *ProcessManager
Expand Down Expand Up @@ -357,6 +362,7 @@ func New(
namespace string,
stdoutToSocket bool,
kubeClient *kubernetes.Clientset,
restConfig *rest.Config,
ptpUpdate *LinuxPTPConfUpdate,
stopCh <-chan struct{},
plugins []string,
Expand All @@ -371,6 +377,9 @@ func New(
}
InitializeOffsetMaps()
pluginManager := registerPlugins(plugins)
// Set RestConfig and Namespace for plugin validation status updates
pluginManager.RestConfig = restConfig
pluginManager.Namespace = namespace
eventChannel := make(chan event.EventChannel, 100)
pm := &ProcessManager{
process: nil,
Expand Down Expand Up @@ -403,6 +412,7 @@ func New(
namespace: namespace,
stdoutToSocket: stdoutToSocket,
kubeClient: kubeClient,
restConfig: restConfig,
ptpUpdate: ptpUpdate,
pluginManager: pluginManager,
hwconfigs: hwconfigs,
Expand Down Expand Up @@ -654,6 +664,11 @@ func (dn *Daemon) applyNodePTPProfiles() error {
dn.pluginManager.PopulateHwConfig(dn.hwconfigs)
*dn.refreshNodePtpDevice = true
dn.readyTracker.setConfig(true)

// Validate plugin names and report errors to PtpConfig status
// This is called after profiles are applied to ensure proper status updates
dn.pluginManager.ValidateAndReportPluginErrors(dn.ptpUpdate.NodeProfiles)

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/daemon/daemon_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func applyTestProfile(t *testing.T, profile *ptpv1.PtpProfile) {
"openshift-ptp",
false,
nil,
nil, // restConfig not needed for tests
&LinuxPTPConfUpdate{
UpdateCh: make(chan bool),
NodeProfiles: []ptpv1.PtpProfile{*profile},
Expand Down Expand Up @@ -206,6 +207,7 @@ func Test_applyProfile_TBC(t *testing.T) {
"openshift-ptp",
false,
nil,
nil, // restConfig not needed for tests
&LinuxPTPConfUpdate{
UpdateCh: make(chan bool),
NodeProfiles: []ptpv1.PtpProfile{},
Expand Down
1 change: 1 addition & 0 deletions pkg/hardwareconfig/hardwareconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ func TestApplyConditionDesiredStatesWithRealData(t *testing.T) {

if targetCondition == nil {
t.Fatalf("Condition '%s' not found in hardware config", tc.conditionName)
return // unreachable but satisfies staticcheck
}

// Validate the expected number of desired states
Expand Down
Loading
Loading