Skip to content

Commit

Permalink
Bug 1540916: Set correct group in HPA scale target
Browse files Browse the repository at this point in the history
  • Loading branch information
spadgett committed Feb 7, 2018
1 parent d025687 commit 632b015
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 82 deletions.
83 changes: 41 additions & 42 deletions app/scripts/controllers/edit/autoscaler.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,48 +90,6 @@ angular.module('openshiftConsole')
return;
}

var createHPA = function() {
$scope.disableInputs = true;
hideErrorNotifications();
var hpa = {
apiVersion: "autoscaling/v1",
kind: "HorizontalPodAutoscaler",
metadata: {
name: $scope.autoscaling.name,
labels: keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels))
},
spec: {
scaleTargetRef: {
kind: $routeParams.kind,
name: $routeParams.name,
apiVersion: "extensions/v1beta1",
subresource: "scale"
},
minReplicas: $scope.autoscaling.minReplicas,
maxReplicas: $scope.autoscaling.maxReplicas,
targetCPUUtilizationPercentage: $scope.autoscaling.targetCPU
}
};

DataService.create(horizontalPodAutoscalerVersion, null, hpa, context)
.then(function(hpa) { // Success
NotificationsService.addNotification({
type: 'success',
message: 'Horizontal pod autoscaler ' + hpa.metadata.name + ' successfully created.'
});

navigateBack();
}, function(result) { // Failure
$scope.disableInputs = false;
NotificationsService.addNotification({
id: 'edit-hpa-error',
type: 'error',
message: 'An error occurred creating the horizontal pod autoscaler.',
details: getErrorDetails(result)
});
});
};

var updateHPA = function(hpa) {
$scope.disableInputs = true;

Expand Down Expand Up @@ -177,6 +135,47 @@ angular.module('openshiftConsole')
}

DataService.get(resourceGroup, $routeParams.name, context).then(function(resource) {
var createHPA = function() {
$scope.disableInputs = true;
hideErrorNotifications();
var hpa = {
apiVersion: "autoscaling/v1",
kind: "HorizontalPodAutoscaler",
metadata: {
name: $scope.autoscaling.name,
labels: keyValueEditorUtils.mapEntries(keyValueEditorUtils.compactEntries($scope.labels))
},
spec: {
scaleTargetRef: {
kind: resource.kind,
name: resource.metadata.name,
apiVersion: resource.apiVersion
},
minReplicas: $scope.autoscaling.minReplicas,
maxReplicas: $scope.autoscaling.maxReplicas,
targetCPUUtilizationPercentage: $scope.autoscaling.targetCPU
}
};

DataService.create(horizontalPodAutoscalerVersion, null, hpa, context)
.then(function(hpa) { // Success
NotificationsService.addNotification({
type: 'success',
message: 'Horizontal pod autoscaler ' + hpa.metadata.name + ' successfully created.'
});

navigateBack();
}, function(result) { // Failure
$scope.disableInputs = false;
NotificationsService.addNotification({
id: 'edit-hpa-error',
type: 'error',
message: 'An error occurred creating the horizontal pod autoscaler.',
details: getErrorDetails(result)
});
});
};

$scope.labels = _.map(
_.get(resource, 'metadata.labels', {}),
function(val, key) {
Expand Down
79 changes: 39 additions & 40 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7637,41 +7637,7 @@ if (o.canI({
resource: "horizontalpodautoscalers",
group: "autoscaling"
}, l, n.project)) {
var m = function() {
e.disableInputs = !0, h();
var t = {
apiVersion: "autoscaling/v1",
kind: "HorizontalPodAutoscaler",
metadata: {
name: e.autoscaling.name,
labels: p.mapEntries(p.compactEntries(e.labels))
},
spec: {
scaleTargetRef: {
kind: n.kind,
name: n.name,
apiVersion: "extensions/v1beta1",
subresource: "scale"
},
minReplicas: e.autoscaling.minReplicas,
maxReplicas: e.autoscaling.maxReplicas,
targetCPUUtilizationPercentage: e.autoscaling.targetCPU
}
};
s.create(y, null, t, r).then(function(e) {
d.addNotification({
type: "success",
message: "Horizontal pod autoscaler " + e.metadata.name + " successfully created."
}), v();
}, function(t) {
e.disableInputs = !1, d.addNotification({
id: "edit-hpa-error",
type: "error",
message: "An error occurred creating the horizontal pod autoscaler.",
details: g(t)
});
});
}, f = function(t) {
var m = function(t) {
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) {
d.addNotification({
type: "success",
Expand All @@ -7685,15 +7651,15 @@ message: "An error occurred creating the horizontal pod autoscaler.",
details: g(t)
});
});
}, S = {};
S = "HorizontalPodAutoscaler" === n.kind ? {
}, f = {};
f = "HorizontalPodAutoscaler" === n.kind ? {
resource: "horizontalpodautoscalers",
group: "autoscaling",
version: "v1"
} : {
resource: a.kindToResource(n.kind),
group: n.group
}, s.get(S, n.name, r).then(function(a) {
}, s.get(f, n.name, r).then(function(a) {
if (e.labels = _.map(_.get(a, "metadata.labels", {}), function(e, t) {
return {
name: t,
Expand All @@ -7704,7 +7670,7 @@ minReplicas: _.get(a, "spec.minReplicas"),
maxReplicas: _.get(a, "spec.maxReplicas"),
targetCPU: _.get(a, "spec.targetCPUUtilizationPercentage")
}), e.disableInputs = !1, e.save = function() {
f(a);
m(a);
}, e.breadcrumbs = i.getBreadcrumbs({
name: e.targetName,
kind: e.targetKind,
Expand All @@ -7716,7 +7682,40 @@ e.breadcrumbs = i.getBreadcrumbs({
object: a,
project: t,
subpage: "Autoscale"
}), e.save = m;
}), e.save = function() {
e.disableInputs = !0, h();
var t = {
apiVersion: "autoscaling/v1",
kind: "HorizontalPodAutoscaler",
metadata: {
name: e.autoscaling.name,
labels: p.mapEntries(p.compactEntries(e.labels))
},
spec: {
scaleTargetRef: {
kind: a.kind,
name: a.metadata.name,
apiVersion: a.apiVersion
},
minReplicas: e.autoscaling.minReplicas,
maxReplicas: e.autoscaling.maxReplicas,
targetCPUUtilizationPercentage: e.autoscaling.targetCPU
}
};
s.create(y, null, t, r).then(function(e) {
d.addNotification({
type: "success",
message: "Horizontal pod autoscaler " + e.metadata.name + " successfully created."
}), v();
}, function(t) {
e.disableInputs = !1, d.addNotification({
id: "edit-hpa-error",
type: "error",
message: "An error occurred creating the horizontal pod autoscaler.",
details: g(t)
});
});
};
var o = {}, l = function() {
var n = _.get(a, "spec.template.spec.containers", []);
e.showCPURequestWarning = !c.hasCPURequest(n, o, t);
Expand Down

0 comments on commit 632b015

Please sign in to comment.