Skip to content

Commit

Permalink
fix(controller): adding scale_api_version to Scale
Browse files Browse the repository at this point in the history
Scale moved to autoscaling/v1 (while deployment, replicationcontroller
each moved to apps/v1)

So... "Scale" resource model is in a different api group than the parent
resource "scale" endpoint that Scale is called through. Both the scale
struct and "scale" HTTP verb cannot use the same api_version property.
  • Loading branch information
Kingdon Barrett committed Oct 4, 2020
1 parent 9c66b39 commit bb05432
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rootfs/scheduler/resources/scale.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
from scheduler.resources import Resource
from scheduler.exceptions import KubeHTTPException

from packaging.version import parse


class Scale(Resource):

@property
def scale_api_version(self):
# API locations have changed since 1.9 and deprecated in 1.16
# https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/
if self.version() >= parse("1.9.0"):
return 'autoscaling/v1'

return 'extensions/v1beta1'

def manifest(self, namespace, name, replicas):
manifest = {
'kind': 'Scale',
'apiVersion': self.api_version,
'apiVersion': self.scale_api_version,
'metadata': {
'namespace': namespace,
'name': name,
Expand Down

0 comments on commit bb05432

Please sign in to comment.