Skip to content

Enable use of StatefulSet in sharedmain. - #1451

Merged
knative-prow-robot merged 1 commit into
knative:masterfrom
mattmoor:allow-statefulset-controllers
Jun 27, 2020
Merged

knative-prow-robot merged 1 commit into
knative:masterfrom
mattmoor:allow-statefulset-controllers

Conversation

@mattmoor

Copy link
Copy Markdown
Member

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).

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).
@mattmoor
mattmoor requested a review from yanweiguo June 27, 2020 15:37
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 27, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 27, 2020
@knative-prow-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor

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

The pull request process is described here

Details 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 27, 2020
@knative-metrics-robot

Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
leaderelection/config.go 72.0% 75.8% 3.8
leaderelection/context.go 84.9% 84.2% -0.7

@vagababov vagababov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

Comment thread leaderelection/config.go

func NewStatefulSetConfig() (*StatefulSetConfig, error) {
var ssc StatefulSetConfig
ssn, _, err := ParseControllerOrdinal()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems strange we parse the value manually and delegate the rest to the envconfig.
It seems envconfig has methods for fancier parsing, which we might use, but this can be done later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder whether we still need StatefulSetName in StatefulSetConfig. It's only used in statefulSetBuilder. BuildElector, where ControllerOrdinal is called. However ControllerOrdinal calls ParseControllerOrdinal which returns stateful set name as well. I think we can just use ParseControllerOrdinal.

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 27, 2020
@knative-prow-robot
knative-prow-robot merged commit 27389b2 into knative:master Jun 27, 2020
@mattmoor
mattmoor deleted the allow-statefulset-controllers branch June 27, 2020 16:54
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. 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.

6 participants