Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubham14bajpai committed Nov 28, 2019
1 parent 0e14d17 commit af1e096
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 1 addition & 3 deletions cmd/migrate/executor/setup_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"github.com/spf13/cobra"
)

var spcName, openebsNamespace string

// NewJob will setup a new migrate job
func NewJob() *cobra.Command {
// Create a new command.
Expand Down Expand Up @@ -61,6 +59,6 @@ func NewJob() *cobra.Command {
func PreRun(cmd *cobra.Command, args []string) {
namespace := getOpenEBSNamespace()
if len(strings.TrimSpace(namespace)) != 0 {
openebsNamespace = namespace
options.openebsNamespace = namespace
}
}
29 changes: 16 additions & 13 deletions pkg/cstor/migrate/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Pool(spcName, openebsNamespace string) error {
Get(spcName, metav1.GetOptions{})
if k8serrors.IsNotFound(err) {
klog.Infof("spc %s not found.", spcName)
_, err := cspc.NewKubeClient().
_, err = cspc.NewKubeClient().
WithNamespace(openebsNamespace).Get(spcName, metav1.GetOptions{})
if err != nil {
return errors.Wrapf(err, "failed to get equivalent cspc for spc %s", spcName)
Expand Down Expand Up @@ -86,6 +86,9 @@ func Pool(spcName, openebsNamespace string) error {
}
cspcObj, err = cspc.NewKubeClient().
WithNamespace(openebsNamespace).Get(cspcObj.Name, metav1.GetOptions{})
if err != nil {
return err
}
for i, poolspec := range cspcObj.Spec.Pools {
if poolspec.NodeSelector[string(apis.HostNameCPK)] ==
cspiObj.Labels[string(apis.HostNameCPK)] {
Expand All @@ -111,7 +114,7 @@ func csptocspi(cspiObj *apis.CStorPoolInstance, cspcObj *apis.CStorPoolCluster,
hostnameLabel := string(apis.HostNameCPK) + "=" + cspiObj.Labels[string(apis.HostNameCPK)]
spcLabel := string(apis.StoragePoolClaimCPK) + "=" + cspcObj.Name
cspLabel := hostnameLabel + "," + spcLabel

var err1 error
cspObj, err := getCSP(cspLabel)
if err != nil {
return err
Expand All @@ -138,7 +141,7 @@ func csptocspi(cspiObj *apis.CStorPoolInstance, cspcObj *apis.CStorPoolCluster,
Times(60).
Wait(5 * time.Second).
Try(func(attempt uint) error {
cspiObj, err1 := cspi.NewKubeClient().
cspiObj, err1 = cspi.NewKubeClient().
WithNamespace(openebsNamespace).
Get(cspiObj.Name, metav1.GetOptions{})
if err1 != nil {
Expand Down Expand Up @@ -172,9 +175,6 @@ func getCSP(cspLabel string) (*apis.CStorPool, error) {
return nil, fmt.Errorf("Invalid number of pools on one node: %d", len(cspList.Items))
}
cspObj := cspList.Items[0]
if err != nil {
return nil, err
}
return &cspObj, nil
}

Expand All @@ -188,12 +188,15 @@ func scaleDownDeployment(cspObj *apis.CStorPool, openebsNamespace string) error
if err != nil {
return err
}
_, err = deploy.NewKubeClient().
WithNamespace(openebsNamespace).Patch(
cspObj.Name,
types.StrategicMergePatchType,
[]byte(replicaPatch),
)
_, err = deploy.NewKubeClient().WithNamespace(openebsNamespace).
Patch(
cspObj.Name,
types.StrategicMergePatchType,
[]byte(replicaPatch),
)
if err != nil {
return err
}
err = retry.
Times(60).
Wait(5 * time.Second).
Expand Down Expand Up @@ -235,7 +238,7 @@ func updateBDC(bdName apis.CspBlockDevice, cspcObj *apis.CStorPoolCluster, opene
}
bdcObj.OwnerReferences[0].Kind = "CStorPoolCluster"
bdcObj.OwnerReferences[0].UID = cspcObj.UID
bdcObj, err = bdc.NewKubeClient().
_, err = bdc.NewKubeClient().
WithNamespace(openebsNamespace).
Update(bdcObj)
if err != nil {
Expand Down

0 comments on commit af1e096

Please sign in to comment.