Skip to content

Commit 632b015

Browse files
committedFeb 7, 2018
Bug 1540916: Set correct group in HPA scale target
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1540916
1 parent d025687 commit 632b015

File tree

2 files changed

+80
-82
lines changed

2 files changed

+80
-82
lines changed
 

‎app/scripts/controllers/edit/autoscaler.js

+41-42
Original file line numberDiff line numberDiff line change
@@ -90,48 +90,6 @@ angular.module('openshiftConsole')
9090
return;
9191
}
9292

93-
var createHPA = function() {
94-
$scope.disableInputs = true;
95-
hideErrorNotifications();
96-
var hpa = {
97-
apiVersion: "autoscaling/v1",
98-
kind: "HorizontalPodAutoscaler",
99-
metadata: {
100-
name: $scope.autoscaling.name,
101-
labels: keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels))
102-
},
103-
spec: {
104-
scaleTargetRef: {
105-
kind: $routeParams.kind,
106-
name: $routeParams.name,
107-
apiVersion: "extensions/v1beta1",
108-
subresource: "scale"
109-
},
110-
minReplicas: $scope.autoscaling.minReplicas,
111-
maxReplicas: $scope.autoscaling.maxReplicas,
112-
targetCPUUtilizationPercentage: $scope.autoscaling.targetCPU
113-
}
114-
};
115-
116-
DataService.create(horizontalPodAutoscalerVersion, null, hpa, context)
117-
.then(function(hpa) { // Success
118-
NotificationsService.addNotification({
119-
type: 'success',
120-
message: 'Horizontal pod autoscaler ' + hpa.metadata.name + ' successfully created.'
121-
});
122-
123-
navigateBack();
124-
}, function(result) { // Failure
125-
$scope.disableInputs = false;
126-
NotificationsService.addNotification({
127-
id: 'edit-hpa-error',
128-
type: 'error',
129-
message: 'An error occurred creating the horizontal pod autoscaler.',
130-
details: getErrorDetails(result)
131-
});
132-
});
133-
};
134-
13593
var updateHPA = function(hpa) {
13694
$scope.disableInputs = true;
13795

@@ -177,6 +135,47 @@ angular.module('openshiftConsole')
177135
}
178136

179137
DataService.get(resourceGroup, $routeParams.name, context).then(function(resource) {
138+
var createHPA = function() {
139+
$scope.disableInputs = true;
140+
hideErrorNotifications();
141+
var hpa = {
142+
apiVersion: "autoscaling/v1",
143+
kind: "HorizontalPodAutoscaler",
144+
metadata: {
145+
name: $scope.autoscaling.name,
146+
labels: keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels))
147+
},
148+
spec: {
149+
scaleTargetRef: {
150+
kind: resource.kind,
151+
name: resource.metadata.name,
152+
apiVersion: resource.apiVersion
153+
},
154+
minReplicas: $scope.autoscaling.minReplicas,
155+
maxReplicas: $scope.autoscaling.maxReplicas,
156+
targetCPUUtilizationPercentage: $scope.autoscaling.targetCPU
157+
}
158+
};
159+
160+
DataService.create(horizontalPodAutoscalerVersion, null, hpa, context)
161+
.then(function(hpa) { // Success
162+
NotificationsService.addNotification({
163+
type: 'success',
164+
message: 'Horizontal pod autoscaler ' + hpa.metadata.name + ' successfully created.'
165+
});
166+
167+
navigateBack();
168+
}, function(result) { // Failure
169+
$scope.disableInputs = false;
170+
NotificationsService.addNotification({
171+
id: 'edit-hpa-error',
172+
type: 'error',
173+
message: 'An error occurred creating the horizontal pod autoscaler.',
174+
details: getErrorDetails(result)
175+
});
176+
});
177+
};
178+
180179
$scope.labels = _.map(
181180
_.get(resource, 'metadata.labels', {}),
182181
function(val, key) {

‎dist/scripts/scripts.js

+39-40
Original file line numberDiff line numberDiff line change
@@ -7637,41 +7637,7 @@ if (o.canI({
76377637
resource: "horizontalpodautoscalers",
76387638
group: "autoscaling"
76397639
}, l, n.project)) {
7640-
var m = function() {
7641-
e.disableInputs = !0, h();
7642-
var t = {
7643-
apiVersion: "autoscaling/v1",
7644-
kind: "HorizontalPodAutoscaler",
7645-
metadata: {
7646-
name: e.autoscaling.name,
7647-
labels: p.mapEntries(p.compactEntries(e.labels))
7648-
},
7649-
spec: {
7650-
scaleTargetRef: {
7651-
kind: n.kind,
7652-
name: n.name,
7653-
apiVersion: "extensions/v1beta1",
7654-
subresource: "scale"
7655-
},
7656-
minReplicas: e.autoscaling.minReplicas,
7657-
maxReplicas: e.autoscaling.maxReplicas,
7658-
targetCPUUtilizationPercentage: e.autoscaling.targetCPU
7659-
}
7660-
};
7661-
s.create(y, null, t, r).then(function(e) {
7662-
d.addNotification({
7663-
type: "success",
7664-
message: "Horizontal pod autoscaler " + e.metadata.name + " successfully created."
7665-
}), v();
7666-
}, function(t) {
7667-
e.disableInputs = !1, d.addNotification({
7668-
id: "edit-hpa-error",
7669-
type: "error",
7670-
message: "An error occurred creating the horizontal pod autoscaler.",
7671-
details: g(t)
7672-
});
7673-
});
7674-
}, f = function(t) {
7640+
var m = function(t) {
76757641
e.disableInputs = !0, (t = angular.copy(t)).metadata.labels = p.mapEntries(p.compactEntries(e.labels)), t.spec.minReplicas = e.autoscaling.minReplicas, t.spec.maxReplicas = e.autoscaling.maxReplicas, t.spec.targetCPUUtilizationPercentage = e.autoscaling.targetCPU, s.update(y, t.metadata.name, t, r).then(function(e) {
76767642
d.addNotification({
76777643
type: "success",
@@ -7685,15 +7651,15 @@ message: "An error occurred creating the horizontal pod autoscaler.",
76857651
details: g(t)
76867652
});
76877653
});
7688-
}, S = {};
7689-
S = "HorizontalPodAutoscaler" === n.kind ? {
7654+
}, f = {};
7655+
f = "HorizontalPodAutoscaler" === n.kind ? {
76907656
resource: "horizontalpodautoscalers",
76917657
group: "autoscaling",
76927658
version: "v1"
76937659
} : {
76947660
resource: a.kindToResource(n.kind),
76957661
group: n.group
7696-
}, s.get(S, n.name, r).then(function(a) {
7662+
}, s.get(f, n.name, r).then(function(a) {
76977663
if (e.labels = _.map(_.get(a, "metadata.labels", {}), function(e, t) {
76987664
return {
76997665
name: t,
@@ -7704,7 +7670,7 @@ minReplicas: _.get(a, "spec.minReplicas"),
77047670
maxReplicas: _.get(a, "spec.maxReplicas"),
77057671
targetCPU: _.get(a, "spec.targetCPUUtilizationPercentage")
77067672
}), e.disableInputs = !1, e.save = function() {
7707-
f(a);
7673+
m(a);
77087674
}, e.breadcrumbs = i.getBreadcrumbs({
77097675
name: e.targetName,
77107676
kind: e.targetKind,
@@ -7716,7 +7682,40 @@ e.breadcrumbs = i.getBreadcrumbs({
77167682
object: a,
77177683
project: t,
77187684
subpage: "Autoscale"
7719-
}), e.save = m;
7685+
}), e.save = function() {
7686+
e.disableInputs = !0, h();
7687+
var t = {
7688+
apiVersion: "autoscaling/v1",
7689+
kind: "HorizontalPodAutoscaler",
7690+
metadata: {
7691+
name: e.autoscaling.name,
7692+
labels: p.mapEntries(p.compactEntries(e.labels))
7693+
},
7694+
spec: {
7695+
scaleTargetRef: {
7696+
kind: a.kind,
7697+
name: a.metadata.name,
7698+
apiVersion: a.apiVersion
7699+
},
7700+
minReplicas: e.autoscaling.minReplicas,
7701+
maxReplicas: e.autoscaling.maxReplicas,
7702+
targetCPUUtilizationPercentage: e.autoscaling.targetCPU
7703+
}
7704+
};
7705+
s.create(y, null, t, r).then(function(e) {
7706+
d.addNotification({
7707+
type: "success",
7708+
message: "Horizontal pod autoscaler " + e.metadata.name + " successfully created."
7709+
}), v();
7710+
}, function(t) {
7711+
e.disableInputs = !1, d.addNotification({
7712+
id: "edit-hpa-error",
7713+
type: "error",
7714+
message: "An error occurred creating the horizontal pod autoscaler.",
7715+
details: g(t)
7716+
});
7717+
});
7718+
};
77207719
var o = {}, l = function() {
77217720
var n = _.get(a, "spec.template.spec.containers", []);
77227721
e.showCPURequestWarning = !c.hasCPURequest(n, o, t);

0 commit comments

Comments
 (0)
Please sign in to comment.