Skip to content

Commit 3f653fc

Browse files
committed
Ensure profile names are distinct within the same node
1 parent fa750e5 commit 3f653fc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/daemon/ptpconfig_status.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ const (
1414
ConditionTypeHardwarePluginReady = "HardwarePluginReady"
1515
)
1616

17-
// FindPtpConfigByProfileName lists all PtpConfigs and returns the name/namespace
18-
// of the one containing a profile with the given name.
17+
// find the PtpConfig CR that contains the given profile name
1918
func FindPtpConfigByProfileName(ptpClient *ptpclient.Clientset, namespace, profileName string) (string, string, bool) {
2019
ptpConfigs, err := ptpClient.PtpV1().PtpConfigs(namespace).List(context.TODO(), metav1.ListOptions{})
2120
if err != nil {
@@ -24,7 +23,11 @@ func FindPtpConfigByProfileName(ptpClient *ptpclient.Clientset, namespace, profi
2423
}
2524
for _, cfg := range ptpConfigs.Items {
2625
for _, p := range cfg.Spec.Profile {
27-
if p.Name != nil && *p.Name == profileName {
26+
if p.Name == nil {
27+
continue
28+
}
29+
qualified := cfg.Name + "_" + *p.Name
30+
if qualified == profileName || *p.Name == profileName {
2831
return cfg.Name, cfg.Namespace, true
2932
}
3033
}

0 commit comments

Comments
 (0)