Merge pull request #9406 from rook/mergify/bp/release-1.8/pr-9394

core: add context parameter to k8sutil configMap (backport #9394)
This commit is contained in:
mergify[bot] authored and GitHub committed 2021-12-13 09:42:17 +00:00
commit a0fa8aa931
3 files changed
+4 -5

No files matched your search

@@ -155,7 +155,7 @@ func (cr *CmdReporter) Run(ctx context.Context, timeout time.Duration) (stdout,
delOpts.Wait = true
delOpts.ErrorOnTimeout = true
// configmap's name will be the same as the app
err := k8sutil.DeleteConfigMap(cr.clientset, jobName, namespace, delOpts)
err := k8sutil.DeleteConfigMap(ctx, cr.clientset, jobName, namespace, delOpts)
if err != nil {
return "", "", -1, fmt.Errorf("%s. failed to delete existing results ConfigMap %s. %+v", errMsg, jobName, err)
}
@@ -180,7 +180,7 @@ func (cr *CmdReporter) Run(ctx context.Context, timeout time.Duration) (stdout,
// just to be explicit: delete idempotently, and don't wait for delete to complete
delOpts = &k8sutil.DeleteOptions{MustDelete: false, WaitOptions: k8sutil.WaitOptions{Wait: false}}
if err := k8sutil.DeleteConfigMap(cr.clientset, jobName, namespace, delOpts); err != nil {
if err := k8sutil.DeleteConfigMap(ctx, cr.clientset, jobName, namespace, delOpts); err != nil {
logger.Errorf("continuing after failing to delete ConfigMap %s for job %s; user may need to delete it manually. %+v",
jobName, jobName, err)
}
+1 -2
View File
@@ -28,8 +28,7 @@ import (
)
// DeleteConfigMap deletes a ConfigMap.
func DeleteConfigMap(clientset kubernetes.Interface, cmName, namespace string, opts *DeleteOptions) error {
ctx := context.TODO()
func DeleteConfigMap(ctx context.Context, clientset kubernetes.Interface, cmName, namespace string, opts *DeleteOptions) error {
k8sOpts := BaseKubernetesDeleteOptions()
delete := func() error { return clientset.CoreV1().ConfigMaps(namespace).Delete(ctx, cmName, *k8sOpts) }
verify := func() error {
+1 -1
View File
@@ -51,7 +51,7 @@ func TestDeleteConfigMap(t *testing.T) {
opts := &DeleteOptions{}
opts.Wait = true
opts.ErrorOnTimeout = true
err = DeleteConfigMap(k8s, "test-configmap", "test-namespace", opts)
err = DeleteConfigMap(ctx, k8s, "test-configmap", "test-namespace", opts)
assert.NoError(t, err)
_, err = k8s.CoreV1().ConfigMaps("test-namespace").Get(ctx, "test-configmap", metav1.GetOptions{})