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

Use fixed strings instead of knativeAutoscalingPrefix #311

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

tpiperatgod
Copy link
Member

Use "autoscaling.knative.dev" instead of the const "knativeAutoscalingPrefix".

Signed-off-by: laminar fangtian@kubesphere.io

@@ -256,26 +255,22 @@ func (r *servingRun) createService(s *openfunction.Serving, cm map[string]string
case "min-scale", "minScale":
minScale = v
}
if _, exist := s.Spec.Annotations[fmt.Sprintf("%s/%s", knativeAutoscalingPrefix, k)]; !exist {
if _, exist := s.Spec.Annotations[fmt.Sprintf("autoscaling.knative.dev/%s", k)]; !exist {
Copy link
Member

@benjaminhuo benjaminhuo Jun 21, 2022

Choose a reason for hiding this comment

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

I mean we should put autoscaling.knative.dev/min-scale: 3 in scaleoption.knative, not min-scale: 3 to be consistent with knative.

The other options are similar.
so might be something like below?:

				switch k {
				case "autoscaling.knative.dev/max-scale", "autoscaling.knative.dev/maxScale":
					maxScale = v
				case "autoscaling.knative.dev/min-scale", "autoscaling.knative.dev/minScale":
					minScale = v
				}

Copy link
Member Author

Choose a reason for hiding this comment

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

are they too long as non-annotation form configurations...

Copy link
Member

@benjaminhuo benjaminhuo Jun 21, 2022

Choose a reason for hiding this comment

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

simply copying knative annotation options here without translation might be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

this does reduce the comprehension cost for the user, while it duplicates the effects of spec.serving.annotations

@@ -256,26 +255,22 @@ func (r *servingRun) createService(s *openfunction.Serving, cm map[string]string
case "min-scale", "minScale":
minScale = v
}
if _, exist := s.Spec.Annotations[fmt.Sprintf("%s/%s", knativeAutoscalingPrefix, k)]; !exist {
if _, exist := s.Spec.Annotations[fmt.Sprintf("autoscaling.knative.dev/%s", k)]; !exist {
s.Spec.Annotations[k] = v
Copy link
Member

Choose a reason for hiding this comment

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

I think we can use the same key as the original, because below code is actually not working because it's lack of autoscaling.knative.dev/ prefix

s.Spec.Annotations[k] = v

Copy link
Member

@benjaminhuo benjaminhuo Jun 22, 2022

Choose a reason for hiding this comment

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

And the priority can be adjusted from

	// Handle the scale options, which have the following priority relationship:
	// Annotations["autoscaling.knative.dev/max-scale" ("autoscaling.knative.dev/min-scale")] >
	// ScaleOptions.Knative["max-scale" ("min-scale")] >
	// ScaleOptions.maxScale (minScale) >

to

	// Handle the scale options, which have the following priority relationship:
	// ScaleOptions.Knative["autoscaling.knative.dev/max-scale" ("autoscaling.knative.dev/min-scale")] >
	// ScaleOptions.maxScale (minScale) >
	// Annotations["autoscaling.knative.dev/max-scale" ("autoscaling.knative.dev/min-scale")] >

which means the "autoscaling.knative.dev/xx in s.spec.annotations has the lowest priority

Use "autoscaling.knative.dev" instead of the const "knativeAutoscalingPrefix".

Signed-off-by: laminar <fangtian@kubesphere.io>
@benjaminhuo
Copy link
Member

Thanks for the fix!

@benjaminhuo benjaminhuo merged commit 0545314 into OpenFunction:main Jun 22, 2022
@tpiperatgod tpiperatgod deleted the dev branch June 22, 2022 12:48
@benjaminhuo benjaminhuo linked an issue Jun 22, 2022 that may be closed by this pull request
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.

Add knative prefix back to the annotation key
2 participants