Skip to content

Commit

Permalink
Merge branch 'complete-auth-support' of https://github.com/dell/csm-o…
Browse files Browse the repository at this point in the history
…perator into complete-auth-support
  • Loading branch information
Michael Edegware committed Jan 18, 2022
2 parents eaf1f96 + 46779b8 commit 9c698fa
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.16 as builder
FROM golang:1.17 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
1 change: 1 addition & 0 deletions api/v1/csipowermaxrevproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
corev1 "k8s.io/api/core/v1"
)

// ProxyLimits max limits
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// ProxyLimits is used for storing the various types of limits
Expand Down
3 changes: 2 additions & 1 deletion api/v1/csm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ func (cr *ContainerStorageModule) GetCSMStatus() *ContainerStorageModuleStatus {
return &cr.Status
}

// GetControllerName - Returns a controller
func (cr *ContainerStorageModule) GetControllerName() string {
return fmt.Sprintf("%s-controller", cr.Name)
}

// GetDaemonSetName - Returns the name of the daemonset for the driver
// GetNodeName - Returns the name of the daemonset for the driver
func (cr *ContainerStorageModule) GetNodeName() string {
return fmt.Sprintf("%s-node", cr.Name)
}
Expand Down
34 changes: 24 additions & 10 deletions api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,31 @@ const (
// PowerStore - placeholder for constant powerstore
PowerStore DriverType = "powerstore"

// Provisioner - placeholder for constant
Provisioner = "provisioner"
Attacher = "attacher"
// Attacher - placeholder for constant
Attacher = "attacher"
// Snapshotter - placeholder for constant
Snapshotter = "snapshotter"
Registrar = "registrar"
Resizer = "resizer"
Sdcmonitor = "sdc-monitor"

Succeeded CSMOperatorConditionType = "Succeeded"
// Registrar - placeholder for constant
Registrar = "registrar"
// Resizer - placeholder for constant
Resizer = "resizer"
// Sdcmonitor - placeholder for constant
Sdcmonitor = "sdc-monitor"

// Succeeded - constant
Succeeded CSMOperatorConditionType = "Succeeded"
// InvalidConfig - constant
InvalidConfig CSMOperatorConditionType = "InvalidConfig"
Running CSMOperatorConditionType = "Running"
Error CSMOperatorConditionType = "Error"
Updating CSMOperatorConditionType = "Updating"
Failed CSMOperatorConditionType = "Failed"
// Running - Constant
Running CSMOperatorConditionType = "Running"
// Error - Constant
Error CSMOperatorConditionType = "Error"
// Updating - Constant
Updating CSMOperatorConditionType = "Updating"
// Failed - Constant
Failed CSMOperatorConditionType = "Failed"
)

// Module defines the desired state of a ContainerStorageModuleModules
Expand Down Expand Up @@ -181,6 +193,7 @@ type Driver struct {
TLSCertSecret string `json:"tlsCertSecret,omitempty" yaml:"tlsCertSecret"`
}

//ContainerTemplate template
type ContainerTemplate struct {

// Name is the name of Container
Expand Down Expand Up @@ -217,6 +230,7 @@ type ContainerTemplate struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector"`
}

//SnapshotClass struct
type SnapshotClass struct {
// Name is the name of the Snapshot Class
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Snapshot Class Name"
Expand Down
1 change: 1 addition & 0 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 2 additions & 0 deletions controllers/csm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ var configVersionKey = fmt.Sprintf("%s/%s", MetadataPrefix, "CSIDriverConfigVers
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile

//Reconcile - main loop
func (r *ContainerStorageModuleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("csm", req.NamespacedName)
// your logic here
Expand Down Expand Up @@ -497,6 +498,7 @@ func (r *ContainerStorageModuleReconciler) SyncCSM(ctx context.Context, cr csmv1
return nil
}

// PreChecks - validate inputs
func (r *ContainerStorageModuleReconciler) PreChecks(ctx context.Context, cr *csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig,
reqLogger logr.Logger) error {
if cr.Spec.Driver.Common.Image == "" {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dell/csm-operator

go 1.16
go 1.17

require (
github.com/go-logr/logr v0.3.0
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
// K8sMinimumSupportedVersion is the minimum supported version for k8s
K8sMinimumSupportedVersion = "1.19"
// K8sMaximumSupportedVersion is the maximum supported version for k8s
K8sMaximumSupportedVersion = "1.22"
K8sMaximumSupportedVersion = "1.23"
// OpenshiftMinimumSupportedVersion is the minimum supported version for openshift
OpenshiftMinimumSupportedVersion = "4.6"
// OpenshiftMaximumSupportedVersion is the maximum supported version for openshift
Expand Down
5 changes: 5 additions & 0 deletions pkg/drivers/powerscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
// +kubebuilder:scaffold:imports
)

// GetPowerScaleController driver
func GetPowerScaleController(cr csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (*utils.ControllerYAML, error) {
configMapPath := fmt.Sprintf("%s/driverconfig/powerscale/%s/controller.yaml", operatorConfig.ConfigDirectory, cr.Spec.Driver.ConfigVersion)
buf, err := ioutil.ReadFile(configMapPath)
Expand Down Expand Up @@ -76,6 +77,7 @@ func GetPowerScaleController(cr csmv1.ContainerStorageModule, operatorConfig uti

}

// GetPowerScaleNode node
func GetPowerScaleNode(cr csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (*utils.NodeYAML, error) {
configMapPath := fmt.Sprintf("%s/driverconfig/powerscale/%s/node.yaml", operatorConfig.ConfigDirectory, cr.Spec.Driver.ConfigVersion)
buf, err := ioutil.ReadFile(configMapPath)
Expand Down Expand Up @@ -139,6 +141,7 @@ func GetPowerScaleNode(cr csmv1.ContainerStorageModule, operatorConfig utils.Ope

}

// GetPowerScaleConfigMap configmap
func GetPowerScaleConfigMap(cr csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (*corev1.ConfigMap, error) {
configMapPath := fmt.Sprintf("%s/driverconfig/powerscale/%s/driver-config-params.yaml", operatorConfig.ConfigDirectory, cr.Spec.Driver.ConfigVersion)
buf, err := ioutil.ReadFile(configMapPath)
Expand Down Expand Up @@ -167,6 +170,7 @@ func GetPowerScaleConfigMap(cr csmv1.ContainerStorageModule, operatorConfig util

}

// GetPowerScaleCSIDriver driver
func GetPowerScaleCSIDriver(cr csmv1.ContainerStorageModule, operatorConfig utils.OperatorConfig) (*storagev1.CSIDriver, error) {
configMapPath := fmt.Sprintf("%s/driverconfig/powerscale/%s/csidriver.yaml", operatorConfig.ConfigDirectory, cr.Spec.Driver.ConfigVersion)
buf, err := ioutil.ReadFile(configMapPath)
Expand All @@ -184,6 +188,7 @@ func GetPowerScaleCSIDriver(cr csmv1.ContainerStorageModule, operatorConfig util

}

// PrecheckPowerScale validate
func PrecheckPowerScale(ctx context.Context, cr *csmv1.ContainerStorageModule, r utils.ReconcileCSM, log logr.Logger) error {
// Check for secrete only
config := cr.Name + "-creds"
Expand Down
6 changes: 6 additions & 0 deletions pkg/utils/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func getDaemonSetStatus(ctx context.Context, instance *csmv1.ContainerStorageMod
}, nil
}

// CalculateState for cr
func CalculateState(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, newStatus *csmv1.ContainerStorageModuleStatus) (bool, error) {
running := false
controllerReplicas, controllerStatus, controllerErr := getDeploymentStatus(ctx, instance, r)
Expand Down Expand Up @@ -143,6 +144,7 @@ func CalculateState(ctx context.Context, instance *csmv1.ContainerStorageModule,
return running, err
}

// SetStatus of cr
func SetStatus(instance *csmv1.ContainerStorageModule, newStatus *csmv1.ContainerStorageModuleStatus) {
instance.GetCSMStatus().State = newStatus.State
instance.GetCSMStatus().LastUpdate.ErrorMessage = newStatus.LastUpdate.ErrorMessage
Expand All @@ -153,6 +155,7 @@ func SetStatus(instance *csmv1.ContainerStorageModule, newStatus *csmv1.Containe
instance.GetCSMStatus().ContainerStorageModuleHash = newStatus.ContainerStorageModuleHash
}

// SetLastStatusUpdate for cr
func SetLastStatusUpdate(status *csmv1.ContainerStorageModuleStatus, conditionType csmv1.CSMOperatorConditionType, errorMsg string) csmv1.LastUpdate {
// If the condition has not changed, then don't update the time
if status.LastUpdate.Condition == conditionType && status.LastUpdate.ErrorMessage == errorMsg {
Expand All @@ -169,6 +172,7 @@ func SetLastStatusUpdate(status *csmv1.ContainerStorageModuleStatus, conditionTy
}
}

// UpdateStatus for cr
func UpdateStatus(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, reqLogger logr.Logger, newStatus, oldStatus *csmv1.ContainerStorageModuleStatus) error {
//running := calculateState(ctx, instance, r, newStatus)
if !reflect.DeepEqual(oldStatus, newStatus) {
Expand All @@ -191,6 +195,7 @@ func UpdateStatus(ctx context.Context, instance *csmv1.ContainerStorageModule, r
return nil
}

// HandleValidationError for cr
func HandleValidationError(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, reqLogger logr.Logger,
validationError error) (reconcile.Result, error) {
reqLogger.Error(validationError, "Validation error")
Expand Down Expand Up @@ -225,6 +230,7 @@ func GetOperatorConditionTypeFromState(state csmv1.CSMStateType) csmv1.CSMOperat
return csmv1.Error
}

// HandleSuccess for cr
func HandleSuccess(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, reqLogger logr.Logger, newStatus, oldStatus *csmv1.ContainerStorageModuleStatus) (reconcile.Result, error) {
errorMsg := ""
running, err := CalculateState(ctx, instance, r, newStatus)
Expand Down
8 changes: 6 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ type NodeYAML struct {
}

const (
DefaultReleaseName = "<DriverDefaultReleaseName>"
// DefaultReleaseName const
DefaultReleaseName = "<DriverDefaultReleaseName>"
// DefaultReleaseNamespace const
DefaultReleaseNamespace = "<DriverDefaultReleaseNamespace>"
DefaultImagePullPolicy = "IfNotPresent"
// DefaultImagePullPolicy const
DefaultImagePullPolicy = "IfNotPresent"
)

// SplitYAML divides a big bytes of yaml files in individual yaml files.
Expand Down Expand Up @@ -263,6 +266,7 @@ func HashContainerStorageModule(instance *csmv1.ContainerStorageModule) uint64 {
return uint64(hash.Sum32())
}

// CSMHashChanged for cr
func CSMHashChanged(instance *csmv1.ContainerStorageModule) (uint64, uint64, bool) {
expectedHash := HashContainerStorageModule(instance)
return expectedHash, instance.GetCSMStatus().ContainerStorageModuleHash, instance.GetCSMStatus().ContainerStorageModuleHash != expectedHash
Expand Down

0 comments on commit 9c698fa

Please sign in to comment.