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

chore(*) migrate from closed channel to context for app lifetime #2804

Merged
merged 5 commits into from
Sep 21, 2021

Conversation

lahabana
Copy link
Contributor

This is required because newer versions of the controller-runtime
will rely on context instead of a closed channel to indicate that
the app should shutdown

Signed-off-by: Charly Molter charly.molter@konghq.com

  • Add backport-to-stable label if the code is backwards compatible. Otherwise, list breaking changes.

This is required because newer versions of the controller-runtime
will rely on context instead of a closed channel to indicate that
the app should shutdown

Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana
Copy link
Contributor Author

Related to #2764

@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2021

Codecov Report

Merging #2804 (1ab5d04) into master (fdc5f1a) will increase coverage by 0.03%.
The diff coverage is 71.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2804      +/-   ##
==========================================
+ Coverage   52.04%   52.08%   +0.03%     
==========================================
  Files         882      882              
  Lines       51320    51321       +1     
==========================================
+ Hits        26708    26728      +20     
+ Misses      22490    22469      -21     
- Partials     2122     2124       +2     
Impacted Files Coverage Δ
pkg/plugins/bootstrap/k8s/plugin.go 2.81% <0.00%> (ø)
pkg/core/alias.go 13.33% <7.14%> (-86.67%) ⬇️
app/kuma-prometheus-sd/cmd/run.go 28.20% <33.33%> (+0.70%) ⬆️
pkg/plugins/config/k8s/store.go 47.36% <33.33%> (ø)
app/kuma-dp/cmd/root.go 68.29% <66.66%> (ø)
app/kuma-cp/cmd/run.go 23.42% <75.00%> (-2.67%) ⬇️
pkg/core/runtime/builder.go 63.95% <92.30%> (ø)
app/kuma-cp/cmd/root.go 53.65% <100.00%> (ø)
app/kuma-dp/cmd/run.go 70.74% <100.00%> (-0.59%) ⬇️
app/kuma-prometheus-sd/cmd/root.go 56.41% <100.00%> (+5.12%) ⬆️
... and 17 more

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 fdc5f1a...1ab5d04. Read the comment docs.

app/kuma-cp/cmd/run.go Outdated Show resolved Hide resolved
app/kuma-prometheus-sd/cmd/root_helper_test.go Outdated Show resolved Hide resolved
app/kuma-prometheus-sd/cmd/run.go Outdated Show resolved Hide resolved
pkg/core/alias.go Outdated Show resolved Hide resolved
@@ -84,11 +84,11 @@ func (r *PodReconciler) Reconcile(req kube_ctrl.Request) (kube_ctrl.Result, erro
if pod.Namespace != r.SystemNamespace {
return kube_ctrl.Result{}, errors.Errorf("Ingress can only be deployed in system namespace %q", r.SystemNamespace)
}
services, err := r.findMatchingServices(pod)
services, err := r.findMatchingServices(ctx, pod)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than passing the context down everywhere, what about making it a public member of PodReconciler, and if it isn't already set in Reconcile, initialize it to context.Background() there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the upgrade to the next version of controller-runtime this method becomes Reconcile(ctx, req) so knowing this I'd rather keep it this way.

pkg/core/runtime/runtime.go Show resolved Hide resolved
@@ -178,7 +179,8 @@ var _ = Describe("Dataplane Lifecycle", func() {
err := callbacks.OnStreamRequest(streamId, &req)
Expect(err).ToNot(HaveOccurred())

close(shutdown)
cancel()
cancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

Twice?

Signed-off-by: Charly Molter <charly.molter@konghq.com>
Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana lahabana merged commit 09949cf into kumahq:master Sep 21, 2021
mergify bot pushed a commit that referenced this pull request Sep 21, 2021
This is required because newer versions of the controller-runtime
will rely on context instead of a closed channel to indicate that
the app should shutdown

Signed-off-by: Charly Molter <charly.molter@konghq.com>
(cherry picked from commit 09949cf)

# Conflicts:
#	.golangci.yml
jakubdyszkiewicz pushed a commit that referenced this pull request Sep 27, 2021
This is required because newer versions of the controller-runtime
will rely on context instead of a closed channel to indicate that
the app should shutdown

Signed-off-by: Charly Molter <charly.molter@konghq.com>
nikita15p pushed a commit to nikita15p/kuma that referenced this pull request Sep 28, 2021
…ahq#2804)

This is required because newer versions of the controller-runtime
will rely on context instead of a closed channel to indicate that
the app should shutdown

Signed-off-by: Charly Molter <charly.molter@konghq.com>
nikita15p pushed a commit to nikita15p/kuma that referenced this pull request Sep 28, 2021
…ahq#2804)

This is required because newer versions of the controller-runtime
will rely on context instead of a closed channel to indicate that
the app should shutdown

Signed-off-by: Charly Molter <charly.molter@konghq.com>
@lahabana lahabana deleted the chore/ctx branch March 29, 2024 12:38
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.

None yet

4 participants