Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
114 changes: 56 additions & 58 deletions cmd/oci-csi-controller-driver/csioptions/csioptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,75 +26,73 @@ const (
fssAddressSuffix = "-fss.sock"
fssVolumeNameAppendedPrefix = "-fss"
CrossNamespaceVolumeDataSource = "CrossNamespaceVolumeDataSource"
VolumeAttributesClass = "VolumeAttributesClass"
VolumeAttributesClass = "VolumeAttributesClass"
)

// CSIOptions structure which contains flag values
type CSIOptions struct {
Master string
Kubeconfig string
CsiAddress string
Endpoint string
FssCsiAddress string
FssEndpoint string
VolumeNamePrefix string
FssVolumeNamePrefix string
VolumeNameUUIDLength int
ShowVersion bool
RetryIntervalStart time.Duration
RetryIntervalMax time.Duration
WorkerThreads uint
OperationTimeout time.Duration
EnableLeaderElection bool
LeaderElectionType string
LeaderElectionNamespace string
StrictTopology bool
Resync time.Duration
Timeout time.Duration
FeatureGates map[string]bool
FinalizerThreads uint
MetricsAddress string
MetricsPath string
ExtraCreateMetadata bool
ReconcileSync time.Duration
EnableResizer bool
GroupSnapshotNamePrefix string
Master string
Kubeconfig string
CsiAddress string
Endpoint string
FssCsiAddress string
FssEndpoint string
VolumeNamePrefix string
FssVolumeNamePrefix string
VolumeNameUUIDLength int
ShowVersion bool
RetryIntervalStart time.Duration
RetryIntervalMax time.Duration
WorkerThreads uint
OperationTimeout time.Duration
EnableLeaderElection bool
LeaderElectionType string
LeaderElectionNamespace string
StrictTopology bool
Resync time.Duration
Timeout time.Duration
FeatureGates map[string]bool
FinalizerThreads uint
MetricsAddress string
MetricsPath string
ExtraCreateMetadata bool
ReconcileSync time.Duration
EnableResizer bool
GroupSnapshotNamePrefix string
GroupSnapshotNameUUIDLength int

}

// NewCSIOptions initializes the flag
func NewCSIOptions() *CSIOptions {
csioptions := CSIOptions{
Master: *flag.String("master", "", "kube master"),
Kubeconfig: *flag.String("kubeconfig", "", "cluster kube config"),
CsiAddress: *flag.String("csi-address", "/run/csi/socket", "Address of the CSI BV driver socket."),
Endpoint: *flag.String("csi-endpoint", "unix://tmp/csi.sock", "CSI BV endpoint"),
FssCsiAddress: *flag.String("fss-csi-address", "/run/fss/socket", "Address of the CSI FSS driver socket."),
FssEndpoint: *flag.String("fss-csi-endpoint", "unix://tmp/csi-fss.sock", "CSI FSS endpoint"),
VolumeNamePrefix: *flag.String("csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume."),
FssVolumeNamePrefix: *flag.String("fss-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for FSS."),
VolumeNameUUIDLength: *flag.Int("csi-volume-name-uuid-length", -1, "Truncates generated UUID of a created volume to this length. Defaults behavior is to NOT truncate."),
ShowVersion: *flag.Bool("csi-version", false, "Show version."),
RetryIntervalStart: *flag.Duration("csi-retry-interval-start", time.Second, "Initial retry interval of failed provisioning or deletion. It doubles with each failure, up to retry-interval-max."),
RetryIntervalMax: *flag.Duration("csi-retry-interval-max", 5*time.Minute, "Maximum retry interval of failed provisioning or deletion."),
WorkerThreads: *flag.Uint("csi-worker-threads", 100, "Number of provisioner worker threads, in other words nr. of simultaneous CSI calls."),
OperationTimeout: *flag.Duration("csi-op-timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume"),
EnableLeaderElection: *flag.Bool("csi-enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules."),
LeaderElectionType: *flag.String("csi-leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'."),
LeaderElectionNamespace: *flag.String("csi-leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set."),
StrictTopology: *flag.Bool("csi-strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node."),
Resync: *flag.Duration("csi-resync", 10*time.Minute, "Resync interval of the controller."),
Timeout: *flag.Duration("csi-timeout", 15*time.Second, "Timeout for waiting for attaching or detaching the volume."),
FinalizerThreads: *flag.Uint("cloning-protection-threads", 1, "Number of simultaniously running threads, handling cloning finalizer removal"),
MetricsAddress: *flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled."),
MetricsPath: *flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`."),
ExtraCreateMetadata: *flag.Bool("extra-create-metadata", false, "If set, add pv/pvc metadata to plugin create requests as parameters."),
ReconcileSync: *flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler."),
EnableResizer: *flag.Bool("csi-bv-expansion-enabled", false, "Enables go routine csi-resizer."),
GroupSnapshotNamePrefix: *flag.String("groupsnapshot-name-prefix", "groupsnapshot", "Prefix to apply to the name of a created group snapshot"),
Master: *flag.String("master", "", "kube master"),
Kubeconfig: *flag.String("kubeconfig", "", "cluster kube config"),
CsiAddress: *flag.String("csi-address", "/run/csi/socket", "Address of the CSI BV driver socket."),
Endpoint: *flag.String("csi-endpoint", "unix://tmp/csi.sock", "CSI BV endpoint"),
FssCsiAddress: *flag.String("fss-csi-address", "/run/fss/socket", "Address of the CSI FSS driver socket."),
FssEndpoint: *flag.String("fss-csi-endpoint", "unix://tmp/csi-fss.sock", "CSI FSS endpoint"),
VolumeNamePrefix: *flag.String("csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a created volume."),
FssVolumeNamePrefix: *flag.String("fss-csi-volume-name-prefix", "pvc", "Prefix to apply to the name of a volume created for FSS."),
VolumeNameUUIDLength: *flag.Int("csi-volume-name-uuid-length", -1, "Truncates generated UUID of a created volume to this length. Defaults behavior is to NOT truncate."),
ShowVersion: *flag.Bool("csi-version", false, "Show version."),
RetryIntervalStart: *flag.Duration("csi-retry-interval-start", time.Second, "Initial retry interval of failed provisioning or deletion. It doubles with each failure, up to retry-interval-max."),
RetryIntervalMax: *flag.Duration("csi-retry-interval-max", 5*time.Minute, "Maximum retry interval of failed provisioning or deletion."),
WorkerThreads: *flag.Uint("csi-worker-threads", 100, "Number of provisioner worker threads, in other words nr. of simultaneous CSI calls."),
OperationTimeout: *flag.Duration("csi-op-timeout", 10*time.Second, "Timeout for waiting for creation or deletion of a volume"),
EnableLeaderElection: *flag.Bool("csi-enable-leader-election", false, "Enables leader election. If leader election is enabled, additional RBAC rules are required. Please refer to the Kubernetes CSI documentation for instructions on setting up these RBAC rules."),
LeaderElectionType: *flag.String("csi-leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'."),
LeaderElectionNamespace: *flag.String("csi-leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set."),
StrictTopology: *flag.Bool("csi-strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node."),
Resync: *flag.Duration("csi-resync", 10*time.Minute, "Resync interval of the controller."),
Timeout: *flag.Duration("csi-timeout", 15*time.Second, "Timeout for waiting for attaching or detaching the volume."),
FinalizerThreads: *flag.Uint("cloning-protection-threads", 1, "Number of simultaniously running threads, handling cloning finalizer removal"),
MetricsAddress: *flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled."),
MetricsPath: *flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`."),
ExtraCreateMetadata: *flag.Bool("extra-create-metadata", false, "If set, add pv/pvc metadata to plugin create requests as parameters."),
ReconcileSync: *flag.Duration("reconcile-sync", 1*time.Minute, "Resync interval of the VolumeAttachment reconciler."),
EnableResizer: *flag.Bool("csi-bv-expansion-enabled", false, "Enables go routine csi-resizer."),
GroupSnapshotNamePrefix: *flag.String("groupsnapshot-name-prefix", "groupsnapshot", "Prefix to apply to the name of a created group snapshot"),
GroupSnapshotNameUUIDLength: *flag.Int("groupsnapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created group snapshot. Defaults behavior is to NOT truncate."),

}
return &csioptions
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/oci-csi-node-driver/nodedriver/nodedriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"go.uber.org/zap"
)

//RunNodeDriver main function to start node driver
// RunNodeDriver main function to start node driver
func RunNodeDriver(nodeOptions nodedriveroptions.NodeOptions, stopCh <-chan struct{}) error {
logger := logging.Logger().Sugar()
logger.Sync()
Expand Down
6 changes: 3 additions & 3 deletions cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

package nodedriveroptions

//NodeCSIOptions contains details about the flag
// NodeCSIOptions contains details about the flag
type NodeCSIOptions struct {
Endpoint string // Used for Block Volume CSI driver
NodeID string
LogLevel string
Master string
Kubeconfig string

EnableFssDriver bool
FssEndpoint string
EnableFssDriver bool
FssEndpoint string
LustreCsiAddress string
LustreKubeletRegistrationPath string
LustreEndpoint string
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/providers/oci/load_balancer_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
api "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/loadbalancer"
"github.com/oracle/oci-cloud-controller-manager/pkg/oci/client"
"github.com/stretchr/testify/assert"
)

Expand Down
16 changes: 8 additions & 8 deletions pkg/csi-util/lustre_lnet_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ type Parameter map[string]interface{}
/*
ValidateLustreVolumeId takes lustreVolumeId as input and returns if its valid or not along with lnetLabel
Ex. volume handle : 10.112.10.6@tcp1:/fsname
volume handle : <MGS NID>[:<MGS NID>]:/<fsname>

volume handle : <MGS NID>[:<MGS NID>]:/<fsname>
*/
func ValidateLustreVolumeId(lusterVolumeId string) (bool, string) {
const minNumOfParamsFromVolumeHandle = 2
Expand Down Expand Up @@ -91,9 +92,9 @@ type LnetService struct {

type OCILnetConfigurator struct{}

func NewLnetService() *LnetService{
func NewLnetService() *LnetService {
return &LnetService{
Configurator: &OCILnetConfigurator{},
Configurator: &OCILnetConfigurator{},
}
}

Expand Down Expand Up @@ -331,7 +332,7 @@ func (ls *LnetService) IsLnetActive(logger *zap.SugaredLogger, lnetLabel string)
}

func (olc *OCILnetConfigurator) ExecuteCommandOnWorkerNode(args ...string) (string, error) {

command := exec.Command("chroot-bash", args...)

output, err := command.CombinedOutput()
Expand Down Expand Up @@ -374,15 +375,15 @@ func isValidShellInput(input string) bool {
return false
}
// List of forbidden characters
forbiddenChars := []string{";", "&", "|", "<", ">", "(", ")", "`", "'", "\"","$","!"}
forbiddenChars := []string{";", "&", "|", "<", ">", "(", ")", "`", "'", "\"", "$", "!"}
for _, char := range forbiddenChars {
if strings.Contains(input, char) {
return false
}
}
return true
}
func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error {
func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson string) error {
if lustreParamsJson == "" {
logger.Debug("No lustre parameters specified.")
return nil
Expand All @@ -401,7 +402,7 @@ func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson strin
for key, value := range param {
logger.Infof("Validating lustre param %s=%s", key, fmt.Sprintf("%v", value))
if !isValidShellInput(key) || !isValidShellInput(fmt.Sprintf("%v", value)) {
invalidParams = append(invalidParams, fmt.Sprintf("%v=%v",key, value))
invalidParams = append(invalidParams, fmt.Sprintf("%v=%v", key, value))
}
}
}
Expand All @@ -411,4 +412,3 @@ func ValidateLustreParameters(logger *zap.SugaredLogger, lustreParamsJson strin
logger.Infof("Successfully validated lustre parameters.")
return nil
}

18 changes: 8 additions & 10 deletions pkg/csi-util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const (
RawBlockStagingFile = "mountfile"

AvailabilityDomainLabel = "csi-ipv6-full-ad-name"

)

// Util interface
Expand Down Expand Up @@ -117,15 +116,14 @@ type NodeMetadata struct {

// CSIConfig represents the structure of the ConfigMap data.
type CSIConfig struct {
Lustre *DriverConfig `yaml:"lustre"`
Lustre *DriverConfig `yaml:"lustre"`
IsLoaded bool
}

// DriverConfig represents driver-specific configurations.
type DriverConfig struct {
SkipNodeUnstage bool `yaml:"skipNodeUnstage"`
SkipNodeUnstage bool `yaml:"skipNodeUnstage"`
SkipLustreParameters bool `yaml:"skipLustreParameters"`

}

func (u *Util) LookupNodeID(k kubernetes.Interface, nodeName string) (string, error) {
Expand All @@ -144,14 +142,14 @@ func (u *Util) LookupNodeID(k kubernetes.Interface, nodeName string) (string, er

func (u *Util) WaitForKubeApiServerToBeReachableWithContext(ctx context.Context, k kubernetes.Interface, backOffCap time.Duration) {

waitForKubeApiServerCtx, waitForKubeApiServerCtxCancel := context.WithTimeout(ctx, time.Second * 45)
waitForKubeApiServerCtx, waitForKubeApiServerCtxCancel := context.WithTimeout(ctx, time.Second*45)
defer waitForKubeApiServerCtxCancel()

backoff := wait.Backoff{
Duration: 1 * time.Second,
Factor: 2.0,
Steps: 5,
Cap: backOffCap,
Cap: backOffCap,
}

wait.ExponentialBackoffWithContext(
Expand All @@ -171,9 +169,9 @@ func (u *Util) WaitForKubeApiServerToBeReachableWithContext(ctx context.Context,
)
}

func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.Interface, nodeID string, nodeMetadata *NodeMetadata) (error) {
func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.Interface, nodeID string, nodeMetadata *NodeMetadata) error {

u.WaitForKubeApiServerToBeReachableWithContext(ctx, k, time.Second * 30)
u.WaitForKubeApiServerToBeReachableWithContext(ctx, k, time.Second*30)

node, err := k.CoreV1().Nodes().Get(ctx, nodeID, metav1.GetOptions{})

Expand Down Expand Up @@ -210,7 +208,7 @@ func (u *Util) LoadNodeMetadataFromApiServer(ctx context.Context, k kubernetes.I
u.Logger.With("nodeId", nodeID, "nodeMetadata", nodeMetadata).Info("Node IP family identified.")
}
nodeMetadata.IsNodeMetadataLoaded = true
return nil
return nil
}

// waitForPathToExist waits for for a given filesystem path to exist.
Expand Down Expand Up @@ -652,7 +650,7 @@ func LoadCSIConfigFromConfigMap(csiConfig *CSIConfig, k kubernetes.Interface, co

if lustreConfig, exists := cm.Data["lustre"]; exists {
if err := yaml.Unmarshal([]byte(lustreConfig), &csiConfig.Lustre); err != nil {
logger.Debugf("Failed to parse lustre key in config map %v. Error: %v",configMapName, err)
logger.Debugf("Failed to parse lustre key in config map %v. Error: %v", configMapName, err)
return
}
logger.Infof("Successfully loaded ConfigMap %v. Using customized configuration for csi driver.", configMapName)
Expand Down
Loading