未验证 提交 a51872d6 编写于 作者: M Marcin Maciaszczyk 提交者: GitHub

Disable job scaling as it is not supported by scale client (#3505)

上级 a28f1f0d
......@@ -902,12 +902,6 @@ func (apiHandler *APIHandler) handleDeploy(request *restful.Request, response *r
}
func (apiHandler *APIHandler) handleScaleResource(request *restful.Request, response *restful.Response) {
k8sClient, err := apiHandler.cManager.Client(request)
if err != nil {
kdErrors.HandleInternalError(response, err)
return
}
cfg, err := apiHandler.cManager.Config(request)
if err != nil {
kdErrors.HandleInternalError(response, err)
......@@ -918,7 +912,7 @@ func (apiHandler *APIHandler) handleScaleResource(request *restful.Request, resp
kind := request.PathParameter("kind")
name := request.PathParameter("name")
count := request.QueryParameter("scaleBy")
replicaCountSpec, err := scaling.ScaleResource(k8sClient, cfg, kind, namespace, name, count)
replicaCountSpec, err := scaling.ScaleResource(cfg, kind, namespace, name, count)
if err != nil {
kdErrors.HandleInternalError(response, err)
return
......
......@@ -15,19 +15,15 @@
package scaling
import (
"strconv"
"strings"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
"k8s.io/client-go/discovery/cached"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/client-go/restmapper"
"k8s.io/client-go/scale"
"k8s.io/client-go/scale/scheme/appsv1beta2"
"strconv"
)
// ReplicaCounts provide the desired and actual number of replicas.
......@@ -57,40 +53,7 @@ func GetScaleSpec(cfg *rest.Config, kind, namespace, name string) (*ReplicaCount
// ScaleResource scales the provided resource using the client scale method in the case of Deployment,
// ReplicaSet, Replication Controller. In the case of a job we are using the jobs resource update
// method since the client scale method does not provide one for the job.
func ScaleResource(client kubernetes.Interface, cfg *rest.Config, kind, namespace, name, count string) (*ReplicaCounts, error) {
if strings.ToLower(kind) == "job" {
return scaleJobResource(client, namespace, name, count)
} else {
return scaleGenericResource(cfg, kind, namespace, name, count)
}
}
// scaleJobResource is exclusively used for jobs as it does not increase/decrease pods but jobs parallelism attribute.
func scaleJobResource(client kubernetes.Interface, namespace, name, count string) (*ReplicaCounts, error) {
j, err := client.BatchV1().Jobs(namespace).Get(name, metaV1.GetOptions{})
if err != nil {
return nil, err
}
c, err := strconv.Atoi(count)
if err != nil {
return nil, err
}
*j.Spec.Parallelism = int32(c)
j, err = client.BatchV1().Jobs(namespace).Update(j)
if err != nil {
return nil, err
}
return &ReplicaCounts{
ActualReplicas: *j.Spec.Parallelism,
DesiredReplicas: *j.Spec.Parallelism,
}, nil
}
func scaleGenericResource(cfg *rest.Config, kind, namespace, name, count string) (*ReplicaCounts, error) {
func ScaleResource(cfg *rest.Config, kind, namespace, name, count string) (*ReplicaCounts, error) {
sc, err := getScaleGetter(cfg)
if err != nil {
return nil, err
......
......@@ -14,7 +14,7 @@
import {Ng2StateDeclaration} from '@uirouter/angular';
import {LogsScaleDefaultActionbar} from '../../../../common/components/actionbars/logsscaledefault/component';
import {LogsDefaultActionbar} from '../../../../common/components/actionbars/logsdefault/component';
import {addNamespacedResourceStateParamsToUrl} from '../../../../common/params/params';
import {stateName, stateUrl} from '../state';
......@@ -34,7 +34,7 @@ export const jobDetailState: Ng2StateDeclaration = {
component: JobDetailComponent,
},
'actionbar@chrome': {
component: LogsScaleDefaultActionbar,
component: LogsDefaultActionbar,
}
},
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册