cluster-api-provider-aws icon indicating copy to clipboard operation
cluster-api-provider-aws copied to clipboard

Refactor reconciler function signatures in controllers

Open Ankitasw opened this issue 3 years ago • 13 comments
trafficstars

/kind refactor

Describe the solution you'd like SInce we have got a lot of input scope parameters to reconcile functions in controllers, it would be good to add an input struct for these functions with all the scopes we are passing in.

Example Current code

func (r *AWSMachineReconciler) reconcileDelete(machineScope *scope.MachineScope, clusterScope cloud.ClusterScoper, ec2Scope scope.EC2Scope, elbScope scope.ELBScope, objectStoreScope scope.S3Scope) (ctrl.Result, error) {

Expectation

type ReconcilerScopes struct {
  machineScope *scope.MachineScope
  clusterScope cloud.ClusterScoper
  ec2Scope scope.EC2Scope
  elbScope scope.ELBScope
  objectStoreScope scope.S3Scope
}
func (r *AWSMachineReconciler) reconcileDelete(rs ReconcilerScopes) (ctrl.Result, error) {

We should take care of all such instances in controllers. Originally posted by @richardcase in https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/2271#r805753482

Ankitasw avatar Mar 16 '22 08:03 Ankitasw

/triage accepted /priority backlog /help

richardcase avatar Mar 16 '22 08:03 richardcase

@richardcase: This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to this:

/triage accepted /priority backlog /help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 16 '22 08:03 k8s-ci-robot

/assign

LucaLanziani avatar Mar 31 '22 01:03 LucaLanziani

@LucaLanziani - it's probably worth synching with @Ankitasw as she is doing some refactoring in a similar area with #3345

richardcase avatar Apr 01 '22 13:04 richardcase

@richardcase I think this refactor should not collide with what I am doing in #3345, is it correct? Yeah but since we will have two PRs raised, we might get merge conflicts.

Ankitasw avatar Apr 01 '22 13:04 Ankitasw

I was looking yesterday at the code and I've seen that in the tests the reconcideDelete method is called using multiple cluster scopes instead of passing the different scopes.

I didn't have time to go into details on why that is but I was thinking that it might look confusing when passing in a struct if the struct looks something like this:

type ReconcilerScopes struct {
  machineScope *scope.MachineScope
  clusterScope cloud.ClusterScoper
  ec2Scope scope.EC2Scope
  elbScope scope.ELBScope
  objectStoreScope scope.S3Scope
}

rs := ReconcilerScopes{
  machineScope: ms,
  clusterScope: cs,
  ec2Scope: cs,
  elbScope: cs,
  objectStoreScope: cs,
}

LucaLanziani avatar Apr 01 '22 13:04 LucaLanziani

@richardcase I think this refactor should not collide with what I am doing in #3345, is it correct? Yeah but since we will have two PRs raised, we might get merge conflicts.

What you are telling me is that I should move faster and try to get my PR in before yours ;P

LucaLanziani avatar Apr 01 '22 13:04 LucaLanziani

@richardcase I think this refactor should not collide with what I am doing in #3345, is it correct? Yeah but since we will have two PRs raised, we might get merge conflicts.

What you are telling me is that I should move faster and try to get my PR in before yours ;P

:rofl: I only mentioned it for awareness because you are working on the same controllers.

richardcase avatar Apr 01 '22 14:04 richardcase

I didn't have time to go into details on why that is but I was thinking that it might look confusing when passing in a struct if the struct looks something like this:

Personally i think we are getting to the point where passing a struct is preferable to the large number of arguments, it would be a bit cleaner. We could call it something like:

type reconcileDeleteInput struct {
}

Or something like that.

richardcase avatar Apr 01 '22 14:04 richardcase

Personally i think we are getting to the point where passing a struct is preferable to the large number of arguments, it would be a bit cleaner. We could call it something like:

type reconcileDeleteInput struct {
}

Or something like that.

I just realized that I linked the wrong line on the test, I'm ok to change the name of the structure, I was more referring to the fact that we are assigning the same cs to ec2Scope, elbScope, objectStoreScope

LucaLanziani avatar Apr 01 '22 14:04 LucaLanziani

/lifecycle active

LucaLanziani avatar Apr 25 '22 16:04 LucaLanziani

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jul 24 '22 17:07 k8s-triage-robot

/remove-lifecycle stale

richardcase avatar Jul 27 '22 16:07 richardcase

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Oct 25 '22 16:10 k8s-triage-robot

/remove-lifecycle stale

Skarlso avatar Oct 26 '22 06:10 Skarlso

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Feb 08 '23 10:02 k8s-triage-robot

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot avatar Feb 08 '24 11:02 k8s-triage-robot