@@ -22,14 +22,18 @@ angular.module('openshiftConsole')
22
22
MetricsService ,
23
23
ModalsService ,
24
24
Navigate ,
25
+ OwnerReferencesService ,
25
26
PodsService ,
26
27
ProjectsService ,
27
28
StorageService ,
28
29
keyValueEditorUtils ,
29
30
kind ) {
30
31
var hasDC = false ;
32
+
31
33
var annotation = $filter ( 'annotation' ) ;
32
34
var displayKind = $filter ( 'humanizeKind' ) ( kind ) ;
35
+ var hasDeployment = $filter ( 'hasDeployment' ) ;
36
+
33
37
switch ( kind ) {
34
38
case 'ReplicaSet' :
35
39
$scope . resource = {
@@ -278,37 +282,47 @@ angular.module('openshiftConsole')
278
282
$scope . isActive = DeploymentsService . isActiveReplicaSet ( $scope . replicaSet , $scope . deployment ) ;
279
283
} ;
280
284
281
- var hasDeployment = $filter ( 'hasDeployment' ) ;
282
- var inProgressDeployment = false ;
285
+ var hasInProgressRollout = function ( replicaSets ) {
286
+ // See if there is any other replica set owned by the deployment with active pods.
287
+ return _ . some ( replicaSets , function ( replicaSet ) {
288
+ // Check if the replica set has pods.
289
+ if ( ! _ . get ( replicaSet , 'status.replicas' ) ) {
290
+ return ;
291
+ }
292
+
293
+ // Check if it's the same replica set we're viewing.
294
+ if ( _ . get ( replicaSet , 'metadata.uid' ) === _ . get ( $scope . replicaSet , 'metadata.uid' ) ) {
295
+ return ;
296
+ }
297
+
298
+ // Check if it's owned by same deployment.
299
+ var controllerReferences = OwnerReferencesService . getControllerReferences ( replicaSet ) ;
300
+ return _ . some ( controllerReferences , { uid : $scope . deployment . metadata . uid } ) ;
301
+ } ) ;
302
+ } ;
303
+
304
+ var rolloutInProgress = false ;
283
305
var updateDeployment = function ( ) {
284
- if ( ! hasDeployment ( $scope . replicaSet ) ) {
306
+ var controllerRefs = OwnerReferencesService . getControllerReferences ( $scope . replicaSet ) ;
307
+ var deploymentRef = _ . find ( controllerRefs , { kind : 'Deployment' } ) ;
308
+ if ( ! deploymentRef ) {
285
309
return ;
286
310
}
287
311
288
- DataService . list ( {
312
+ DataService . get ( {
289
313
group : 'extensions' ,
290
314
resource : 'deployments'
291
- } , context ) . then ( function ( resp ) {
292
- var deployments = resp . by ( 'metadata.name' ) ;
293
- var replicaSetSelector = new LabelSelector ( $scope . replicaSet . spec . selector ) ;
294
- $scope . deployment = _ . find ( deployments , function ( deployment ) {
295
- var deploymentSelector = new LabelSelector ( deployment . spec . selector ) ;
296
- return deploymentSelector . covers ( replicaSetSelector ) ;
297
- } ) ;
298
- if ( ! $scope . deployment ) {
299
- $scope . deploymentMissing = true ;
300
- return ;
301
- }
302
-
315
+ } , deploymentRef . name , context ) . then ( function ( deployment ) {
316
+ $scope . deployment = deployment ;
303
317
$scope . healthCheckURL = Navigate . healthCheckURL ( $routeParams . project ,
304
318
"Deployment" ,
305
- $scope . deployment . metadata . name ,
319
+ deployment . metadata . name ,
306
320
"extensions" ) ;
307
321
308
322
watches . push ( DataService . watchObject ( {
309
323
group : 'extensions' ,
310
324
resource : 'deployments'
311
- } , $scope . deployment . metadata . name , context , function ( deployment , action ) {
325
+ } , deployment . metadata . name , context , function ( deployment , action ) {
312
326
if ( action === "DELETED" ) {
313
327
$scope . alerts [ 'deployment-deleted' ] = {
314
328
type : "warning" ,
@@ -323,6 +337,7 @@ angular.module('openshiftConsole')
323
337
return ;
324
338
}
325
339
340
+ $scope . deployment = deployment ;
326
341
$scope . breadcrumbs = BreadcrumbsService . getBreadcrumbs ( {
327
342
object : $scope . replicaSet ,
328
343
displayName : '#' + DeploymentsService . getRevision ( $scope . replicaSet ) ,
@@ -341,31 +356,9 @@ angular.module('openshiftConsole')
341
356
watches . push ( DataService . watch ( {
342
357
group : 'extensions' ,
343
358
resource : 'replicasets'
344
- } , context , function ( replicaSets ) {
345
- var deploymentSelector = new LabelSelector ( $scope . deployment . spec . selector ) ;
346
- inProgressDeployment = false ;
347
-
348
- // See if there is more than one replica set that matches the
349
- // deployment selector with active replicas.
350
- var numActive = 0 ;
351
- _ . each ( replicaSets . by ( 'metadata.name' ) , function ( replicaSet ) {
352
- if ( ! replicaSet . status . replicas ) {
353
- return ;
354
- }
355
-
356
- if ( ! deploymentSelector . covers ( new LabelSelector ( replicaSet . spec . selector ) ) ) {
357
- return ;
358
- }
359
-
360
- numActive ++ ;
361
-
362
- if ( numActive > 1 ) {
363
- inProgressDeployment = true ;
364
-
365
- // Stop looping.
366
- return false ;
367
- }
368
- } ) ;
359
+ } , context , function ( replicaSetData ) {
360
+ var replicaSets = replicaSetData . by ( 'metadata.name' ) ;
361
+ rolloutInProgress = hasInProgressRollout ( replicaSets ) ;
369
362
} ) ) ;
370
363
} ) ;
371
364
} ;
@@ -429,6 +422,10 @@ angular.module('openshiftConsole')
429
422
setLogVars ( replicaSet ) ;
430
423
updateHPAWarnings ( ) ;
431
424
getImageStreamImage ( ) ;
425
+
426
+ if ( $scope . deployment ) {
427
+ checkActiveRevision ( ) ;
428
+ }
432
429
} ) ) ;
433
430
434
431
if ( $scope . deploymentConfigName ) {
@@ -589,7 +586,7 @@ angular.module('openshiftConsole')
589
586
return false ;
590
587
}
591
588
592
- return $scope . isActive && ! inProgressDeployment ;
589
+ return $scope . isActive && ! rolloutInProgress ;
593
590
} ;
594
591
595
592
$scope . removeVolume = function ( volume ) {
0 commit comments