Skip to content

Commit

Permalink
incorporate review comments
Browse files Browse the repository at this point in the history
Signed-off-by: sonasingh46 <sonasingh46@gmail.com>
  • Loading branch information
sonasingh46 committed Dec 19, 2018
1 parent 8a357e4 commit cbc19e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/maya-apiserver/spc-watcher/handler.go
Expand Up @@ -148,7 +148,7 @@ func (c *Controller) syncSpc(spcGot *apis.StoragePoolClaim) error {
// pendingPoolCount holds the pending pool that should be provisioned to get the desired state.
pendingPoolCount := maxPoolCount - currentPoolCount
// Call the storage pool create logic to provision the pending pools.
err = c.storagePoolCreateWrapper(pendingPoolCount, spcGot)
err = c.create(pendingPoolCount, spcGot)
if err != nil {
return err
}
Expand All @@ -158,21 +158,21 @@ func (c *Controller) syncSpc(spcGot *apis.StoragePoolClaim) error {

// addEventHandler is the event handler for the add event of spc.
func (c *Controller) addEventHandler(spc *apis.StoragePoolClaim) error {
err := storagePoolValidator(spc)
err := validate(spc)
if err != nil {
return err
}
currentPoolCount, err := c.getCurrentPoolCount(spc)
if err != nil {
return err
}
err = c.storagePoolCreateWrapper(spc.Spec.MaxPools-currentPoolCount, spc)
err = c.create(spc.Spec.MaxPools-currentPoolCount, spc)
return nil
}

// storagePoolCreateWrapper is a wrapper function that calls the actual function to create pool as many time
// as the number of pools need to be created.
func (c *Controller) storagePoolCreateWrapper(maxPool int, spc *apis.StoragePoolClaim) error {
func (c *Controller) create(maxPool int, spc *apis.StoragePoolClaim) error {
var newSpcLease Leaser
newSpcLease = &Lease{spc, SpcLeaseKey, c.clientset, c.kubeclientset}
err := newSpcLease.Hold()
Expand All @@ -192,7 +192,7 @@ func (c *Controller) storagePoolCreateWrapper(maxPool int, spc *apis.StoragePool
}

// storagePoolValidator validates the spc configuration before creation of pool.
func storagePoolValidator(spc *apis.StoragePoolClaim) error {
func validate(spc *apis.StoragePoolClaim) error {
// Validations for poolType
if spc.Spec.MaxPools <= 0 {
return errors.Errorf("aborting storagepool create operation for %s as maxPool count is invalid ", spc.Name)
Expand Down

0 comments on commit cbc19e9

Please sign in to comment.