Repository: kubermatic/machine-controller
Pull request #1294 (2022-05-17 14:05:04)

Contexts, contexts everywhere.
**What this PR does / why we need it**:
This PR gets rid of the maaaaany TODO/Background contexts and instead just properly injects them everywhere. It also removes the custom signals package, since this has been part of controller-runtime for quite some time now.

**Optional Release Note**:
```release-note
NONE
```


kubermatic-bot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubermatic/machine-controller/pull/1294#" title="Author self-approved">xrstf</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **ahmedwaleedmalik** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @ahmedwaleedmalik` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubermatic%2Fmachine-controller).

<details open>
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubermatic/machine-controller/blob/master/OWNERS)~~ [xrstf]
- **[pkg/cloudprovider/provider/OWNERS](https://github.com/kubermatic/machine-controller/blob/master/pkg/cloudprovider/provider/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["ahmedwaleedmalik"]} -->
kubermatic-bot: @xrstf: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-machine-controller-e2e-nutanix | fcdad9e312a528fcabd6ab193faa459f0398057a | [link](https://public-prow.loodse.com/view/gs/prow-dev-public-data/pr-logs/pull/kubermatic_machine-controller/1294/pull-machine-controller-e2e-nutanix/1526564481063194624) | false | `/test pull-machine-controller-e2e-nutanix`

[Full PR test history](https://public-prow.loodse.com/pr-history?org=kubermatic&repo=machine-controller&pr=1294)

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
xrstf: @ahmedwaleedmalik I had fun. :p
kubermatic-bot: @xrstf: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-machine-controller-e2e-azure-custom-image-reference | fcdad9e312a528fcabd6ab193faa459f0398057a | [link](https://public-prow.loodse.com/view/gs/prow-dev-public-data/pr-logs/pull/kubermatic_machine-controller/1294/pull-machine-controller-e2e-azure-custom-image-reference/1526564476021641216) | true | `/test pull-machine-controller-e2e-azure-custom-image-reference`
pull-machine-controller-e2e-equinix-metal | fcdad9e312a528fcabd6ab193faa459f0398057a | [link](https://public-prow.loodse.com/view/gs/prow-dev-public-data/pr-logs/pull/kubermatic_machine-controller/1294/pull-machine-controller-e2e-equinix-metal/1526564477703557120) | false | `/test pull-machine-controller-e2e-equinix-metal`
pull-machine-controller-e2e-nutanix | c123f316a9f2b78c650924a8531076ddd1ab12a3 | [link](https://public-prow.loodse.com/view/gs/prow-dev-public-data/pr-logs/pull/kubermatic_machine-controller/1294/pull-machine-controller-e2e-nutanix/1526842974040756224) | false | `/test pull-machine-controller-e2e-nutanix`

[Full PR test history](https://public-prow.loodse.com/pr-history?org=kubermatic&repo=machine-controller&pr=1294)

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
kubermatic-bot: LGTM label has been added.  <details>Git tree hash: 5bfcf9e1dcb94ed19170e52b372532caa64059a2</details>
kubermatic-bot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubermatic/machine-controller/pull/1294#pullrequestreview-976625456" title="Approved">ahmedwaleedmalik</a>*, *<a href="https://github.com/kubermatic/machine-controller/pull/1294#" title="Author self-approved">xrstf</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubermatic%2Fmachine-controller).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubermatic/machine-controller/blob/master/OWNERS)~~ [ahmedwaleedmalik,xrstf]
- ~~[pkg/cloudprovider/provider/OWNERS](https://github.com/kubermatic/machine-controller/blob/master/pkg/cloudprovider/provider/OWNERS)~~ [ahmedwaleedmalik]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/cmd/machine-controller/main.go b/cmd/machine-controller/main.go
index 20b6b205..6b946b34 100644
--- a/cmd/machine-controller/main.go
+++ b/cmd/machine-controller/main.go
@@ -41,7 +41,6 @@ import (
 	"github.com/kubermatic/machine-controller/pkg/health"
 	machinesv1alpha1 "github.com/kubermatic/machine-controller/pkg/machines/v1alpha1"
 	"github.com/kubermatic/machine-controller/pkg/node"
-	"github.com/kubermatic/machine-controller/pkg/signals"
 	osmv1alpha1 "k8c.io/operating-system-manager/pkg/crd/osm/v1alpha1"
 
 	apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -53,6 +52,7 @@ import (
 	"k8s.io/klog"
 	"sigs.k8s.io/controller-runtime/pkg/healthz"
 	"sigs.k8s.io/controller-runtime/pkg/manager"
+	"sigs.k8s.io/controller-runtime/pkg/manager/signals"
 	"sigs.k8s.io/controller-runtime/pkg/metrics"
 )
 
@@ -282,13 +282,10 @@ func main() {
 		runOptions.bootstrapTokenServiceAccountName = &types.NamespacedName{Namespace: flagParts[0], Name: flagParts[1]}
 	}
 
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-	signalCh := signals.SetupSignalHandler()
+	ctx := signals.SetupSignalHandler()
 	go func() {
-		<-signalCh
+		<-ctx.Done()
 		klog.Info("caught signal, shutting down...")
-		cancel()
 	}()
 
 	mgr, err := createManager(5*time.Minute, runOptions)
diff --git a/pkg/admission/machines.go b/pkg/admission/machines.go
index d317ef61..978dd5d9 100644
--- a/pkg/admission/machines.go
+++ b/pkg/admission/machines.go
@@ -165,7 +165,7 @@ func (ad *admissionData) defaultAndValidateMachineSpec(ctx context.Context, spec
 	}
 	spec = &defaultedSpec
 
-	if err := prov.Validate(*spec); err != nil {
+	if err := prov.Validate(ctx, *spec); err != nil {
 		return fmt.Errorf("validation failed: %w", err)
 	}
 
diff --git a/pkg/apis/cluster/v1alpha1/migrations/migrations.go b/pkg/apis/cluster/v1alpha1/migrations/migrations.go
index b2696588..0d1f712f 100644
--- a/pkg/apis/cluster/v1alpha1/migrations/migrations.go
+++ b/pkg/apis/cluster/v1alpha1/migrations/migrations.go
@@ -293,13 +293,13 @@ func migrateMachines(ctx context.Context, client ctrlruntimeclient.Client, kubeC
 			klog.Infof("Attempting to update the UID at the cloud provider for machine.cluster.k8s.io/v1alpha1 %s", machinesV1Alpha1Machine.Name)
 			newMachineWithOldUID := finalClusterV1Alpha1Machine.DeepCopy()
 			newMachineWithOldUID.UID = machinesV1Alpha1Machine.UID
-			if err := prov.MigrateUID(newMachineWithOldUID, finalClusterV1Alpha1Machine.UID); err != nil {
+			if err := prov.MigrateUID(ctx, newMachineWithOldUID, finalClusterV1Alpha1Machine.UID); err != nil {
 				return fmt.Errorf("running the provider migration for the UID failed: %w", err)
 			}
 			// Block until we can actually GET the instance with the new UID
 			var isMigrated bool
 			for i := 0; i < 100; i++ {
-				if _, err := prov.Get(finalClusterV1Alpha1Machine, providerData); err == nil {
+				if _, err := prov.Get(ctx, finalClusterV1Alpha1Machine, providerData); err == nil {
 					isMigrated = true
 					break
 				}
diff --git a/pkg/cloudprovider/provider/alibaba/provider.go b/pkg/cloudprovider/provider/alibaba/provider.go
index 33201c3b..64cd3339 100644
--- a/pkg/cloudprovider/provider/alibaba/provider.go
+++ b/pkg/cloudprovider/provider/alibaba/provider.go
@@ -17,6 +17,7 @@ limitations under the License.
 package alibaba
 
 import (
+	"context"
 	"encoding/base64"
 	"errors"
 	"fmt"
@@ -107,7 +108,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Validate(machineSpec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, machineSpec clusterv1alpha1.MachineSpec) error {
 	c, pc, err := p.getConfig(machineSpec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -148,7 +149,7 @@ func (p *provider) Validate(machineSpec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -197,7 +198,7 @@ func (p *provider) GetCloudConfig(spec clusterv1alpha1.MachineSpec) (config stri
 	return "", "", nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -257,8 +258,8 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &alibabaInstance{instance: foundInstance}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
-	foundInstance, err := p.Get(machine, data)
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+	foundInstance, err := p.Get(ctx, machine, data)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return util.RemoveFinalizerOnInstanceNotFound(finalizerInstance, machine, data)
@@ -302,7 +303,7 @@ func (p *provider) MachineMetricsLabels(machine *clusterv1alpha1.Machine) (map[s
 	return labels, err
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to decode providerconfig: %w", err)
diff --git a/pkg/cloudprovider/provider/anexia/provider.go b/pkg/cloudprovider/provider/anexia/provider.go
index fca8ea5e..337389fa 100644
--- a/pkg/cloudprovider/provider/anexia/provider.go
+++ b/pkg/cloudprovider/provider/anexia/provider.go
@@ -58,7 +58,7 @@ type provider struct {
 	configVarResolver *providerconfig.ConfigVarResolver
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance instance.Instance, retErr error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance instance.Instance, retErr error) {
 	status := getProviderStatus(machine)
 	klog.V(3).Infof(fmt.Sprintf("'%s' has status %#v", machine.Name, status))
 
@@ -70,7 +70,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		return nil, fmt.Errorf("unable to get provider config: %w", err)
 	}
 
-	ctx := utils.CreateReconcileContext(utils.ReconcileContext{
+	ctx = utils.CreateReconcileContext(ctx, utils.ReconcileContext{
 		Status:       &status,
 		UserData:     userdata,
 		Config:       config,
@@ -96,7 +96,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		if err != nil {
 			return nil, err
 		}
-		return p.Get(machine, data)
+		return p.Get(ctx, machine, data)
 	}
 
 	// provision machine
@@ -104,7 +104,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	if err != nil {
 		return nil, err
 	}
-	return p.Get(machine, data)
+	return p.Get(ctx, machine, data)
 }
 
 func waitForVM(ctx context.Context, client anxclient.Client) error {
@@ -335,7 +335,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 }
 
 // Validate returns success or failure based according to its ProviderSpec.
-func (p *provider) Validate(machinespec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, machinespec clusterv1alpha1.MachineSpec) error {
 	config, _, err := p.getConfig(machinespec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -372,7 +372,7 @@ func (p *provider) Validate(machinespec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	config, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, newError(common.InvalidConfigurationMachineError, "failed to parse MachineSpec: %v", err)
@@ -392,10 +392,10 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 		return nil, cloudprovidererrors.ErrInstanceNotFound
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), anxtypes.GetRequestTimeout)
+	timeoutCtx, cancel := context.WithTimeout(ctx, anxtypes.GetRequestTimeout)
 	defer cancel()
 
-	info, err := vsphereAPI.Info().Get(ctx, status.InstanceID)
+	info, err := vsphereAPI.Info().Get(timeoutCtx, status.InstanceID)
 	if err != nil {
 		return nil, fmt.Errorf("failed get machine info: %w", err)
 	}
@@ -409,7 +409,7 @@ func (p *provider) GetCloudConfig(_ clusterv1alpha1.MachineSpec) (string, string
 	return "", "", nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (isDeleted bool, retErr error) {
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (isDeleted bool, retErr error) {
 	status := getProviderStatus(machine)
 	// make sure status is reflected in Machine Object
 	defer func() {
@@ -433,12 +433,12 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 		return false, newError(common.InvalidConfigurationMachineError, "failed to get machine status: %v", err)
 	}
 
-	ctx, cancel := context.WithTimeout(context.Background(), anxtypes.DeleteRequestTimeout)
+	deleteCtx, cancel := context.WithTimeout(ctx, anxtypes.DeleteRequestTimeout)
 	defer cancel()
 
 	// first check whether there is an provisioning ongoing
 	if status.DeprovisioningID == "" {
-		response, err := vsphereAPI.Provisioning().VM().Deprovision(ctx, status.InstanceID, false)
+		response, err := vsphereAPI.Provisioning().VM().Deprovision(deleteCtx, status.InstanceID, false)
 		if err != nil {
 			var respErr *anxclient.ResponseError
 			// Only error if the error was not "not found"
@@ -449,7 +449,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 		status.DeprovisioningID = response.Identifier
 	}
 
-	return isTaskDone(ctx, cli, status.DeprovisioningID)
+	return isTaskDone(deleteCtx, cli, status.DeprovisioningID)
 }
 
 func isTaskDone(ctx context.Context, cli anxclient.Client, progressIdentifier string) (bool, error) {
@@ -470,7 +470,7 @@ func isTaskDone(ctx context.Context, cli anxclient.Client, progressIdentifier st
 	return false, nil
 }
 
-func (p *provider) MigrateUID(_ *clusterv1alpha1.Machine, _ k8stypes.UID) error {
+func (p *provider) MigrateUID(_ context.Context, _ *clusterv1alpha1.Machine, _ k8stypes.UID) error {
 	return nil
 }
 
diff --git a/pkg/cloudprovider/provider/anexia/utils/utils.go b/pkg/cloudprovider/provider/anexia/utils/utils.go
index 97aa73d5..51a2a549 100644
--- a/pkg/cloudprovider/provider/anexia/utils/utils.go
+++ b/pkg/cloudprovider/provider/anexia/utils/utils.go
@@ -36,8 +36,8 @@ type ReconcileContext struct {
 	ProviderData *cloudprovidertypes.ProviderData
 }
 
-func CreateReconcileContext(cc ReconcileContext) context.Context {
-	return context.WithValue(context.Background(), MachineReconcileContextKey, cc)
+func CreateReconcileContext(ctx context.Context, cc ReconcileContext) context.Context {
+	return context.WithValue(ctx, MachineReconcileContextKey, cc)
 }
 
 func GetReconcileContext(ctx context.Context) ReconcileContext {
diff --git a/pkg/cloudprovider/provider/aws/provider.go b/pkg/cloudprovider/provider/aws/provider.go
index fc2592c1..e9911e57 100644
--- a/pkg/cloudprovider/provider/aws/provider.go
+++ b/pkg/cloudprovider/provider/aws/provider.go
@@ -17,6 +17,7 @@ limitations under the License.
 package aws
 
 import (
+	"context"
 	"encoding/base64"
 	"encoding/json"
 	"errors"
@@ -572,7 +573,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, err
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, spec clusterv1alpha1.MachineSpec) error {
 	config, pc, _, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -684,7 +685,7 @@ func getVpc(client *ec2.EC2, id string) (*ec2.Vpc, error) {
 	return vpcOut.Vpcs[0], nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	config, pc, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -836,7 +837,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &awsInstance{instance: runOut.Instances[0]}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(_ context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
 	ec2instance, err := p.get(machine)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
@@ -889,7 +890,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertyp
 	return false, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	return p.get(machine)
 }
 
@@ -976,7 +977,7 @@ func (p *provider) MachineMetricsLabels(machine *clusterv1alpha1.Machine) (map[s
 	return labels, err
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	machineInstance, err := p.get(machine)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
diff --git a/pkg/cloudprovider/provider/azure/provider.go b/pkg/cloudprovider/provider/azure/provider.go
index beaf5a9d..3313d3ae 100644
--- a/pkg/cloudprovider/provider/azure/provider.go
+++ b/pkg/cloudprovider/provider/azure/provider.go
@@ -548,7 +548,7 @@ func getStorageProfile(config *config, providerCfg *providerconfigtypes.Config)
 	return sp, nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	config, providerCfg, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -589,13 +589,13 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		}); err != nil {
 			return nil, err
 		}
-		publicIP, err = createOrUpdatePublicIPAddress(context.TODO(), publicIPName(ifaceName(machine)), network.IPVersionIPv4, sku, network.IPAllocationMethodStatic, machine.UID, config)
+		publicIP, err = createOrUpdatePublicIPAddress(ctx, publicIPName(ifaceName(machine)), network.IPVersionIPv4, sku, network.IPAllocationMethodStatic, machine.UID, config)
 		if err != nil {
 			return nil, fmt.Errorf("failed to create public IP: %w", err)
 		}
 
 		if ipFamily == util.DualStack {
-			publicIPv6, err = createOrUpdatePublicIPAddress(context.TODO(), publicIPv6Name(ifaceName(machine)), network.IPVersionIPv6, sku, network.IPAllocationMethodStatic, machine.UID, config)
+			publicIPv6, err = createOrUpdatePublicIPAddress(ctx, publicIPv6Name(ifaceName(machine)), network.IPVersionIPv6, sku, network.IPAllocationMethodStatic, machine.UID, config)
 			if err != nil {
 				return nil, fmt.Errorf("failed to create public IP: %w", err)
 			}
@@ -610,7 +610,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		return nil, err
 	}
 
-	iface, err := createOrUpdateNetworkInterface(context.TODO(), ifaceName(machine), machine.UID, config, publicIP, publicIPv6, ipFamily)
+	iface, err := createOrUpdateNetworkInterface(ctx, ifaceName(machine), machine.UID, config, publicIP, publicIPv6, ipFamily)
 	if err != nil {
 		return nil, fmt.Errorf("failed to generate main network interface: %w", err)
 	}
@@ -686,12 +686,12 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		return nil, err
 	}
 
-	future, err := vmClient.CreateOrUpdate(context.TODO(), config.ResourceGroup, machine.Name, vmSpec)
+	future, err := vmClient.CreateOrUpdate(ctx, config.ResourceGroup, machine.Name, vmSpec)
 	if err != nil {
 		return nil, fmt.Errorf("trying to create a VM: %w", err)
 	}
 
-	err = future.WaitForCompletionRef(context.TODO(), vmClient.Client)
+	err = future.WaitForCompletionRef(ctx, vmClient.Client)
 	if err != nil {
 		return nil, fmt.Errorf("waiting for operation returned: %w", err)
 	}
@@ -702,17 +702,17 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	}
 
 	// get the actual VM object filled in with additional data
-	vm, err = vmClient.Get(context.TODO(), config.ResourceGroup, machine.Name, "")
+	vm, err = vmClient.Get(ctx, config.ResourceGroup, machine.Name, "")
 	if err != nil {
 		return nil, fmt.Errorf("failed to retrieve updated data for VM %q: %w", machine.Name, err)
 	}
 
-	ipAddresses, err := getVMIPAddresses(context.TODO(), config, &vm)
+	ipAddresses, err := getVMIPAddresses(ctx, config, &vm)
 	if err != nil {
 		return nil, fmt.Errorf("failed to retrieve IP addresses for VM %q: %w", machine.Name, err)
 	}
 
-	status, err := getVMStatus(context.TODO(), config, machine.Name)
+	status, err := getVMStatus(ctx, config, machine.Name)
 	if err != nil {
 		return nil, fmt.Errorf("failed to retrieve status for VM %q: %w", machine.Name, err)
 	}
@@ -720,7 +720,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &azureVM{vm: &vm, ipAddresses: ipAddresses, status: status}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
 	config, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return false, fmt.Errorf("failed to parse MachineSpec: %w", err)
@@ -728,7 +728,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 
 	if kuberneteshelper.HasFinalizer(machine, finalizerVM) {
 		klog.Infof("deleting VM %q", machine.Name)
-		if err = deleteVMsByMachineUID(context.TODO(), config, machine.UID); err != nil {
+		if err = deleteVMsByMachineUID(ctx, config, machine.UID); err != nil {
 			return false, fmt.Errorf("failed to delete instance for  machine %q: %w", machine.Name, err)
 		}
 
@@ -741,7 +741,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 
 	if kuberneteshelper.HasFinalizer(machine, finalizerDisks) {
 		klog.Infof("deleting disks of VM %q", machine.Name)
-		if err := deleteDisksByMachineUID(context.TODO(), config, machine.UID); err != nil {
+		if err := deleteDisksByMachineUID(ctx, config, machine.UID); err != nil {
 			return false, fmt.Errorf("failed to remove disks of machine %q: %w", machine.Name, err)
 		}
 		if err := data.Update(machine, func(updatedMachine *clusterv1alpha1.Machine) {
@@ -753,7 +753,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 
 	if kuberneteshelper.HasFinalizer(machine, finalizerNIC) {
 		klog.Infof("deleting network interfaces of VM %q", machine.Name)
-		if err := deleteInterfacesByMachineUID(context.TODO(), config, machine.UID); err != nil {
+		if err := deleteInterfacesByMachineUID(ctx, config, machine.UID); err != nil {
 			return false, fmt.Errorf("failed to remove network interfaces of machine %q: %w", machine.Name, err)
 		}
 		if err := data.Update(machine, func(updatedMachine *clusterv1alpha1.Machine) {
@@ -765,7 +765,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 
 	if kuberneteshelper.HasFinalizer(machine, finalizerPublicIP) {
 		klog.Infof("deleting public IP addresses of VM %q", machine.Name)
-		if err := deleteIPAddressesByMachineUID(context.TODO(), config, machine.UID); err != nil {
+		if err := deleteIPAddressesByMachineUID(ctx, config, machine.UID); err != nil {
 			return false, fmt.Errorf("failed to remove public IP addresses of machine %q: %w", machine.Name, err)
 		}
 		if err := data.Update(machine, func(updatedMachine *clusterv1alpha1.Machine) {
@@ -862,17 +862,17 @@ func getVMStatus(ctx context.Context, c *config, vmName string) (instance.Status
 	}
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
-	return p.get(machine)
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+	return p.get(ctx, machine)
 }
 
-func (p *provider) get(machine *clusterv1alpha1.Machine) (*azureVM, error) {
+func (p *provider) get(ctx context.Context, machine *clusterv1alpha1.Machine) (*azureVM, error) {
 	config, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, fmt.Errorf("failed to parse MachineSpec: %w", err)
 	}
 
-	vm, err := getVMByUID(context.TODO(), config, machine.UID)
+	vm, err := getVMByUID(ctx, config, machine.UID)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return nil, cloudprovidererrors.ErrInstanceNotFound
@@ -881,12 +881,12 @@ func (p *provider) get(machine *clusterv1alpha1.Machine) (*azureVM, error) {
 		return nil, fmt.Errorf("failed to find machine %q by its UID: %w", machine.UID, err)
 	}
 
-	ipAddresses, err := getVMIPAddresses(context.TODO(), config, vm)
+	ipAddresses, err := getVMIPAddresses(ctx, config, vm)
 	if err != nil {
 		return nil, fmt.Errorf("failed to retrieve IP addresses for VM %v: %w", vm.Name, err)
 	}
 
-	status, err := getVMStatus(context.TODO(), config, machine.Name)
+	status, err := getVMStatus(ctx, config, machine.Name)
 	if err != nil {
 		return nil, fmt.Errorf("failed to retrieve status for VM %v: %w", vm.Name, err)
 	}
@@ -932,9 +932,9 @@ func (p *provider) GetCloudConfig(spec clusterv1alpha1.MachineSpec) (config stri
 	return s, "azure", nil
 }
 
-func validateDiskSKUs(c *config) error {
+func validateDiskSKUs(ctx context.Context, c *config) error {
 	if c.OSDiskSKU != nil || c.DataDiskSKU != nil {
-		sku, err := getSKU(context.TODO(), c)
+		sku, err := getSKU(ctx, c)
 		if err != nil {
 			return fmt.Errorf("failed to get VM SKU: %w", err)
 		}
@@ -969,7 +969,7 @@ func validateDiskSKUs(c *config) error {
 	return nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, providerConfig, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -1023,20 +1023,20 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 		return fmt.Errorf("failed to (create) vm client: %w", err)
 	}
 
-	_, err = vmClient.List(context.TODO(), c.ResourceGroup, "")
+	_, err = vmClient.List(ctx, c.ResourceGroup, "")
 	if err != nil {
 		return fmt.Errorf("failed to list virtual machines: %w", err)
 	}
 
-	if _, err := getVirtualNetwork(context.TODO(), c); err != nil {
+	if _, err := getVirtualNetwork(ctx, c); err != nil {
 		return fmt.Errorf("failed to get virtual network: %w", err)
 	}
 
-	if _, err := getSubnet(context.TODO(), c); err != nil {
+	if _, err := getSubnet(ctx, c); err != nil {
 		return fmt.Errorf("failed to get subnet: %w", err)
 	}
 
-	if err := validateDiskSKUs(c); err != nil {
+	if err := validateDiskSKUs(ctx, c); err != nil {
 		return fmt.Errorf("failed to validate disk SKUs: %w", err)
 	}
 
@@ -1056,10 +1056,7 @@ func publicIPv6Name(ifaceName string) string {
 	return ifaceName + "-pubipv6"
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-
+func (p *provider) MigrateUID(ctx context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	config, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return cloudprovidererrors.TerminalError{
diff --git a/pkg/cloudprovider/provider/baremetal/provider.go b/pkg/cloudprovider/provider/baremetal/provider.go
index 0ae28cff..e62e757f 100644
--- a/pkg/cloudprovider/provider/baremetal/provider.go
+++ b/pkg/cloudprovider/provider/baremetal/provider.go
@@ -166,7 +166,7 @@ func (p provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha1
 	return spec, err
 }
 
-func (p provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p provider) Validate(_ context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, _, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -183,7 +183,7 @@ func (p provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -192,7 +192,7 @@ func (p provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.Pr
 		}
 	}
 
-	server, err := c.driver.GetServer(context.Background(), machine.UID, c.driverSpec)
+	server, err := c.driver.GetServer(ctx, machine.UID, c.driverSpec)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return nil, cloudprovidererrors.ErrInstanceNotFound
@@ -206,11 +206,11 @@ func (p provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.Pr
 	}, nil
 }
 
-func (p provider) GetCloudConfig(spec clusterv1alpha1.MachineSpec) (config string, name string, err error) {
+func (p provider) GetCloudConfig(_ clusterv1alpha1.MachineSpec) (config string, name string, err error) {
 	return "", "", nil
 }
 
-func (p provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -219,7 +219,6 @@ func (p provider) Create(machine *clusterv1alpha1.Machine, data *cloudproviderty
 		}
 	}
 
-	ctx := context.Background()
 	if err := util.CreateMachineCloudInitSecret(ctx, userdata, machine.Name, data.Client); err != nil {
 		return nil, fmt.Errorf("failed to create cloud-init secret for machine %s: %w", machine.Name, err)
 	}
@@ -246,7 +245,7 @@ func (p provider) Create(machine *clusterv1alpha1.Machine, data *cloudproviderty
 	}, nil
 }
 
-func (p provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+func (p provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return false, cloudprovidererrors.TerminalError{
@@ -255,7 +254,6 @@ func (p provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		}
 	}
 
-	ctx := context.Background()
 	if err := c.driver.DeprovisionServer(ctx, machine.UID); err != nil {
 		return false, fmt.Errorf("failed to de-provision server: %w", err)
 	}
@@ -276,14 +274,14 @@ func (p provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return true, nil
 }
 
-func (p provider) MachineMetricsLabels(machine *clusterv1alpha1.Machine) (map[string]string, error) {
+func (p provider) MachineMetricsLabels(_ *clusterv1alpha1.Machine) (map[string]string, error) {
 	return nil, nil
 }
 
-func (p provider) MigrateUID(machine *clusterv1alpha1.Machine, uid types.UID) error {
+func (p provider) MigrateUID(_ context.Context, _ *clusterv1alpha1.Machine, _ types.UID) error {
 	return nil
 }
 
-func (p provider) SetMetricsForMachines(machines clusterv1alpha1.MachineList) error {
+func (p provider) SetMetricsForMachines(_ clusterv1alpha1.MachineList) error {
 	return nil
 }
diff --git a/pkg/cloudprovider/provider/digitalocean/provider.go b/pkg/cloudprovider/provider/digitalocean/provider.go
index 031b14a3..fcbe3db0 100644
--- a/pkg/cloudprovider/provider/digitalocean/provider.go
+++ b/pkg/cloudprovider/provider/digitalocean/provider.go
@@ -93,12 +93,12 @@ func getSlugForOS(os providerconfigtypes.OperatingSystem) (string, error) {
 	return "", providerconfigtypes.ErrOSNotSupported
 }
 
-func getClient(token string) *godo.Client {
+func getClient(ctx context.Context, token string) *godo.Client {
 	tokenSource := &TokenSource{
 		AccessToken: token,
 	}
 
-	oauthClient := oauth2.NewClient(context.Background(), tokenSource)
+	oauthClient := oauth2.NewClient(ctx, tokenSource)
 	return godo.NewClient(oauthClient)
 }
 
@@ -165,7 +165,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, pc, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -188,8 +188,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 		return fmt.Errorf("invalid operating system specified %q: %w", pc.OperatingSystem, err)
 	}
 
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	regions, _, err := client.Regions.List(ctx, &godo.ListOptions{PerPage: 1000})
 	if err != nil {
@@ -265,7 +264,7 @@ func uploadRandomSSHPublicKey(ctx context.Context, service godo.KeysService) (st
 	return newDoKey.Fingerprint, nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -274,8 +273,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		}
 	}
 
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	fingerprint, err := uploadRandomSSHPublicKey(ctx, client.Keys)
 	if err != nil {
@@ -337,8 +335,8 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &doInstance{droplet: droplet}, err
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
-	instance, err := p.get(machine)
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
+	instance, err := p.get(ctx, machine)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return true, nil
@@ -353,8 +351,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertyp
 			Message: fmt.Sprintf("Failed to parse MachineSpec, due to %v", err),
 		}
 	}
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	doID, err := strconv.Atoi(instance.ID())
 	if err != nil {
@@ -369,11 +366,11 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertyp
 	return false, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
-	return p.get(machine)
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+	return p.get(ctx, machine)
 }
 
-func (p *provider) get(machine *clusterv1alpha1.Machine) (*doInstance, error) {
+func (p *provider) get(ctx context.Context, machine *clusterv1alpha1.Machine) (*doInstance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -382,7 +379,7 @@ func (p *provider) get(machine *clusterv1alpha1.Machine) (*doInstance, error) {
 		}
 	}
 
-	droplets, err := p.listDroplets(c.Token)
+	droplets, err := p.listDroplets(ctx, c.Token)
 	if err != nil {
 		return nil, err
 	}
@@ -396,9 +393,8 @@ func (p *provider) get(machine *clusterv1alpha1.Machine) (*doInstance, error) {
 	return nil, cloudprovidererrors.ErrInstanceNotFound
 }
 
-func (p *provider) listDroplets(token string) ([]godo.Droplet, error) {
-	ctx := context.TODO()
-	client := getClient(token)
+func (p *provider) listDroplets(ctx context.Context, token string) ([]godo.Droplet, error) {
+	client := getClient(ctx, token)
 	result := make([]godo.Droplet, 0)
 
 	opt := &godo.ListOptions{
@@ -428,15 +424,12 @@ func (p *provider) listDroplets(token string) ([]godo.Droplet, error) {
 	return result, nil
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-
+func (p *provider) MigrateUID(ctx context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to decode providerconfig: %w", err)
 	}
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 	droplets, _, err := client.Droplets.List(ctx, &godo.ListOptions{PerPage: 1000})
 	if err != nil {
 		return fmt.Errorf("failed to list droplets: %w", err)
diff --git a/pkg/cloudprovider/provider/equinixmetal/provider.go b/pkg/cloudprovider/provider/equinixmetal/provider.go
index da076e57..94ac01b8 100644
--- a/pkg/cloudprovider/provider/equinixmetal/provider.go
+++ b/pkg/cloudprovider/provider/equinixmetal/provider.go
@@ -17,6 +17,7 @@ limitations under the License.
 package equinixmetal
 
 import (
+	"context"
 	"encoding/json"
 	"errors"
 	"fmt"
@@ -163,7 +164,7 @@ func (p *provider) getMetalDevice(machine *clusterv1alpha1.Machine) (*packngo.De
 	return device, client, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, _, pc, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -214,7 +215,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, _, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -254,8 +255,8 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &metalDevice{device: device}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
-	instance, err := p.Get(machine, data)
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+	instance, err := p.Get(ctx, machine, data)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return true, nil
@@ -293,7 +294,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	device, _, err := p.getMetalDevice(machine)
 	if err != nil {
 		return nil, err
@@ -305,7 +306,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 	return nil, cloudprovidererrors.ErrInstanceNotFound
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newID types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, machine *clusterv1alpha1.Machine, newID types.UID) error {
 	device, client, err := p.getMetalDevice(machine)
 	if err != nil {
 		return err
diff --git a/pkg/cloudprovider/provider/fake/provider.go b/pkg/cloudprovider/provider/fake/provider.go
index b2595051..b3d116d5 100644
--- a/pkg/cloudprovider/provider/fake/provider.go
+++ b/pkg/cloudprovider/provider/fake/provider.go
@@ -17,6 +17,7 @@ limitations under the License.
 package fake
 
 import (
+	"context"
 	"encoding/json"
 	"fmt"
 
@@ -65,7 +66,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 }
 
 // Validate returns success or failure based according to its FakeCloudProviderSpec.
-func (p *provider) Validate(machinespec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, machinespec clusterv1alpha1.MachineSpec) error {
 	pconfig, err := providerconfigtypes.GetConfig(machinespec.ProviderSpec)
 	if err != nil {
 		return err
@@ -85,28 +86,28 @@ func (p *provider) Validate(machinespec clusterv1alpha1.MachineSpec) error {
 	return fmt.Errorf("failing validation as requested")
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(_ context.Context, _ *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	return CloudProviderInstance{}, nil
 }
 
-func (p *provider) GetCloudConfig(spec clusterv1alpha1.MachineSpec) (string, string, error) {
+func (p *provider) GetCloudConfig(_ clusterv1alpha1.MachineSpec) (string, string, error) {
 	return "", "", nil
 }
 
 // Create creates a cloud instance according to the given machine.
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(_ context.Context, _ *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData, _ string) (instance.Instance, error) {
 	return CloudProviderInstance{}, nil
 }
 
-func (p *provider) Cleanup(_ *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(_ context.Context, _ *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
 	return true, nil
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, uid types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, _ *clusterv1alpha1.Machine, _ types.UID) error {
 	return nil
 }
 
-func (p *provider) MachineMetricsLabels(machine *clusterv1alpha1.Machine) (map[string]string, error) {
+func (p *provider) MachineMetricsLabels(_ *clusterv1alpha1.Machine) (map[string]string, error) {
 	return map[string]string{}, nil
 }
 
diff --git a/pkg/cloudprovider/provider/gce/provider.go b/pkg/cloudprovider/provider/gce/provider.go
index 4d4bd176..54f63f9d 100644
--- a/pkg/cloudprovider/provider/gce/provider.go
+++ b/pkg/cloudprovider/provider/gce/provider.go
@@ -21,6 +21,7 @@ limitations under the License.
 package gce
 
 import (
+	"context"
 	"errors"
 	"fmt"
 	"net/http"
@@ -101,7 +102,7 @@ func (p *Provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 }
 
 // Validate checks the given machine's specification.
-func (p *Provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *Provider) Validate(_ context.Context, spec clusterv1alpha1.MachineSpec) error {
 	// Read configuration.
 	cfg, err := newConfig(p.resolver, spec.ProviderSpec)
 	if err != nil {
@@ -142,7 +143,7 @@ func (p *Provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 }
 
 // Get retrieves a node instance that is associated with the given machine.
-func (p *Provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *Provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	return p.get(machine)
 }
 
@@ -209,7 +210,7 @@ func (p *Provider) GetCloudConfig(spec clusterv1alpha1.MachineSpec) (config stri
 }
 
 // Create inserts a cloud instance according to the given machine.
-func (p *Provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *Provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	// Read configuration.
 	cfg, err := newConfig(p.resolver, machine.Spec.ProviderSpec)
 	if err != nil {
@@ -285,11 +286,11 @@ func (p *Provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		return nil, newError(common.InvalidConfigurationMachineError, errInsertInstance, err)
 	}
 	// Retrieve it to get a full qualified instance.
-	return p.Get(machine, data)
+	return p.Get(ctx, machine, data)
 }
 
 // Cleanup deletes the instance associated with the machine and all associated resources.
-func (p *Provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *Provider) Cleanup(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
 	// Read configuration.
 	cfg, err := newConfig(p.resolver, machine.Spec.ProviderSpec)
 	if err != nil {
@@ -340,7 +341,7 @@ func (p *Provider) MachineMetricsLabels(machine *clusterv1alpha1.Machine) (map[s
 
 // MigrateUID updates the UID of an instance after the controller migrates types
 // and the UID of the machine object changed.
-func (p *Provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
+func (p *Provider) MigrateUID(_ context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	// Read configuration.
 	cfg, err := newConfig(p.resolver, machine.Spec.ProviderSpec)
 	if err != nil {
diff --git a/pkg/cloudprovider/provider/hetzner/provider.go b/pkg/cloudprovider/provider/hetzner/provider.go
index 0db5fe0e..07651494 100644
--- a/pkg/cloudprovider/provider/hetzner/provider.go
+++ b/pkg/cloudprovider/provider/hetzner/provider.go
@@ -184,7 +184,7 @@ func (p *provider) getServerPlacementGroup(ctx context.Context, client *hcloud.C
 	return createdPg.PlacementGroup, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, pc, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -199,7 +199,6 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 		return fmt.Errorf("invalid/not supported operating system specified %q: %w", pc.OperatingSystem, err)
 	}
 
-	ctx := context.TODO()
 	client := getClient(c.Token)
 
 	if c.Location != "" && c.Datacenter != "" {
@@ -247,7 +246,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -256,7 +255,6 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		}
 	}
 
-	ctx := context.TODO()
 	client := getClient(c.Token)
 
 	if c.Image == "" {
@@ -388,8 +386,8 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &hetznerServer{server: serverCreateRes.Server}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
-	instance, err := p.Get(machine, data)
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+	instance, err := p.Get(ctx, machine, data)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return true, nil
@@ -405,7 +403,6 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 		}
 	}
 
-	ctx := context.TODO()
 	client := getClient(c.Token)
 	hzServer := instance.(*hetznerServer).server
 
@@ -443,7 +440,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -452,7 +449,6 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 		}
 	}
 
-	ctx := context.TODO()
 	client := getClient(c.Token)
 
 	servers, _, err := client.Server.List(ctx, hcloud.ServerListOpts{ListOpts: hcloud.ListOpts{
@@ -471,10 +467,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 	return nil, cloudprovidererrors.ErrInstanceNotFound
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-
+func (p *provider) MigrateUID(ctx context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return cloudprovidererrors.TerminalError{
diff --git a/pkg/cloudprovider/provider/kubevirt/provider.go b/pkg/cloudprovider/provider/kubevirt/provider.go
index 8cd0fd4b..b31ee13c 100644
--- a/pkg/cloudprovider/provider/kubevirt/provider.go
+++ b/pkg/cloudprovider/provider/kubevirt/provider.go
@@ -327,7 +327,7 @@ func getNamespace() string {
 	return ns
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -339,7 +339,6 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 	if err != nil {
 		return nil, fmt.Errorf("failed to get kubevirt client: %w", err)
 	}
-	ctx := context.Background()
 
 	virtualMachine := &kubevirtv1.VirtualMachine{}
 	if err := sigClient.Get(ctx, types.NamespacedName{Namespace: c.Namespace, Name: machine.Name}, virtualMachine); err != nil {
@@ -384,11 +383,11 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 // We don't use the UID for kubevirt because the name of a VMI must stay stable
 // in order for the node name to stay stable. The operator is responsible for ensuring
 // there are no conflicts, e.G. by using one Namespace per Kubevirt user cluster.
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, uid types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, _ *clusterv1alpha1.Machine, _ types.UID) error {
 	return nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, pc, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -414,7 +413,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	}
 	// Check if we can reach the API of the target cluster.
 	vmi := &kubevirtv1.VirtualMachineInstance{}
-	if err := sigClient.Get(context.Background(), types.NamespacedName{Namespace: c.Namespace, Name: "not-expected-to-exist"}, vmi); err != nil && !kerrors.IsNotFound(err) {
+	if err := sigClient.Get(ctx, types.NamespacedName{Namespace: c.Namespace, Name: "not-expected-to-exist"}, vmi); err != nil && !kerrors.IsNotFound(err) {
 		return fmt.Errorf("failed to request VirtualMachineInstances: %w", err)
 	}
 
@@ -451,7 +450,7 @@ func (p *provider) MachineMetricsLabels(machine *clusterv1alpha1.Machine) (map[s
 	return labels, err
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -469,7 +468,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	resourceRequirements := kubevirtv1.ResourceRequirements{}
 	labels := map[string]string{"kubevirt.io/vm": machine.Name}
 	// Add a common label to all VirtualMachines spawned by the same MachineDeployment (= MachineDeployment name).
-	if mdName, err := controllerutil.GetMachineDeploymentNameForMachine(context.Background(), machine, data.Client); err == nil {
+	if mdName, err := controllerutil.GetMachineDeploymentNameForMachine(ctx, machine, data.Client); err == nil {
 		labels[machineDeploymentLabelKey] = mdName
 	}
 
@@ -477,7 +476,6 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	if err != nil {
 		return nil, fmt.Errorf("failed to get kubevirt client: %w", err)
 	}
-	ctx := context.Background()
 
 	// Add VMIPreset label if specified
 	if c.FlavorName != "" {
@@ -572,7 +570,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &kubeVirtServer{}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return false, cloudprovidererrors.TerminalError{
@@ -584,7 +582,6 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertyp
 	if err != nil {
 		return false, fmt.Errorf("failed to get kubevirt client: %w", err)
 	}
-	ctx := context.Background()
 
 	vm := &kubevirtv1.VirtualMachine{}
 	if err := sigClient.Get(ctx, types.NamespacedName{Namespace: c.Namespace, Name: machine.Name}, vm); err != nil {
diff --git a/pkg/cloudprovider/provider/linode/provider.go b/pkg/cloudprovider/provider/linode/provider.go
index 7389756b..2738c7d0 100644
--- a/pkg/cloudprovider/provider/linode/provider.go
+++ b/pkg/cloudprovider/provider/linode/provider.go
@@ -94,12 +94,12 @@ func getSlugForOS(os providerconfigtypes.OperatingSystem) (string, error) {
 	return "", providerconfigtypes.ErrOSNotSupported
 }
 
-func getClient(token string) linodego.Client {
+func getClient(ctx context.Context, token string) linodego.Client {
 	tokenSource := &TokenSource{
 		AccessToken: token,
 	}
 
-	oauthClient := oauth2.NewClient(context.Background(), tokenSource)
+	oauthClient := oauth2.NewClient(ctx, tokenSource)
 
 	client := linodego.NewClient(oauthClient)
 	client.SetUserAgent("Kubermatic linodego")
@@ -163,7 +163,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, pc, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -186,8 +186,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 		return fmt.Errorf("invalid operating system specified %q: %w", pc.OperatingSystem, err)
 	}
 
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	_, err = client.GetRegion(ctx, c.Region)
 	if err != nil {
@@ -212,7 +211,7 @@ func createRandomPassword() (string, error) {
 	return rootPass, nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	c, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -221,8 +220,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		}
 	}
 
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	sshkey, err := ssh.NewKey()
 	if err != nil {
@@ -274,8 +272,8 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &linodeInstance{linode: linode}, err
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
-	instance, err := p.Get(machine, data)
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+	instance, err := p.Get(ctx, machine, data)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			return true, nil
@@ -290,8 +288,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 			Message: fmt.Sprintf("Failed to parse MachineSpec, due to %v", err),
 		}
 	}
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	linodeID, err := strconv.Atoi(instance.ID())
 	if err != nil {
@@ -315,7 +312,7 @@ func getListOptions(name string) *linodego.ListOptions {
 	return listOptions
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -324,8 +321,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 		}
 	}
 
-	ctx := context.TODO()
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 
 	listOptions := getListOptions(machine.Spec.Name)
 	linodes, err := client.ListInstances(ctx, listOptions)
@@ -343,15 +339,12 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 	return nil, cloudprovidererrors.ErrInstanceNotFound
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-
+func (p *provider) MigrateUID(ctx context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to decode providerconfig: %w", err)
 	}
-	client := getClient(c.Token)
+	client := getClient(ctx, c.Token)
 	listOptions := getListOptions(machine.Spec.Name)
 	linodes, err := client.ListInstances(ctx, listOptions)
 	if err != nil {
diff --git a/pkg/cloudprovider/provider/nutanix/provider.go b/pkg/cloudprovider/provider/nutanix/provider.go
index 6a7cdfe6..5c6d7ea3 100644
--- a/pkg/cloudprovider/provider/nutanix/provider.go
+++ b/pkg/cloudprovider/provider/nutanix/provider.go
@@ -17,6 +17,7 @@ limitations under the License.
 package nutanix
 
 import (
+	"context"
 	"errors"
 	"fmt"
 	"strconv"
@@ -195,7 +196,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, spec clusterv1alpha1.MachineSpec) error {
 	config, _, _, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse machineSpec: %w", err)
@@ -241,10 +242,10 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	vm, err := p.create(machine, userdata)
 	if err != nil {
-		_, cleanupErr := p.Cleanup(machine, data)
+		_, cleanupErr := p.Cleanup(ctx, machine, data)
 		if cleanupErr != nil {
 			return nil, fmt.Errorf("cleaning up failed with err %v after creation failed with err %w", cleanupErr, err)
 		}
@@ -273,7 +274,7 @@ func (p *provider) create(machine *clusterv1alpha1.Machine, userdata string) (in
 	return createVM(client, machine.Name, *config, pc.OperatingSystem, userdata)
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
 	return p.cleanup(machine, data)
 }
 
@@ -338,7 +339,7 @@ func (p *provider) cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 	return true, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	config, _, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -403,7 +404,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, data *cloudprovidertype
 	}, nil
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, uid ktypes.UID) error {
+func (p *provider) MigrateUID(_ context.Context, _ *clusterv1alpha1.Machine, _ ktypes.UID) error {
 	return nil
 }
 
diff --git a/pkg/cloudprovider/provider/openstack/provider.go b/pkg/cloudprovider/provider/openstack/provider.go
index 16deef23..8b591c1c 100644
--- a/pkg/cloudprovider/provider/openstack/provider.go
+++ b/pkg/cloudprovider/provider/openstack/provider.go
@@ -17,6 +17,7 @@ limitations under the License.
 package openstack
 
 import (
+	"context"
 	"encoding/json"
 	"errors"
 	"fmt"
@@ -440,7 +441,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(_ context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, pc, _, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -556,7 +557,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+func (p *provider) Create(_ context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
 	cfg, _, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -725,13 +726,13 @@ func deleteInstanceDueToFatalLogged(computeClient *gophercloud.ServiceClient, se
 	klog.V(0).Infof("Instance %s got deleted", serverID)
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
 	var hasFloatingIPReleaseFinalizer bool
 	if finalizers := sets.NewString(machine.Finalizers...); finalizers.Has(floatingIPReleaseFinalizer) {
 		hasFloatingIPReleaseFinalizer = true
 	}
 
-	instance, err := p.Get(machine, data)
+	instance, err := p.Get(ctx, machine, data)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			if hasFloatingIPReleaseFinalizer {
@@ -773,7 +774,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 	return false, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+func (p *provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	c, _, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -816,7 +817,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.P
 	return nil, cloudprovidererrors.ErrInstanceNotFound
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	c, _, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return cloudprovidererrors.TerminalError{
diff --git a/pkg/cloudprovider/provider/scaleway/provider.go b/pkg/cloudprovider/provider/scaleway/provider.go
index 4e66e32a..cb69420c 100644
--- a/pkg/cloudprovider/provider/scaleway/provider.go
+++ b/pkg/cloudprovider/provider/scaleway/provider.go
@@ -139,7 +139,7 @@ func (p *provider) AddDefaults(spec clusterv1alpha1.MachineSpec) (clusterv1alpha
 	return spec, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	c, pc, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to parse config: %w", err)
@@ -172,7 +172,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	return nil
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (cloudInstance.Instance, error) {
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (cloudInstance.Instance, error) {
 	c, pc, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -181,7 +181,6 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 		}
 	}
 
-	ctx := context.TODO()
 	api, err := c.getInstanceAPI()
 	if err != nil {
 		return nil, err
@@ -221,7 +220,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return &scwServer{server: serverResp.Server}, err
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (bool, error) {
 	i, err := p.get(machine)
 	if err != nil {
 		if errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
@@ -237,7 +236,6 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertyp
 			Message: fmt.Sprintf("Failed to parse MachineSpec, due to %v", err),
 		}
 	}
-	ctx := context.TODO()
 	api, err := c.getInstanceAPI()
 	if err != nil {
 		return false, err
@@ -254,7 +252,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, _ *cloudprovidertyp
 	return false, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (cloudInstance.Instance, error) {
+func (p *provider) Get(_ context.Context, machine *clusterv1alpha1.Machine, _ *cloudprovidertypes.ProviderData) (cloudInstance.Instance, error) {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, cloudprovidererrors.TerminalError{
@@ -319,7 +317,7 @@ func (p *provider) get(machine *clusterv1alpha1.Machine) (*scwServer, error) {
 	return nil, cloudprovidererrors.ErrInstanceNotFound
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, newUID types.UID) error {
+func (p *provider) MigrateUID(_ context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error {
 	c, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to decode providerconfig: %w", err)
diff --git a/pkg/cloudprovider/provider/vsphere/client.go b/pkg/cloudprovider/provider/vsphere/client.go
index 1d2d00b1..f89f9c0e 100644
--- a/pkg/cloudprovider/provider/vsphere/client.go
+++ b/pkg/cloudprovider/provider/vsphere/client.go
@@ -78,8 +78,8 @@ func NewSession(ctx context.Context, config *Config) (*Session, error) {
 }
 
 // Logout closes the idling vCenter connections.
-func (s *Session) Logout() {
-	if err := s.Client.Logout(context.Background()); err != nil {
+func (s *Session) Logout(ctx context.Context) {
+	if err := s.Client.Logout(ctx); err != nil {
 		utilruntime.HandleError(fmt.Errorf("vsphere client failed to logout: %w", err))
 	}
 }
diff --git a/pkg/cloudprovider/provider/vsphere/provider.go b/pkg/cloudprovider/provider/vsphere/provider.go
index 09c49b2c..db36990a 100644
--- a/pkg/cloudprovider/provider/vsphere/provider.go
+++ b/pkg/cloudprovider/provider/vsphere/provider.go
@@ -199,9 +199,7 @@ func (p *provider) getConfig(provSpec clusterv1alpha1.ProviderSpec) (*Config, *p
 	return &c, pconfig, rawConfig, nil
 }
 
-func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
+func (p *provider) Validate(ctx context.Context, spec clusterv1alpha1.MachineSpec) error {
 	config, pc, _, err := p.getConfig(spec.ProviderSpec)
 	if err != nil {
 		return fmt.Errorf("failed to get config: %w", err)
@@ -211,7 +209,7 @@ func (p *provider) Validate(spec clusterv1alpha1.MachineSpec) error {
 	if err != nil {
 		return fmt.Errorf("failed to create vCenter session: %w", err)
 	}
-	defer session.Logout()
+	defer session.Logout(ctx)
 
 	if config.Tags != nil {
 		restAPISession, err := NewRESTSession(ctx, config)
@@ -294,10 +292,10 @@ func machineInvalidConfigurationTerminalError(err error) error {
 	}
 }
 
-func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
-	vm, err := p.create(machine, userdata)
+func (p *provider) Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+	vm, err := p.create(ctx, machine, userdata)
 	if err != nil {
-		_, cleanupErr := p.Cleanup(machine, data)
+		_, cleanupErr := p.Cleanup(ctx, machine, data)
 		if cleanupErr != nil {
 			return nil, fmt.Errorf("cleaning up failed with err %v after creation failed with err %w", cleanupErr, err)
 		}
@@ -306,9 +304,7 @@ func (p *provider) Create(machine *clusterv1alpha1.Machine, data *cloudprovidert
 	return vm, nil
 }
 
-func (p *provider) create(machine *clusterv1alpha1.Machine, userdata string) (instance.Instance, error) {
-	ctx := context.Background()
-
+func (p *provider) create(ctx context.Context, machine *clusterv1alpha1.Machine, userdata string) (instance.Instance, error) {
 	config, pc, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, fmt.Errorf("failed to parse config: %w", err)
@@ -318,7 +314,7 @@ func (p *provider) create(machine *clusterv1alpha1.Machine, userdata string) (in
 	if err != nil {
 		return nil, fmt.Errorf("failed to create vCenter session: %w", err)
 	}
-	defer session.Logout()
+	defer session.Logout(ctx)
 
 	var containerLinuxUserdata string
 	if pc.OperatingSystem == providerconfigtypes.OperatingSystemFlatcar {
@@ -378,10 +374,7 @@ func (p *provider) create(machine *clusterv1alpha1.Machine, userdata string) (in
 	return Server{name: virtualMachine.Name(), status: instance.StatusRunning, id: virtualMachine.Reference().Value}, nil
 }
 
-func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
-	ctx, cancel := context.WithCancel(context.Background())
-	defer cancel()
-
+func (p *provider) Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (bool, error) {
 	config, pc, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return false, fmt.Errorf("failed to parse config: %w", err)
@@ -391,7 +384,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 	if err != nil {
 		return false, fmt.Errorf("failed to create vCenter session: %w", err)
 	}
-	defer session.Logout()
+	defer session.Logout(ctx)
 
 	virtualMachine, err := p.get(ctx, config.Folder, machine.Spec, session.Finder)
 	if err != nil {
@@ -475,9 +468,7 @@ func (p *provider) Cleanup(machine *clusterv1alpha1.Machine, data *cloudprovider
 	return true, nil
 }
 
-func (p *provider) Get(machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
-	ctx := context.Background()
-
+func (p *provider) Get(ctx context.Context, machine *clusterv1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
 	config, _, _, err := p.getConfig(machine.Spec.ProviderSpec)
 	if err != nil {
 		return nil, fmt.Errorf("failed to parse config: %w", err)
@@ -487,7 +478,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, data *cloudprovidertype
 	if err != nil {
 		return nil, fmt.Errorf("failed to create vCenter session: %w", err)
 	}
-	defer session.Logout()
+	defer session.Logout(ctx)
 
 	virtualMachine, err := p.get(ctx, config.Folder, machine.Spec, session.Finder)
 	if err != nil {
@@ -541,7 +532,7 @@ func (p *provider) Get(machine *clusterv1alpha1.Machine, data *cloudprovidertype
 	return Server{name: virtualMachine.Name(), status: instance.StatusRunning, addresses: addresses, id: virtualMachine.Reference().Value}, nil
 }
 
-func (p *provider) MigrateUID(machine *clusterv1alpha1.Machine, uid ktypes.UID) error {
+func (p *provider) MigrateUID(_ context.Context, _ *clusterv1alpha1.Machine, _ ktypes.UID) error {
 	return nil
 }
 
diff --git a/pkg/cloudprovider/types/types.go b/pkg/cloudprovider/types/types.go
index 5dc22fb8..adc9010b 100644
--- a/pkg/cloudprovider/types/types.go
+++ b/pkg/cloudprovider/types/types.go
@@ -37,7 +37,7 @@ type Provider interface {
 	//
 	// In case of any error a "terminal" error should be set,
 	// See v1alpha1.MachineStatus for more info
-	Validate(machinespec clusterv1alpha1.MachineSpec) error
+	Validate(ctx context.Context, machinespec clusterv1alpha1.MachineSpec) error
 
 	// Get gets a node that is associated with the given machine.
 	//
@@ -46,19 +46,19 @@ type Provider interface {
 	// See v1alpha1.MachineStatus for more info and TerminalError type
 	//
 	// In case the instance cannot be found, github.com/kubermatic/machine-controller/pkg/cloudprovider/errors/ErrInstanceNotFound will be returned
-	Get(machine *clusterv1alpha1.Machine, data *ProviderData) (instance.Instance, error)
+	Get(ctx context.Context, machine *clusterv1alpha1.Machine, data *ProviderData) (instance.Instance, error)
 
 	// GetCloudConfig will return the cloud provider specific cloud-config, which gets consumed by the kubelet
 	GetCloudConfig(spec clusterv1alpha1.MachineSpec) (config string, name string, err error)
 
 	// Create creates a cloud instance according to the given machine
-	Create(machine *clusterv1alpha1.Machine, data *ProviderData, userdata string) (instance.Instance, error)
+	Create(ctx context.Context, machine *clusterv1alpha1.Machine, data *ProviderData, userdata string) (instance.Instance, error)
 
 	// Cleanup will delete the instance associated with the machine and all associated resources.
 	// If all resources have been cleaned up, true will be returned.
 	// In case the cleanup involves asynchronous deletion of resources & those resources are not gone yet,
 	// false should be returned. This is to indicate that the cleanup is not done, but needs to be called again at a later point
-	Cleanup(machine *clusterv1alpha1.Machine, data *ProviderData) (bool, error)
+	Cleanup(ctx context.Context, machine *clusterv1alpha1.Machine, data *ProviderData) (bool, error)
 
 	// MachineMetricsLabels returns labels used for the Prometheus metrics
 	// about created machines, e.g. instance type, instance size, region
@@ -69,7 +69,7 @@ type Provider interface {
 
 	// MigrateUID is called when the controller migrates types and the UID of the machine object changes
 	// All cloud providers that use Machine.UID to uniquely identify resources must implement this
-	MigrateUID(machine *clusterv1alpha1.Machine, uid types.UID) error
+	MigrateUID(ctx context.Context, machine *clusterv1alpha1.Machine, newUID types.UID) error
 
 	// SetMetricsForMachines allows providers to provide provider-specific metrics. This may be implemented
 	// as no-op
diff --git a/pkg/cloudprovider/validationwrapper.go b/pkg/cloudprovider/validationwrapper.go
index 6cd7c45f..965e2205 100644
--- a/pkg/cloudprovider/validationwrapper.go
+++ b/pkg/cloudprovider/validationwrapper.go
@@ -17,6 +17,7 @@ limitations under the License.
 package cloudprovider
 
 import (
+	"context"
 	"fmt"
 
 	"github.com/kubermatic/machine-controller/pkg/apis/cluster/v1alpha1"
@@ -43,7 +44,7 @@ func (w *cachingValidationWrapper) AddDefaults(spec v1alpha1.MachineSpec) (v1alp
 
 // Validate tries to get the validation result from the cache and if not found, calls the
 // cloudproviders Validate and saves that to the cache.
-func (w *cachingValidationWrapper) Validate(spec v1alpha1.MachineSpec) error {
+func (w *cachingValidationWrapper) Validate(ctx context.Context, spec v1alpha1.MachineSpec) error {
 	result, exists, err := cache.Get(spec)
 	if err != nil {
 		return fmt.Errorf("error getting validation result from cache: %w", err)
@@ -54,7 +55,7 @@ func (w *cachingValidationWrapper) Validate(spec v1alpha1.MachineSpec) error {
 	}
 
 	klog.V(6).Infof("Got cache miss for validation")
-	err = w.actualProvider.Validate(spec)
+	err = w.actualProvider.Validate(ctx, spec)
 	if err := cache.Set(spec, err); err != nil {
 		return fmt.Errorf("failed to set cache after validation: %w", err)
 	}
@@ -63,8 +64,8 @@ func (w *cachingValidationWrapper) Validate(spec v1alpha1.MachineSpec) error {
 }
 
 // Get just calls the underlying cloudproviders Get.
-func (w *cachingValidationWrapper) Get(machine *v1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
-	return w.actualProvider.Get(machine, data)
+func (w *cachingValidationWrapper) Get(ctx context.Context, machine *v1alpha1.Machine, data *cloudprovidertypes.ProviderData) (instance.Instance, error) {
+	return w.actualProvider.Get(ctx, machine, data)
 }
 
 // GetCloudConfig just calls the underlying cloudproviders GetCloudConfig.
@@ -73,18 +74,18 @@ func (w *cachingValidationWrapper) GetCloudConfig(spec v1alpha1.MachineSpec) (st
 }
 
 // Create just calls the underlying cloudproviders Create.
-func (w *cachingValidationWrapper) Create(machine *v1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
-	return w.actualProvider.Create(machine, data, userdata)
+func (w *cachingValidationWrapper) Create(ctx context.Context, machine *v1alpha1.Machine, data *cloudprovidertypes.ProviderData, userdata string) (instance.Instance, error) {
+	return w.actualProvider.Create(ctx, machine, data, userdata)
 }
 
 // Cleanup just calls the underlying cloudproviders Cleanup.
-func (w *cachingValidationWrapper) Cleanup(m *v1alpha1.Machine, mcd *cloudprovidertypes.ProviderData) (bool, error) {
-	return w.actualProvider.Cleanup(m, mcd)
+func (w *cachingValidationWrapper) Cleanup(ctx context.Context, m *v1alpha1.Machine, mcd *cloudprovidertypes.ProviderData) (bool, error) {
+	return w.actualProvider.Cleanup(ctx, m, mcd)
 }
 
 // MigrateUID just calls the underlying cloudproviders MigrateUID.
-func (w *cachingValidationWrapper) MigrateUID(m *v1alpha1.Machine, newUID types.UID) error {
-	return w.actualProvider.MigrateUID(m, newUID)
+func (w *cachingValidationWrapper) MigrateUID(ctx context.Context, m *v1alpha1.Machine, newUID types.UID) error {
+	return w.actualProvider.MigrateUID(ctx, m, newUID)
 }
 
 // MachineMetricsLabels just calls the underlying cloudproviders MachineMetricsLabels.
diff --git a/pkg/controller/machine/machine_controller.go b/pkg/controller/machine/machine_controller.go
index fda75629..3eb909bc 100644
--- a/pkg/controller/machine/machine_controller.go
+++ b/pkg/controller/machine/machine_controller.go
@@ -338,13 +338,13 @@ func (r *Reconciler) updateMachineErrorIfTerminalError(machine *clusterv1alpha1.
 	return fmt.Errorf("%s, due to %w", errMsg, err)
 }
 
-func (r *Reconciler) createProviderInstance(prov cloudprovidertypes.Provider, machine *clusterv1alpha1.Machine, userdata string) (instance.Instance, error) {
+func (r *Reconciler) createProviderInstance(ctx context.Context, prov cloudprovidertypes.Provider, machine *clusterv1alpha1.Machine, userdata string) (instance.Instance, error) {
 	// Ensure finalizer is there.
 	_, err := r.ensureDeleteFinalizerExists(machine)
 	if err != nil {
 		return nil, fmt.Errorf("failed to add %q finalizer: %w", FinalizerDeleteInstance, err)
 	}
-	i, err := prov.Create(machine, r.providerData, userdata)
+	i, err := prov.Create(ctx, machine, r.providerData, userdata)
 	if err != nil {
 		return nil, err
 	}
@@ -573,7 +573,7 @@ func (r *Reconciler) deleteMachine(ctx context.Context, prov cloudprovidertypes.
 		return &reconcile.Result{RequeueAfter: 10 * time.Second}, nil
 	}
 
-	if result, err := r.deleteCloudProviderInstance(prov, machine); result != nil || err != nil {
+	if result, err := r.deleteCloudProviderInstance(ctx, prov, machine); result != nil || err != nil {
 		return result, err
 	}
 
@@ -634,14 +634,14 @@ func (r *Reconciler) retrieveNodesRelatedToMachine(ctx context.Context, machine
 	return nodes, nil
 }
 
-func (r *Reconciler) deleteCloudProviderInstance(prov cloudprovidertypes.Provider, machine *clusterv1alpha1.Machine) (*reconcile.Result, error) {
+func (r *Reconciler) deleteCloudProviderInstance(ctx context.Context, prov cloudprovidertypes.Provider, machine *clusterv1alpha1.Machine) (*reconcile.Result, error) {
 	finalizers := sets.NewString(machine.Finalizers...)
 	if !finalizers.Has(FinalizerDeleteInstance) {
 		return nil, nil
 	}
 
 	// Delete the instance
-	completelyGone, err := prov.Cleanup(machine, r.providerData)
+	completelyGone, err := prov.Cleanup(ctx, machine, r.providerData)
 	if err != nil {
 		message := fmt.Sprintf("%v. Please manually delete %s finalizer from the machine object.", err, FinalizerDeleteInstance)
 		return nil, r.updateMachineErrorIfTerminalError(machine, common.DeleteMachineError, message, err, "failed to delete machine at cloud provider")
@@ -673,7 +673,7 @@ func (r *Reconciler) deleteCloudProviderInstance(prov cloudprovidertypes.Provide
 		}
 
 		if rhelConfig.RHSMOfflineToken != "" {
-			if err := r.redhatSubscriptionManager.UnregisterInstance(rhelConfig.RHSMOfflineToken, machineName); err != nil {
+			if err := r.redhatSubscriptionManager.UnregisterInstance(ctx, rhelConfig.RHSMOfflineToken, machineName); err != nil {
 				return nil, fmt.Errorf("failed to delete subscription for machine name %s: %w", machine.Name, err)
 			}
 		}
@@ -733,7 +733,7 @@ func (r *Reconciler) ensureInstanceExistsForMachine(
 ) (*reconcile.Result, error) {
 	klog.V(6).Infof("Requesting instance for machine '%s' from cloudprovider because no associated node with status ready found...", machine.Name)
 
-	providerInstance, err := prov.Get(machine, r.providerData)
+	providerInstance, err := prov.Get(ctx, machine, r.providerData)
 
 	// case 2: retrieving instance from provider was not successful
 	if err != nil {
@@ -840,7 +840,7 @@ func (r *Reconciler) ensureInstanceExistsForMachine(
 			}
 
 			// Create the instance
-			if _, err = r.createProviderInstance(prov, machine, userdata); err != nil {
+			if _, err = r.createProviderInstance(ctx, prov, machine, userdata); err != nil {
 				message := fmt.Sprintf("%v. Unable to create a machine.", err)
 				return nil, r.updateMachineErrorIfTerminalError(machine, common.CreateMachineError, message, err, "failed to create machine at cloudprovider")
 			}
diff --git a/pkg/rhsm/subscription_manager.go b/pkg/rhsm/subscription_manager.go
index 93a36753..90f6b918 100644
--- a/pkg/rhsm/subscription_manager.go
+++ b/pkg/rhsm/subscription_manager.go
@@ -34,8 +34,7 @@ const defaultTimeout = 10 * time.Second
 
 // RedHatSubscriptionManager is responsible for removing redhat subscriptions.
 type RedHatSubscriptionManager interface {
-	//TODO(irozzo) add context in input to give more control to the caller
-	UnregisterInstance(offlineToken, machineName string) error
+	UnregisterInstance(ctx context.Context, offlineToken, machineName string) error
 }
 
 type pagination struct {
@@ -70,8 +69,7 @@ func NewRedHatSubscriptionManager() RedHatSubscriptionManager {
 	}
 }
 
-func newOAuthClientWithRefreshToken(refreshToken string, tokenURL string) *http.Client {
-	ctx := context.Background()
+func newOAuthClientWithRefreshToken(ctx context.Context, refreshToken string, tokenURL string) *http.Client {
 	// Use the custom HTTP client when requesting an access token in order to
 	// set a timeout value.
 	// See: https://github.com/golang/oauth2/blob/c85d3e98c914e3a33234ad863dcbff5dbc425bb8/internal/token.go#L232
@@ -92,9 +90,7 @@ func newOAuthClientWithRefreshToken(refreshToken string, tokenURL string) *http.
 	return c
 }
 
-func (d *defaultRedHatSubscriptionManager) UnregisterInstance(offlineToken, machineName string) error {
-	ctx := context.Background()
-
+func (d *defaultRedHatSubscriptionManager) UnregisterInstance(ctx context.Context, offlineToken, machineName string) error {
 	var (
 		retries    = 0
 		maxRetries = 15
@@ -151,7 +147,7 @@ func (d *defaultRedHatSubscriptionManager) findSystemsProfile(ctx context.Contex
 }
 
 func (d *defaultRedHatSubscriptionManager) deleteSubscription(ctx context.Context, uuid, offlineToken string) error {
-	client := newOAuthClientWithRefreshToken(offlineToken, d.authURL)
+	client := newOAuthClientWithRefreshToken(ctx, offlineToken, d.authURL)
 	req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/%s", d.apiURL, uuid), nil)
 	if err != nil {
 		return fmt.Errorf("failed to create delete system request: %w", err)
@@ -180,7 +176,7 @@ func (d *defaultRedHatSubscriptionManager) deleteSubscription(ctx context.Contex
 }
 
 func (d *defaultRedHatSubscriptionManager) executeFindSystemsRequest(ctx context.Context, offlineToken string, offset int) (*systemsResponse, error) {
-	client := newOAuthClientWithRefreshToken(offlineToken, d.authURL)
+	client := newOAuthClientWithRefreshToken(ctx, offlineToken, d.authURL)
 	req, err := http.NewRequest("GET", fmt.Sprintf(d.apiURL+"?limit=%v&offset=%v", d.requestsLimiter, offset), nil)
 	if err != nil {
 		return nil, fmt.Errorf("failed to create fetch systems request: %w", err)
diff --git a/pkg/signals/signal.go b/pkg/signals/signal.go
deleted file mode 100644
index 393a285f..00000000
--- a/pkg/signals/signal.go
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Copyright 2017 The Kubernetes Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package signals
-
-import (
-	"os"
-	"os/signal"
-	"syscall"
-)
-
-var (
-	onlyOneSignalHandler = make(chan struct{})
-	shutdownSignals      = []os.Signal{os.Interrupt, syscall.SIGTERM}
-)
-
-// SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned
-// which is closed on one of these signals. If a second signal is caught, the program
-// is terminated with exit code 1.
-func SetupSignalHandler() (stopCh <-chan struct{}) {
-	close(onlyOneSignalHandler) // panics when called twice
-
-	stop := make(chan struct{})
-	c := make(chan os.Signal, 2)
-	signal.Notify(c, shutdownSignals...)
-	go func() {
-		<-c
-		close(stop)
-		<-c
-		os.Exit(1) // second signal. Exit directly.
-	}()
-
-	return stop
-}


Test patch:
diff --git a/pkg/cloudprovider/provider/anexia/provider_test.go b/pkg/cloudprovider/provider/anexia/provider_test.go
index 5daaaf4a..9345f745 100644
--- a/pkg/cloudprovider/provider/anexia/provider_test.go
+++ b/pkg/cloudprovider/provider/anexia/provider_test.go
@@ -17,6 +17,7 @@ limitations under the License.
 package anexia
 
 import (
+	"context"
 	"encoding/json"
 	"errors"
 	"net/http"
@@ -57,7 +58,7 @@ func TestAnexiaProvider(t *testing.T) {
 		testhelper.Mux.HandleFunc("/api/vsphere/v1/search/by_name.json", createSearchHandler(t, waitUntilVMIsFound))
 
 		providerStatus := anxtypes.ProviderStatus{}
-		ctx := utils.CreateReconcileContext(utils.ReconcileContext{
+		ctx := utils.CreateReconcileContext(context.Background(), utils.ReconcileContext{
 			Machine: &v1alpha1.Machine{
 				ObjectMeta: metav1.ObjectMeta{Name: "TestMachine"},
 			},
@@ -149,7 +150,7 @@ func TestAnexiaProvider(t *testing.T) {
 		})
 
 		providerStatus := anxtypes.ProviderStatus{}
-		ctx := utils.CreateReconcileContext(utils.ReconcileContext{
+		ctx := utils.CreateReconcileContext(context.Background(), utils.ReconcileContext{
 			Machine: &v1alpha1.Machine{
 				ObjectMeta: metav1.ObjectMeta{Name: "TestMachine"},
 			},
@@ -185,7 +186,7 @@ func TestAnexiaProvider(t *testing.T) {
 				},
 			},
 		}
-		ctx := utils.CreateReconcileContext(utils.ReconcileContext{
+		ctx := utils.CreateReconcileContext(context.Background(), utils.ReconcileContext{
 			Status:       &providerStatus,
 			UserData:     "",
 			Config:       nil,
@@ -213,7 +214,7 @@ func TestAnexiaProvider(t *testing.T) {
 			ReservedIP: "",
 			IPState:    "",
 		}
-		ctx := utils.CreateReconcileContext(utils.ReconcileContext{Status: providerStatus})
+		ctx := utils.CreateReconcileContext(context.Background(), utils.ReconcileContext{Status: providerStatus})
 
 		t.Run("with unbound reserved IP", func(t *testing.T) {
 			expectedIP := "8.8.8.8"
@@ -270,7 +271,7 @@ func TestValidate(t *testing.T) {
 
 	provider := New(nil)
 	for _, testCase := range getSpecsForValidationTest(t, configCases) {
-		err := provider.Validate(testCase.Spec)
+		err := provider.Validate(context.Background(), testCase.Spec)
 		if testCase.ExpectedError != nil {
 			testhelper.AssertEquals(t, testCase.ExpectedError.Error(), err.Error())
 		} else {
diff --git a/pkg/cloudprovider/provider/gce/provider_test.go b/pkg/cloudprovider/provider/gce/provider_test.go
index f63ef224..d8a36cc4 100644
--- a/pkg/cloudprovider/provider/gce/provider_test.go
+++ b/pkg/cloudprovider/provider/gce/provider_test.go
@@ -161,7 +161,7 @@ func TestValidate(t *testing.T) {
 
 	for _, test := range tests {
 		t.Run(test.name, func(t *testing.T) {
-			err := p.Validate(test.mspec)
+			err := p.Validate(context.Background(), test.mspec)
 			if (err != nil) != test.expectErr {
 				t.Fatalf("expectedErr: %t, got: %v", test.expectErr, err)
 			}
diff --git a/pkg/cloudprovider/provider/openstack/provider_test.go b/pkg/cloudprovider/provider/openstack/provider_test.go
index 249815af..672aa763 100644
--- a/pkg/cloudprovider/provider/openstack/provider_test.go
+++ b/pkg/cloudprovider/provider/openstack/provider_test.go
@@ -295,7 +295,7 @@ func TestCreateServer(t *testing.T) {
 			// It only verifies that the content of the create request matches
 			// the expectation
 			// TODO(irozzo) check the returned instance too
-			_, err := p.Create(m, tt.data, tt.userdata)
+			_, err := p.Create(context.Background(), m, tt.data, tt.userdata)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("provider.Create() or = %v, wantErr %v", err, tt.wantErr)
 				return
diff --git a/pkg/cloudprovider/provider/vsphere/helper_test.go b/pkg/cloudprovider/provider/vsphere/helper_test.go
index 8bdad74a..359d867e 100644
--- a/pkg/cloudprovider/provider/vsphere/helper_test.go
+++ b/pkg/cloudprovider/provider/vsphere/helper_test.go
@@ -98,7 +98,7 @@ func TestResolveDatastoreRef(t *testing.T) {
 			tt.config.Datacenter = "DC0"
 
 			session, err := NewSession(ctx, tt.config)
-			defer session.Logout()
+			defer session.Logout(ctx)
 			if err != nil {
 				t.Fatalf("error creating session: %v", err)
 			}
@@ -216,7 +216,7 @@ func TestResolveResourcePoolRef(t *testing.T) {
 			tt.config.Datacenter = "DC0"
 
 			session, err := NewSession(ctx, tt.config)
-			defer session.Logout()
+			defer session.Logout(ctx)
 			if err != nil {
 				t.Fatalf("error creating session: %v", err)
 			}
diff --git a/pkg/cloudprovider/provider/vsphere/provider_test.go b/pkg/cloudprovider/provider/vsphere/provider_test.go
index 3987483e..481d030e 100644
--- a/pkg/cloudprovider/provider/vsphere/provider_test.go
+++ b/pkg/cloudprovider/provider/vsphere/provider_test.go
@@ -178,7 +178,7 @@ func TestValidate(t *testing.T) {
 			tt.args.URL = vSphereURL
 			m := cloudprovidertesting.Creator{Name: "test", Namespace: "vsphere", ProviderSpecGetter: tt.args.rawProviderSpec}.
 				CreateMachine(t)
-			if err := p.Validate(m.Spec); (err != nil) != tt.wantErr {
+			if err := p.Validate(context.Background(), m.Spec); (err != nil) != tt.wantErr {
 				t.Errorf("provider.Validate() error = %v, wantErr %v", err, tt.wantErr)
 			}
 		})
diff --git a/pkg/rhsm/subscription_manager_test.go b/pkg/rhsm/subscription_manager_test.go
index a95b4d57..e081401f 100644
--- a/pkg/rhsm/subscription_manager_test.go
+++ b/pkg/rhsm/subscription_manager_test.go
@@ -17,6 +17,7 @@ limitations under the License.
 package rhsm
 
 import (
+	"context"
 	"fmt"
 	"net/http"
 	"net/http/httptest"
@@ -62,7 +63,7 @@ func TestDefaultRedHatSubscriptionManager_UnregisterInstance(t *testing.T) {
 			manager.(*defaultRedHatSubscriptionManager).authURL = tt.testingServer.URL
 			manager.(*defaultRedHatSubscriptionManager).requestsLimiter = tt.requestLimiter
 
-			if err := manager.UnregisterInstance(tt.offlineToken, tt.machineName); err != nil {
+			if err := manager.UnregisterInstance(context.Background(), tt.offlineToken, tt.machineName); err != nil {
 				t.Fatalf("failed executing test: %v", err)
 			}
 		})
diff --git a/test/e2e/provisioning/migrateuidscenario.go b/test/e2e/provisioning/migrateuidscenario.go
index 96579ff0..66e3537a 100644
--- a/test/e2e/provisioning/migrateuidscenario.go
+++ b/test/e2e/provisioning/migrateuidscenario.go
@@ -87,10 +87,12 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 	}
 	machine.Spec = defaultedSpec
 
+	ctx := context.Background()
+
 	// Step 0: Create instance with old UID
 	maxTries := 15
 	for i := 0; i < maxTries; i++ {
-		_, err := prov.Get(machine, providerData)
+		_, err := prov.Get(ctx, machine, providerData)
 		if err != nil {
 			if !errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 				if i < maxTries-1 {
@@ -100,7 +102,7 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 				}
 				return fmt.Errorf("failed to get machine %s before creating it: %w", machine.Name, err)
 			}
-			_, err := prov.Create(machine, providerData, "#cloud-config\n")
+			_, err := prov.Create(ctx, machine, providerData, "#cloud-config\n")
 			if err != nil {
 				if i < maxTries-1 {
 					time.Sleep(10 * time.Second)
@@ -115,7 +117,7 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 
 	// Step 1: Verify we can successfully get the instance
 	for i := 0; i < maxTries; i++ {
-		if _, err := prov.Get(machine, providerData); err != nil {
+		if _, err := prov.Get(ctx, machine, providerData); err != nil {
 			if i < maxTries-1 {
 				klog.V(4).Infof("failed to get instance for machine %s before migrating on try %v with err=%v, will retry", machine.Name, i, err)
 				time.Sleep(10 * time.Second)
@@ -128,7 +130,7 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 
 	// Step 2: Migrate UID
 	for i := 0; i < maxTries; i++ {
-		if err := prov.MigrateUID(machine, newUID); err != nil {
+		if err := prov.MigrateUID(ctx, machine, newUID); err != nil {
 			if i < maxTries-1 {
 				time.Sleep(10 * time.Second)
 				klog.V(4).Infof("failed to migrate UID for machine %s  on try %v with err=%v, will retry", machine.Name, i, err)
@@ -142,7 +144,7 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 
 	// Step 3: Verify we can successfully get the instance with the new UID
 	for i := 0; i < maxTries; i++ {
-		if _, err := prov.Get(machine, providerData); err != nil {
+		if _, err := prov.Get(ctx, machine, providerData); err != nil {
 			if i < maxTries-1 {
 				time.Sleep(10 * time.Second)
 				klog.V(4).Infof("failed to get instance for machine %s after migrating on try %v with err=%v, will retry", machine.Name, i, err)
@@ -156,7 +158,7 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 	// Step 4: Delete the instance and then verify instance is gone
 	for i := 0; i < maxTries; i++ {
 		// Deletion part 0: Delete and continue on err if there are tries left
-		done, err := prov.Cleanup(machine, providerData)
+		done, err := prov.Cleanup(ctx, machine, providerData)
 		if err != nil {
 			if i < maxTries-1 {
 				klog.V(4).Infof("Failed to delete machine %s on try %v with err=%v, will retry", machine.Name, i, err)
@@ -172,7 +174,7 @@ func verifyMigrateUID(kubeConfig, manifestPath string, parameters []string, time
 		}
 
 		// Deletion part 1: Get and continue if err != cloudprovidererrors.ErrInstanceNotFound if there are tries left
-		_, err = prov.Get(machine, providerData)
+		_, err = prov.Get(ctx, machine, providerData)
 		if err != nil && errors.Is(err, cloudprovidererrors.ErrInstanceNotFound) {
 			break
 		}