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

use AutoHandlers instead of custom enablement logic #1585

Merged
merged 14 commits into from
Aug 5, 2021

Conversation

mflendrich
Copy link
Contributor

@mflendrich mflendrich commented Jul 23, 2021

part of #1580

This PR:

  • puts the behavior of dynamically enabling KongClusterPlugin support under an auto setting (as opposed to enabled, thus providing explicit distinction between "enabled unconditionally, please fail when not working" and "enabled if the cluster supports it and silently disabled otherwise")
  • puts the behavior of dynamically enabling knative ingress support under auto (ditto)
  • puts the behavior of dynamically picking the highest supported ingress version under auto (ditto)
  • replaces flag defaults for the above with auto (was enabled)
  • refactors AutoHandler into using k8s client.Client instead of client.Reader - a wider interface - because the existing implementation of CRDExists() makes use of raw REST calls that are not possible with client.Reader
  • removes explicit flag settings from the integration test invocation - so that we test that the default settings result in a functional setup. Note that this isn't a complete test for the auto enablement status.

@mflendrich mflendrich requested a review from a team as a code owner July 23, 2021 23:26
@mflendrich mflendrich temporarily deployed to Configure ci July 23, 2021 23:26 Inactive
@mflendrich mflendrich requested a review from shaneutt July 23, 2021 23:28
@mflendrich mflendrich marked this pull request as draft July 23, 2021 23:28
@codecov
Copy link

codecov bot commented Jul 23, 2021

Codecov Report

Merging #1585 (b5f3145) into next (15d7609) will decrease coverage by 0.07%.
The diff coverage is 95.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #1585      +/-   ##
==========================================
- Coverage   62.12%   62.04%   -0.08%     
==========================================
  Files          83       81       -2     
  Lines        7326     7272      -54     
==========================================
- Hits         4551     4512      -39     
+ Misses       2443     2431      -12     
+ Partials      332      329       -3     
Flag Coverage Δ
integration-test 62.04% <95.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/manager/controllerdef.go 95.48% <93.97%> (+11.08%) ⬆️
internal/manager/config.go 91.96% <100.00%> (-0.15%) ⬇️
internal/manager/ingressapi.go 97.05% <100.00%> (ø)
internal/manager/run.go 47.82% <100.00%> (ø)
internal/sendconfig/sendconfig.go 54.07% <0.00%> (-12.60%) ⬇️
internal/proxy/clientgo_cached_proxy_resolver.go 81.41% <0.00%> (-1.77%) ⬇️
internal/ctrlutils/ingress-status.go 48.67% <0.00%> (-1.21%) ⬇️
internal/parser/parser.go 87.67% <0.00%> (-1.15%) ⬇️
...trollers/configuration/zz_generated_controllers.go 35.82% <0.00%> (+0.50%) ⬆️
pkg/apis/configuration/v1/zz_generated.deepcopy.go 37.50% <0.00%> (+4.83%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15d7609...b5f3145. Read the comment docs.

@mflendrich mflendrich temporarily deployed to Configure ci July 23, 2021 23:45 Inactive
@shaneutt shaneutt force-pushed the refactor/cleanup-enablement branch from 7c3facd to 3871221 Compare July 28, 2021 20:57
@shaneutt
Copy link
Contributor

As per #1591 I rebased this onto the structural changes now in next, let me know if there are any problems 👍

Copy link
Contributor

@rainest rainest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the content currently here per #1580 (comment). If we ultimately decide to use booleans, we can refactor that separately. We want the change to AutoHander implementation regardless.

As far as I understand the WIP status, there are only some further documentation changes and test changes pending, and the code is not expected to change further. Less interested in those/reasonably confident that the additions will be fine, so going ahead and approving this on the basis of the implementation changes. Please dismiss and re-request review if the subsequent changes are large enough that you want another pass.

One question though: this changes the config defaults such that everything is enabled or auto by default, but doesn't remove all controller flags from the tests. Is there a reason we're still leaving in some of the overrides? Most look now irrelevant, and the disabled kongconsumer controller looks outright wrong/left over from when it wasn't implemented.

Tests pass on next with all of the flags removed from the test, and will presumably pass with them all removed when we make whatever remaining tests changes are needed here.

Lastly, integration testing with some CRDs absent seems a bit excessive, since it'd require a completely different cluster environment. Can we mock the K8S API and resource availability in it? Unit tests for CRDExists and the Ingress version negotiator sound more reasonable.

internal/manager/config.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ccfishk ccfishk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@rainest rainest mentioned this pull request Aug 3, 2021
1 task
* refactor(mgr) use booleans for controller flags

Change flags for managing controllers from a custom
enabled/auto/disabled type to booleans. By default, all controllers are
enabled. If a controller's enable flag is set to false, it is disabled.
Enabled controllers that have an auto loader are loaded if they are
enabled and their auto loader indicates they should load.

Remove the KongStateEnabled flag. This was a leftover from an earlier
design where the controller managed Kong state information via a special
Secret. It had no remaining associated code and was only present in
configuration.

Rename controller flags to reflect that they enable controllers.

Remove enablement status type, associated utility functions, and custom
flag handler.

* fix(test) only defer body close if exists

Move deferred body close checks after the error checkers. If an error is
present, no body exists, and the deferred attempt to close it segfaults.

Co-authored-by: Michał Flendrich <michal@flendrich.pro>
@mflendrich mflendrich marked this pull request as ready for review August 5, 2021 13:27
@mflendrich mflendrich changed the title [wip] use AutoHandlers instead of custom enablement logic use AutoHandlers instead of custom enablement logic Aug 5, 2021
@mflendrich mflendrich enabled auto-merge (squash) August 5, 2021 18:37
@mflendrich mflendrich merged commit 52bf3fc into next Aug 5, 2021
@mflendrich mflendrich deleted the refactor/cleanup-enablement branch August 5, 2021 21:18
@rainest rainest mentioned this pull request Aug 11, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants