Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Make MaxConcurrentReconciles configurable #138

Merged
merged 17 commits into from
Jun 5, 2024
Merged

Conversation

piepmatz
Copy link
Contributor

What is the purpose of this pull request/Why do we need it?

Improve performance by having more worker goroutines per controller.

Description of changes:

Besides the actual flags for specifying the number of concurrent reconciles per controller, this change adds locks as needed for thread safety.

This applies to 3 kinds of operations:

  • Creating, updating and deleting LANs, as they are shared across machines.
  • IP block creation and deletion for machine failover IPs, as they are shared across machines.
  • Accessing the IonosCloudCluster.Status.CurrentRequestByDatacenter map, as it is shared across machines.

For locking, a new locker package was added.

Special notes for your reviewer:

Reviewing commit by commit should be the easiest way.

Checklist:

  • Documentation updated
  • Unit Tests added
  • E2E Tests added
  • Includes emojis

api/v1alpha1/ionoscloudcluster_types.go Outdated Show resolved Hide resolved
api/v1alpha1/ionoscloudcluster_types.go Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
api/v1alpha1/ionoscloudcluster_types.go Outdated Show resolved Hide resolved
internal/util/locker/locker.go Show resolved Hide resolved
internal/service/cloud/network.go Outdated Show resolved Hide resolved
piepmatz added 9 commits May 29, 2024 15:47
Keeps the `api` package clean.

To scope the lock to a specific ICC, we make use of the keyed locks here
again, even though we don't need their ability to react on canceled
contexts. We therefore pass `context.Background` and ignore the error,
as none can occur.

In contrast to the previous approach, we lose the differentiation
between read-only and read-write locks, but even for writing the locks
are very short-lived, so it doesn't matter.
(If we only had unit tests for the controllers...)

Locking `CurrentRequestByDatacenter` in the cluster scope is better than
doing in the machine scope. I had that first, but the code looked
strange and unrelated when suddenly patching the cluster after doing
things in the machine scope.

That's why the cluster scope contains a locker now. However, that
scope is used from the machine controller. It cannot (and should not)
access the cluster controller, so when building the cluster scope, the
machine controller needs to pass its own locker.
At the same time, the cluster controller also creates a cluster scope
and is now required to pass a locker, even though it doesn't actually
need one for its own work.

An alternative could be having a controller package-wide locker (global
variable)
Same for the `SetupWithManager` methods.

I'm not convinced about this, but it's in-line with other providers.
internal/service/cloud/network.go Show resolved Hide resolved
internal/service/cloud/network.go Show resolved Hide resolved
scope/cluster.go Show resolved Hide resolved
scope/cluster.go Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
7.6% Duplication on New Code

See analysis details on SonarCloud

@piepmatz piepmatz merged commit 08a6d12 into main Jun 5, 2024
9 checks passed
@piepmatz piepmatz deleted the controller-concurrency branch June 5, 2024 11:25
Mattes83 pushed a commit to Mattes83/cluster-api-provider-ionoscloud that referenced this pull request Jun 7, 2024
Improve performance by having more worker goroutines per controller.

Besides the actual flags for specifying the number of concurrent
reconciles per controller, this change adds locks as needed for thread
safety.

This applies to 3 kinds of operations:
- Creating, updating and deleting LANs, as they are shared across
machines.
- IP block creation and deletion for machine failover IPs, as they are
shared across machines.
- Accessing the `IonosCloudCluster.Status.CurrentRequestByDatacenter`
map, as it is shared across machines.

For locking, a new `locker` package was added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants