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

Add persistent cache store backed by ConfigMap. Refactor mtping #3451

Merged
merged 12 commits into from
Jul 17, 2020

Conversation

lionelvillard
Copy link
Member

@lionelvillard lionelvillard commented Jun 30, 2020

One step towards #3157

Proposed Changes

  • Add a new PersistentStore utility for persisting informer cache to a ConfigMap
  • Adapter can now be configured to watch for ConfigMap changes. Disabled by default.
  • mtping now watches a single (for now) configmap, instead of watching all PingSources.

Release Note

- 🧽 The multi-tenant PingSource adapter consumes less resources.

Docs

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 30, 2020
@lionelvillard lionelvillard changed the title mtping now gets PingSources spec from a mounted configmap WIP: mtping now gets PingSources spec from a mounted configmap Jun 30, 2020
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2020
@lionelvillard
Copy link
Member Author

FYI. @nachocano @pierDipi

@lionelvillard
Copy link
Member Author

lionelvillard commented Jul 1, 2020

I'm really not convinced mounting the configmap vs creating a watch is more efficient. Under the cover the kubelet creates a reflector for each pod with a mounted configmap (not verified): https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/util/manager/watch_based_manager.go#L149

Since HA works with watches, I think I'll stick with it (at least for now).

@nachocano @pierDipi I know you have been looking at this. Any insights?

Edit: more info: https://kubernetes.io/docs/concepts/configuration/configmap/#mounted-configmaps-are-updated-automatically. Specifically: improves performance of your cluster by significantly reducing load on kube-apiserver, by closing watches for config maps marked as immutable.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 14, 2020
@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 14, 2020
@lionelvillard lionelvillard changed the title WIP: mtping now gets PingSources spec from a mounted configmap WIP: add persistent cache store backed by ConfigMap Jul 14, 2020
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 14, 2020
@lionelvillard lionelvillard changed the title WIP: add persistent cache store backed by ConfigMap Add persistent cache store backed by ConfigMap. Refactor mtping Jul 14, 2020
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2020
@lgtm-com
Copy link

lgtm-com bot commented Jul 14, 2020

This pull request introduces 1 alert when merging 0a0275a into 5c276d0 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jul 14, 2020

This pull request introduces 1 alert when merging 706ae64 into 5c276d0 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

Copy link
Contributor

@cr22rc cr22rc left a comment

Choose a reason for hiding this comment

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

Look at minor issues
/lgm

cmd/mtping/main.go Show resolved Hide resolved
pkg/reconciler/pingsource/pingsource.go Outdated Show resolved Hide resolved
pkg/adapter/mtping/adapter.go Outdated Show resolved Hide resolved
event.SetExtension(key, override)
}
}

ctx := context.Background()
ctx = cloudevents.ContextWithTarget(ctx, sink)
ctx = cloudevents.ContextWithTarget(ctx, cfg.SinkURI)
Copy link
Contributor

Choose a reason for hiding this comment

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

check for error returned?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is no error returned here.

@knative-prow-robot knative-prow-robot added the area/test-and-release Test infrastructure, tests or release label Jul 15, 2020
@lionelvillard
Copy link
Member Author

this is really annoying. Can't reproduce locally :-(

@lionelvillard
Copy link
Member Author

seems unrelated
/test pull-knative-eventing-integration-tests

@lionelvillard
Copy link
Member Author

/test pull-knative-eventing-integration-tests

@vaikas
Copy link
Contributor

vaikas commented Jul 16, 2020

Can you share more about the motivation for this? controller is watching for all the CRs already, are you running into issues there?

@lionelvillard
Copy link
Member Author

This is for #3157. The gist of it is in this comment

The main motivation is to be able to partition CRs across multiple receive adapters and to make sure they are HA. It seems natural to use a ConfigMap as our resource lock, which happens to also contain the resources the leading receive adapter needs to handle. At the same time, using a ConfigMap makes our receive adapters lighter weight since they don't need to store all CRs anymore.

Note that GCPPubSub is already doing this I believe (except that it mounts the ConfigMap instead of setting a watch).

The HA design follows the Per-Reconciler Leader Election design adapted to support Adapter instead of LeaderAware reconciler.

Does that make sense? @vaikas

@cr22rc
Copy link
Contributor

cr22rc commented Jul 17, 2020

/lgtm

@knative-prow-robot
Copy link
Contributor

@cr22rc: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/adapter/mtping/adapter.go 100.0% 90.0% -10.0
pkg/adapter/mtping/config.go Do not exist 85.7%
pkg/adapter/mtping/runner.go 92.9% 84.5% -8.4
pkg/adapter/v2/config_watcher.go Do not exist 78.9%
pkg/adapter/v2/main.go 60.4% 54.8% -5.6
pkg/reconciler/pingsource/controller.go 93.1% 93.5% 0.4
pkg/utils/cache/persisted_store.go Do not exist 78.6%

if entry, ok := a.entryids[key]; ok {
a.Logger.Info("deleting schedule", zap.Any("key", key))
a.RemoveSchedule(entry.entryID)
delete(a.entryids, key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you need some synchronization when you're messing with the map and using it in different places?

Copy link
Member Author

Choose a reason for hiding this comment

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

The map in only used in this function and it is guaranteed to be called by only one go routine (see persistent_store)

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@vaikas
Copy link
Contributor

vaikas commented Jul 17, 2020

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 17, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cr22rc, lionelvillard, vaikas

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:
  • OWNERS [lionelvillard,vaikas]

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

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-eventing-integration-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-eventing-integration-tests:

test/e2e.TestPingSourceV1Alpha2EventTypes

@lionelvillard
Copy link
Member Author

/test pull-knative-eventing-integration-tests

@knative-prow-robot knative-prow-robot merged commit 1cbaa24 into knative:master Jul 17, 2020
@lionelvillard lionelvillard deleted the mtping-configmap branch August 28, 2020 15:38
@lionelvillard lionelvillard restored the mtping-configmap branch September 3, 2020 15:42
@lionelvillard lionelvillard deleted the mtping-configmap branch September 3, 2020 15:59
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. area/test-and-release Test infrastructure, tests or release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants