@@ -42,7 +42,7 @@ def validate_app_id(value):
4242 """
4343 Check that the value follows the kubernetes name constraints
4444 """
45- match = re .match (r'[a-z]([a-z0-9-]*[a-z0-9])?(?<!-canary) $' , value )
45+ match = re .match (r'[a-z]([a-z0-9-]*[a-z0-9])?$' , value )
4646 if not match :
4747 raise ValidationError ("App name must start with an alphabetic character, cannot end with a"
4848 + " hyphen and can only contain a-z (lowercase), 0-9 and hyphens." )
@@ -190,11 +190,8 @@ def restart(self, **kwargs): # noqa
190190 Restart deployments with the kubectl rollout api
191191 """
192192 deployments = []
193- app_settings = self .appsettings_set .latest ()
194193 if self .structure [kwargs ['type' ]] > 0 :
195- if kwargs ['type' ] in app_settings .canaries :
196- deployments .append (self ._get_job_id (kwargs ['type' ], True ))
197- deployments .append (self ._get_job_id (kwargs ['type' ], False ))
194+ deployments .append (self ._get_job_id (kwargs ['type' ]))
198195 try :
199196 tasks = [
200197 functools .partial (
@@ -219,13 +216,6 @@ def scale(self, user, structure):
219216 self .log (err_msg , logging .WARNING )
220217 raise DryccException (err_msg )
221218 app_settings = self .appsettings_set .latest ()
222- if release .canary :
223- self ._scale (
224- user ,
225- structure ,
226- self .release_set .filter (failed = False , canary = False ).latest (),
227- app_settings
228- )
229219 self ._scale (user , structure , release , app_settings )
230220
231221 def pipeline (self , release , force_deploy = False , rollback_on_failure = True ):
@@ -293,9 +283,8 @@ def deploy(self, release, procfile_types=None, force_deploy=False, rollback_on_f
293283 if procfile_types is not None and scale_type not in procfile_types :
294284 continue
295285 scale_type_volumes = [_ for _ in volumes if scale_type in _ .path .keys ()]
296- if not release .canary or scale_type in app_settings .canaries :
297- deploys [scale_type ] = self ._gather_app_settings (
298- release , app_settings , scale_type , replicas , volumes = scale_type_volumes )
286+ deploys [scale_type ] = self ._gather_app_settings (
287+ release , app_settings , scale_type , replicas , volumes = scale_type_volumes )
299288 self ._deploy (
300289 deploys , procfile_types , prev_release , release , force_deploy , rollback_on_failure )
301290 # cleanup old release objects from kubernetes
@@ -307,22 +296,12 @@ def mount(self, user, volume, structure=None):
307296 raise DryccException ('No build associated with this release' )
308297 release = self .release_set .filter (failed = False ).latest ()
309298 app_settings = self .appsettings_set .latest ()
310- if release .canary :
311- self ._mount (
312- user ,
313- volume ,
314- self .release_set .filter (failed = False , canary = False ).latest (),
315- app_settings ,
316- structure = structure ,
317- )
318299 self ._mount (user , volume , release , app_settings , structure = structure )
319300
320301 def cleanup_old (self , procfile_types = None ):
321- names , app_settings = [], self . appsettings_set . latest ()
302+ names = []
322303 for scale_type in self .structure .keys ():
323- if scale_type in app_settings .canaries :
324- names .append (self ._get_job_id (scale_type , True ))
325- names .append (self ._get_job_id (scale_type , False ))
304+ names .append (self ._get_job_id (scale_type ))
326305 labels = {'heritage' : 'drycc' }
327306 if procfile_types is not None :
328307 labels ["type__in" ] = procfile_types
@@ -360,7 +339,7 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits):
360339 data ['restart_policy' ] = 'Never'
361340 data ['active_deadline_seconds' ] = timeout
362341 data ['ttl_seconds_after_finished' ] = expires
363- name = self ._get_job_id (PROCFILE_TYPE_RUN , release . canary ) + '-' + pod_name ()
342+ name = self ._get_job_id (PROCFILE_TYPE_RUN ) + '-' + pod_name ()
364343 self .log ("{} on {} runs '{}'" .format (user .username , name , command ))
365344 kwargs .update (data )
366345 try :
@@ -509,27 +488,21 @@ def image_pull_secret(self, namespace, registry, image):
509488 return name
510489
511490 def state_to_k8s (self ):
512- def _load_procfile_types (canary ):
513- procfile_types = set ()
514- for procfile_type , scale in self .structure .items ():
515- response = self .scheduler ().deployment .get (
516- self .id , self ._get_job_id (procfile_type , canary ),
517- ignore_exception = True )
518- if response .status_code == 404 and scale > 0 :
519- procfile_types .add (procfile_type )
520- elif response .status_code != 200 :
521- data = response .json ()
522- self .log ('get deployment status_code {}, message: {}' .format (
523- response .status_code , data .get ("message" , "" )), logging .ERROR )
524- return procfile_types
525-
526491 release = self .release_set .filter (failed = False ).latest ()
527492 if release .build is None :
528493 self .log ('the last release does not have a build, skipping deployment...' )
529494 return
530- procfile_types = _load_procfile_types (False )
531- if release .canary :
532- procfile_types = procfile_types .union (_load_procfile_types (canary = True ))
495+ procfile_types = set ()
496+ for procfile_type , scale in self .structure .items ():
497+ response = self .scheduler ().deployment .get (
498+ self .id , self ._get_job_id (procfile_type ),
499+ ignore_exception = True )
500+ if response .status_code == 404 and scale > 0 :
501+ procfile_types .add (procfile_type )
502+ elif response .status_code != 200 :
503+ data = response .json ()
504+ self .log ('get deployment status_code {}, message: {}' .format (
505+ response .status_code , data .get ("message" , "" )), logging .ERROR )
533506 if len (procfile_types ) == 0 :
534507 self .log ('the cluster status is the latest, skipping deployment...' )
535508 return
@@ -585,11 +558,8 @@ def to_measurements(self, timestamp: float):
585558 def __str__ (self ):
586559 return self .id
587560
588- def _get_job_id (self , container_type , canary ):
589- job_id = f"{ self .id } -{ container_type } "
590- if canary :
591- job_id = f"{ job_id } -canary"
592- return job_id
561+ def _get_job_id (self , container_type ):
562+ return f"{ self .id } -{ container_type } "
593563
594564 def _clean_app_logs (self ):
595565 """Delete application logs stored by the logger component"""
@@ -607,23 +577,22 @@ def _mount(self, user, volume, release, app_settings, structure=None):
607577 volumes = Volume .objects .filter (app = self )
608578 tasks = []
609579 for scale_type , replicas in structure .items () if structure else self .structure .items ():
610- if scale_type != PROCFILE_TYPE_RUN and (
611- not release .canary or scale_type in app_settings .canaries ):
580+ if scale_type != PROCFILE_TYPE_RUN :
612581 replicas = self .structure .get (scale_type , 0 )
613582 scale_type_volumes = [
614583 volume for volume in volumes if scale_type in volume .path .keys ()]
615584 data = self ._gather_app_settings (
616585 release , app_settings , scale_type , replicas , volumes = scale_type_volumes )
617586 deployment = self .scheduler ().deployment .get (
618- self .id , self ._get_job_id (scale_type , release . canary )).json ()
587+ self .id , self ._get_job_id (scale_type )).json ()
619588 spec_annotations = deployment ['spec' ]['template' ]['metadata' ].get (
620589 'annotations' , {})
621590 self .set_application_config (release , scale_type )
622591 # gather volume proc types to be deployed
623592 tasks .append (functools .partial (
624593 self .scheduler ().deployment .patch ,
625594 namespace = self .id ,
626- name = self ._get_job_id (scale_type , release . canary ),
595+ name = self ._get_job_id (scale_type ),
627596 image = release .get_deploy_image (scale_type ),
628597 command = release .get_deploy_command (scale_type ),
629598 args = release .get_deploy_args (scale_type ),
@@ -653,7 +622,7 @@ def _deploy(self, deploys, procfile_types, prev_release,
653622 tasks .append (functools .partial (
654623 self .scheduler ().deploy ,
655624 namespace = self .id ,
656- name = self ._get_job_id (scale_type , release . canary ),
625+ name = self ._get_job_id (scale_type ),
657626 image = release .get_deploy_image (scale_type ),
658627 command = release .get_deploy_command (scale_type ),
659628 args = release .get_deploy_args (scale_type ),
@@ -664,8 +633,7 @@ def _deploy(self, deploys, procfile_types, prev_release,
664633 except KubeException as e :
665634 # Don't rollback if the previous release doesn't have a build which means
666635 # this is the first build and all the previous releases are just config changes.
667- if (prev_release .canary == release .canary and
668- rollback_on_failure and prev_release .build is not None ):
636+ if (rollback_on_failure and prev_release .build is not None ):
669637 err = 'There was a problem deploying {}. Rolling back to release {}.' .format (
670638 release .version_name , prev_release .version_name )
671639 # This goes in the log before the rollback starts
@@ -701,7 +669,6 @@ def _scale(self, user, structure, release, app_settings): # noqa
701669 """Scale containers up or down to match requested structure."""
702670 # use create to make sure minimum resources are created
703671 self .create ()
704-
705672 # Validate structure
706673 try :
707674 for target , count in structure .copy ().items ():
@@ -752,7 +719,7 @@ def _scale_pods(self, scale_types, release, app_settings):
752719 functools .partial (
753720 self .scheduler ().scale ,
754721 namespace = self .id ,
755- name = self ._get_job_id (scale_type , release . canary ),
722+ name = self ._get_job_id (scale_type ),
756723 image = release .get_deploy_image (scale_type ),
757724 command = release .get_deploy_command (scale_type ),
758725 args = release .get_deploy_args (scale_type ),
@@ -905,7 +872,7 @@ def _check_deployment_in_progress(self, deploys, release, force_deploy=False):
905872 if force_deploy :
906873 return
907874 for scale_type , kwargs in deploys .items ():
908- name = self ._get_job_id (scale_type , release . canary )
875+ name = self ._get_job_id (scale_type )
909876 # Is there an existing deployment in progress?
910877 in_progress , deploy_okay = self .scheduler ().deployment .in_progress (
911878 self .id , name , kwargs .get ("deploy_timeout" ), kwargs .get ("deploy_batches" ),
0 commit comments