• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

k8snetworkplumbingwg / sriov-network-operator / 13856261115

14 Mar 2025 12:09PM UTC coverage: 48.251% (-0.6%) from 48.875%
13856261115

Pull #856

github

web-flow
Merge 2cb0a44e6 into 230f50baa
Pull Request #856: Reach MetaData service over IPv6

0 of 52 new or added lines in 1 file covered. (0.0%)

673 existing lines in 11 files now uncovered.

7350 of 15233 relevant lines covered (48.25%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/pkg/consts/constants.go
1
package consts
2

3
import (
4
        "fmt"
5
        "time"
6
)
7

8
type DrainState string
9

10
// PlatformTypes
11
type PlatformTypes int
12

13
const (
14
        Chroot = "/host"
15
        Host   = "/host"
16

17
        ResyncPeriod               = 5 * time.Minute
18
        DaemonRequeueTime          = 30 * time.Second
19
        DrainControllerRequeueTime = 5 * time.Second
20

21
        DefaultConfigName                  = "default"
22
        ConfigDaemonPath                   = "./bindata/manifests/daemon"
23
        InjectorWebHookPath                = "./bindata/manifests/webhook"
24
        OperatorWebHookPath                = "./bindata/manifests/operator-webhook"
25
        MetricsExporterPath                = "./bindata/manifests/metrics-exporter"
26
        SystemdServiceOcpPath              = "./bindata/manifests/sriov-config-service/openshift"
27
        SystemdServiceOcpMachineConfigName = "sriov-config-service"
28
        ServiceCAConfigMapAnnotation       = "service.beta.openshift.io/inject-cabundle"
29
        InjectorWebHookName                = "network-resources-injector-config"
30
        OperatorWebHookName                = "sriov-operator-webhook-config"
31
        DeprecatedOperatorWebHookName      = "operator-webhook-config"
32
        PluginPath                         = "./bindata/manifests/plugins"
33
        DaemonPath                         = "./bindata/manifests/daemon"
34
        DefaultPolicyName                  = "default"
35
        ConfigMapName                      = "device-plugin-config"
36
        DaemonSet                          = "DaemonSet"
37
        Role                               = "Role"
38
        RoleBinding                        = "RoleBinding"
39
        ServiceAccount                     = "ServiceAccount"
40
        DPConfigFileName                   = "config.json"
41
        OVSHWOLMachineConfigNameSuffix     = "ovs-hw-offload"
42
        LeaderElectionID                   = "a56def2a.openshift.io"
43

44
        LinkTypeEthernet   = "ether"
45
        LinkTypeInfiniband = "infiniband"
46

47
        LinkTypeIB  = "IB"
48
        LinkTypeETH = "ETH"
49

50
        LinkAdminStateUp   = "up"
51
        LinkAdminStateDown = "down"
52

53
        UninitializedNodeGUID = "0000:0000:0000:0000"
54

55
        DeviceTypeVfioPci   = "vfio-pci"
56
        DeviceTypeNetDevice = "netdevice"
57
        VdpaTypeVirtio      = "virtio"
58
        VdpaTypeVhost       = "vhost"
59

60
        RdmaSubsystemModeShared    = "shared"
61
        RdmaSubsystemModeExclusive = "exclusive"
62

63
        ClusterTypeOpenshift  = "openshift"
64
        ClusterTypeKubernetes = "kubernetes"
65

66
        SriovConfBasePath          = "/etc/sriov-operator"
67
        PfAppliedConfig            = SriovConfBasePath + "/pci"
68
        SriovSwitchDevConfPath     = SriovConfBasePath + "/sriov_config.json"
69
        SriovHostSwitchDevConfPath = Host + SriovSwitchDevConfPath
70
        ManagedOVSBridgesPath      = SriovConfBasePath + "/managed-ovs-bridges.json"
71

72
        MachineConfigPoolPausedAnnotation       = "sriovnetwork.openshift.io/state"
73
        MachineConfigPoolPausedAnnotationIdle   = "Idle"
74
        MachineConfigPoolPausedAnnotationPaused = "Paused"
75

76
        SriovDevicePluginLabel         = "sriovnetwork.openshift.io/device-plugin"
77
        SriovDevicePluginLabelEnabled  = "Enabled"
78
        SriovDevicePluginLabelDisabled = "Disabled"
79

80
        NodeDrainAnnotation             = "sriovnetwork.openshift.io/state"
81
        NodeStateDrainAnnotation        = "sriovnetwork.openshift.io/desired-state"
82
        NodeStateDrainAnnotationCurrent = "sriovnetwork.openshift.io/current-state"
83
        DrainIdle                       = "Idle"
84
        DrainRequired                   = "Drain_Required"
85
        RebootRequired                  = "Reboot_Required"
86
        Draining                        = "Draining"
87
        DrainComplete                   = "DrainComplete"
88

89
        SyncStatusSucceeded  = "Succeeded"
90
        SyncStatusFailed     = "Failed"
91
        SyncStatusInProgress = "InProgress"
92

93
        DrainDeleted = "Deleted"
94
        DrainEvicted = "Evicted"
95

96
        MCPPauseAnnotationState = "sriovnetwork.openshift.io/state"
97
        MCPPauseAnnotationTime  = "sriovnetwork.openshift.io/time"
98

99
        // NodeStateKeepUntilAnnotation contains name of the "keep until time" annotation for SriovNetworkNodeState object.
100
        // The "keep until time" specifies the earliest time at which the state object can be removed
101
        // if the daemon's pod is not found on the node.
102
        NodeStateKeepUntilAnnotation = "sriovnetwork.openshift.io/keep-state-until"
103
        // DefaultNodeStateCleanupDelayMinutes contains default delay before removing stale SriovNetworkNodeState CRs
104
        // (the CRs that no longer have a corresponding node with the daemon).
105
        DefaultNodeStateCleanupDelayMinutes = 30
106

107
        CheckpointFileName = "sno-initial-node-state.json"
108
        Unknown            = "Unknown"
109

110
        SysBus                = "/sys/bus"
111
        SysBusPciDevices      = SysBus + "/pci/devices"
112
        SysBusPciDrivers      = SysBus + "/pci/drivers"
113
        SysBusPciDriversProbe = SysBus + "/pci/drivers_probe"
114
        SysClassNet           = "/sys/class/net"
115
        ProcKernelCmdLine     = "/proc/cmdline"
116
        NetClass              = 0x02
117
        NumVfsFile            = "sriov_numvfs"
118
        BusPci                = "pci"
119
        BusVdpa               = "vdpa"
120

121
        UdevFolder          = "/etc/udev"
122
        HostUdevFolder      = Host + UdevFolder
123
        UdevRulesFolder     = UdevFolder + "/rules.d"
124
        HostUdevRulesFolder = Host + UdevRulesFolder
125
        UdevDisableNM       = "/bindata/scripts/udev-find-sriov-pf.sh"
126
        UdevRepName         = "/bindata/scripts/switchdev-vf-link-name.sh"
127
        // nolint:goconst
128
        PFNameUdevRule = `SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNELS=="%s", NAME="%s"`
129
        // nolint:goconst
130
        NMUdevRule = `SUBSYSTEM=="net", ` +
131
                `ACTION=="add|change|move", ` +
132
                `ATTRS{device}=="%s", ` +
133
                `IMPORT{program}="/etc/udev/disable-nm-sriov.sh $env{INTERFACE} %s"`
134
        // nolint:goconst
135
        SwitchdevUdevRule = `SUBSYSTEM=="net", ` +
136
                `ACTION=="add|move", ` +
137
                `ATTRS{phys_switch_id}=="%s", ` +
138
                `ATTR{phys_port_name}=="pf%svf*", ` +
139
                `IMPORT{program}="/etc/udev/switchdev-vf-link-name.sh $attr{phys_port_name}", ` +
140
                `NAME="%s_$env{NUMBER}"`
141

142
        KernelArgPciRealloc       = "pci=realloc"
143
        KernelArgIntelIommu       = "intel_iommu=on"
144
        KernelArgIommuPt          = "iommu=pt"
145
        KernelArgIommuPassthrough = "iommu.passthrough=1"
146
        KernelArgRdmaShared       = "ib_core.netns_mode=1"
147
        KernelArgRdmaExclusive    = "ib_core.netns_mode=0"
148

149
        // Systemd consts
150
        SriovSystemdConfigPath        = SriovConfBasePath + "/sriov-interface-config.yaml"
151
        SriovSystemdResultPath        = SriovConfBasePath + "/sriov-interface-result.yaml"
152
        SriovSystemdSupportedNicPath  = SriovConfBasePath + "/sriov-supported-nics-ids.yaml"
153
        SriovSystemdServiceBinaryPath = "/var/lib/sriov/sriov-network-config-daemon"
154

155
        SriovServicePath            = "/etc/systemd/system/sriov-config.service"
156
        SriovPostNetworkServicePath = "/etc/systemd/system/sriov-config-post-network.service"
157

158
        // Feature gates
159
        // ParallelNicConfigFeatureGate: allow to configure nics in parallel
160
        ParallelNicConfigFeatureGate = "parallelNicConfig"
161

162
        // ResourceInjectorMatchConditionFeatureGate: switch injector to fail policy and add mactch condition
163
        // this will make the mutating webhook to be called only when a pod has 'k8s.v1.cni.cncf.io/networks' annotation
164
        ResourceInjectorMatchConditionFeatureGate = "resourceInjectorMatchCondition"
165

166
        // MetricsExporterFeatureGate: enable SriovNetworkMetricsExporter on the same node as where the config-daemon run
167
        MetricsExporterFeatureGate = "metricsExporter"
168

169
        // ManageSoftwareBridgesFeatureGate: enables management of software bridges by the operator
170
        ManageSoftwareBridgesFeatureGate = "manageSoftwareBridges"
171

172
        // MellanoxFirmwareResetFeatureGate: enables the firmware reset via mstfwreset before a reboot
173
        MellanoxFirmwareResetFeatureGate = "mellanoxFirmwareReset"
174

175
        // The path to the file on the host filesystem that contains the IB GUID distribution for IB VFs
176
        InfinibandGUIDConfigFilePath = SriovConfBasePath + "/infiniband/guids"
177
)
178

179
const (
180
        // Baremetal platform
181
        Baremetal PlatformTypes = iota
182
        // VirtualOpenStack platform
183
        VirtualOpenStack
184
)
185

186
func (e PlatformTypes) String() string {
1✔
187
        switch e {
1✔
UNCOV
188
        case Baremetal:
×
UNCOV
189
                return "Baremetal"
×
190
        case VirtualOpenStack:
1✔
191
                return "Virtual/Openstack"
1✔
UNCOV
192
        default:
×
UNCOV
193
                return fmt.Sprintf("%d", int(e))
×
194
        }
195
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc