Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dell/csm-operator into 1594…
Browse files Browse the repository at this point in the history
…_remove_extra_fields
  • Loading branch information
AkshaySainiDell committed Dec 11, 2024
2 parents 9c4fa54 + b734947 commit e15599d
Show file tree
Hide file tree
Showing 98 changed files with 1,003 additions and 321 deletions.
4 changes: 0 additions & 4 deletions api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ type Driver struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Snapshot Classes"
SnapshotClass []SnapshotClass `json:"snapshotClass,omitempty" yaml:"snapshotClass"`

// ForceUpdate is the boolean flag used to force an update of the driver instance
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Force update"
ForceUpdate bool `json:"forceUpdate,omitempty" yaml:"forceUpdate"`

// AuthSecret is the name of the credentials secret for the driver
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Auth Secret"
AuthSecret string `json:"authSecret,omitempty" yaml:"authSecret"`
Expand Down
9 changes: 0 additions & 9 deletions bundle/manifests/dell-csm-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ metadata:
"csiDriverType": "powermax",
"dnsPolicy": "ClusterFirstWithHostNet",
"forceRemoveDriver": true,
"forceUpdate": false,
"node": {
"envs": [
{
Expand Down Expand Up @@ -899,7 +898,6 @@ metadata:
"csiDriverType": "powerstore",
"dnsPolicy": "ClusterFirstWithHostNet",
"forceRemoveDriver": true,
"forceUpdate": false,
"node": {
"envs": [
{
Expand Down Expand Up @@ -1080,7 +1078,6 @@ metadata:
"csiDriverType": "unity",
"dnsPolicy": "ClusterFirstWithHostNet",
"forceRemoveDriver": true,
"forceUpdate": false,
"node": {
"envs": [
{
Expand Down Expand Up @@ -1197,7 +1194,6 @@ metadata:
"csiDriverType": "powerflex",
"dnsPolicy": "ClusterFirstWithHostNet",
"forceRemoveDriver": true,
"forceUpdate": false,
"initContainers": [
{
"envs": [
Expand Down Expand Up @@ -1997,11 +1993,6 @@ spec:
when CR is deleted
displayName: Force Remove Driver
path: driver.forceRemoveDriver
- description:
ForceUpdate is the boolean flag used to force an update of the
driver instance
displayName: Force update
path: driver.forceUpdate
- description: Args is the set of arguments for the container
displayName: Container Arguments
path: driver.initContainers[0].args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,11 +991,6 @@ spec:
ForceRemoveDriver is the boolean flag used to remove
driver deployment when CR is deleted
type: boolean
forceUpdate:
description:
ForceUpdate is the boolean flag used to force an
update of the driver instance
type: boolean
initContainers:
description: InitContainers is the specification for Driver InitContainers
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,6 @@ spec:
ForceRemoveDriver is the boolean flag used to remove
driver deployment when CR is deleted
type: boolean
forceUpdate:
description: >-
ForceUpdate is the boolean flag used to force an update
of the driver instance
type: boolean
initContainers:
description: >-
InitContainers is the specification for Driver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,6 @@ spec:
when CR is deleted
displayName: Force Remove Driver
path: driver.forceRemoveDriver
- description:
ForceUpdate is the boolean flag used to force an update of the
driver instance
displayName: Force update
path: driver.forceUpdate
- description: Args is the set of arguments for the container
displayName: Container Arguments
path: driver.initContainers[0].args
Expand Down
1 change: 0 additions & 1 deletion config/samples/storage_v1_csm_powerflex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ spec:
configVersion: v2.12.0
replicas: 1
dnsPolicy: ClusterFirstWithHostNet
forceUpdate: false
forceRemoveDriver: true
common:
image: "quay.io/dell/container-storage-modules/csi-vxflexos:v2.12.0"
Expand Down
1 change: 0 additions & 1 deletion config/samples/storage_v1_csm_powermax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ spec:
# Default credential secret for Powermax, if not set it to ""
authSecret: powermax-creds
dnsPolicy: ClusterFirstWithHostNet
forceUpdate: false
forceRemoveDriver: true
common:
image: quay.io/dell/container-storage-modules/csi-powermax:v2.12.0
Expand Down
1 change: 0 additions & 1 deletion config/samples/storage_v1_csm_powerstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ spec:
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
forceUpdate: false
forceRemoveDriver: true
common:
image: "quay.io/dell/container-storage-modules/csi-powerstore:v2.12.0"
Expand Down
1 change: 0 additions & 1 deletion config/samples/storage_v1_csm_unity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ spec:
# Controller count
replicas: 2
dnsPolicy: ClusterFirstWithHostNet
forceUpdate: false
forceRemoveDriver: true
common:
image: "quay.io/dell/container-storage-modules/csi-unity:v2.12.0"
Expand Down
10 changes: 10 additions & 0 deletions controllers/csm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,3 +1536,13 @@ func (r *ContainerStorageModuleReconciler) GetUpdateCount() int32 {
func (r *ContainerStorageModuleReconciler) GetK8sClient() kubernetes.Interface {
return r.K8sClient
}

func (r *ContainerStorageModuleReconciler) GetMatchingNodes(ctx context.Context, labelKey string, labelValue string) (*corev1.NodeList, error) {
nodeList := &corev1.NodeList{}
opts := []client.ListOption{
client.MatchingLabels{labelKey: labelValue},
}
err := r.List(ctx, nodeList, opts...)

return nodeList, err
}
54 changes: 54 additions & 0 deletions controllers/csm_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2382,3 +2382,57 @@ func (suite *CSMControllerTestSuite) makeFakeRevProxyCSM(name string, ns string,
err = suite.fakeClient.Create(ctx, &csm)
assert.Nil(suite.T(), err)
}

func (suite *CSMControllerTestSuite) TestGetNodeLabels() {
// TBD: crclient/client.go needs to be augmented to filter on labels during
// the List return for a viable thorough test. Since this functionality is
// missing, this test is quite elementary as a result.

csm := shared.MakeCSM(csmName, suite.namespace, configVersion)
csm.Spec.Driver.CSIDriverType = csmv1.PowerScale
csm.Spec.Driver.Common.Image = "image"
csm.Annotations[configVersionKey] = configVersion

sec := shared.MakeSecret(csmName+"-creds", suite.namespace, configVersion)
err := suite.fakeClient.Create(ctx, sec)
if err != nil {
panic(err)
}

csm.ObjectMeta.Finalizers = []string{CSMFinalizerName}
err = suite.fakeClient.Create(ctx, &csm)
if err != nil {
panic(err)
}

reconciler := suite.createReconciler()

// create node object, add to fakeclient, reconcile.GetMatchingNodes
node := shared.MakeNode("node1", suite.namespace)
node.Labels["topology.kubernetes.io/zone"] = "US-EAST"

err = suite.fakeClient.Create(ctx, &node)
assert.Nil(suite.T(), err)

nodeList := &corev1.NodeList{}
err = suite.fakeClient.List(ctx, nodeList, nil)
assert.Nil(suite.T(), err)

nodeListMatching, err := reconciler.GetMatchingNodes(ctx, "topology.kubernetes.io/zone", "US-EAST")
ctrl.Log.Info("node list response (1)", "number of nodes is: ", len(nodeListMatching.Items))

// Check the len to be 1 else fail
if len(nodeListMatching.Items) != 1 {
ctrl.Log.Error(err, "Unexpected length on node list.", "length", len(nodeListMatching.Items))
panic(err)
}

for _, node := range nodeListMatching.Items {
ctrl.Log.Info("Matching node item", "name ", node.ObjectMeta.GetName())
}
if node.ObjectMeta.GetName() != "node1" {
ctrl.Log.Error(err, "Unmatched label on node.")
panic(err)
}
assert.Nil(suite.T(), err)
}
5 changes: 0 additions & 5 deletions deploy/crds/storage.dell.com.crds.all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -990,11 +990,6 @@ spec:
ForceRemoveDriver is the boolean flag used to remove
driver deployment when CR is deleted
type: boolean
forceUpdate:
description:
ForceUpdate is the boolean flag used to force an
update of the driver instance
type: boolean
initContainers:
description: InitContainers is the specification for Driver InitContainers
items:
Expand Down
50 changes: 50 additions & 0 deletions pkg/drivers/powerflex.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,53 @@ func ModifyPowerflexCR(yamlString string, cr csmv1.ContainerStorageModule, fileT
}
return yamlString
}

// ExtractZonesFromSecret - Reads the array config secret and returns the zone label information
func ExtractZonesFromSecret(ctx context.Context, kube client.Client, namespace string, secret string) (map[string]string, error) {
log := logger.GetLogger(ctx)

arraySecret, err := utils.GetSecret(ctx, secret, namespace, kube)
if err != nil {
return nil, fmt.Errorf("reading secret [%s] error [%s]", secret, err)
}

type StorageArrayConfig struct {
SystemID string `json:"systemId"`
Zone struct {
Name string `json:"name"`
} `json:"zone"`
}

data := arraySecret.Data
configBytes := data["config"]
zonesMapData := make(map[string]string)

if string(configBytes) != "" {
yamlConfig := make([]StorageArrayConfig, 0)
configs, err := yaml.JSONToYAML(configBytes)
if err != nil {
return nil, fmt.Errorf("unable to parse multi-array configuration[%v]", err)
}
err = yaml.Unmarshal(configs, &yamlConfig)
if err != nil {
return nil, fmt.Errorf("unable to unmarshal multi-array configuration[%v]", err)
}

for _, configParam := range yamlConfig {
if configParam.SystemID == "" {
return nil, fmt.Errorf("invalid value for SystemID")
}
if configParam.Zone.Name != "" {
zonesMapData[configParam.SystemID] = configParam.Zone.Name
log.Infof("Zoning information configured for systemID %s: %v ", configParam.SystemID, zonesMapData)
} else {
log.Info("Zoning information not found in the array config. Continue with topology-unaware driver installation mode")
return zonesMapData, nil
}
}
} else {
return nil, fmt.Errorf("Array details are not provided in vxflexos-config secret")
}

return zonesMapData, nil
}
Loading

0 comments on commit e15599d

Please sign in to comment.