Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-1018] Custom Storage Group Feature #997

Merged
merged 91 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
e194e8d
add StorageGroup property in proto message
CraneShiEMC Feb 27, 2023
59ad30d
generate types.pb.go from types.proto
CraneShiEMC Feb 27, 2023
765ecc3
make non-lvg volume creation consistent with storage group label
CraneShiEMC Feb 27, 2023
55b0e23
set storageGroup to volume CR
CraneShiEMC Mar 5, 2023
49f10e6
support syncing storage group label to LVG CR if necessary
CraneShiEMC Mar 13, 2023
4dde7f1
fix
CraneShiEMC Mar 13, 2023
e5a693a
fix UT
CraneShiEMC Mar 13, 2023
2bb28ef
remove setting storageGroup property in volume CR eventually
CraneShiEMC Mar 15, 2023
2fce327
sync driveCR's storage-group label to AC
CraneShiEMC Mar 20, 2023
f0b3c83
fix UT
CraneShiEMC Mar 20, 2023
231f3ec
fix UT
CraneShiEMC Mar 20, 2023
50506da
Merge branch 'master' into feature-storage-group-poc-non-lvg-manual-l…
CraneShiEMC Mar 20, 2023
13a4df4
Merge branch 'master' into feature-storage-group-poc-non-lvg-manual-l…
CraneShiEMC Mar 23, 2023
a19fa0e
Merge branch 'master' into feature-storage-group-poc-manual-label-drive
CraneShiEMC Apr 23, 2023
78e986e
rename and extract the storagegroup label key as constants
CraneShiEMC Apr 24, 2023
833a677
sync the storage-group label removal from drives to ACs
CraneShiEMC Apr 26, 2023
09f9f3b
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC May 5, 2023
7d57051
remove sync storage-group label from drive to AC in capacitycontroller
CraneShiEMC May 5, 2023
c7225e4
Revert "remove sync storage-group label from drive to AC in capacityc…
CraneShiEMC May 5, 2023
7abaaf1
Add StorageGroup Schema Definition and generated files
CraneShiEMC May 6, 2023
dd2911c
refine StorageGroup definition
CraneShiEMC May 7, 2023
946359e
Add storagegroup controller
CraneShiEMC May 7, 2023
237a282
Add storagegroup crd to scheme
CraneShiEMC May 8, 2023
dc427b3
handling of storagegroup creation
CraneShiEMC May 14, 2023
668f002
remove sync storage-group label from drive to AC in capacitycontroller
CraneShiEMC May 5, 2023
16d96be
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC May 14, 2023
bc2a375
fix
CraneShiEMC May 15, 2023
3d75309
add debug log
CraneShiEMC May 15, 2023
086146e
support storage-group deletion
CraneShiEMC May 15, 2023
c67ede0
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC May 18, 2023
92b82f6
Handle invalidField and make MatchFields ANDed
CraneShiEMC May 19, 2023
0a17dbf
support NumberDrivesPerNode in DriveSelector
CraneShiEMC May 19, 2023
87f1db9
fix & add log for noDriveSelected and invalidField
CraneShiEMC May 20, 2023
7abce20
refine log
CraneShiEMC May 20, 2023
0f72b5b
fix issue in noDriveSelected and numberDrivesPerNode support
CraneShiEMC May 21, 2023
f966767
refine log
CraneShiEMC May 22, 2023
25d33cc
fix matchFields issue on bool type
CraneShiEMC May 22, 2023
52f933f
fix the issue that drive with non-lvg volume may be selected
CraneShiEMC May 22, 2023
3448a18
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC May 25, 2023
1802e7e
fix golint
CraneShiEMC May 25, 2023
7f35687
fix golint
CraneShiEMC May 25, 2023
eb41273
refine handleStorageGroupCreation
CraneShiEMC May 27, 2023
b36a14d
refine handleStorageGroupCreation
CraneShiEMC May 28, 2023
7d61b3f
refine to fix golint error
CraneShiEMC May 29, 2023
03049a9
fix golint
CraneShiEMC May 29, 2023
baf7afb
refine log
CraneShiEMC May 30, 2023
bb78b37
Change storagegroup print column
CraneShiEMC May 30, 2023
520144d
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC May 30, 2023
3636d47
support manual storage-group labeling on drive again
CraneShiEMC May 30, 2023
566f49e
Merge branch 'feature-storage-group-initial' of https://github.com/de…
CraneShiEMC May 30, 2023
f035c0d
only watch storagegroup delete event in storagegroup controller
CraneShiEMC May 31, 2023
381ff9c
Refactor func to add/rm sg label and enhance manual sg labeling
CraneShiEMC May 31, 2023
80a56c8
support to get ac for drive with lvg in drive sg label sync
CraneShiEMC Jun 4, 2023
09f27be
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC Jun 4, 2023
9d10619
now also include drive del event for storagegroup controller
CraneShiEMC Jun 5, 2023
4c558f9
fix log error
CraneShiEMC Jun 5, 2023
82597ba
fix that no del event of sg is caught
CraneShiEMC Jun 5, 2023
1c10de2
refine log & add initial draft of func syncDriveOnAllStorageGroups
CraneShiEMC Jun 5, 2023
d02dc02
support simple status tracking of storagegroup
CraneShiEMC Jun 5, 2023
8364271
add support of storage group label sync on new drive creation
CraneShiEMC Jun 5, 2023
a3bdbfd
fix lint error
CraneShiEMC Jun 5, 2023
ee055c8
fix lint error
CraneShiEMC Jun 5, 2023
d6b0c18
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC Jun 6, 2023
9d1f096
service procedure only supports storage group whose numDrivesPerNode …
CraneShiEMC Jun 6, 2023
bd75ce6
fix sg nil annotation panic error
CraneShiEMC Jun 7, 2023
5565239
service procedure support of storage group whose numDrivesPerNode>0
CraneShiEMC Jun 9, 2023
caa6679
fix go lint error
CraneShiEMC Jun 9, 2023
aa1ec1d
fix issue in reconcile of sg with numberDrivesPerNode>0
CraneShiEMC Jun 10, 2023
ab28f47
refine logic for reconcile of sg with numDrivesPerNode>0
CraneShiEMC Jun 11, 2023
0a6452d
sg label restore on drive selected by sg with numDrviesPerNode>0
CraneShiEMC Jun 11, 2023
d96429f
refine the logic to sync drive label on sg with numDrivesPerNode>0
CraneShiEMC Jun 11, 2023
1dd0b14
Revert syncing storage group label to LVG CR if necessary
CraneShiEMC Jun 11, 2023
17fa105
fix error in log
CraneShiEMC Jun 11, 2023
046da2c
add more log for adding sg label to drive
CraneShiEMC Jun 12, 2023
1634127
refine log
CraneShiEMC Jun 12, 2023
3e9accd
refine code comment and increase UT coverage
CraneShiEMC Jun 12, 2023
fcaf2f6
try increase UT coverage
CraneShiEMC Jun 12, 2023
077d75e
Merge branch 'master' into feature-storage-group-initial
CraneShiEMC Jun 15, 2023
9eebed9
resolve review comments
CraneShiEMC Jun 20, 2023
0ce6eee
refine storagegroupcontroller updateEventFilter & nil labels case handle
CraneShiEMC Jun 21, 2023
ad569d9
try fix golint
CraneShiEMC Jun 21, 2023
b2d9c09
try to fix golint
CraneShiEMC Jun 21, 2023
cba700d
fix devkit base image tag to 15.4 to resolve devkit image build failure
CraneShiEMC Jun 21, 2023
f9e8688
nil map can still work for map entry read
CraneShiEMC Jun 23, 2023
d4463f0
refine error handling and error log
CraneShiEMC Jun 26, 2023
daf9fc3
add comments to main function
CraneShiEMC Jun 26, 2023
d861003
refine error messages for labeling and label removal in sg handling
CraneShiEMC Jun 26, 2023
6c9ec1f
removal some deprecated bool flags
CraneShiEMC Jun 26, 2023
2e544de
sync storage group label to LVG CR if necessary
CraneShiEMC Jun 26, 2023
8341362
refine sg ctrl's drive update event predicate to include drive removal
CraneShiEMC Jun 26, 2023
04f731e
still only focus on drive sg label update event
CraneShiEMC Jun 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ generate-deepcopy:
controller-gen object paths=api/v1/drivecrd/drive_types.go paths=api/v1/drivecrd/groupversion_info.go output:dir=api/v1/drivecrd
controller-gen object paths=api/v1/lvgcrd/logicalvolumegroup_types.go paths=api/v1/lvgcrd/groupversion_info.go output:dir=api/v1/lvgcrd
controller-gen object paths=api/v1/nodecrd/node_types.go paths=api/v1/nodecrd/groupversion_info.go output:dir=api/v1/nodecrd
controller-gen object paths=api/v1/storagegroupcrd/storagegroup_types.go paths=api/v1/storagegroupcrd/groupversion_info.go output:dir=api/v1/storagegroupcrd

generate-baremetal-crds: install-controller-gen
controller-gen $(CRD_OPTIONS) paths=api/v1/availablecapacitycrd/availablecapacity_types.go paths=api/v1/availablecapacitycrd/groupversion_info.go output:crd:dir=$(CSI_CHART_CRDS_PATH)
Expand All @@ -120,6 +121,7 @@ generate-baremetal-crds: install-controller-gen
controller-gen $(CRD_OPTIONS) paths=api/v1/drivecrd/drive_types.go paths=api/v1/drivecrd/groupversion_info.go output:crd:dir=$(CSI_CHART_CRDS_PATH)
controller-gen $(CRD_OPTIONS) paths=api/v1/lvgcrd/logicalvolumegroup_types.go paths=api/v1/lvgcrd/groupversion_info.go output:crd:dir=$(CSI_CHART_CRDS_PATH)
controller-gen $(CRD_OPTIONS) paths=api/v1/nodecrd/node_types.go paths=api/v1/nodecrd/groupversion_info.go output:crd:dir=$(CSI_CHART_CRDS_PATH)
controller-gen $(CRD_OPTIONS) paths=api/v1/storagegroupcrd/storagegroup_types.go paths=api/v1/storagegroupcrd/groupversion_info.go output:crd:dir=$(CSI_CHART_CRDS_PATH)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here need a PR on csi-baremetal-operator to add the new sg crd definition there.

Copy link
Collaborator Author

@CraneShiEMC CraneShiEMC Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually had a PR on csi-baremetal-operator for the corresponding storage group feature including the addition of sg crd, dell/csi-baremetal-operator#180... Sorry for forgetting to provide it for your review before...

generate-api: compile-proto generate-baremetal-crds generate-deepcopy

Expand Down
220 changes: 166 additions & 54 deletions api/generated/v1/types.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions api/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,7 @@ const (
// CSI Drive taint-like label key and value
DriveTaintKey = "drive.csi-baremetal.dell.com/taint"
DriveTaintValue = "NoSchedule"

// CSI StorageGroup label key
StorageGroupLabelKey = "drive.csi-baremetal.dell.com/storage-group"
)
38 changes: 38 additions & 0 deletions api/v1/storagegroupcrd/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright © 2020 Dell Inc. or its subsidiaries. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package sgcrd contains API Schema definitions for the StorageGroup v1 API group
// +groupName=csi-baremetal.dell.com
// +versionName=v1
package sgcrd

import (
"k8s.io/apimachinery/pkg/runtime/schema"
crScheme "sigs.k8s.io/controller-runtime/pkg/scheme"

v1 "github.com/dell/csi-baremetal/api/v1"
)

var (
// GroupVersionStorageGroup is group version used to register these objects
GroupVersionStorageGroup = schema.GroupVersion{Group: v1.CSICRsGroupVersion, Version: v1.Version}

// SchemeBuilderStorageGroup is used to add go types to the GroupVersionKind scheme
SchemeBuilderStorageGroup = &crScheme.Builder{GroupVersion: GroupVersionStorageGroup}

// AddToSchemeStorageGroup adds the types in this group-version to the given scheme.
AddToSchemeStorageGroup = SchemeBuilderStorageGroup.AddToScheme
)
58 changes: 58 additions & 0 deletions api/v1/storagegroupcrd/storagegroup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright © 2020 Dell Inc. or its subsidiaries. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package sgcrd

import (
api "github.com/dell/csi-baremetal/api/generated/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:object:root=true

// StorageGroup is the Schema for the StorageGroups API
// +kubebuilder:resource:scope=Cluster,shortName={sg,sgs}
// +kubebuilder:printcolumn:name="DRIVES_PER_NODE",type="string",JSONPath=".spec.driveSelector.numberDrivesPerNode",description="numberDrivesPerNode of StorageGroup's DriveSelector"
// +kubebuilder:printcolumn:name="TYPE",type="string",JSONPath=".spec.driveSelector.matchFields.Type",description="Drive Type of StorageGroup's DriveSelector"
// +kubebuilder:printcolumn:name="SLOT",type="string",JSONPath=".spec.driveSelector.matchFields.Slot",description="Drive Slot of StorageGroup's DriveSelector"
// +kubebuilder:printcolumn:name="PATH",type="string",JSONPath=".spec.driveSelector.matchFields.Path",description="Drive Path of StorageGroup's DriveSelector"
// +kubebuilder:printcolumn:name="SYSTEM",type="string",JSONPath=".spec.driveSelector.matchFields.IsSystem",description="Whether StorageGroup's DriveSelector to Select System Drive"
type StorageGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec api.StorageGroupSpec `json:"spec,omitempty"`
}

// +kubebuilder:object:root=true

// StorageGroupList contains a list of StorageGroup
//+kubebuilder:object:generate=true
type StorageGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []StorageGroup `json:"items"`
}

func init() {
SchemeBuilderStorageGroup.Register(&StorageGroup{}, &StorageGroupList{})
}

func (in *StorageGroup) DeepCopyInto(out *StorageGroup) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
}
60 changes: 60 additions & 0 deletions api/v1/storagegroupcrd/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions api/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ message Volume {
string Usage = 13;
// inline volumes are not support anymore. need to remove field in the next version
bool Ephemeral = 14;
string StorageGroup = 15;
}

message AvailableCapacity {
Expand Down Expand Up @@ -80,6 +81,7 @@ message CapacityRequest {
string Name = 1;
string StorageClass = 2;
int64 Size = 3;
string StorageGroup = 4;
}

message LogicalVolumeGroup {
Expand All @@ -97,3 +99,12 @@ message Node {
// key - address type, value - address, align with NodeAddress struct from k8s.io/api/core/v1
map<string, string> Addresses = 2;
}

message StorageGroupSpec {
DriveSelector driveSelector = 1;
}

message DriveSelector {
int32 numberDrivesPerNode = 1;
map<string, string> matchFields = 2;
}
12 changes: 12 additions & 0 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
accrd "github.com/dell/csi-baremetal/api/v1/availablecapacitycrd"
"github.com/dell/csi-baremetal/api/v1/drivecrd"
"github.com/dell/csi-baremetal/api/v1/lvgcrd"
sgcrd "github.com/dell/csi-baremetal/api/v1/storagegroupcrd"
"github.com/dell/csi-baremetal/api/v1/volumecrd"
"github.com/dell/csi-baremetal/pkg/base"
"github.com/dell/csi-baremetal/pkg/base/featureconfig"
Expand All @@ -51,6 +52,7 @@ import (
"github.com/dell/csi-baremetal/pkg/controller"
"github.com/dell/csi-baremetal/pkg/controller/capacitycontroller"
"github.com/dell/csi-baremetal/pkg/crcontrollers/reservation"
"github.com/dell/csi-baremetal/pkg/crcontrollers/storagegroup"
"github.com/dell/csi-baremetal/pkg/metrics"
)

Expand Down Expand Up @@ -168,6 +170,10 @@ func createManager(ctx context.Context, client *k8s.KubeClient, log *logrus.Logg
return nil, err
}

if err := sgcrd.AddToSchemeStorageGroup(scheme); err != nil {
return nil, err
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Namespace: *namespace,
Expand Down Expand Up @@ -196,5 +202,11 @@ func createManager(ctx context.Context, client *k8s.KubeClient, log *logrus.Logg
if err = capacityController.SetupWithManager(mgr); err != nil {
return nil, err
}

storageGroupController := storagegroup.NewController(client, kubeCache, log)
if err = storageGroupController.SetupWithManager(mgr); err != nil {
return nil, err
}

return mgr, nil
}
2 changes: 1 addition & 1 deletion devkit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt update \
&& /kind/kind-build.sh /kind


FROM opensuse/leap:latest
FROM opensuse/leap:15.4

ARG arg_docker_ver
ARG arg_go_ver
Expand Down
2 changes: 1 addition & 1 deletion pkg/base/capacityplanner/node_capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (nc *nodeCapacity) selectACForVolume(vol *genV1.Volume) *accrd.AvailableCap
}

for _, ac := range nc.acsOrder[vol.StorageClass] {
if requiredSize <= nc.acs[ac].Spec.Size {
if requiredSize <= nc.acs[ac].Spec.Size && nc.acs[ac].Labels[v1.StorageGroupLabelKey] == vol.StorageGroup {
libzhang marked this conversation as resolved.
Show resolved Hide resolved
// check if AC is reserved
reservation, ok := nc.reservedACs[ac]

Expand Down
19 changes: 17 additions & 2 deletions pkg/base/k8s/kubeclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"github.com/dell/csi-baremetal/api/v1/drivecrd"
"github.com/dell/csi-baremetal/api/v1/lvgcrd"
"github.com/dell/csi-baremetal/api/v1/nodecrd"
sgcrd "github.com/dell/csi-baremetal/api/v1/storagegroupcrd"
"github.com/dell/csi-baremetal/api/v1/volumecrd"
"github.com/dell/csi-baremetal/pkg/base"
checkErr "github.com/dell/csi-baremetal/pkg/base/error"
Expand Down Expand Up @@ -227,15 +228,15 @@
// ConstructLVGCR constructs LogicalVolumeGroup custom resource from api.LogicalVolumeGroup struct
// Receives a name for k8s ObjectMeta and an instance of api.LogicalVolumeGroup struct
// Returns an instance of LogicalVolumeGroup CR struct
func (k *KubeClient) ConstructLVGCR(name string, apiLVG api.LogicalVolumeGroup) *lvgcrd.LogicalVolumeGroup {
func (k *KubeClient) ConstructLVGCR(name, storageGroup string, apiLVG api.LogicalVolumeGroup) *lvgcrd.LogicalVolumeGroup {
return &lvgcrd.LogicalVolumeGroup{
TypeMeta: apisV1.TypeMeta{
Kind: crdV1.LVGKind,
APIVersion: crdV1.APIV1Version,
},
ObjectMeta: apisV1.ObjectMeta{
Name: name,
Labels: constructDefaultAppMap(),
Labels: constructLVGCRLabels(storageGroup),
},
Spec: apiLVG,
}
Expand Down Expand Up @@ -409,6 +410,12 @@
return nil, err
}

// register csi storagegroup crd
err := sgcrd.AddToSchemeStorageGroup(scheme)
if err != nil {
return nil, err
}

Check warning on line 417 in pkg/base/k8s/kubeclient.go

View check run for this annotation

Codecov / codecov/patch

pkg/base/k8s/kubeclient.go#L416-L417

Added lines #L416 - L417 were not covered by tests

return scheme, nil
}

Expand All @@ -420,3 +427,11 @@
}
return
}

func constructLVGCRLabels(storageGroup string) (labels map[string]string) {
labels = constructDefaultAppMap()
if storageGroup != "" {
labels[crdV1.StorageGroupLabelKey] = storageGroup
}
return labels
}
15 changes: 14 additions & 1 deletion pkg/base/k8s/kubeclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
testID = "someID"
testNode1Name = "node1"
testDriveLocation1 = "drive"
testStorageGroup = "test-group"
)

var (
Expand Down Expand Up @@ -496,7 +497,7 @@ var _ = Describe("Constructor methods", func() {
})
Context("ConstructLVGCR", func() {
It("Should return right LogicalVolumeGroup CR", func() {
constructedCR := k8sclient.ConstructLVGCR(testLVGName, testApiLVG)
constructedCR := k8sclient.ConstructLVGCR(testLVGName, "", testApiLVG)
Expect(constructedCR.TypeMeta.Kind).To(Equal(testLVGCR.TypeMeta.Kind))
Expect(constructedCR.TypeMeta.APIVersion).To(Equal(testLVGCR.TypeMeta.APIVersion))
Expect(constructedCR.ObjectMeta.Name).To(Equal(testLVGCR.ObjectMeta.Name))
Expand All @@ -505,6 +506,18 @@ var _ = Describe("Constructor methods", func() {
Expect(constructedCR.Labels).To(Equal(constructDefaultAppMap()))
})
})
Context("ConstructLVGCR with storage group", func() {
It("Should return right LogicalVolumeGroup CR with storage group", func() {
constructedCR := k8sclient.ConstructLVGCR(testLVGName, testStorageGroup, testApiLVG)
Expect(constructedCR.TypeMeta.Kind).To(Equal(testLVGCR.TypeMeta.Kind))
Expect(constructedCR.TypeMeta.APIVersion).To(Equal(testLVGCR.TypeMeta.APIVersion))
Expect(constructedCR.ObjectMeta.Name).To(Equal(testLVGCR.ObjectMeta.Name))
Expect(constructedCR.ObjectMeta.Namespace).To(Equal(testLVGCR.ObjectMeta.Namespace))
Expect(constructedCR.Labels[apiV1.StorageGroupLabelKey]).To(Equal(testStorageGroup))
Expect(constructedCR.Spec).To(Equal(testLVGCR.Spec))
Expect(constructedCR.Labels).To(Equal(constructLVGCRLabels(testStorageGroup)))
})
})
})

// remove all crds (volume and ac)
Expand Down
6 changes: 3 additions & 3 deletions pkg/common/ac_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// AvailableCapacityOperations is the interface for interact with AvailableCapacity CRs from Controller
type AvailableCapacityOperations interface {
RecreateACToLVGSC(ctx context.Context, sc string, acs ...accrd.AvailableCapacity) *accrd.AvailableCapacity
RecreateACToLVGSC(ctx context.Context, sc, sg string, acs ...accrd.AvailableCapacity) *accrd.AvailableCapacity
}

// ACOperationsImpl is the basic implementation of AvailableCapacityOperations interface
Expand All @@ -56,7 +56,7 @@
// Concerts first AC to LVG SC and set size of remaining to 0
// Receives newSC as string (e.g. HDDLVG) and AvailableCapacities where LVG should be based
// Returns created AC or nil
func (a *ACOperationsImpl) RecreateACToLVGSC(ctx context.Context, newSC string,
func (a *ACOperationsImpl) RecreateACToLVGSC(ctx context.Context, newSC, storageGroup string,
acs ...accrd.AvailableCapacity) *accrd.AvailableCapacity {
ll := a.log.WithFields(logrus.Fields{
"method": "RecreateACToLVGSC",
Expand Down Expand Up @@ -90,7 +90,7 @@
)

// create LVG CR based on ACs
lvg := a.k8sClient.ConstructLVGCR(name, apiLVG)
lvg := a.k8sClient.ConstructLVGCR(name, storageGroup, apiLVG)

Check warning on line 93 in pkg/common/ac_operations.go

View check run for this annotation

Codecov / codecov/patch

pkg/common/ac_operations.go#L93

Added line #L93 was not covered by tests
if err = a.k8sClient.CreateCR(ctx, name, lvg); err != nil {
ll.Errorf("Unable to create LVG CR: %v", err)
return nil
Expand Down
Loading
Loading