Skip to content

Commit

Permalink
refact(deps): bump k8s and client-go deps to version v0.20.2 (#1789)
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
  • Loading branch information
shubham14bajpai authored Mar 8, 2021
1 parent 8f9d4f9 commit 5c43ada
Show file tree
Hide file tree
Showing 2,204 changed files with 201,810 additions and 240,370 deletions.
18 changes: 12 additions & 6 deletions cmd/cstor-pool-mgmt/controller/backup-controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package backupcontroller

import (
"context"
"fmt"
"os"
"reflect"
Expand Down Expand Up @@ -61,14 +62,16 @@ func (c *BackupController) syncHandler(key string, operation common.QueueOperati
bkp.Status = apis.CStorBackupStatus(status)
}

nbkp, err := c.clientset.OpenebsV1alpha1().CStorBackups(bkp.Namespace).Get(bkp.Name, metav1.GetOptions{})
nbkp, err := c.clientset.OpenebsV1alpha1().CStorBackups(bkp.Namespace).
Get(context.TODO(), bkp.Name, metav1.GetOptions{})
if err != nil {
return err
}

nbkp.Status = bkp.Status

_, err = c.clientset.OpenebsV1alpha1().CStorBackups(nbkp.Namespace).Update(nbkp)
_, err = c.clientset.OpenebsV1alpha1().CStorBackups(nbkp.Namespace).
Update(context.TODO(), nbkp, metav1.UpdateOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -107,7 +110,8 @@ func (c *BackupController) syncEventHandler(bkp *apis.CStorBackup) (string, erro
// If the backup is in init state then only we will complete the backup
if IsInitStatus(bkp) {
bkp.Status = apis.BKPCStorStatusInProgress
_, err := c.clientset.OpenebsV1alpha1().CStorBackups(bkp.Namespace).Update(bkp)
_, err := c.clientset.OpenebsV1alpha1().CStorBackups(bkp.Namespace).
Update(context.TODO(), bkp, metav1.UpdateOptions{})
if err != nil {
klog.Errorf("Failed to update backup:%s status : %v", bkp.Name, err.Error())
return "", err
Expand Down Expand Up @@ -141,7 +145,7 @@ func (c *BackupController) getCStorBackupResource(key string) (*apis.CStorBackup
return nil, nil
}

bkp, err := c.clientset.OpenebsV1alpha1().CStorBackups(ns).Get(name, metav1.GetOptions{})
bkp, err := c.clientset.OpenebsV1alpha1().CStorBackups(ns).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
if errors.IsNotFound(err) {
runtime.HandleError(fmt.Errorf("bkp '%s' in work queue no longer exists", key))
Expand Down Expand Up @@ -225,7 +229,8 @@ func IsOnlyStatusChange(oldbkp, newbkp *apis.CStorBackup) bool {
// CStorCompletedBackups.Spec.SnapName = b-0
func (c *BackupController) updateCStorCompletedBackup(bkp *apis.CStorBackup) error {
lastbkpname := bkp.Spec.BackupName + "-" + bkp.Spec.VolumeName
bkplast, err := c.clientset.OpenebsV1alpha1().CStorCompletedBackups(bkp.Namespace).Get(lastbkpname, v1.GetOptions{})
bkplast, err := c.clientset.OpenebsV1alpha1().CStorCompletedBackups(bkp.Namespace).
Get(context.TODO(), lastbkpname, v1.GetOptions{})
if err != nil {
klog.Errorf("Failed to get last completed backup for %s vol:%v", bkp.Spec.BackupName, bkp.Spec.VolumeName)
return nil
Expand All @@ -236,7 +241,8 @@ func (c *BackupController) updateCStorCompletedBackup(bkp *apis.CStorBackup) err

// PrevSnapName store the name of last backed up snapshot
bkplast.Spec.PrevSnapName = bkp.Spec.SnapName
_, err = c.clientset.OpenebsV1alpha1().CStorCompletedBackups(bkp.Namespace).Update(bkplast)
_, err = c.clientset.OpenebsV1alpha1().CStorCompletedBackups(bkp.Namespace).
Update(context.TODO(), bkplast, metav1.UpdateOptions{})
if err != nil {
klog.Errorf("Failed to update lastbackup for %s", bkplast.Name)
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package backupcontroller

import (
"context"
"os"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -167,7 +168,8 @@ func (c *BackupController) cleanupOldBackup(clientset clientset.Interface) {
bkplistop := metav1.ListOptions{
LabelSelector: bkplabel,
}
bkplist, err := clientset.OpenebsV1alpha1().CStorBackups(metav1.NamespaceAll).List(bkplistop)
bkplist, err := clientset.OpenebsV1alpha1().CStorBackups(metav1.NamespaceAll).
List(context.TODO(), bkplistop)
if err != nil {
return
}
Expand All @@ -191,7 +193,8 @@ func (c *BackupController) cleanupOldBackup(clientset clientset.Interface) {
func updateBackupStatus(clientset clientset.Interface, bkp apis.CStorBackup, status apis.CStorBackupStatus) {
bkp.Status = status

_, err := clientset.OpenebsV1alpha1().CStorBackups(bkp.Namespace).Update(&bkp)
_, err := clientset.OpenebsV1alpha1().CStorBackups(bkp.Namespace).
Update(context.TODO(), &bkp, v1.UpdateOptions{})
if err != nil {
klog.Errorf("Failed to update backup(%s) status(%s)", status, bkp.Name)
return
Expand All @@ -201,7 +204,8 @@ func updateBackupStatus(clientset clientset.Interface, bkp apis.CStorBackup, sta
// findLastBackupStat will find the status of backup from last completed-backup
func findLastBackupStat(clientset clientset.Interface, bkp apis.CStorBackup) apis.CStorBackupStatus {
lastbkpname := bkp.Spec.BackupName + "-" + bkp.Spec.VolumeName
lastbkp, err := clientset.OpenebsV1alpha1().CStorCompletedBackups(bkp.Namespace).Get(lastbkpname, v1.GetOptions{})
lastbkp, err := clientset.OpenebsV1alpha1().CStorCompletedBackups(bkp.Namespace).
Get(context.TODO(), lastbkpname, v1.GetOptions{})
if err != nil {
// Unable to fetch the last backup, so we will return fail state
klog.Errorf("Failed to fetch last completed backup:%s error:%s", lastbkpname, err.Error())
Expand Down
7 changes: 5 additions & 2 deletions cmd/cstor-pool-mgmt/controller/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package common

import (
"context"
"reflect"
"sync"
"time"
Expand Down Expand Up @@ -209,7 +210,8 @@ func PoolNameHandler(cVR *apis.CStorVolumeReplica, cnt int) bool {
// CheckForCStorPoolCRD is Blocking call for checking status of CStorPool CRD.
func CheckForCStorPoolCRD(clientset clientset.Interface) {
for {
_, err := clientset.OpenebsV1alpha1().CStorPools().List(metav1.ListOptions{})
_, err := clientset.OpenebsV1alpha1().CStorPools().
List(context.TODO(), metav1.ListOptions{})
if err != nil {
klog.Errorf("CStorPool CRD not found. Retrying after %v, error: %v", CRDRetryInterval, err)
time.Sleep(CRDRetryInterval)
Expand All @@ -227,7 +229,8 @@ func CheckForCStorVolumeReplicaCRD(clientset clientset.Interface) {
// or not, we are trying to handle only the error of CVR CR List api indirectly.
// CRD has only two types of scope, cluster and namespaced. If CR list api
// for default namespace works fine, then CR list api works for all namespaces.
_, err := clientset.OpenebsV1alpha1().CStorVolumeReplicas(string(DefaultNameSpace)).List(metav1.ListOptions{})
_, err := clientset.OpenebsV1alpha1().CStorVolumeReplicas(string(DefaultNameSpace)).
List(context.TODO(), metav1.ListOptions{})
if err != nil {
klog.Errorf("CStorVolumeReplica CRD not found. Retrying after %v, error: %v", CRDRetryInterval, err)
time.Sleep(CRDRetryInterval)
Expand Down
26 changes: 17 additions & 9 deletions cmd/cstor-pool-mgmt/controller/pool-controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package poolcontroller

import (
"context"
"fmt"
"os"
"reflect"
Expand Down Expand Up @@ -119,7 +120,8 @@ func (c *CStorPoolController) syncHandler(key string, operation common.QueueOper
"Failed to reconcile csp version",
err,
)
_, err = c.clientset.OpenebsV1alpha1().CStorPools().Update(cspObject)
_, err = c.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cspObject, metav1.UpdateOptions{})
if err != nil {
klog.Errorf("failed to update versionDetails status for csp %s:%s", cspObject.Name, err.Error())
}
Expand All @@ -138,7 +140,8 @@ func (c *CStorPoolController) syncHandler(key string, operation common.QueueOper

if err != nil {
klog.Errorf(err.Error())
_, err := c.clientset.OpenebsV1alpha1().CStorPools().Update(cspObject)
_, err := c.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cspObject, metav1.UpdateOptions{})
if err != nil {
return err
}
Expand All @@ -153,7 +156,8 @@ func (c *CStorPoolController) syncHandler(key string, operation common.QueueOper
// ToDo: Instead of having statusSync, capacitySync we can make it generic resource sync which syncs all the
// ToDo: requried fields on CSP ( Some code re-organization will be required)
c.syncCsp(cspObject)
_, err = c.clientset.OpenebsV1alpha1().CStorPools().Update(cspObject)
_, err = c.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cspObject, metav1.UpdateOptions{})
if err != nil {
c.recorder.Event(cspObject, corev1.EventTypeWarning, string(common.FailedSynced), string(common.MessageResourceSyncFailure)+err.Error())
return err
Expand Down Expand Up @@ -432,7 +436,8 @@ func (c *CStorPoolController) getPoolResource(key string) (*apis.CStorPool, erro
return nil, nil
}

cStorPoolGot, err := c.clientset.OpenebsV1alpha1().CStorPools().Get(name, metav1.GetOptions{})
cStorPoolGot, err := c.clientset.OpenebsV1alpha1().CStorPools().
Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
// The cStorPool resource may no longer exist, in which case we stop
// processing.
Expand All @@ -452,7 +457,8 @@ func (c *CStorPoolController) removeFinalizer(cStorPoolGot *apis.CStorPool) erro
return nil
}
cStorPoolGot.Finalizers = util.RemoveString(cStorPoolGot.Finalizers, apis.PoolProtectionFinalizer)
_, err := c.clientset.OpenebsV1alpha1().CStorPools().Update(cStorPoolGot)
_, err := c.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cStorPoolGot, metav1.UpdateOptions{})
if err != nil {
return err
}
Expand All @@ -471,7 +477,7 @@ func (c *CStorPoolController) addPoolProtectionFinalizer(
cspObj, err := c.clientset.
OpenebsV1alpha1().
CStorPools().
Update(cStorPool)
Update(context.TODO(), cStorPool, metav1.UpdateOptions{})
if err != nil {
return nil, errors.Wrapf(
err,
Expand Down Expand Up @@ -692,7 +698,8 @@ func (c *CStorPoolController) reconcileVersion(csp *apis.CStorPool) (*apis.CStor
cspObj := csp.DeepCopy()
if csp.VersionDetails.Status.State != apis.ReconcileInProgress {
cspObj.VersionDetails.Status.SetInProgressStatus()
cspObj, err = c.clientset.OpenebsV1alpha1().CStorPools().Update(cspObj)
cspObj, err = c.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cspObj, metav1.UpdateOptions{})
if err != nil {
return csp, err
}
Expand All @@ -713,7 +720,8 @@ func (c *CStorPoolController) reconcileVersion(csp *apis.CStorPool) (*apis.CStor
}
csp = cspObj.DeepCopy()
cspObj.VersionDetails.SetSuccessStatus()
cspObj, err = c.clientset.OpenebsV1alpha1().CStorPools().Update(cspObj)
cspObj, err = c.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cspObj, metav1.UpdateOptions{})
if err != nil {
return csp, errors.Wrap(err, "failed to update csp with versionDetails")
}
Expand All @@ -734,7 +742,7 @@ func (c *CStorPoolController) populateVersion(csp *apis.CStorPool) (
cspObj.VersionDetails.Status.Current = v
cspObj.VersionDetails.Desired = v
cspObj, err = c.clientset.OpenebsV1alpha1().CStorPools().
Update(cspObj)
Update(context.TODO(), cspObj, metav1.UpdateOptions{})

if err != nil {
return csp, errors.Wrap(err, "failed to update csp while adding versiondetails")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
package poolcontroller

import (
"context"
"os"
"testing"
"time"
Expand Down Expand Up @@ -107,7 +108,8 @@ func TestGetPoolResource(t *testing.T) {
}
for desc, ut := range testPoolResource {
// Create Pool resource
_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().Create(ut.test)
_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().
Create(context.TODO(), ut.test, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Desc:%v, Unable to create resource : %v", desc, ut.test.ObjectMeta.Name)
}
Expand Down Expand Up @@ -158,7 +160,8 @@ func TestRemoveFinalizer(t *testing.T) {
}
for desc, ut := range testPoolResource {
// Create Pool resource
_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().Create(ut.test)
_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().
Create(context.TODO(), ut.test, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Desc:%v, Unable to create resource : %v", desc, ut.test.ObjectMeta.Name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ limitations under the License.
package poolcontroller

import (
"context"
"fmt"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/runtime"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -128,7 +130,8 @@ func NewCStorPoolController(
cStorPool.Status.Phase = apis.CStorPoolStatusPending
}

cStorPool, _ = controller.clientset.OpenebsV1alpha1().CStorPools().Update(cStorPool)
cStorPool, _ = controller.clientset.OpenebsV1alpha1().CStorPools().
Update(context.TODO(), cStorPool, v1.UpdateOptions{})
controller.enqueueCStorPool(cStorPool, q)
},
UpdateFunc: func(old, new interface{}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
package poolcontroller

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -96,7 +97,8 @@ func TestProcessNextWorkItemModify(t *testing.T) {
},
}

_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().Create(testPoolResource["img2PoolResource"].test)
_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().
Create(context.TODO(), testPoolResource["img2PoolResource"].test, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Unable to create resource : %v", testPoolResource["img2PoolResource"].test.ObjectMeta.Name)
}
Expand Down Expand Up @@ -150,7 +152,8 @@ func TestProcessNextWorkItemDestroy(t *testing.T) {
},
}

_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().Create(testPoolResource["img2PoolResource"].test)
_, err := poolController.clientset.OpenebsV1alpha1().CStorPools().
Create(context.TODO(), testPoolResource["img2PoolResource"].test, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Unable to create resource : %v", testPoolResource["img2PoolResource"].test.ObjectMeta.Name)
}
Expand Down
23 changes: 14 additions & 9 deletions cmd/cstor-pool-mgmt/controller/replica-controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package replicacontroller

import (
"context"
"encoding/json"
"fmt"
"os"
Expand Down Expand Up @@ -125,7 +126,8 @@ func (c *CStorVolumeReplicaController) syncHandler(
err,
)
_, err = c.clientset.OpenebsV1alpha1().
CStorVolumeReplicas(cvrGot.Namespace).Update(cvrGot)
CStorVolumeReplicas(cvrGot.Namespace).
Update(context.TODO(), cvrGot, metav1.UpdateOptions{})
if err != nil {
klog.Errorf("failed to update versionDetails status for cvr %s:%s", cvrGot.Name, err.Error())
}
Expand Down Expand Up @@ -165,7 +167,7 @@ func (c *CStorVolumeReplicaController) syncHandler(
_, err1 := c.clientset.
OpenebsV1alpha1().
CStorVolumeReplicas(cvrGot.Namespace).
Update(cvrGot)
Update(context.TODO(), cvrGot, metav1.UpdateOptions{})
if err1 != nil {
return errors.Wrapf(
err,
Expand Down Expand Up @@ -194,7 +196,7 @@ func (c *CStorVolumeReplicaController) syncHandler(
_, err = c.clientset.
OpenebsV1alpha1().
CStorVolumeReplicas(cvrGot.Namespace).
Update(cvrGot)
Update(context.TODO(), cvrGot, metav1.UpdateOptions{})
if err != nil {
return errors.Wrapf(
err,
Expand Down Expand Up @@ -347,7 +349,7 @@ func (c *CStorVolumeReplicaController) removeFinalizer(
_, err = c.clientset.
OpenebsV1alpha1().
CStorVolumeReplicas(cvrObj.Namespace).
Patch(cvrObj.Name, types.JSONPatchType, cvrPatchBytes)
Patch(context.TODO(), cvrObj.Name, types.JSONPatchType, cvrPatchBytes, metav1.PatchOptions{})
if err != nil {
return errors.Wrapf(
err,
Expand Down Expand Up @@ -518,7 +520,7 @@ func (c *CStorVolumeReplicaController) getVolumeReplicaResource(

cStorVolumeReplicaUpdated, err := c.clientset.OpenebsV1alpha1().
CStorVolumeReplicas(namespace).
Get(name, metav1.GetOptions{})
Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
// The cStorPool resource may no longer exist, in which case we stop
// processing.
Expand Down Expand Up @@ -703,7 +705,8 @@ func (c *CStorVolumeReplicaController) reconcileVersion(cvr *apis.CStorVolumeRep
if cvrObj.VersionDetails.Status.State != apis.ReconcileInProgress {
cvrObj.VersionDetails.Status.SetInProgressStatus()
cvrObj, err = c.clientset.OpenebsV1alpha1().
CStorVolumeReplicas(cvrObj.Namespace).Update(cvrObj)
CStorVolumeReplicas(cvrObj.Namespace).
Update(context.TODO(), cvrObj, metav1.UpdateOptions{})
if err != nil {
return cvr, err
}
Expand All @@ -725,7 +728,8 @@ func (c *CStorVolumeReplicaController) reconcileVersion(cvr *apis.CStorVolumeRep
cvr = cvrObj.DeepCopy()
cvrObj.VersionDetails.SetSuccessStatus()
cvrObj, err = c.clientset.OpenebsV1alpha1().
CStorVolumeReplicas(cvrObj.Namespace).Update(cvrObj)
CStorVolumeReplicas(cvrObj.Namespace).
Update(context.TODO(), cvrObj, metav1.UpdateOptions{})
if err != nil {
return cvr, err
}
Expand All @@ -745,7 +749,7 @@ func (c *CStorVolumeReplicaController) populateVersion(cvr *apis.CStorVolumeRepl
cvrObj.VersionDetails.Status.Current = v
cvrObj.VersionDetails.Desired = v
cvrObj, err := c.clientset.OpenebsV1alpha1().CStorVolumeReplicas(cvrObj.Namespace).
Update(cvrObj)
Update(context.TODO(), cvrObj, metav1.UpdateOptions{})

if err != nil {
return cvr, err
Expand All @@ -766,7 +770,8 @@ func setReplicaID(u *upgradeParams) (*apis.CStorVolumeReplica, error) {
return cvr, err
}
cvrObj, err = u.client.OpenebsV1alpha1().
CStorVolumeReplicas(cvrObj.Namespace).Update(cvrObj)
CStorVolumeReplicas(cvrObj.Namespace).
Update(context.TODO(), cvrObj, metav1.UpdateOptions{})
if err != nil {
return cvr, err
}
Expand Down
Loading

0 comments on commit 5c43ada

Please sign in to comment.