Commit Graph

24 Commits

Author SHA1 Message Date
Victor Agababov 6940870178
Fix the test for go 1.15 (#1574)
The duration parsing errors are now quoted, so check for prefix
2020-07-30 17:51:01 -07:00
Victor Agababov afdc8bb9f4
Fix the race in the test (#1545)
The test was inherently racy and I saw it flake more than once (e.g. https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_pkg/1526/pull-knative-pkg-unit-tests/1286086935722332160)
So this fixes it.
Also other minor nits around the test to make it more readable.
2020-07-22 18:14:57 -07:00
Yanwei Guo 0166004ef1
Another try to use hash.BucketSet for standard leader election mode (#1530)
* do not record for empty metric config

* Revert "do not record for empty metric config"

This reverts commit 539a5e4dbb.

* redo

* use local

* typo

* Update leaderelection/context.go

Co-authored-by: Matt Moore <mattmoor@vmware.com>

* merge another pr

* update dep

* Update hash/bucketer_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update hash/bucketer_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* output diff

* output diff

Co-authored-by: Matt Moore <mattmoor@vmware.com>
Co-authored-by: Victor Agababov <vagababov@gmail.com>
2020-07-21 14:02:54 -07:00
Matt Moore c0a9ec7f11
Make the chaosduck jitter (#1527) 2020-07-21 08:53:36 -07:00
Victor Agababov 6cd456823f
Revert "Use hash.BucketSet for standard leader election mode (#1490)" (#1518)
This reverts commit 8d80e63709.
2020-07-17 20:40:33 -07:00
Yanwei Guo 8d80e63709
Use hash.BucketSet for standard leader election mode (#1490)
* do not record for empty metric config

* Revert "do not record for empty metric config"

This reverts commit 539a5e4dbb.

* for standard

* delete bucket

* add s
2020-07-15 16:13:33 -07:00
Yanwei Guo 258f5b86c2
Use hash.BucketSet for StatefulSet mode (#1481)
* do not record for empty metric config

* Revert "do not record for empty metric config"

This reverts commit 539a5e4dbb.

* use hash bucektset for statefulset mode

* add test

* address comments from victor

* use make
2020-07-14 12:18:19 -07:00
Matt Moore 3a916efe5c
Add flags to disable chaos per-component and configure period. (#1487)
* Add flags to disable chaos per-component and configure period.

* Use the new hotness for creating the set
2020-07-14 09:30:19 -07:00
Victor Agababov 16eea5bd5b
remove the ResourceLock field from the pkg/LE (#1482)
we only use a single possible way, so no need to have, parse and validate
field that is in effectg a constant.
2020-07-14 09:15:18 -07:00
Victor Agababov ac02cac99b
Preallocate sets in pkg (#1485) 2020-07-14 00:09:18 -07:00
Matt Moore 906cdfd465
Remove ha.ExtractDeployment dependency. (#1484)
This was part of the review feedback, but it inadvertently introduced a dependency that redefined a flag causing the duck to crash loop.

This copies the function instead of pulling in the dependency.
2020-07-13 23:52:18 -07:00
Matt Moore 5f4f82f095
Add a new "chaosduck" e2e test tool for leaderelection. (#1333)
* Add a new "chaosduck" e2e test tool for leaderelection.

This adds a new main package under knative.dev/pkg/leaderelection/chaosduck, which
decodes the leases in the system namespace to establish the set of components and
their leader pod names and kills a leader pod for each component on a certain period.

* Incorporate feedback from vagababov

* super nit
2020-07-13 15:41:18 -07:00
Matt Moore a81727701f
Enable leader election by default. (#1476)
* Enable HA by default.

This consolidates the core of sharedmain around the new leaderelection logic, which will now be **enabled by default**.

This can now be disabled with `--disable-ha` or by passing `sharedmain.WithHADisabled(ctx)` to `sharedmain.MainWithConfig`.

* vagababov comments, build failure

* Open an issue for enabledComponents removal.

* Move the configmap watcher startup.

This race was uncovered by the chaos duck on knative/serving!  When we have enabled a feature flag, e.g. multi-container, and the webhook pods are restarted, there is a brief window where the webhook is up and healthy before the configmaps have synchronized and the new webhook pod realizes the feature is enabled.

* Drop the import alias
2020-07-13 12:43:18 -07:00
Dave Protasowski e16ecb840d
use coordination.Leases exclusively for leader election (#1439)
* use coordination.Leases exclusively for leader election

Prior locks were for K8s version <1.16

* fix error message
2020-06-29 12:57:29 -07:00
Victor Agababov fe0740d31f
Some cleanups around LE (#1452)
* Some cleanups around LE

- make funcs and types not expected to be used outside private (we can always make them public, should the need arise)
- add some more checks in tests
- fix some strings

* streamline

* hide new

* review

* more
2020-06-27 12:23:28 -07:00
Matt Moore 27389b2fa0
Enable use of StatefulSet in sharedmain. (#1451)
This change allows for (just webhook for now) controllers going through sharedmain to opt into Yanwei's logic by setting several environment variables.

I was able to pull this change in downstream and change the webhook to use a StatefulSet with the following environment:
```
+        # These settings are used for statefulset-based
+        # leader selection.
+        - name: CONTROLLER_ORDINAL
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.name
+        - name: STATEFUL_SERVICE_NAME
+          value: "webhook"
```

Running the above with 10 replicas and 10 buckets worked as intended (keys were evenly distributed across the replicas).
2020-06-27 09:29:28 -07:00
Yanwei Guo f1ee372577
Introduce a StatefulSet type elector builder (#1438)
* do not record for empty metric config

* Revert "do not record for empty metric config"

This reverts commit 539a5e4dbb.

* introduce statefulset builder

* change comment

* address victors comment and capsulation

* make exported func

* Update leaderelection/ordinal_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* Update leaderelection/ordinal_test.go

Co-authored-by: Victor Agababov <vagababov@gmail.com>

* address comment

* format

* address comment from matt

Co-authored-by: Victor Agababov <vagababov@gmail.com>
2020-06-25 19:26:28 -07:00
Matt Moore 7df8fc5d77
Implement the first wave of per-reconciler leaderelection. (#1301)
* Implement the first wave of per-reconciler leaderelection.

Detailed design: https://docs.google.com/document/d/1i_QHjQO2T3SNv49xjZLWlivcc0UvZN1Tbw2NKxThkyM/edit#
Issue: https://github.com/knative/pkg/issues/1181

* Feedback from vagababov

* Feedback from yanweiguo

* Drop IsLeaderFor from the LeaderAware interface.

* Moar vagababov nits

* dprotaso feedback

* Add issue comment, error return

* Incorporate dprotaso test feedback
2020-06-18 19:07:25 -07:00
Victor Agababov fef70cc261
Unexport some constants (#1393)
* fix the space issue

* merge shenanigans

* nit and tests

* Unexport some constants that don't seem to be used anywhere
2020-06-09 11:40:32 -07:00
Markus Thömmes 60f4ae1dbe
Use config map parsing lib and enhance it further. (#1335)
* Use config map parsing lib and enhance it further.

* Unexport test struct values.

* Migrate tracing config too.

* Use sample-rate.
2020-05-18 10:42:06 -07:00
Matt Moore 2d0c254ac6
Incorporate component name into ComponentConfig. (#1246) 2020-04-25 10:15:49 -07:00
Markus Thömmes c09083a601
Fix a few simple linter warnings: unused code, govet warnings etc. (#1191) 2020-04-06 08:21:20 -07:00
Victor Agababov 59d2b06f3e
Fix the defaulting for the leader election config map (#1182)
* update go-cmpt to work with 1.14.

Mostly to fix https://github.com/google/go-cmp/issues/167, but we also pinned at some
random commit, rather than at a release version.

* add new pkg

* Make sure we use same versions in pkg and serving

* Fix the defaulting for the leader election cm

This was missing, but now we can provide the default values.

* Fix the defaulting for the leader election cm

This was missing, but now we can provide the default values.
2020-03-31 07:23:51 -07:00
Paul Morie ca35cb8791
add leader election support to sharedmain (#1019)
* Add leader election config and to sharedmain

* Add new dependencies

* Extract method for RunLeaderElected

* Make leader election config constructor validate

* Rename leader election files

* Always start profiling server whether component has LE lock or not

* Fix entering unreachable section when leader election is disabled

* Address PR feedback
2020-02-26 14:40:50 -08:00