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

Make autoscaling configuration available to the HPA reconciler. #4237

Merged
merged 1 commit into from
Jun 4, 2019

Conversation

markusthoemmes
Copy link
Contributor

Proposed Changes

The HPA reconciler used to not need this configuration but future changes will rely on the autoscaler config. In particular, the default target knobs will need to be able to the HPA reconciler to be able to correctly determine the target concurrency for the HPA spec once /metric=concurrency gets plumbed into the HPA as well.

Release Note

NONE

The HPA reconciler used to not need this configuration but future changes will rely on the autoscaler config. In particular, the default target knobs will need to be able to the HPA reconciler to be able to correctly determine the target concurrency for the HPA spec once /metric=concurrency gets plumbed into the HPA as well.
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 4, 2019
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 4, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@markusthoemmes: 0 warnings.

In response to this:

Proposed Changes

The HPA reconciler used to not need this configuration but future changes will rely on the autoscaler config. In particular, the default target knobs will need to be able to the HPA reconciler to be able to correctly determine the target concurrency for the HPA spec once /metric=concurrency gets plumbed into the HPA as well.

Release Note

NONE

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-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markusthoemmes

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:

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers area/autoscale labels Jun 4, 2019
@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/reconciler/autoscaling/hpa/hpa.go 93.3% 93.3% 0.1

@markusthoemmes
Copy link
Contributor Author

/assign @vagababov

}
}

type testConfigStore struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps just type testConfigStore *config.Config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in Slack: This gets kinda hairy as I need cannot use the pointer type as the aliased type. I'd end up with type testConfigStore config.Config. All of the functions will remain pointer receivers though.

In the ToContext method I'll need to cast the value so the compiler eats it. On the caller side I'll need to define extra variables to be able to get a pointer to this new type.

Here's what the diff would look like:

diff --git a/pkg/reconciler/autoscaling/hpa/hpa_test.go b/pkg/reconciler/autoscaling/hpa/hpa_test.go
index 0af6c524..74de5a22 100644
--- a/pkg/reconciler/autoscaling/hpa/hpa_test.go
+++ b/pkg/reconciler/autoscaling/hpa/hpa_test.go
@@ -415,13 +415,14 @@ func TestReconcile(t *testing.T) {
 	}}
 
 	defer logtesting.ClearAll()
+	configStore := testConfigStore(*defaultConfig())
 	table.Test(t, MakeFactory(func(listers *Listers, opt reconciler.Options) controller.Reconciler {
 		return &Reconciler{
 			Base:        reconciler.NewBase(opt, controllerAgentName),
 			paLister:    listers.GetPodAutoscalerLister(),
 			sksLister:   listers.GetServerlessServiceLister(),
 			hpaLister:   listers.GetHorizontalPodAutoscalerLister(),
-			configStore: &testConfigStore{config: defaultConfig()},
+			configStore: &configStore,
 		}
 	}))
 }
@@ -506,12 +507,10 @@ func defaultConfig() *config.Config {
 	}
 }
 
-type testConfigStore struct {
-	config *config.Config
-}
+type testConfigStore config.Config
 
 func (t *testConfigStore) ToContext(ctx context.Context) context.Context {
-	return config.ToContext(ctx, t.config)
+	return config.ToContext(ctx, (*config.Config)(t))
 }
 
 func (t *testConfigStore) WatchConfigs(w configmap.Watcher) {}

@vagababov
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2019
@knative-prow-robot knative-prow-robot merged commit 8968e75 into knative:master Jun 4, 2019
joshrider pushed a commit to joshrider/serving that referenced this pull request Jun 10, 2019
…ive#4237)

The HPA reconciler used to not need this configuration but future changes will rely on the autoscaler config. In particular, the default target knobs will need to be able to the HPA reconciler to be able to correctly determine the target concurrency for the HPA spec once /metric=concurrency gets plumbed into the HPA as well.
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/API API objects and controllers area/autoscale cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants