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

kubevirt / hyperconverged-cluster-operator / 30617551503

31 Jul 2026 08:47AM UTC coverage: 82.159% (-3.5%) from 85.645%
30617551503

Pull #4468

github

web-flow
Merge b4277c458 into 2ec4241d5
Pull Request #4468: Remove iommufd-device-plugin operand from HCO

2 of 562 new or added lines in 1 file covered. (0.36%)

575 existing lines in 1 file now uncovered.

11895 of 14478 relevant lines covered (82.16%)

2.22 hits per line

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

5.12
/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
        hcov1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1"
24
        hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
25
        "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
26
)
27

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

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

34
type DeploymentOperatorParams struct {
35
        Namespace                     string
36
        Image                         string
37
        WebhookImage                  string
38
        CliDownloadsImage             string
39
        KVUIPluginImage               string
40
        KVUIProxyImage                string
41
        NetworkResourcesInjectorImage 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
        InFlightOperationsVersion     string
65
        Env                           []corev1.EnvVar
66
        AddNetworkPolicyLabels        bool
67
}
68

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

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

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

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

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

NEW
UNCOV
252
        return envs
×
253
}
254

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

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

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

NEW
UNCOV
319
        return labels
×
320
}
321

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

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

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

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

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

NEW
UNCOV
617
func roleWithAllPermissions(apiGroup string, resources []string) rbacv1.PolicyRule {
×
NEW
UNCOV
618
        return rbacv1.PolicyRule{
×
NEW
UNCOV
619
                APIGroups: stringListToSlice(apiGroup),
×
NEW
UNCOV
620
                Resources: resources,
×
NEW
UNCOV
621
                Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete", "patch"),
×
NEW
UNCOV
622
        }
×
NEW
UNCOV
623
}
×
624

625
var GetOperatorCR = GetOperatorV1CR
626

UNCOV
627
func GetOperatorV1beta1CR() *hcov1beta1.HyperConverged {
×
UNCOV
628
        defaultScheme := runtime.NewScheme()
×
UNCOV
629
        _ = hcov1beta1.AddToScheme(defaultScheme)
×
UNCOV
630
        _ = hcov1beta1.RegisterDefaults(defaultScheme)
×
UNCOV
631
        defaultHco := &hcov1beta1.HyperConverged{
×
UNCOV
632
                TypeMeta: metav1.TypeMeta{
×
UNCOV
633
                        APIVersion: hcov1beta1.APIVersion,
×
UNCOV
634
                        Kind:       util.HyperConvergedKind,
×
UNCOV
635
                },
×
UNCOV
636
                ObjectMeta: metav1.ObjectMeta{
×
UNCOV
637
                        Name: crName,
×
UNCOV
638
                }}
×
UNCOV
639
        defaultScheme.Default(defaultHco)
×
UNCOV
640
        return defaultHco
×
UNCOV
641
}
×
642

643
func GetOperatorV1CR() *hcov1.HyperConverged {
16✔
644
        defaultScheme := runtime.NewScheme()
16✔
645
        _ = hcov1.AddToScheme(defaultScheme)
16✔
646
        _ = hcov1.RegisterDefaults(defaultScheme)
16✔
647
        defaultHco := &hcov1.HyperConverged{
16✔
648
                TypeMeta: metav1.TypeMeta{
16✔
649
                        APIVersion: hcov1.APIVersion,
16✔
650
                        Kind:       util.HyperConvergedKind,
16✔
651
                },
16✔
652
                ObjectMeta: metav1.ObjectMeta{
16✔
653
                        Name: crName,
16✔
654
                }}
16✔
655
        defaultScheme.Default(defaultHco)
16✔
656
        return defaultHco
16✔
657
}
16✔
658

NEW
UNCOV
659
func getReadinessProbe(endpoint string, port int32) *corev1.Probe {
×
NEW
UNCOV
660
        return &corev1.Probe{
×
NEW
UNCOV
661
                ProbeHandler: corev1.ProbeHandler{
×
NEW
UNCOV
662
                        HTTPGet: &corev1.HTTPGetAction{
×
NEW
UNCOV
663
                                Path: endpoint,
×
NEW
UNCOV
664
                                Port: intstr.IntOrString{
×
NEW
UNCOV
665
                                        Type:   intstr.Int,
×
NEW
UNCOV
666
                                        IntVal: port,
×
NEW
UNCOV
667
                                },
×
NEW
UNCOV
668
                                Scheme: corev1.URISchemeHTTP,
×
NEW
UNCOV
669
                        },
×
NEW
UNCOV
670
                },
×
NEW
UNCOV
671
                InitialDelaySeconds: 5,
×
NEW
UNCOV
672
                PeriodSeconds:       5,
×
NEW
UNCOV
673
                FailureThreshold:    1,
×
NEW
UNCOV
674
        }
×
NEW
UNCOV
675
}
×
676

NEW
UNCOV
677
func getLivenessProbe(endpoint string, port int32) *corev1.Probe {
×
NEW
UNCOV
678
        return &corev1.Probe{
×
NEW
UNCOV
679
                ProbeHandler: corev1.ProbeHandler{
×
NEW
UNCOV
680
                        HTTPGet: &corev1.HTTPGetAction{
×
NEW
UNCOV
681
                                Path: endpoint,
×
NEW
UNCOV
682
                                Port: intstr.IntOrString{
×
NEW
UNCOV
683
                                        Type:   intstr.Int,
×
NEW
UNCOV
684
                                        IntVal: port,
×
NEW
UNCOV
685
                                },
×
NEW
UNCOV
686
                                Scheme: corev1.URISchemeHTTP,
×
NEW
UNCOV
687
                        },
×
NEW
UNCOV
688
                },
×
NEW
UNCOV
689
                InitialDelaySeconds: 30,
×
NEW
UNCOV
690
                PeriodSeconds:       5,
×
NEW
UNCOV
691
                FailureThreshold:    1,
×
NEW
UNCOV
692
        }
×
NEW
UNCOV
693
}
×
694

NEW
UNCOV
695
func getMetricsPort() corev1.ContainerPort {
×
NEW
UNCOV
696
        return corev1.ContainerPort{
×
NEW
UNCOV
697
                Name:          util.MetricsPortName,
×
NEW
UNCOV
698
                ContainerPort: util.MetricsPort,
×
NEW
UNCOV
699
                Protocol:      corev1.ProtocolTCP,
×
NEW
UNCOV
700
        }
×
NEW
UNCOV
701
}
×
702

NEW
UNCOV
703
func getWebhookPort() corev1.ContainerPort {
×
NEW
UNCOV
704
        return corev1.ContainerPort{
×
NEW
UNCOV
705
                Name:          util.WebhookPortName,
×
NEW
UNCOV
706
                ContainerPort: util.WebhookPort,
×
NEW
UNCOV
707
                Protocol:      corev1.ProtocolTCP,
×
NEW
UNCOV
708
        }
×
NEW
UNCOV
709
}
×
710

NEW
UNCOV
711
func stringListToSlice(words ...string) []string {
×
NEW
UNCOV
712
        return words
×
NEW
UNCOV
713
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc