Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6676bab9
Unverified
Commit
6676bab9
authored
Dec 08, 2016
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unmarshaling into internal version of CustomMetricTargetList in validation
parent
3654d637
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
validation.go
pkg/apis/autoscaling/validation/validation.go
+2
-2
horizontal.go
pkg/controller/podautoscaler/horizontal.go
+7
-7
No files found.
pkg/apis/autoscaling/validation/validation.go
View file @
6676bab9
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
apivalidation
"k8s.io/kubernetes/pkg/api/validation"
apivalidation
"k8s.io/kubernetes/pkg/api/validation"
pathvalidation
"k8s.io/kubernetes/pkg/api/validation/path"
pathvalidation
"k8s.io/kubernetes/pkg/api/validation/path"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions
/v1beta1
"
"k8s.io/kubernetes/pkg/controller/podautoscaler"
"k8s.io/kubernetes/pkg/controller/podautoscaler"
"k8s.io/kubernetes/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/util/validation/field"
)
)
...
@@ -87,7 +87,7 @@ func validateHorizontalPodAutoscalerAnnotations(annotations map[string]string, f
...
@@ -87,7 +87,7 @@ func validateHorizontalPodAutoscalerAnnotations(annotations map[string]string, f
allErrs
:=
field
.
ErrorList
{}
allErrs
:=
field
.
ErrorList
{}
if
annotationValue
,
found
:=
annotations
[
podautoscaler
.
HpaCustomMetricsTargetAnnotationName
];
found
{
if
annotationValue
,
found
:=
annotations
[
podautoscaler
.
HpaCustomMetricsTargetAnnotationName
];
found
{
// Try to parse the annotation
// Try to parse the annotation
var
targetList
extensions
.
CustomMetricTargetList
var
targetList
v1beta1
.
CustomMetricTargetList
if
err
:=
json
.
Unmarshal
([]
byte
(
annotationValue
),
&
targetList
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
annotationValue
),
&
targetList
);
err
!=
nil
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"annotations"
),
annotations
,
"failed to parse custom metrics target annotation"
))
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
.
Child
(
"annotations"
),
annotations
,
"failed to parse custom metrics target annotation"
))
}
else
{
}
else
{
...
...
pkg/controller/podautoscaler/horizontal.go
View file @
6676bab9
...
@@ -26,7 +26,7 @@ import (
...
@@ -26,7 +26,7 @@ import (
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/resource"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
autoscaling
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
autoscaling
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
extensions
v1beta1
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
metav1
"k8s.io/kubernetes/pkg/apis/meta/v1"
metav1
"k8s.io/kubernetes/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/cache"
unversionedautoscaling
"k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/autoscaling/v1"
unversionedautoscaling
"k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/typed/autoscaling/v1"
...
@@ -144,7 +144,7 @@ func getLastScaleTime(hpa *autoscaling.HorizontalPodAutoscaler) time.Time {
...
@@ -144,7 +144,7 @@ func getLastScaleTime(hpa *autoscaling.HorizontalPodAutoscaler) time.Time {
return
lastScaleTime
.
Time
return
lastScaleTime
.
Time
}
}
func
(
a
*
HorizontalController
)
computeReplicasForCPUUtilization
(
hpa
*
autoscaling
.
HorizontalPodAutoscaler
,
scale
*
extensions
.
Scale
)
(
int32
,
*
int32
,
time
.
Time
,
error
)
{
func
(
a
*
HorizontalController
)
computeReplicasForCPUUtilization
(
hpa
*
autoscaling
.
HorizontalPodAutoscaler
,
scale
*
extensions
v1beta1
.
Scale
)
(
int32
,
*
int32
,
time
.
Time
,
error
)
{
targetUtilization
:=
int32
(
defaultTargetCPUUtilizationPercentage
)
targetUtilization
:=
int32
(
defaultTargetCPUUtilizationPercentage
)
if
hpa
.
Spec
.
TargetCPUUtilizationPercentage
!=
nil
{
if
hpa
.
Spec
.
TargetCPUUtilizationPercentage
!=
nil
{
targetUtilization
=
*
hpa
.
Spec
.
TargetCPUUtilizationPercentage
targetUtilization
=
*
hpa
.
Spec
.
TargetCPUUtilizationPercentage
...
@@ -190,7 +190,7 @@ func (a *HorizontalController) computeReplicasForCPUUtilization(hpa *autoscaling
...
@@ -190,7 +190,7 @@ func (a *HorizontalController) computeReplicasForCPUUtilization(hpa *autoscaling
// Returns number of replicas, metric which required highest number of replicas,
// Returns number of replicas, metric which required highest number of replicas,
// status string (also json-serialized extensions.CustomMetricsCurrentStatusList),
// status string (also json-serialized extensions.CustomMetricsCurrentStatusList),
// last timestamp of the metrics involved in computations or error, if occurred.
// last timestamp of the metrics involved in computations or error, if occurred.
func
(
a
*
HorizontalController
)
computeReplicasForCustomMetrics
(
hpa
*
autoscaling
.
HorizontalPodAutoscaler
,
scale
*
extensions
.
Scale
,
func
(
a
*
HorizontalController
)
computeReplicasForCustomMetrics
(
hpa
*
autoscaling
.
HorizontalPodAutoscaler
,
scale
*
extensions
v1beta1
.
Scale
,
cmAnnotation
string
)
(
replicas
int32
,
metric
string
,
status
string
,
timestamp
time
.
Time
,
err
error
)
{
cmAnnotation
string
)
(
replicas
int32
,
metric
string
,
status
string
,
timestamp
time
.
Time
,
err
error
)
{
if
cmAnnotation
==
""
{
if
cmAnnotation
==
""
{
...
@@ -199,7 +199,7 @@ func (a *HorizontalController) computeReplicasForCustomMetrics(hpa *autoscaling.
...
@@ -199,7 +199,7 @@ func (a *HorizontalController) computeReplicasForCustomMetrics(hpa *autoscaling.
currentReplicas
:=
scale
.
Status
.
Replicas
currentReplicas
:=
scale
.
Status
.
Replicas
var
targetList
extensions
.
CustomMetricTargetList
var
targetList
extensions
v1beta1
.
CustomMetricTargetList
if
err
:=
json
.
Unmarshal
([]
byte
(
cmAnnotation
),
&
targetList
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
cmAnnotation
),
&
targetList
);
err
!=
nil
{
a
.
eventRecorder
.
Event
(
hpa
,
v1
.
EventTypeWarning
,
"FailedParseCustomMetricsAnnotation"
,
err
.
Error
())
a
.
eventRecorder
.
Event
(
hpa
,
v1
.
EventTypeWarning
,
"FailedParseCustomMetricsAnnotation"
,
err
.
Error
())
return
0
,
""
,
""
,
time
.
Time
{},
fmt
.
Errorf
(
"failed to parse custom metrics annotation: %v"
,
err
)
return
0
,
""
,
""
,
time
.
Time
{},
fmt
.
Errorf
(
"failed to parse custom metrics annotation: %v"
,
err
)
...
@@ -209,8 +209,8 @@ func (a *HorizontalController) computeReplicasForCustomMetrics(hpa *autoscaling.
...
@@ -209,8 +209,8 @@ func (a *HorizontalController) computeReplicasForCustomMetrics(hpa *autoscaling.
return
0
,
""
,
""
,
time
.
Time
{},
fmt
.
Errorf
(
"no custom metrics in annotation"
)
return
0
,
""
,
""
,
time
.
Time
{},
fmt
.
Errorf
(
"no custom metrics in annotation"
)
}
}
statusList
:=
extensions
.
CustomMetricCurrentStatusList
{
statusList
:=
extensions
v1beta1
.
CustomMetricCurrentStatusList
{
Items
:
make
([]
extensions
.
CustomMetricCurrentStatus
,
0
),
Items
:
make
([]
extensions
v1beta1
.
CustomMetricCurrentStatus
,
0
),
}
}
for
_
,
customMetricTarget
:=
range
targetList
.
Items
{
for
_
,
customMetricTarget
:=
range
targetList
.
Items
{
...
@@ -249,7 +249,7 @@ func (a *HorizontalController) computeReplicasForCustomMetrics(hpa *autoscaling.
...
@@ -249,7 +249,7 @@ func (a *HorizontalController) computeReplicasForCustomMetrics(hpa *autoscaling.
a
.
eventRecorder
.
Event
(
hpa
,
v1
.
EventTypeWarning
,
"FailedSetCustomMetrics"
,
err
.
Error
())
a
.
eventRecorder
.
Event
(
hpa
,
v1
.
EventTypeWarning
,
"FailedSetCustomMetrics"
,
err
.
Error
())
return
0
,
""
,
""
,
time
.
Time
{},
fmt
.
Errorf
(
"failed to set custom metric value: %v"
,
err
)
return
0
,
""
,
""
,
time
.
Time
{},
fmt
.
Errorf
(
"failed to set custom metric value: %v"
,
err
)
}
}
statusList
.
Items
=
append
(
statusList
.
Items
,
extensions
.
CustomMetricCurrentStatus
{
statusList
.
Items
=
append
(
statusList
.
Items
,
extensions
v1beta1
.
CustomMetricCurrentStatus
{
Name
:
customMetricTarget
.
Name
,
Name
:
customMetricTarget
.
Name
,
CurrentValue
:
quantity
,
CurrentValue
:
quantity
,
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment