Skip to content

Commit

Permalink
added idempotent support
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubham14bajpai committed Nov 29, 2019
1 parent fcd0146 commit 92ab1aa
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions pkg/cstor/migrate/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,31 @@ 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),
)
if err != nil {
return err
}
err = retry.
Times(60).
Wait(5 * time.Second).
Try(func(attempt uint) error {
_, err1 := pod.NewKubeClient().
WithNamespace(openebsNamespace).
Get(cspPod.Items[0].Name, metav1.GetOptions{})
if !k8serrors.IsNotFound(err1) {
return errors.Errorf("failed to get csp pod because %s", err1)
}
return nil
})
if err != nil {
return err
if len(cspPod.Items) > 0 {
_, 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).
Try(func(attempt uint) error {
_, err1 := pod.NewKubeClient().
WithNamespace(openebsNamespace).
Get(cspPod.Items[0].Name, metav1.GetOptions{})
if !k8serrors.IsNotFound(err1) {
return errors.Errorf("failed to get csp pod because %s", err1)
}
return nil
})
if err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit 92ab1aa

Please sign in to comment.