Skip to content

Commit b6e9eb1

Browse files
cdvulturachuzhoy
andauthored
hw-accel: bump KMM to release-2.4 and added back preflightvalidationocp with new CRD (rh-ecosystem-edge#1060)
* hw-accel: bump KMM to release-2.4 and added back preflightvalidationocp with a new CRD * Update pkg/schemes/kmm/v1beta1/module_types.go Co-authored-by: Alexander Chuzhoy <[email protected]> --------- Co-authored-by: Alexander Chuzhoy <[email protected]>
1 parent 27fc624 commit b6e9eb1

12 files changed

+1019
-57
lines changed

internal/sync/configs/kmm-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- name: kmm-v1beta1
33
sync: true
44
repo_link: "https://github.com/rh-ecosystem-edge/kernel-module-management"
5-
branch: release-2.3
5+
branch: release-2.4
66
remote_api_directory: api/v1beta1
77
local_api_directory: schemes/kmm/v1beta1
88
replace_imports:
@@ -17,7 +17,7 @@
1717
- name: kmm-v1beta2
1818
sync: true
1919
repo_link: "https://github.com/rh-ecosystem-edge/kernel-module-management"
20-
branch: release-2.3
20+
branch: release-2.4
2121
remote_api_directory: api/v1beta2
2222
local_api_directory: schemes/kmm/v1beta2
2323
replace_imports:
@@ -32,7 +32,7 @@
3232
- name: hmm-hub-v1beta1
3333
sync: true
3434
repo_link: "https://github.com/rh-ecosystem-edge/kernel-module-management"
35-
branch: release-2.3
35+
branch: release-2.4
3636
remote_api_directory: api-hub/v1beta1
3737
local_api_directory: schemes/kmm-hub/v1beta1
3838
replace_imports:

pkg/kmm/module_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func TestModuleBuildModuleSpec(t *testing.T) {
608608

609609
func buildValidTestModule(apiClient *clients.Settings) *ModuleBuilder {
610610
moduleBuilder := NewModuleBuilder(apiClient, defaultModuleName, defaultModuleNamespace)
611-
moduleBuilder.Definition.Spec.ModuleLoader = v1beta1.ModuleLoaderSpec{ServiceAccountName: "Test"}
611+
moduleBuilder.Definition.Spec.ModuleLoader = &v1beta1.ModuleLoaderSpec{ServiceAccountName: "Test"}
612612

613613
return moduleBuilder
614614
}

pkg/kmm/preflightvalidationocp.go

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/golang/glog"
88
"github.com/openshift-kni/eco-goinfra/pkg/clients"
99
"github.com/openshift-kni/eco-goinfra/pkg/msg"
10-
moduleV1Beta1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/kmm/v1beta1"
10+
kmmv1beta2 "github.com/openshift-kni/eco-goinfra/pkg/schemes/kmm/v1beta2"
1111
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1212
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1313
goclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -17,9 +17,9 @@ import (
1717
// containing connection to the cluster and the preflightvalidationocp definitions.
1818
type PreflightValidationOCPBuilder struct {
1919
// PreflightValidationOCP definition. Used to create a PreflightValidationOCP object.
20-
Definition *moduleV1Beta1.PreflightValidationOCP
20+
Definition *kmmv1beta2.PreflightValidationOCP
2121
// Created PreflightValidationOCP object.
22-
Object *moduleV1Beta1.PreflightValidationOCP
22+
Object *kmmv1beta2.PreflightValidationOCP
2323
// ApiClient to interact with the cluster.
2424
apiClient *clients.Settings
2525
// errorMsg is processed before the object is created or updated.
@@ -42,16 +42,16 @@ func NewPreflightValidationOCPBuilder(
4242
return nil
4343
}
4444

45-
err := apiClient.AttachScheme(moduleV1Beta1.AddToScheme)
45+
err := apiClient.AttachScheme(kmmv1beta2.AddToScheme)
4646
if err != nil {
47-
glog.V(100).Infof("Failed to add module v1beta1 scheme to client schemes")
47+
glog.V(100).Infof("Failed to add module v1beta2 scheme to client schemes")
4848

4949
return nil
5050
}
5151

5252
builder := &PreflightValidationOCPBuilder{
5353
apiClient: apiClient,
54-
Definition: &moduleV1Beta1.PreflightValidationOCP{
54+
Definition: &kmmv1beta2.PreflightValidationOCP{
5555
ObjectMeta: metav1.ObjectMeta{
5656
Name: name,
5757
Namespace: nsname,
@@ -78,35 +78,41 @@ func NewPreflightValidationOCPBuilder(
7878
return builder
7979
}
8080

81-
// WithReleaseImage sets the image for which the preflightvalidationocp checks the module.
82-
func (builder *PreflightValidationOCPBuilder) WithReleaseImage(image string) *PreflightValidationOCPBuilder {
81+
// WithKernelVersion sets the image for which the preflightvalidationocp checks the module.
82+
func (builder *PreflightValidationOCPBuilder) WithKernelVersion(kernelVersion string) *PreflightValidationOCPBuilder {
8383
if valid, _ := builder.validate(); !valid {
8484
return builder
8585
}
8686

87-
if image == "" {
88-
builder.errorMsg = "invald 'image' argument can not be nil"
87+
if kernelVersion == "" {
88+
builder.errorMsg = "invalid 'kernelVersion' argument can not be nil"
8989

9090
return builder
9191
}
9292

93-
glog.V(100).Infof("Creating new PreflightValidationOCP with release image: %s",
94-
image)
93+
glog.V(100).Infof("Creating new PreflightValidationOCP with kernelVersion: %s",
94+
kernelVersion)
9595

96-
builder.Definition.Spec.ReleaseImage = image
96+
builder.Definition.Spec.KernelVersion = kernelVersion
9797

9898
return builder
9999
}
100100

101-
// WithUseRTKernel specifies if the kernel is realtime.
102-
func (builder *PreflightValidationOCPBuilder) WithUseRTKernel(flag bool) *PreflightValidationOCPBuilder {
101+
// WithDtkImage specifies if the kernel is realtime.
102+
func (builder *PreflightValidationOCPBuilder) WithDtkImage(dtkImage string) *PreflightValidationOCPBuilder {
103103
if valid, _ := builder.validate(); !valid {
104104
return builder
105105
}
106106

107-
glog.V(100).Infof("Creating new PreflightValidationOCP with UseRTKernel set to: %s", flag)
107+
if dtkImage == "" {
108+
builder.errorMsg = "invalid 'dtkImage' argument can not be nil"
108109

109-
builder.Definition.Spec.UseRTKernel = flag
110+
return builder
111+
}
112+
113+
glog.V(100).Infof("Creating new PreflightValidationOCP with dtkImage set to: %s", dtkImage)
114+
115+
builder.Definition.Spec.DTKImage = dtkImage
110116

111117
return builder
112118
}
@@ -117,7 +123,7 @@ func (builder *PreflightValidationOCPBuilder) WithPushBuiltImage(push bool) *Pre
117123
return builder
118124
}
119125

120-
glog.V(100).Infof("Creating new PreflightValidaionOCP with PushBuiltImage set to: %s", push)
126+
glog.V(100).Infof("Creating new PreflightValidationOCP with PushBuiltImage set to: %s", push)
121127

122128
builder.Definition.Spec.PushBuiltImage = push
123129

@@ -159,19 +165,19 @@ func PullPreflightValidationOCP(apiClient *clients.Settings,
159165
if apiClient == nil {
160166
glog.V(100).Infof("The apiClient is empty")
161167

162-
return nil, fmt.Errorf("preflightvalidation 'apiClient' cannot be empty")
168+
return nil, fmt.Errorf("preflightvalidationocp 'apiClient' cannot be empty")
163169
}
164170

165-
err := apiClient.AttachScheme(moduleV1Beta1.AddToScheme)
171+
err := apiClient.AttachScheme(kmmv1beta2.AddToScheme)
166172
if err != nil {
167-
glog.V(100).Infof("Failed to add module v1beta1 scheme to client schemes")
173+
glog.V(100).Infof("Failed to add module v1beta2 scheme to client schemes")
168174

169175
return nil, err
170176
}
171177

172178
builder := &PreflightValidationOCPBuilder{
173179
apiClient: apiClient,
174-
Definition: &moduleV1Beta1.PreflightValidationOCP{
180+
Definition: &kmmv1beta2.PreflightValidationOCP{
175181
ObjectMeta: metav1.ObjectMeta{
176182
Name: name,
177183
Namespace: nsname,
@@ -239,7 +245,7 @@ func (builder *PreflightValidationOCPBuilder) Update() (*PreflightValidationOCPB
239245
return builder, err
240246
}
241247

242-
// Exists checks if the defined preflightvalidationocp has already need created.
248+
// Exists checks if the defined preflightvalidationocp has already been created.
243249
func (builder *PreflightValidationOCPBuilder) Exists() bool {
244250
if valid, _ := builder.validate(); !valid {
245251
return false
@@ -285,22 +291,25 @@ func (builder *PreflightValidationOCPBuilder) Delete() (*PreflightValidationOCPB
285291
}
286292

287293
// Get fetches the defined preflightvalidationocp from the cluster.
288-
func (builder *PreflightValidationOCPBuilder) Get() (*moduleV1Beta1.PreflightValidationOCP, error) {
294+
func (builder *PreflightValidationOCPBuilder) Get() (*kmmv1beta2.PreflightValidationOCP, error) {
289295
if valid, err := builder.validate(); !valid {
290296
return nil, err
291297
}
292298

293299
glog.V(100).Infof("Getting preflightvalidationocp %s from namespace %s",
294300
builder.Definition.Name, builder.Definition.Namespace)
295301

296-
preflightvalidationocp := &moduleV1Beta1.PreflightValidationOCP{}
302+
preflightvalidationocp := &kmmv1beta2.PreflightValidationOCP{}
297303

298304
err := builder.apiClient.Get(context.TODO(), goclient.ObjectKey{
299305
Name: builder.Definition.Name,
300306
Namespace: builder.Definition.Namespace,
301307
}, preflightvalidationocp)
302308

303309
if err != nil {
310+
glog.V(100).Infof("Preflightvalidationocp object %s does not exist in namespace %s",
311+
builder.Definition.Name, builder.Definition.Namespace)
312+
304313
return nil, err
305314
}
306315

@@ -325,7 +334,7 @@ func (builder *PreflightValidationOCPBuilder) validate() (bool, error) {
325334
}
326335

327336
if builder.apiClient == nil {
328-
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)
337+
glog.V(100).Infof("The %s builder apiClient is nil", resourceCRD)
329338

330339
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
331340
}

0 commit comments

Comments
 (0)