core: add context to k8sutil replicaset and secret
This commit adds context parameter to k8sutil replicaset and secret functions. By this, we can handle cancellation during API call of replicaset and secret resource. Signed-off-by: Yuichiro Ueno <y1r.ueno@gmail.com>
This commit is contained in:
1 parent
3309e9a3ee
commit
b6ce262e7f
3 files changed
+3
-5
No files matched your search
@@ -107,7 +107,7 @@ func CreateBootstrapPeerSecret(ctx *clusterd.Context, clusterInfo *cephclient.Cl
|
||||
|
||||
// Create Secret
|
||||
logger.Debugf("store %s-mirror bootstrap token in a Kubernetes Secret %q in namespace %q", daemonType, s.Name, ns)
|
||||
_, err = k8sutil.CreateOrUpdateSecret(ctx.Clientset, s)
|
||||
_, err = k8sutil.CreateOrUpdateSecret(clusterInfo.Context, ctx.Clientset, s)
|
||||
if err != nil && !kerrors.IsAlreadyExists(err) {
|
||||
return ImmediateRetryResult, errors.Wrapf(err, "failed to create %s-mirror bootstrap peer %q secret", daemonType, s.Name)
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ import (
|
||||
)
|
||||
|
||||
// DeleteReplicaSet makes a best effort at deleting a deployment and its pods, then waits for them to be deleted
|
||||
func DeleteReplicaSet(clientset kubernetes.Interface, namespace, name string) error {
|
||||
ctx := context.TODO()
|
||||
func DeleteReplicaSet(ctx context.Context, clientset kubernetes.Interface, namespace, name string) error {
|
||||
deleteAction := func(options *metav1.DeleteOptions) error {
|
||||
return clientset.AppsV1().ReplicaSets(namespace).Delete(ctx, name, *options)
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ import (
|
||||
)
|
||||
|
||||
// CreateOrUpdateSecret creates a secret or updates the secret declaratively if it already exists.
|
||||
func CreateOrUpdateSecret(clientset kubernetes.Interface, secretDefinition *v1.Secret) (*v1.Secret, error) {
|
||||
ctx := context.TODO()
|
||||
func CreateOrUpdateSecret(ctx context.Context, clientset kubernetes.Interface, secretDefinition *v1.Secret) (*v1.Secret, error) {
|
||||
name := secretDefinition.Name
|
||||
logger.Debugf("creating secret %s", name)
|
||||
|
||||
|
||||
Reference in new issue
Block a user