Skip to content

Commit

Permalink
Merge pull request #7 from edcdavid/add-option-container-exe
Browse files Browse the repository at this point in the history
add option to use container executables instead of host
  • Loading branch information
edcdavid authored Aug 28, 2024
2 parents 9a7efa4 + dbd9eef commit 9277f6a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions l2lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type L2Info interface {
GetPortsGettingPTP() []*l2.PtpIf

SetL2Client(kubernetes.Interface, *rest.Config)
GetL2DiscoveryConfig(ptpInterfacesOnly, allIFs bool, l2DiscoveryImage string) (config L2Info, err error)
GetL2DiscoveryConfig(ptpInterfacesOnly, allIFs, useContainerCmds bool, l2DiscoveryImage string) (config L2Info, err error)
}

const (
Expand Down Expand Up @@ -140,9 +140,9 @@ func (config *L2DiscoveryConfig) SetL2Client(k8sClient kubernetes.Interface, res
}

// Gets existing L2 configuration or creates a new one (if refresh is set to true)
func (config *L2DiscoveryConfig) GetL2DiscoveryConfig(ptpInterfacesOnly, allIFs bool, l2DiscoveryImage string) (L2Info, error) {
func (config *L2DiscoveryConfig) GetL2DiscoveryConfig(ptpInterfacesOnly, allIFs, useContainerCmds bool, l2DiscoveryImage string) (L2Info, error) {
if GlobalL2DiscoveryConfig.refresh {
err := GlobalL2DiscoveryConfig.DiscoverL2Connectivity(ptpInterfacesOnly, allIFs, l2DiscoveryImage)
err := GlobalL2DiscoveryConfig.DiscoverL2Connectivity(ptpInterfacesOnly, allIFs, useContainerCmds, l2DiscoveryImage)
if err != nil {
GlobalL2DiscoveryConfig.refresh = false
return nil, fmt.Errorf("failed to discover L2 connectivity: %w", err)
Expand All @@ -165,7 +165,7 @@ func (config *L2DiscoveryConfig) reset() {
}

// Discovers the L2 connectivity using l2discovery daemonset
func (config *L2DiscoveryConfig) DiscoverL2Connectivity(ptpInterfacesOnly, allIFs bool, l2DiscoveryImage string) error {
func (config *L2DiscoveryConfig) DiscoverL2Connectivity(ptpInterfacesOnly, allIFs, useContainerCmds bool, l2DiscoveryImage string) error {
GlobalL2DiscoveryConfig.reset()
GlobalL2DiscoveryConfig.InitSkippedInterfaces()
// initializes clusterwide ptp interfaces
Expand All @@ -178,6 +178,9 @@ func (config *L2DiscoveryConfig) DiscoverL2Connectivity(ptpInterfacesOnly, allIF
if allIFs {
env = append(env, v1core.EnvVar{Name: "L2DISCOVERY_ALLIFS", Value: "true"})
}
if useContainerCmds {
env = append(env, v1core.EnvVar{Name: "L2DISCOVERY_USECONTAINERCMDS", Value: "true"})
}
_, err = daemonsets.CreateDaemonSet(L2DiscoveryDsName, L2DiscoveryNsName, L2DiscoveryContainerName, l2DiscoveryImage, dummyMap, env, timeoutDaemon,
L2ContainerCPUReq, L2ContainerCPULim, L2ContainerMemReq, L2ContainerMemLim)
if err != nil {
Expand Down

0 comments on commit 9277f6a

Please sign in to comment.