Skip to content

Commit

Permalink
Changed if condition order
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih authored and kmova committed May 1, 2021
1 parent 5145478 commit aa46f93
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/provisioner-localpv/app/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,21 @@ func (p *Provisioner) Provision(opts pvController.ProvisionOptions) (*v1.Persist
size = pvc.Spec.Resources.Requests["storage"]
}
sendEventOrIgnore(pvc.Name, name, size.String(), stgType, analytics.VolumeProvision)
if stgType == "hostpath" {
return p.ProvisionHostPath(opts, pvCASConfig)
}

// StorageType: Device
if stgType == "device" {
return p.ProvisionBlockDevice(opts, pvCASConfig)
}

// EXCEPTION: Block VolumeMode
if *opts.PVC.Spec.VolumeMode == v1.PersistentVolumeBlock && stgType != "device" {
return nil, fmt.Errorf("PV with BlockMode is not supported with StorageType %v", stgType)
}

// StorageType: Hostpath
if stgType == "hostpath" {
return p.ProvisionHostPath(opts, pvCASConfig)
}
alertlog.Logger.Errorw("",
"eventcode", "local.pv.provision.failure",
"msg", "Failed to provision Local PV",
Expand Down

0 comments on commit aa46f93

Please sign in to comment.