Skip to content

Implement proper contexts in scope methods #1573

@salasberryfin

Description

@salasberryfin

Description

The project uses context.TODO() extensively because no proper context is implemented in some scope methods. This is an accepted solution for a simplified use of contexts in testing code and we can keep this unchanged, but it should be fixed in any non-test files as this context configuration is essentially a placeholder that will never time out.

A quick search shows that this should be addressed in the following files:

  • cloud/scope/machine.go
  • cloud/scope/cluster.go
  • cloud/scope/managedcluster.go
  • cloud/scope/managedcontrolplane.go
  • cloud/scope/managedmachinepool.go

I may have missed other occurrences of this syntax

One possible solution is to pass contexts as a scope method parameter:

func (s *ClusterScope) PatchObject(ctx context.Context) error {
    ...
}

This solution is aligned with other CAPI projects, i.e. CAPZ

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions