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

kubevirt / hyperconverged-cluster-operator / 23590193690

26 Mar 2026 10:45AM UTC coverage: 80.034% (+0.03%) from 80.0%
23590193690

Pull #4129

github

web-flow
Merge bc9898669 into f28e0ae02
Pull Request #4129: Fix a flaky tests

6 of 13 new or added lines in 1 file covered. (46.15%)

80 existing lines in 6 files now uncovered.

10390 of 12982 relevant lines covered (80.03%)

2.05 hits per line

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

5.3
/pkg/components/components.go
1
package components
2

3
import (
4
        persesv1alpha1 "github.com/rhobs/perses-operator/api/v1alpha1"
5
        admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
6
        appsv1 "k8s.io/api/apps/v1"
7
        corev1 "k8s.io/api/core/v1"
8
        networkingv1 "k8s.io/api/networking/v1"
9
        rbacv1 "k8s.io/api/rbac/v1"
10
        "k8s.io/apimachinery/pkg/api/resource"
11
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
        "k8s.io/apimachinery/pkg/runtime"
13
        "k8s.io/apimachinery/pkg/util/intstr"
14
        "k8s.io/utils/ptr"
15

16
        cnaoapi "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1"
17
        kvapi "kubevirt.io/api/core"
18
        aaqapi "kubevirt.io/application-aware-quota/staging/src/kubevirt.io/application-aware-quota-api/pkg/apis/core"
19
        cdiapi "kubevirt.io/containerized-data-importer-api/pkg/apis/core"
20
        migrationapi "kubevirt.io/kubevirt-migration-operator/api/v1alpha1"
21
        sspapi "kubevirt.io/ssp-operator/api/v1beta3"
22

23
        hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
24
        "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
25
)
26

27
const DisableOperandDeletionAnnotation = "console.openshift.io/disable-operand-delete"
28

29
const (
30
        crName = util.HyperConvergedName
31
)
32

33
type DeploymentOperatorParams struct {
34
        Namespace                string
35
        Image                    string
36
        WebhookImage             string
37
        CliDownloadsImage        string
38
        KVUIPluginImage          string
39
        KVUIProxyImage           string
40
        PasstImage               string
41
        PasstCNIImage            string
42
        WaspAgentImage           string
43
        AIEWebhookImage          string
44
        ImagePullPolicy          string
45
        ConversionContainer      string
46
        VmwareContainer          string
47
        VirtIOWinContainer       string
48
        Smbios                   string
49
        Machinetype              string
50
        Amd64MachineType         string
51
        Arm64MachineType         string
52
        S390xMachineType         string
53
        HcoKvIoVersion           string
54
        KubevirtVersion          string
55
        KvVirtLancherOsVersion   string
56
        CdiVersion               string
57
        CnaoVersion              string
58
        SspVersion               string
59
        HppoVersion              string
60
        MtqVersion               string
61
        AaqVersion               string
62
        MigrationOperatorVersion string
63
        AutopilotVersion         string
64
        Env                      []corev1.EnvVar
65
        AddNetworkPolicyLabels   bool
66
}
67

68
func GetDeploymentSpecOperator(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
69
        envs := buildEnvVars(params)
×
70

×
71
        return appsv1.DeploymentSpec{
×
72
                Replicas: ptr.To[int32](1),
×
73
                Selector: &metav1.LabelSelector{
×
74
                        MatchLabels: map[string]string{
×
75
                                "name": util.HCOOperatorName,
×
76
                        },
×
77
                },
×
78
                Strategy: appsv1.DeploymentStrategy{
×
79
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
80
                },
×
81
                Template: corev1.PodTemplateSpec{
×
82
                        ObjectMeta: metav1.ObjectMeta{
×
83
                                Labels: getLabelsWithNetworkPolicies(util.HCOOperatorName, params),
×
84
                        },
×
85
                        Spec: corev1.PodSpec{
×
86
                                ServiceAccountName: util.HCOOperatorName,
×
87
                                SecurityContext:    GetStdPodSecurityContext(),
×
88
                                Containers: []corev1.Container{
×
89
                                        {
×
90
                                                Name:            util.HCOOperatorName,
×
91
                                                Image:           params.Image,
×
92
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
93
                                                Command:         stringListToSlice(util.HCOOperatorName),
×
94
                                                ReadinessProbe:  getReadinessProbe(util.ReadinessEndpointName, util.HealthProbePort),
×
95
                                                LivenessProbe:   getLivenessProbe(util.LivenessEndpointName, util.HealthProbePort),
×
96
                                                Env:             envs,
×
97
                                                Resources: corev1.ResourceRequirements{
×
98
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
99
                                                                corev1.ResourceCPU:    resource.MustParse("10m"),
×
100
                                                                corev1.ResourceMemory: resource.MustParse("96Mi"),
×
101
                                                        },
×
102
                                                },
×
103
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
104
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
105
                                                Ports: []corev1.ContainerPort{
×
106
                                                        getMetricsPort(),
×
107
                                                },
×
108
                                        },
×
109
                                },
×
110
                                PriorityClassName: "system-cluster-critical",
×
111
                        },
×
112
                },
×
113
        }
×
UNCOV
114
}
×
115

116
func buildEnvVars(params *DeploymentOperatorParams) []corev1.EnvVar {
×
117
        envs := append([]corev1.EnvVar{
×
118
                {
×
119
                        // deprecated: left here for CI test.
×
120
                        Name:  util.OperatorWebhookModeEnv,
×
121
                        Value: "false",
×
122
                },
×
123
                {
×
124
                        Name:  util.ContainerAppName,
×
125
                        Value: util.ContainerOperatorApp,
×
126
                },
×
127
                {
×
128
                        Name:  "KVM_EMULATION",
×
129
                        Value: "",
×
130
                },
×
131
                {
×
132
                        Name:  "OPERATOR_IMAGE",
×
133
                        Value: params.Image,
×
134
                },
×
135
                {
×
136
                        Name:  "OPERATOR_NAME",
×
137
                        Value: util.HCOOperatorName,
×
138
                },
×
139
                {
×
140
                        Name:  "OPERATOR_NAMESPACE",
×
141
                        Value: params.Namespace,
×
142
                },
×
143
                {
×
144
                        Name: "POD_NAME",
×
145
                        ValueFrom: &corev1.EnvVarSource{
×
146
                                FieldRef: &corev1.ObjectFieldSelector{
×
147
                                        FieldPath: "metadata.name",
×
148
                                },
×
149
                        },
×
150
                },
×
151
                {
×
152
                        Name:  "VIRTIOWIN_CONTAINER",
×
153
                        Value: params.VirtIOWinContainer,
×
154
                },
×
155
                {
×
156
                        Name:  "SMBIOS",
×
157
                        Value: params.Smbios,
×
158
                },
×
159
                {
×
160
                        Name:  "MACHINETYPE",
×
161
                        Value: params.Machinetype,
×
162
                },
×
163
                {
×
164
                        Name:  "AMD64_MACHINETYPE",
×
165
                        Value: params.Amd64MachineType,
×
166
                },
×
167
                {
×
168
                        Name:  "ARM64_MACHINETYPE",
×
169
                        Value: params.Arm64MachineType,
×
170
                },
×
171
                {
×
172
                        Name:  "S390X_MACHINETYPE",
×
173
                        Value: params.S390xMachineType,
×
174
                },
×
175
                {
×
176
                        Name:  util.HcoKvIoVersionName,
×
177
                        Value: params.HcoKvIoVersion,
×
178
                },
×
179
                {
×
180
                        Name:  util.KubevirtVersionEnvV,
×
181
                        Value: params.KubevirtVersion,
×
182
                },
×
183
                {
×
184
                        Name:  util.CdiVersionEnvV,
×
185
                        Value: params.CdiVersion,
×
186
                },
×
187
                {
×
188
                        Name:  util.CnaoVersionEnvV,
×
189
                        Value: params.CnaoVersion,
×
190
                },
×
191
                {
×
192
                        Name:  util.SspVersionEnvV,
×
193
                        Value: params.SspVersion,
×
194
                },
×
195
                {
×
196
                        Name:  util.HppoVersionEnvV,
×
197
                        Value: params.HppoVersion,
×
198
                },
×
199
                {
×
200
                        Name:  util.AaqVersionEnvV,
×
201
                        Value: params.AaqVersion,
×
202
                },
×
203
                {
×
204
                        Name:  util.MigrationOperatorVersionEnvV,
×
205
                        Value: params.MigrationOperatorVersion,
×
206
                },
×
207
                {
×
208
                        Name:  util.AutopilotVersionEnvV,
×
209
                        Value: params.AutopilotVersion,
×
210
                },
×
211
                {
×
212
                        Name:  util.KVUIPluginImageEnvV,
×
213
                        Value: params.KVUIPluginImage,
×
214
                },
×
215
                {
×
216
                        Name:  util.KVUIProxyImageEnvV,
×
217
                        Value: params.KVUIProxyImage,
×
218
                },
×
219
                {
×
220
                        Name:  util.PasstImageEnvV,
×
221
                        Value: params.PasstImage,
×
222
                },
×
223
                {
×
224
                        Name:  util.PasstCNIImageEnvV,
×
225
                        Value: params.PasstCNIImage,
×
226
                },
×
227
                {
×
228
                        Name:  util.WaspAgentImageEnvV,
×
229
                        Value: params.WaspAgentImage,
×
230
                },
×
231
                {
×
232
                        Name:  util.AIEWebhookImageEnvV,
×
233
                        Value: params.AIEWebhookImage,
×
234
                },
×
235
        }, params.Env...)
×
236

×
237
        if params.KvVirtLancherOsVersion != "" {
×
UNCOV
238
                envs = append(envs, corev1.EnvVar{
×
239
                        Name:  util.KvVirtLauncherOSVersionEnvV,
×
240
                        Value: params.KvVirtLancherOsVersion,
×
241
                })
×
242
        }
×
243

244
        if params.AddNetworkPolicyLabels {
×
UNCOV
245
                envs = append(envs, corev1.EnvVar{
×
246
                        Name:  util.DeployNetworkPoliciesEnvV,
×
UNCOV
247
                        Value: "true",
×
UNCOV
248
                })
×
249
        }
×
250

251
        return envs
×
252
}
253

254
func GetDeploymentSpecCliDownloads(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
255
        return appsv1.DeploymentSpec{
×
256
                Replicas: ptr.To[int32](1),
×
257
                Selector: &metav1.LabelSelector{
×
258
                        MatchLabels: map[string]string{
×
259
                                "name": util.CLIDownloadsName,
×
260
                        },
×
261
                },
×
262
                Strategy: appsv1.DeploymentStrategy{
×
263
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
264
                },
×
265
                Template: corev1.PodTemplateSpec{
×
266
                        ObjectMeta: metav1.ObjectMeta{
×
267
                                Labels: GetLabels(util.CLIDownloadsName, params.HcoKvIoVersion),
×
268
                        },
×
269
                        Spec: corev1.PodSpec{
×
270
                                ServiceAccountName:           util.CLIDownloadsName,
×
271
                                AutomountServiceAccountToken: ptr.To(false),
×
272
                                SecurityContext:              GetStdPodSecurityContext(),
×
273
                                Containers: []corev1.Container{
×
274
                                        {
×
275
                                                Name:            "server",
×
276
                                                Image:           params.CliDownloadsImage,
×
277
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
278
                                                Resources: corev1.ResourceRequirements{
×
279
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
280
                                                                corev1.ResourceCPU:    resource.MustParse("10m"),
×
281
                                                                corev1.ResourceMemory: resource.MustParse("96Mi"),
×
282
                                                        },
×
283
                                                },
×
284
                                                Ports: []corev1.ContainerPort{
×
285
                                                        {
×
286
                                                                Protocol:      corev1.ProtocolTCP,
×
287
                                                                ContainerPort: util.CliDownloadsServerPort,
×
288
                                                        },
×
289
                                                },
×
290
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
291
                                                ReadinessProbe:           getReadinessProbe("/health", util.CliDownloadsServerPort),
×
292
                                                LivenessProbe:            getLivenessProbe("/health", util.CliDownloadsServerPort),
×
293
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
294
                                        },
×
295
                                },
×
UNCOV
296
                                PriorityClassName: "system-cluster-critical",
×
297
                        },
×
298
                },
×
299
        }
×
300
}
×
301

302
func GetLabels(name, hcoKvIoVersion string) map[string]string {
×
303
        return map[string]string{
×
304
                "name":                 name,
×
UNCOV
305
                util.AppLabelVersion:   hcoKvIoVersion,
×
306
                util.AppLabelPartOf:    util.HyperConvergedCluster,
×
307
                util.AppLabelComponent: string(util.AppComponentDeployment),
×
308
        }
×
309
}
×
310

311
func getLabelsWithNetworkPolicies(deploymentName string, params *DeploymentOperatorParams) map[string]string {
×
UNCOV
312
        labels := GetLabels(deploymentName, params.HcoKvIoVersion)
×
313
        if params.AddNetworkPolicyLabels {
×
UNCOV
314
                labels[util.AllowEgressToDNSAndAPIServerLabel] = "true"
×
UNCOV
315
                labels[util.AllowIngressToMetricsEndpointLabel] = "true"
×
UNCOV
316
        }
×
317

UNCOV
318
        return labels
×
319
}
320

321
func GetStdPodSecurityContext() *corev1.PodSecurityContext {
3✔
322
        return &corev1.PodSecurityContext{
3✔
323
                RunAsNonRoot: ptr.To(true),
3✔
324
                SeccompProfile: &corev1.SeccompProfile{
3✔
325
                        Type: corev1.SeccompProfileTypeRuntimeDefault,
3✔
326
                },
3✔
327
        }
3✔
328
}
3✔
329

330
func GetStdContainerSecurityContext() *corev1.SecurityContext {
3✔
331
        return &corev1.SecurityContext{
3✔
332
                AllowPrivilegeEscalation: ptr.To(false),
3✔
333
                Capabilities: &corev1.Capabilities{
3✔
334
                        Drop: []corev1.Capability{"ALL"},
3✔
335
                },
3✔
336
        }
3✔
337
}
3✔
338

339
// Currently we are abusing the pod readiness to signal to OLM that HCO is not ready
340
// for an upgrade. This has a lot of side effects, one of this is the validating webhook
341
// being not able to receive traffic when exposed by a pod that is not reporting ready=true.
342
// This can cause a lot of side effects if not deadlocks when the system reach a status where,
343
// for any possible reason, HCO pod cannot be ready and so HCO pod cannot validate any further update or
344
// delete request on HCO CR.
345
// A proper solution is properly use the readiness probe only to report the pod readiness and communicate
346
// status to OLM via conditions once OLM will be ready for:
347
// https://github.com/operator-framework/enhancements/blob/master/enhancements/operator-conditions.md
348
// in the meanwhile a quick (but dirty!) solution is to expose the same hco binary on two distinct pods:
349
// the first one will run only the controller and the second one (almost always ready) just the validating
350
// webhook one.
351
func GetDeploymentSpecWebhook(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
352
        return appsv1.DeploymentSpec{
×
353
                Replicas: ptr.To[int32](1),
×
354
                Selector: &metav1.LabelSelector{
×
355
                        MatchLabels: map[string]string{
×
356
                                "name": util.HCOWebhookName,
×
357
                        },
×
358
                },
×
359
                Strategy: appsv1.DeploymentStrategy{
×
360
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
361
                },
×
362
                Template: corev1.PodTemplateSpec{
×
363
                        ObjectMeta: metav1.ObjectMeta{
×
364
                                Labels: getLabelsWithNetworkPolicies(util.HCOWebhookName, params),
×
365
                        },
×
366
                        Spec: corev1.PodSpec{
×
367
                                ServiceAccountName: util.HCOOperatorName,
×
368
                                SecurityContext:    GetStdPodSecurityContext(),
×
369
                                Containers: []corev1.Container{
×
370
                                        {
×
371
                                                Name:            util.HCOWebhookName,
×
372
                                                Image:           params.WebhookImage,
×
373
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
374
                                                Command:         stringListToSlice(util.HCOWebhookName),
×
375
                                                ReadinessProbe:  getReadinessProbe(util.ReadinessEndpointName, util.HealthProbePort),
×
376
                                                LivenessProbe:   getLivenessProbe(util.LivenessEndpointName, util.HealthProbePort),
×
377
                                                Env: append([]corev1.EnvVar{
×
378
                                                        {
×
379
                                                                // deprecated: left here for CI test.
×
380
                                                                Name:  util.OperatorWebhookModeEnv,
×
381
                                                                Value: "true",
×
382
                                                        },
×
383
                                                        {
×
384
                                                                Name:  util.ContainerAppName,
×
385
                                                                Value: util.ContainerWebhookApp,
×
386
                                                        },
×
387
                                                        {
×
388
                                                                Name:  "OPERATOR_IMAGE",
×
389
                                                                Value: params.WebhookImage,
×
390
                                                        },
×
391
                                                        {
×
392
                                                                Name:  "OPERATOR_NAME",
×
393
                                                                Value: util.HCOWebhookName,
×
394
                                                        },
×
395
                                                        {
×
396
                                                                Name:  "OPERATOR_NAMESPACE",
×
397
                                                                Value: params.Namespace,
×
398
                                                        },
×
399
                                                        {
×
400
                                                                Name: "POD_NAME",
×
401
                                                                ValueFrom: &corev1.EnvVarSource{
×
402
                                                                        FieldRef: &corev1.ObjectFieldSelector{
×
403
                                                                                FieldPath: "metadata.name",
×
404
                                                                        },
×
405
                                                                },
×
406
                                                        },
×
407
                                                        {
×
408
                                                                Name:  util.HcoKvIoVersionName,
×
409
                                                                Value: params.HcoKvIoVersion,
×
410
                                                        },
×
411
                                                }, params.Env...),
×
412
                                                Resources: corev1.ResourceRequirements{
×
413
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
414
                                                                corev1.ResourceCPU:    resource.MustParse("5m"),
×
415
                                                                corev1.ResourceMemory: resource.MustParse("48Mi"),
×
416
                                                        },
×
417
                                                },
×
418
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
419
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
420
                                                Ports: []corev1.ContainerPort{
×
421
                                                        getWebhookPort(),
×
422
                                                        getMetricsPort(),
×
423
                                                },
×
424
                                        },
×
425
                                },
×
UNCOV
426
                                PriorityClassName: "system-node-critical",
×
UNCOV
427
                        },
×
UNCOV
428
                },
×
UNCOV
429
        }
×
UNCOV
430
}
×
431

432
var (
433
        emptyAPIGroup = []string{""}
434
)
435

436
func GetClusterPermissions() []rbacv1.PolicyRule {
×
437
        const configOpenshiftIO = "config.openshift.io"
×
438
        const operatorOpenshiftIO = "operator.openshift.io"
×
439
        return []rbacv1.PolicyRule{
×
440
                {
×
441
                        APIGroups: stringListToSlice(util.APIVersionGroup),
×
442
                        Resources: stringListToSlice("hyperconvergeds"),
×
443
                        Verbs:     stringListToSlice("get", "list", "update", "watch"),
×
444
                },
×
445
                {
×
446
                        APIGroups: stringListToSlice(util.APIVersionGroup),
×
447
                        Resources: stringListToSlice("hyperconvergeds/finalizers", "hyperconvergeds/status"),
×
448
                        Verbs:     stringListToSlice("get", "list", "create", "update", "watch"),
×
449
                },
×
450
                roleWithAllPermissions(kvapi.GroupName, stringListToSlice("kubevirts", "kubevirts/finalizers")),
×
451
                {
×
452
                        APIGroups: stringListToSlice(kvapi.GroupName),
×
453
                        Resources: stringListToSlice("virtualmachineinstances"),
×
454
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
455
                },
×
456
                roleWithAllPermissions(cdiapi.GroupName, stringListToSlice("cdis", "cdis/finalizers")),
×
457
                roleWithAllPermissions(sspapi.GroupVersion.Group, stringListToSlice("ssps", "ssps/finalizers")),
×
458
                roleWithAllPermissions(cnaoapi.GroupVersion.Group, stringListToSlice("networkaddonsconfigs", "networkaddonsconfigs/finalizers")),
×
459
                roleWithAllPermissions(aaqapi.GroupName, stringListToSlice("aaqs", "aaqs/finalizers")),
×
460
                roleWithAllPermissions(migrationapi.GroupVersion.Group, stringListToSlice("migcontrollers", "migcontrollers/finalizers")),
×
461
                roleWithAllPermissions("", stringListToSlice("configmaps")),
×
462
                {
×
463
                        APIGroups: emptyAPIGroup,
×
464
                        Resources: stringListToSlice("events"),
×
465
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "patch"),
×
466
                },
×
467
                roleWithAllPermissions("", stringListToSlice("services")),
×
468
                {
×
469
                        APIGroups: emptyAPIGroup,
×
470
                        Resources: stringListToSlice("pods", "nodes"),
×
471
                        Verbs:     stringListToSlice("get", "list", "watch", "patch"),
×
472
                },
×
473
                roleWithAllPermissions("", stringListToSlice("secrets")),
×
474
                {
×
475
                        APIGroups: emptyAPIGroup,
×
476
                        Resources: stringListToSlice("endpoints"),
×
477
                        Verbs:     stringListToSlice("get", "list", "delete", "watch"),
×
478
                },
×
479
                {
×
480
                        APIGroups: emptyAPIGroup,
×
481
                        Resources: stringListToSlice("namespaces"),
×
482
                        Verbs:     stringListToSlice("get", "list", "watch", "patch", "update"),
×
483
                },
×
484
                {
×
485
                        APIGroups: stringListToSlice("apps"),
×
486
                        Resources: stringListToSlice("deployments", "replicasets", "daemonsets"),
×
487
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
488
                },
×
489
                roleWithAllPermissions("rbac.authorization.k8s.io",
×
490
                        stringListToSlice("roles", "clusterroles", "rolebindings", "clusterrolebindings")),
×
491
                {
×
492
                        APIGroups: stringListToSlice("apiextensions.k8s.io"),
×
493
                        Resources: stringListToSlice("customresourcedefinitions"),
×
494
                        Verbs:     stringListToSlice("get", "list", "update", "patch", "watch", "delete"),
×
495
                },
×
496
                {
×
497
                        APIGroups: stringListToSlice("apiextensions.k8s.io"),
×
498
                        Resources: stringListToSlice("customresourcedefinitions/status", "customresourcedefinitions/finalizers"),
×
499
                        Verbs:     stringListToSlice("get", "list", "watch", "patch", "update"),
×
500
                },
×
501
                roleWithAllPermissions("monitoring.coreos.com", stringListToSlice("servicemonitors", "prometheusrules")),
×
502
                {
×
503
                        APIGroups: stringListToSlice("operators.coreos.com"),
×
504
                        Resources: stringListToSlice("clusterserviceversions"),
×
505
                        Verbs:     stringListToSlice("get", "list", "watch", "update", "patch"),
×
506
                },
×
507
                {
×
508
                        APIGroups: stringListToSlice("scheduling.k8s.io"),
×
509
                        Resources: stringListToSlice("priorityclasses"),
×
510
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "delete", "patch"),
×
511
                },
×
512
                {
×
513
                        APIGroups: stringListToSlice("admissionregistration.k8s.io"),
×
514
                        Resources: stringListToSlice("validatingwebhookconfigurations"),
×
515
                        Verbs:     stringListToSlice("list", "watch", "update", "patch"),
×
516
                },
×
517
                {
×
518
                        APIGroups: stringListToSlice("admissionregistration.k8s.io"),
×
519
                        Resources: stringListToSlice("mutatingwebhookconfigurations"),
×
520
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
521
                },
×
522
                roleWithAllPermissions("console.openshift.io", stringListToSlice("consoleclidownloads", "consolequickstarts")),
×
523
                {
×
524
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
525
                        Resources: stringListToSlice("clusterversions", "infrastructures", "networks"),
×
526
                        Verbs:     stringListToSlice("get", "list"),
×
527
                },
×
528
                {
×
529
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
530
                        Resources: stringListToSlice("ingresses"),
×
531
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
532
                },
×
533
                {
×
534
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
535
                        Resources: stringListToSlice("ingresses/status"),
×
536
                        Verbs:     stringListToSlice("update"),
×
537
                },
×
538
                {
×
539
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
540
                        Resources: stringListToSlice("apiservers"),
×
541
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
542
                },
×
543
                {
×
544
                        APIGroups: stringListToSlice(operatorOpenshiftIO),
×
545
                        Resources: stringListToSlice("kubedeschedulers"),
×
546
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
547
                },
×
548
                {
×
549
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
550
                        Resources: stringListToSlice("dnses"),
×
551
                        Verbs:     stringListToSlice("get"),
×
552
                },
×
553
                roleWithAllPermissions("coordination.k8s.io", stringListToSlice("leases")),
×
554
                roleWithAllPermissions("route.openshift.io", stringListToSlice("routes")),
×
555
                {
×
556
                        APIGroups: stringListToSlice("route.openshift.io"),
×
557
                        Resources: stringListToSlice("routes/custom-host"),
×
558
                        Verbs:     stringListToSlice("create", "update", "patch"),
×
559
                },
×
560
                {
×
561
                        APIGroups: stringListToSlice("operators.coreos.com"),
×
562
                        Resources: stringListToSlice("operatorconditions"),
×
563
                        Verbs:     stringListToSlice("get", "list", "watch", "update", "patch"),
×
564
                },
×
565
                roleWithAllPermissions("image.openshift.io", stringListToSlice("imagestreams")),
×
566
                roleWithAllPermissions("console.openshift.io", stringListToSlice("consoleplugins")),
×
567
                {
×
568
                        APIGroups: stringListToSlice("operator.openshift.io"),
×
569
                        Resources: stringListToSlice("consoles"),
×
570
                        Verbs:     stringListToSlice("get", "list", "watch", "update"),
×
571
                },
×
572
                {
×
573
                        APIGroups: stringListToSlice("monitoring.coreos.com"),
×
574
                        Resources: stringListToSlice("alertmanagers", "alertmanagers/api"),
×
575
                        Verbs:     stringListToSlice("get", "list", "create", "delete"),
×
576
                },
×
577
                {
×
578
                        APIGroups: stringListToSlice(""),
×
579
                        Resources: stringListToSlice("serviceaccounts"),
×
580
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
581
                },
×
582
                {
×
583
                        APIGroups: stringListToSlice("k8s.cni.cncf.io"),
×
584
                        Resources: stringListToSlice("network-attachment-definitions"),
×
585
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
586
                },
×
587
                {
×
588
                        APIGroups: stringListToSlice("security.openshift.io"),
×
589
                        Resources: stringListToSlice("securitycontextconstraints"),
×
590
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
591
                },
×
592
                {
×
593
                        APIGroups: stringListToSlice(networkingv1.GroupName),
×
UNCOV
594
                        Resources: stringListToSlice("networkpolicies"),
×
595
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
596
                },
×
597
                {
×
598
                        APIGroups: stringListToSlice(admissionregistrationv1.GroupName),
×
599
                        Resources: stringListToSlice("validatingadmissionpolicies", "validatingadmissionpolicybindings"),
×
600
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
601
                },
×
UNCOV
602
                {
×
UNCOV
603
                        APIGroups: stringListToSlice(persesv1alpha1.GroupVersion.Group),
×
UNCOV
604
                        Resources: stringListToSlice("persesdashboards", "persesdatasources"),
×
UNCOV
605
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
UNCOV
606
                },
×
UNCOV
607
        }
×
UNCOV
608
}
×
609

UNCOV
610
func roleWithAllPermissions(apiGroup string, resources []string) rbacv1.PolicyRule {
×
UNCOV
611
        return rbacv1.PolicyRule{
×
UNCOV
612
                APIGroups: stringListToSlice(apiGroup),
×
UNCOV
613
                Resources: resources,
×
UNCOV
614
                Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete", "patch"),
×
UNCOV
615
        }
×
UNCOV
616
}
×
617

618
func GetOperatorCR() *hcov1beta1.HyperConverged {
14✔
619
        defaultScheme := runtime.NewScheme()
14✔
620
        _ = hcov1beta1.AddToScheme(defaultScheme)
14✔
621
        _ = hcov1beta1.RegisterDefaults(defaultScheme)
14✔
622
        defaultHco := &hcov1beta1.HyperConverged{
14✔
623
                TypeMeta: metav1.TypeMeta{
14✔
624
                        APIVersion: util.APIVersion,
14✔
625
                        Kind:       util.HyperConvergedKind,
14✔
626
                },
14✔
627
                ObjectMeta: metav1.ObjectMeta{
14✔
628
                        Name: crName,
14✔
629
                }}
14✔
630
        defaultScheme.Default(defaultHco)
14✔
631
        return defaultHco
14✔
632
}
14✔
633

634
func getReadinessProbe(endpoint string, port int32) *corev1.Probe {
×
635
        return &corev1.Probe{
×
UNCOV
636
                ProbeHandler: corev1.ProbeHandler{
×
637
                        HTTPGet: &corev1.HTTPGetAction{
×
638
                                Path: endpoint,
×
639
                                Port: intstr.IntOrString{
×
640
                                        Type:   intstr.Int,
×
641
                                        IntVal: port,
×
642
                                },
×
643
                                Scheme: corev1.URISchemeHTTP,
×
644
                        },
×
645
                },
×
646
                InitialDelaySeconds: 5,
×
647
                PeriodSeconds:       5,
×
648
                FailureThreshold:    1,
×
649
        }
×
650
}
×
651

652
func getLivenessProbe(endpoint string, port int32) *corev1.Probe {
×
653
        return &corev1.Probe{
×
UNCOV
654
                ProbeHandler: corev1.ProbeHandler{
×
655
                        HTTPGet: &corev1.HTTPGetAction{
×
656
                                Path: endpoint,
×
657
                                Port: intstr.IntOrString{
×
658
                                        Type:   intstr.Int,
×
659
                                        IntVal: port,
×
660
                                },
×
661
                                Scheme: corev1.URISchemeHTTP,
×
UNCOV
662
                        },
×
663
                },
×
664
                InitialDelaySeconds: 30,
×
665
                PeriodSeconds:       5,
×
666
                FailureThreshold:    1,
×
667
        }
×
668
}
×
669

UNCOV
670
func getMetricsPort() corev1.ContainerPort {
×
671
        return corev1.ContainerPort{
×
672
                Name:          util.MetricsPortName,
×
673
                ContainerPort: util.MetricsPort,
×
UNCOV
674
                Protocol:      corev1.ProtocolTCP,
×
UNCOV
675
        }
×
UNCOV
676
}
×
677

UNCOV
678
func getWebhookPort() corev1.ContainerPort {
×
UNCOV
679
        return corev1.ContainerPort{
×
UNCOV
680
                Name:          util.WebhookPortName,
×
UNCOV
681
                ContainerPort: util.WebhookPort,
×
UNCOV
682
                Protocol:      corev1.ProtocolTCP,
×
UNCOV
683
        }
×
UNCOV
684
}
×
685

UNCOV
686
func stringListToSlice(words ...string) []string {
×
UNCOV
687
        return words
×
UNCOV
688
}
×
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

© 2026 Coveralls, Inc