From fef921162b744bb996afa341aae15db53564bc41 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Mon, 22 May 2017 15:40:37 -0400 Subject: [PATCH] Init Containers Added to Pod Template Update for pod template directive to allow displaying init containers --- app/scripts/controllers/pod.js | 21 --- app/scripts/directives/resources.js | 72 +++++++++ app/scripts/filters/resources.js | 5 + app/views/_container-statuses.html | 69 +++++++++ app/views/_pod-template-container.html | 184 +++++++++++++++++++++++ app/views/_pod-template.html | 193 +++---------------------- app/views/browse/_pod-details.html | 25 +--- dist/scripts/scripts.js | 53 ++++++- dist/scripts/templates.js | 119 +++++++++++---- 9 files changed, 494 insertions(+), 247 deletions(-) create mode 100644 app/views/_container-statuses.html create mode 100644 app/views/_pod-template-container.html diff --git a/app/scripts/controllers/pod.js b/app/scripts/controllers/pod.js index 45160b1f06..1ca396d945 100644 --- a/app/scripts/controllers/pod.js +++ b/app/scripts/controllers/pod.js @@ -415,27 +415,6 @@ angular.module('openshiftConsole') return running; }; - $scope.showDebugAction = function(containerStatus) { - if (_.get($scope, 'pod.status.phase') === 'Completed') { - return false; - } - - if (annotation($scope.pod, 'openshift.io/build.name')) { - return false; - } - - if ($filter('isDebugPod')($scope.pod)) { - return false; - } - - var waitingReason = _.get(containerStatus, 'state.waiting.reason'); - if (waitingReason === 'ImagePullBackOff' || waitingReason === 'ErrImagePull') { - return false; - } - - return !_.get(containerStatus, 'state.running') || !containerStatus.ready; - }; - $scope.$on('$destroy', function(){ DataService.unwatchAll(watches); cleanUpDebugPod(); diff --git a/app/scripts/directives/resources.js b/app/scripts/directives/resources.js index 1a7584ea5a..9a6a62a57d 100644 --- a/app/scripts/directives/resources.js +++ b/app/scripts/directives/resources.js @@ -1,6 +1,65 @@ 'use strict'; angular.module('openshiftConsole') + .directive('containerStatuses', function($filter) { + return { + restrict: 'E', + scope: { + pod: '=', + onDebugTerminal: '=?', + detailed: '=?' + }, + templateUrl: 'views/_container-statuses.html', + link: function(scope) { + scope.hasDebugTerminal = angular.isFunction(scope.onDebugTerminal); + + var isContainerTerminatedSuccessfully = $filter('isContainerTerminatedSuccessfully'); + var haveAllContainersTerminatedSuccessfully = function(containerStatuses) { + return _.every(containerStatuses, isContainerTerminatedSuccessfully); + }; + + scope.$watch('pod', function(updatedPod) { + scope.initContainersTerminated = haveAllContainersTerminatedSuccessfully(updatedPod.status.initContainerStatuses); + + if (scope.expandInitContainers !== false) { + scope.expandInitContainers = !scope.initContainersTerminated; + } + }); + + scope.toggleInitContainer = function() { + scope.expandInitContainers = !scope.expandInitContainers; + }; + + scope.showDebugAction = function (containerStatus) { + + if (_.get(scope.pod, 'status.phase') === 'Completed') { + return false; + } + + if ($filter('annotation')(scope.pod, 'openshift.io/build.name')) { + return false; + } + + if ($filter('isDebugPod')(scope.pod)) { + return false; + } + + var waitingReason = _.get(containerStatus, 'state.waiting.reason'); + if (waitingReason === 'ImagePullBackOff' || waitingReason === 'ErrImagePull') { + return false; + } + + return !_.get(containerStatus, 'state.running') || !containerStatus.ready; + }; + + scope.debugTerminal = function(containerStatusName) { + if (scope.hasDebugTerminal) { + return scope.onDebugTerminal.call(this, containerStatusName); + } + }; + } + }; + }) .directive('podTemplate', function() { return { restrict: 'E', @@ -15,6 +74,19 @@ angular.module('openshiftConsole') templateUrl: 'views/_pod-template.html' }; }) + .directive('podTemplateContainer', function() { + return { + restrict: 'E', + scope: { + container: '=podTemplateContainer', + imagesByDockerReference: '=', + builds: '=', + detailed: '=?', + labelPrefix: '@?' + }, + templateUrl: 'views/_pod-template-container.html' + }; + }) .directive('annotations', function() { return { restrict: 'E', diff --git a/app/scripts/filters/resources.js b/app/scripts/filters/resources.js index 0dd720863d..097f9cc4ba 100644 --- a/app/scripts/filters/resources.js +++ b/app/scripts/filters/resources.js @@ -314,6 +314,11 @@ angular.module('openshiftConsole') return containerStatus.state.terminated && containerStatus.state.terminated.exitCode !== 0; }; }) + .filter('isContainerTerminatedSuccessfully', function() { + return function(containerStatus) { + return containerStatus.state.terminated && containerStatus.state.terminated.exitCode === 0; + }; + }) .filter('isContainerUnprepared', function() { return function(containerStatus) { if (!containerStatus.state.running || diff --git a/app/views/_container-statuses.html b/app/views/_container-statuses.html new file mode 100644 index 0000000000..cde6bb1e61 --- /dev/null +++ b/app/views/_container-statuses.html @@ -0,0 +1,69 @@ + + +
+

+ + + + + completed successfully + + + + Show + Hide + Details + + +

+ +
+

Init container {{containerStatus.name}}

+ +
+
State:
+
+ +
+
Last State
+
+ +
+
Ready:
+
{{containerStatus.ready}}
+
Restart Count:
+
{{containerStatus.restartCount}}
+
+
+
+ +
+

Container {{containerStatus.name}}

+ +
+
State:
+
+ +
+
Last State
+
+ +
+
Ready:
+
{{containerStatus.ready}}
+
Restart Count:
+
{{containerStatus.restartCount}}
+ + +
+
diff --git a/app/views/_pod-template-container.html b/app/views/_pod-template-container.html new file mode 100644 index 0000000000..46e581d176 --- /dev/null +++ b/app/views/_pod-template-container.html @@ -0,0 +1,184 @@ + + +
+
{{container.name}}
+ +
+
+ +
+
+ Image: + {{container.image | imageStreamName}} + + {{container.image | imageStreamName}} + {{imagesByDockerReference[container.image].metadata.name | stripSHAPrefix | limitTo: 7}} + + {{imagesByDockerReference[container.image].dockerImageMetadata.Size | humanizeSize}} + + +
+
+ +
+ +
+
+ +
+
+ Source: + + + + {{build.spec.revision.git.message}} + {{build.spec.revision.git.commit | limitTo:7}} + + authored by {{build.spec.revision.git.author.name}} + + + + {{build.spec.source.git.uri}} + + + + {{build.spec.source.type || 'Unknown'}} + + +
+
+
+ +
+
+ +
+
+ + Command: + + + + + + + +
+
+ +
+
+ +
+
+ Ports: + + {{port.containerPort}}/{{port.protocol}} ({{port.name}}) {{port.hostPort}}, + + + and {{container.ports.length - 1}} + others + other + +
+
+ +
+
+ +
+
+ Mount: + + {{mount.name}}, subpath {{mount.subPath}} → {{mount.mountPath}} + {{mount | volumeMountMode : podTemplate.spec.volumes}} + +
+
+ +
+
+ +
+
+ CPU: + + {{container.resources.requests.cpu | usageWithUnits: 'cpu'}} to {{container.resources.limits.cpu | usageWithUnits: 'cpu'}} + + + {{container.resources.limits.cpu | usageWithUnits: 'cpu'}} limit + + + {{container.resources.requests.cpu | usageWithUnits: 'cpu'}} requested + +
+
+ +
+
+ +
+
+ Memory: + + {{container.resources.requests.memory | usageWithUnits: 'memory'}} to {{container.resources.limits.memory | usageWithUnits: 'memory'}} + + + {{container.resources.limits.memory | usageWithUnits: 'memory'}} limit + + + {{container.resources.requests.memory | usageWithUnits: 'memory'}} requested + +
+
+ +
+
+ +
+
+ Readiness Probe: + +
+
+ +
+
+ +
+
+ Liveness Probe: + +
+
+ +
diff --git a/app/views/_pod-template.html b/app/views/_pod-template.html index ac23b7eddd..9b92c913a7 100644 --- a/app/views/_pod-template.html +++ b/app/views/_pod-template.html @@ -7,188 +7,43 @@ addHealthCheckUrl (optional) --> - +
- This container has no health checks + Container {{podTemplate.spec.containers[0].name}} does not have health checks Not all containers have health checks to ensure your application is running correctly. Add Health Checks
-
-
-
-
Container: {{container.name}}
-
-
- -
-
- Image: - {{container.image | imageStreamName}} - - {{container.image | imageStreamName}} - {{imagesByDockerReference[container.image].metadata.name | stripSHAPrefix | limitTo: 7}} - - {{imagesByDockerReference[container.image].dockerImageMetadata.Size | humanizeSize}} - - -
-
-
- -
-
- -
-
- Source: - - - - {{build.spec.revision.git.message}} - {{build.spec.revision.git.commit | limitTo:7}} - - authored by {{build.spec.revision.git.author.name}} - - - - {{build.spec.source.git.uri}} - - - - {{build.spec.source.type || 'Unknown'}} - - -
-
-
+
+

Init Containers

-
-
- -
-
- - Command: - - - - - - - -
-
+
+
-
-
- -
-
- Ports: - - {{port.containerPort}}/{{port.protocol}} ({{port.name}}) {{port.hostPort}}, - - - and {{container.ports.length - 1}} - others - other - -
-
+ -
-
- -
-
- Mount: - - {{mount.name}}, subpath {{mount.subPath}} → {{mount.mountPath}} - {{mount | volumeMountMode : podTemplate.spec.volumes}} - -
-
- -
-
- -
-
- CPU: - - {{container.resources.requests.cpu | usageWithUnits: 'cpu'}} to {{container.resources.limits.cpu | usageWithUnits: 'cpu'}} - - - {{container.resources.limits.cpu | usageWithUnits: 'cpu'}} limit - - - {{container.resources.requests.cpu | usageWithUnits: 'cpu'}} requested - -
-
+
+
+
-
-
- -
-
- Memory: - - {{container.resources.requests.memory | usageWithUnits: 'memory'}} to {{container.resources.limits.memory | usageWithUnits: 'memory'}} - - - {{container.resources.limits.memory | usageWithUnits: 'memory'}} limit - - - {{container.resources.requests.memory | usageWithUnits: 'memory'}} requested - -
-
+
+

Containers

-
-
- -
-
- Readiness Probe: - -
-
+
+
-
-
- -
-
- Liveness Probe: - -
-
+
-
-

Container {{containerStatus.name}}

-
-
State:
-
- -
-
Last State
-
- -
-
Ready:
-
{{containerStatus.ready}}
-
Restart Count:
-
{{containerStatus.restartCount}}
- -
+
+
+

Template

\n" + + "

\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "completed successfully\n" + + "\n" + + "\n" + + "\n" + + "Show\n" + + "Hide\n" + + "Details\n" + + "\n" + + "\n" + + "

\n" + + "
\n" + + "

Init container {{containerStatus.name}}

\n" + + "
\n" + + "
State:
\n" + + "
\n" + + "\n" + + "
\n" + + "
Last State
\n" + + "
\n" + + "\n" + + "
\n" + + "
Ready:
\n" + + "
{{containerStatus.ready}}
\n" + + "
Restart Count:
\n" + + "
{{containerStatus.restartCount}}
\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + "

Container {{containerStatus.name}}

\n" + + "
\n" + + "
State:
\n" + + "
\n" + + "\n" + + "
\n" + + "
Last State
\n" + + "
\n" + + "\n" + + "
\n" + + "
Ready:
\n" + + "
{{containerStatus.ready}}
\n" + + "
Restart Count:
\n" + + "
{{containerStatus.restartCount}}
\n" + + "
\n" + + "Debug in Terminal\n" + + "
\n" + + "
\n" + + "
" + ); + + $templateCache.put('views/_edit-request-limit.html', "\n" + "

\n" + @@ -187,18 +245,9 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( ); - $templateCache.put('views/_pod-template.html', - "
\n" + - "\n" + - "This container has no health checks\n" + - " 1\">Not all containers have health checks\n" + - "to ensure your application is running correctly.\n" + - "Add Health Checks\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
Container: {{container.name}}
\n" + + $templateCache.put('views/_pod-template-container.html', + "
\n" + + "
{{container.name}}
\n" + "
\n" + "
\n" + "\n" + @@ -353,6 +402,31 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "\n" + "
\n" + "
\n" + + "
" + ); + + + $templateCache.put('views/_pod-template.html', + "
\n" + + "\n" + + "Container {{podTemplate.spec.containers[0].name}} does not have health checks\n" + + " 1\">Not all containers have health checks\n" + + "to ensure your application is running correctly.\n" + + "Add Health Checks\n" + + "
\n" + + "
\n" + + "

Init Containers

\n" + + "
\n" + + "
\n" + + "\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + + "

Containers

\n" + + "
\n" + + "
\n" + + "\n" + "
\n" + "
\n" + "
\n" + @@ -1262,25 +1336,8 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "\n" + "\n" + "\n" + - "
\n" + - "

Container {{containerStatus.name}}

\n" + - "
\n" + - "
State:
\n" + - "
\n" + - "\n" + - "
\n" + - "
Last State
\n" + - "
\n" + - "\n" + - "
\n" + - "
Ready:
\n" + - "
{{containerStatus.ready}}
\n" + - "
Restart Count:
\n" + - "
{{containerStatus.restartCount}}
\n" + - "
\n" + - "Debug in Terminal\n" + - "
\n" + - "
\n" + + "
\n" + + "\n" + "
\n" + "
\n" + "
\n" +