Skip to content

refactor: Group setup by feature flag #3647

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

Merged

Conversation

dlipovetsky
Copy link
Contributor

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
While reviewing #3633, I noticed that we had set up reconcilers and webhooks based on feature flags in main itself, although we put some code in a separate enableGates function. I also noticed that we had two identical conditional blocks to setup EKS-only reconcilers and webhooks, respectively.

To make the setup code easier to follow, I grouped it by feature flag, because that seems like the most useful grouping. (This means we interleave the setup of reconcilers and webhooks; I think this is safe, but hope to get feedback).

I also moved the EKS-only setup into a separate function.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 4, 2022
@k8s-ci-robot
Copy link
Contributor

@dlipovetsky: This issue is currently awaiting triage.

If CAPA/CAPI contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 4, 2022
@dlipovetsky
Copy link
Contributor Author

Test failed:

=== RUN   TestAWSMachineReconciler_Reconcile/Should_not_Reconcile_if_AWSCluster_is_not_ready
I0804 00:20:43.000630   22680 http.go:97] controller-runtime/webhook/webhooks "msg"="received request" "UID"="d669b5fa-cd56-43e7-b8de-f0d23f9f7fdd" "kind"={"group":"infrastructure.cluster.x-k8s.io","version":"v1beta1","kind":"AWSMachine"} "resource"={"group":"infrastructure.cluster.x-k8s.io","version":"v1beta1","resource":"awsmachines"} "webhook"="/mutate-infrastructure-cluster-x-k8s-io-v1beta1-awsmachine"
I0804 00:20:43.001033   22680 http.go:136] controller-runtime/webhook/webhooks "msg"="wrote response" "UID"="d669b5fa-cd56-43e7-b8de-f0d23f9f7fdd" "allowed"=true "code"=200 "reason"="" "webhook"="/mutate-infrastructure-cluster-x-k8s-io-v1beta1-awsmachine"
I0804 00:20:43.003586   22680 http.go:97] controller-runtime/webhook/webhooks "msg"="received request" "UID"="15e768c4-d44b-452d-a280-7793a5de6352" "kind"={"group":"infrastructure.cluster.x-k8s.io","version":"v1beta1","kind":"AWSMachine"} "resource"={"group":"infrastructure.cluster.x-k8s.io","version":"v1beta1","resource":"awsmachines"} "webhook"="/validate-infrastructure-cluster-x-k8s-io-v1beta1-awsmachine"
I0804 00:20:43.003815   22680 http.go:136] controller-runtime/webhook/webhooks "msg"="wrote response" "UID"="15e768c4-d44b-452d-a280-7793a5de6352" "allowed"=true "code"=200 "reason"="" "webhook"="/validate-infrastructure-cluster-x-k8s-io-v1beta1-awsmachine"
    awsmachine_controller_unit_test.go:2312: 
        Expected
            <*errors.StatusError | 0xc000b5ef00>: {
                ErrStatus: {
                    TypeMeta: {Kind: "", APIVersion: ""},
                    ListMeta: {
                        SelfLink: "",
                        ResourceVersion: "",
                        Continue: "",
                        RemainingItemCount: nil,
                    },
                    Status: "Failure",
                    Message: "Machine.cluster.x-k8s.io \"capi-test-machine\" not found",
                    Reason: "NotFound",
                    Details: {
                        Name: "capi-test-machine",
                        Group: "cluster.x-k8s.io",
                        Kind: "Machine",
                        UID: "",
                        Causes: nil,
                        RetryAfterSeconds: 0,
                    },
                    Code: 404,
                },
            }
        to be nil
...
    --- FAIL: TestAWSMachineReconciler_Reconcile/Should_not_Reconcile_if_AWSCluster_is_not_ready (0.06s)

I've repeated (not using cached results) this test 10 times locally but still haven't seen a failure.

@Ankitasw
Copy link
Member

Ankitasw commented Aug 4, 2022

/retest

@Ankitasw
Copy link
Member

Ankitasw commented Aug 4, 2022

retest passed, weird that it failed as this issue was fixed long back. lets see if we face this again, although little difficult to debug if not failing locally.

@richardcase
Copy link
Member

/test ?

@k8s-ci-robot
Copy link
Contributor

@richardcase: The following commands are available to trigger required jobs:

  • /test pull-cluster-api-provider-aws-build
  • /test pull-cluster-api-provider-aws-test
  • /test pull-cluster-api-provider-aws-verify

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-aws-apidiff-main
  • /test pull-cluster-api-provider-aws-e2e
  • /test pull-cluster-api-provider-aws-e2e-blocking
  • /test pull-cluster-api-provider-aws-e2e-clusterclass
  • /test pull-cluster-api-provider-aws-e2e-conformance
  • /test pull-cluster-api-provider-aws-e2e-conformance-with-ci-artifacts
  • /test pull-cluster-api-provider-aws-e2e-eks

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-provider-aws-apidiff-main
  • pull-cluster-api-provider-aws-build
  • pull-cluster-api-provider-aws-test
  • pull-cluster-api-provider-aws-verify

In response to this:

/test ?

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.

@richardcase
Copy link
Member

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks

@richardcase
Copy link
Member

I like this change @dlipovetsky , its a lot cleaner 👍

From myside:

/lgtm

(assuming the e2e pass)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2022
@Ankitasw
Copy link
Member

Ankitasw commented Aug 8, 2022

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks

@sedefsavas
Copy link
Contributor

/approve

@sedefsavas sedefsavas added this to the v1.6.0 milestone Aug 9, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sedefsavas

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit 13f00d0 into kubernetes-sigs:main Aug 9, 2022
@k8s-ci-robot k8s-ci-robot modified the milestones: v1.6.0, v1.x Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants