Skip to content

Commit 3f3be4d

Browse files
authored
fix(scheduler): check if RC exists during a deploy before trying to use Deployments (#996)
This prevents RCs and Deployments fighting about pods when upgrading from v2.3 to v2.4 - An application is not migrated to Deployments until configuration / image / etc is udone Fixes #995
1 parent be52487 commit 3f3be4d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

rootfs/scheduler/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,28 @@ def log(self, namespace, message, level=logging.INFO):
8484
logger.log(level, "[{}]: {}".format(namespace, message))
8585

8686
def deploy(self, namespace, name, image, entrypoint, command, **kwargs): # noqa
87-
"""Scale Deployment depending on what's requested"""
87+
"""Deploy Deployment depending on what's requested"""
8888
self.deploy_timeout = kwargs.get('deploy_timeout')
89-
9089
app_type = kwargs.get('app_type')
90+
version = kwargs.get('version')
9191
routable = kwargs.get('routable', False)
9292
service_annotations = kwargs.get('service_annotations', {})
9393
port = kwargs.get('envs', {}).get('PORT', None)
9494

95+
# If an RC already exists then stop processing of the deploy
96+
try:
97+
# construct old school RC name
98+
rc_name = '{}-{}-{}'.format(namespace, version, app_type)
99+
self.get_rc(namespace, rc_name)
100+
self.log(namespace, 'RC {} already exists. Stopping deploy'.format(rc_name))
101+
return
102+
except KubeHTTPException:
103+
# if RC doesn't exist then let the app continue
104+
pass
105+
95106
# create a deployment if missing, otherwise update to trigger a release
96107
try:
97108
# labels that represent the pod(s)
98-
version = kwargs.get('version')
99109
labels = {
100110
'app': namespace,
101111
'version': version,

0 commit comments

Comments
 (0)