File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -768,27 +768,15 @@ def _delete_namespace(self, namespace):
768768 # REPLICATION CONTROLLER #
769769
770770 def _get_old_rc (self , namespace , app_type ):
771- url = self ._api ("/namespaces/{}/replicationcontrollers" , namespace )
772- resp = self .session .get (url )
773- if unhealthy (resp .status_code ):
774- error (resp , 'get ReplicationControllers in Namespace "{}"' , namespace )
775-
776- exists = False
777- prev_rc = []
778- for rc in resp .json ()['items' ]:
779- if (
780- 'app' in rc ['spec' ]['selector' ] and
781- namespace == rc ['metadata' ]['labels' ]['app' ] and
782- 'type' in rc ['spec' ]['selector' ] and
783- app_type == rc ['spec' ]['selector' ]['type' ]
784- ):
785- exists = True
786- prev_rc = rc
787- break
788- if exists :
789- return prev_rc
771+ labels = {
772+ 'app' : namespace ,
773+ 'type' : app_type
774+ }
775+ controllers = self ._get_rcs (namespace , labels = labels ).json ()
776+ if len (controllers ['items' ]) == 0 :
777+ return False
790778
791- return 0
779+ return controllers [ 'items' ][ 0 ]
792780
793781 def _get_rc_status (self , namespace , name ):
794782 url = self ._api ("/namespaces/{}/replicationcontrollers/{}" , namespace , name )
You can’t perform that action at this time.
0 commit comments