mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Receive target Object metrics for v2
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
fd0f46a87c
commit
525d439e7c
@ -21,7 +21,7 @@ const hpaV2 = {
|
||||
}
|
||||
|
||||
describe("HorizontalPodAutoscalerApi", () => {
|
||||
describe("HPA v1", () => {
|
||||
describe("HPA v2", () => {
|
||||
it("should return correct empty metrics", () => {
|
||||
const hpa = new HorizontalPodAutoscaler(hpaV2);
|
||||
|
||||
@ -103,5 +103,32 @@ describe("HorizontalPodAutoscalerApi", () => {
|
||||
|
||||
expect(hpa.getMetricValues(hpa.getMetrics()[0])).toEqual("unknown / 1k");
|
||||
});
|
||||
|
||||
it("should return correct object metrics", () => {
|
||||
const hpa = new HorizontalPodAutoscaler(
|
||||
{
|
||||
...hpaV2,
|
||||
spec: {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
object: {
|
||||
metric: {
|
||||
name: "requests-per-second"
|
||||
},
|
||||
target: {
|
||||
type: "Value",
|
||||
value: "10k"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expect(hpa.getMetricValues(hpa.getMetrics()[0])).toEqual("unknown / 10k");
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -45,10 +45,19 @@ export interface ExternalMetricSource {
|
||||
|
||||
export interface ObjectMetricSource {
|
||||
averageValue?: string;
|
||||
metricName: string;
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
target: CrossVersionObjectReference;
|
||||
targetValue: string;
|
||||
targetValue?: string;
|
||||
|
||||
// autoscaling/v2
|
||||
metric?: {
|
||||
name?: string;
|
||||
},
|
||||
target: {
|
||||
type?: string;
|
||||
value?: string;
|
||||
};
|
||||
describedObject?: CrossVersionObjectReference;
|
||||
}
|
||||
|
||||
export interface PodsMetricSource {
|
||||
@ -344,10 +353,7 @@ function getObjectMetricValue(currentMetric: ObjectMetricStatus | undefined, tar
|
||||
currentMetric?.currentValue
|
||||
?? currentMetric?.averageValue
|
||||
),
|
||||
target: (
|
||||
targetMetric?.targetValue
|
||||
?? targetMetric?.averageValue
|
||||
),
|
||||
target: targetMetric?.target?.value
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user