/
consts.go
121 lines (95 loc) · 3.25 KB
/
consts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package utils
import (
"fmt"
"os"
"strings"
"time"
"github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery"
)
// RoleWorkerCNF contains role name of cnf worker nodes
var RoleWorkerCNF string
// NodeSelectorLabels contains the node labels the perfomance profile should match
var NodeSelectorLabels map[string]string
// PerformanceProfileName contains the name of the PerformanceProfile created for tests
// or an existing profile when discover mode is enabled
var PerformanceProfileName string
// NodesSelector represents the label selector used to filter impacted nodes.
var NodesSelector string
// ProfileNotFound is true when discovery mode is enabled and no valid profile was found
var ProfileNotFound bool
// NtoImage represents NTO Image location which is either quay.io or any other internal registry
var NTOImage string
// MustGatherDir represents Mustgather directory created using oc adm mustgather
var MustGatherDir string
func init() {
RoleWorkerCNF = os.Getenv("ROLE_WORKER_CNF")
if RoleWorkerCNF == "" {
RoleWorkerCNF = "worker-cnf"
}
PerformanceProfileName = os.Getenv("PERF_TEST_PROFILE")
if PerformanceProfileName == "" {
PerformanceProfileName = "performance"
}
NodesSelector = os.Getenv("NODES_SELECTOR")
NodeSelectorLabels = map[string]string{
fmt.Sprintf("%s/%s", LabelRole, RoleWorkerCNF): "",
}
NTOImage = os.Getenv("NTO_IMAGE")
if NTOImage == "" {
NTOImage = "quay.io/openshift/origin-cluster-node-tuning-operator:latest"
}
MustGatherDir = os.Getenv("MUSTGATHER_DIR")
if discovery.Enabled() {
profile, err := discovery.GetDiscoveryPerformanceProfile(NodesSelector)
if err == discovery.ErrProfileNotFound {
ProfileNotFound = true
return
}
if err != nil {
fmt.Println("Failed to find profile in discovery mode", err)
ProfileNotFound = true
return
}
PerformanceProfileName = profile.Name
NodeSelectorLabels = profile.Spec.NodeSelector
if NodesSelector != "" {
keyValue := strings.Split(NodesSelector, "=")
if len(keyValue) == 1 {
keyValue = append(keyValue, "")
}
NodeSelectorLabels[keyValue[0]] = keyValue[1]
}
}
}
const (
// RoleWorker contains the worker role
RoleWorker = "worker"
// RoleMaster contains the master role
RoleMaster = "master"
)
const (
// LabelRole contains the key for the role label
LabelRole = "node-role.kubernetes.io"
// LabelHostname contains the key for the hostname label
LabelHostname = "kubernetes.io/hostname"
)
const (
// NamespaceMachineConfigOperator contains the namespace of the machine-config-opereator
NamespaceMachineConfigOperator = "openshift-machine-config-operator"
// NamespaceTesting contains the name of the testing namespace
NamespaceTesting = "performance-addon-operators-testing"
// DeploymentName contains the name of the deployment
DeploymentName = "test-deployment"
)
const (
// FilePathKubeletConfig contains the kubelet.conf file path
FilePathKubeletConfig = "/etc/kubernetes/kubelet.conf"
)
const (
// ContainerMachineConfigDaemon contains the name of the machine-config-daemon container
ContainerMachineConfigDaemon = "machine-config-daemon"
)
const (
// LogsFetchDuration represents how much in the past we need to go when fetching the pod logs
LogsFetchDuration = 10 * time.Minute
)