diff --git a/vendor/k8s.io/kubernetes/pkg/controller/podautoscaler/horizontal.go b/vendor/k8s.io/kubernetes/pkg/controller/podautoscaler/horizontal.go index 65a7a6f17021..99fbd3c80c9a 100644 --- a/vendor/k8s.io/kubernetes/pkg/controller/podautoscaler/horizontal.go +++ b/vendor/k8s.io/kubernetes/pkg/controller/podautoscaler/horizontal.go @@ -360,6 +360,20 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho } mappings, err := a.mapper.RESTMappings(targetGK) + // TODO(directxman12): this is a dirty, dirty hack because legacy oapi isn't part of + // the standard discovery, like normal APIs. We can remove it if/when we get + // rid of the legacy oapi group entirely. It makes me cry a bit inside, but such is life. + if (targetGK == schema.GroupKind{Kind: "DeploymentConfig"}) { + err = nil + // NB: we don't convert to apps.openshift.io here since the patched scale client + // will do it for us. + mappings = []*apimeta.RESTMapping{ + { + Resource: "deploymentconfigs", + GroupVersionKind: targetGK.WithVersion("v1"), + }, + } + } if err != nil { a.eventRecorder.Event(hpa, v1.EventTypeWarning, "FailedGetScale", err.Error()) setCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, "FailedGetScale", "the HPA controller was unable to get the target's current scale: %v", err) diff --git a/vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/scale/client.go b/vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/scale/client.go index 3f85197a0b6f..a6876ec2401d 100644 --- a/vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/scale/client.go +++ b/vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/scale/client.go @@ -19,14 +19,23 @@ package scale import ( "fmt" + "github.com/golang/glog" autoscaling "k8s.io/api/autoscaling/v1" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime/schema" serializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/client-go/dynamic" restclient "k8s.io/client-go/rest" + + oappsv1 "github.com/openshift/api/apps/v1" ) +var dcGVR = schema.GroupVersionResource{ + Group: "", + Version: "v1", + Resource: "deploymentconfigs", +} + var scaleConverter = NewScaleConverter() var codecs = serializer.NewCodecFactory(scaleConverter.Scheme()) @@ -89,6 +98,14 @@ func (c *scaleClient) pathAndVersionFor(resource schema.GroupResource) (string, return "", gvr, fmt.Errorf("unable to get full preferred group-version-resource for %s: %v", resource.String(), err) } + // TODO(directxman12): this is a dirty, dirty hack because oapi just appears in discovery as "/v1", like + // the kube core API. We can remove it if/when we get rid of the legacy oapi group entirely. It makes me + // cry a bit inside, but such is life. + glog.Infof("DEBUG: %#v == %#v: %v", gvr, dcGVR, gvr == dcGVR) + if gvr == dcGVR { + gvr = oappsv1.SchemeGroupVersion.WithResource(gvr.Resource) + } + groupVer := gvr.GroupVersion() // we need to set the API path based on GroupVersion (defaulting to the legacy path if none is set)