Skip to content

Commit

Permalink
fix(cstor-pool-mgmt): import cstor pool using UID in CSP object witho…
Browse files Browse the repository at this point in the history
…ut reading disklist (#1307)



Signed-off-by: mittachaitu <[email protected]>
  • Loading branch information
sai chaithanya authored and kmova committed Jun 19, 2019
1 parent 8ec5e59 commit 198af5a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions cmd/cstor-pool-mgmt/controller/pool-controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,11 @@ func (c *CStorPoolController) cStorPoolEventHandler(operation common.QueueOperat
}

func (c *CStorPoolController) cStorPoolAddEventHandler(cStorPoolGot *apis.CStorPool) (string, error) {
// CheckValidPool is to check if pool attributes are correct.
devIDList, err := c.getDeviceIDs(cStorPoolGot)
if err != nil {
return string(apis.CStorPoolStatusOffline), errors.Wrapf(err, "failed to get device id of disks for csp %s", cStorPoolGot.Name)
}
// ValidatePool is to check if pool attributes are correct.
err = pool.ValidatePool(cStorPoolGot, devIDList)
if err != nil {
// To import the pool this check is important
if cStorPoolGot.ObjectMeta.UID == "" {
c.recorder.Event(cStorPoolGot, corev1.EventTypeWarning, string(common.FailureValidate), string(common.MessageResourceFailValidate))
return string(apis.CStorPoolStatusOffline), err
return string(apis.CStorPoolStatusOffline), fmt.Errorf("Poolname/UID cannot be empty")
}

/* If pool is already present.
Pool CR status is online. This means pool (main car) is running successfully,
but watcher container got restarted.
Expand Down Expand Up @@ -225,6 +218,18 @@ func (c *CStorPoolController) cStorPoolAddEventHandler(cStorPoolGot *apis.CStorP
common.SyncResources.IsImported = false
}

// CheckValidPool is to check if pool attributes are correct.
devIDList, err := c.getDeviceIDs(cStorPoolGot)
if err != nil {
return string(apis.CStorPoolStatusOffline), errors.Wrapf(err, "failed to get device id of disks for csp %s", cStorPoolGot.Name)
}
// ValidatePool is to check if pool attributes are correct.
err = pool.ValidatePool(cStorPoolGot, devIDList)
if err != nil {
c.recorder.Event(cStorPoolGot, corev1.EventTypeWarning, string(common.FailureValidate), string(common.MessageResourceFailValidate))
return string(apis.CStorPoolStatusOffline), err
}

// IsInitStatus is to check if initial status of cstorpool object is `init`.
if IsEmptyStatus(cStorPoolGot) || IsPendingStatus(cStorPoolGot) {
if len(common.InitialImportedPoolVol) != 0 {
Expand Down

0 comments on commit 198af5a

Please sign in to comment.