-
Notifications
You must be signed in to change notification settings - Fork 232
Init Containers #1560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init Containers #1560
Conversation
@cdcabrera Let's show the container statuses on the left in the same order as the spec on the right (spec order should win). Let me know when you're ready for code review. |
Good catch on the sorting order, can do. And yes indeed on the code review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cdcabrera.
I feel like visually it's not immediately obvious which containers are init containers. You have to look closely at the label, which is small text. Maybe we do need a separate heading. (I know you implemented what I suggested.)
I also think we should collapse init containers under status when they're complete and show a summary and a details link.
We should check the logic for debug terminals. I think it'll need changes.
app/scripts/directives/resources.js
Outdated
restrict: 'E', | ||
scope: { | ||
podStatus: '=', | ||
initStatus: '=?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should decide if we want one directive for all statuses or a directive for each individual container status or (or both). I'm OK either way. If we have one directive, I'd call it containerStatuses
since it doesn't show all of pod status, just the status of the containers.
If we have one directive, I'd remove initStatus
and just always show it. @jwforres and I talked about maybe collapsing the init container status with a summary when the init containers are complete. @cdcabrera let's discuss
app/scripts/directives/resources.js
Outdated
scope: { | ||
podStatus: '=', | ||
initStatus: '=?', | ||
terminal: '=?' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd give this a more descriptive name like startDebugTerminal
app/scripts/directives/resources.js
Outdated
}, | ||
templateUrl: 'views/_pod-status.html', | ||
link: function(scope) { | ||
scope.isTerminal = angular.isFunction(scope.terminal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like isTerminal
is slightly confusing since the directive itself is not a terminal. Maybe hasDebugTerminal
or enableDebugTerminal
?
app/scripts/directives/resources.js
Outdated
@@ -24,10 +71,18 @@ angular.module('openshiftConsole') | |||
imagesByDockerReference: '=', | |||
builds: '=', | |||
detailed: '=?', | |||
initContainers: '=?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here. I'd remove initContainers
, have one pod-template
directive, and just show init containers when detailed
is enabled. This means you'll need to pull the contents from the ng-repeat
in the view for a container into a separate directive, maybe pod-template-container
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appears the property detailed
is also used for the health checks if missing
info alert... adjusting the initContainers
as part of details now affects the banner display as well.
app/scripts/directives/resources.js
Outdated
templateUrl: 'views/_pod-template.html' | ||
templateUrl: 'views/_pod-template.html', | ||
link: function(scope) { | ||
scope.podTemplateContainers = _.get(scope.podTemplate, 'spec.containers', []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest scope.initContainers
and scope.containers
as variable names
app/scripts/controllers/pod.js
Outdated
@@ -419,7 +419,7 @@ angular.module('openshiftConsole') | |||
return running; | |||
}; | |||
|
|||
$scope.showDebugAction = function(containerStatus) { | |||
/*$scope.showDebugAction = function(containerStatus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When finished, don't forget to remove the commented out code.
f01e52e
to
9ce4398
Compare
@@ -0,0 +1,48 @@ | |||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious about these comments here, these variables are not in the directive scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caught podStatus
earlier, should be updated now... if we're going for only listing values/properties/variables used in the templates can adjust accordingly
@@ -0,0 +1,188 @@ | |||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above re:scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caught initPrefix
earlier, should be updated now...
@spadgett links for hide/show on |
1181054
to
32f480c
Compare
I was envisioning something like
or
in normal text with a green checkmark. Most of the time when they run and complete you don't care too much, so they shouldn't take as much focus. |
"Init Template" isn't really right. It's only one template. I'd rather leave the "Template" heading and have subheadings "Init Containers" and "Containers" in the same weight as "Volumes" just below. |
b851f05
to
c75329e
Compare
@spadgett updated screen captures for |
app/scripts/directives/resources.js
Outdated
scope.podContainerStatuses = _.get(scope.containerStatuses, 'status.containerStatuses', []); | ||
scope.podContainerInitStatuses = _.get(scope.containerStatuses, 'status.initContainerStatuses', []); | ||
|
||
scope.hasContainerFailed = function (containerStatus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need to make this a scope var if it's not used in the view. Suggest just using
var isContainerFailed = $filter('isContainerFailed');
then below calling isContainerFailed()
app/scripts/directives/resources.js
Outdated
return $filter('isContainerFailed')(containerStatus) !== false; | ||
}; | ||
|
||
scope.haveContainersFailed = function(containerStatuses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here. Doesn't need to be a scope function. _.some
makes this easier.
var isContainerFailed = $filter('isContainerFailed');
var haveContainersFailed = function(containerStatuses) {
return _.some(containerStatuses, isContainerFailed);
};
app/scripts/directives/resources.js
Outdated
return { | ||
restrict: 'E', | ||
scope: { | ||
containerStatuses: '=', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this pod
since it's taking in a pod, not the containerStatuses array
app/scripts/directives/resources.js
Outdated
return true; | ||
}; | ||
|
||
scope.expandInitContainers = scope.initContainersFailed = scope.haveContainersFailed(scope.podContainerInitStatuses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't update when the pod status changes. I'd expect the section to automatically collapse if the init containers complete when you're on the page.
app/scripts/directives/resources.js
Outdated
templateUrl: 'views/_pod-template.html', | ||
link: function(scope) { | ||
scope.containers = _.get(scope.podTemplate, 'spec.containers', []); | ||
scope.initContainers = _.get(scope.podTemplate, 'spec.initContainers', []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this assignment here, it won't update when the pod status changes. Easier just to access podTemplate.spec.containers
or podTemplate.spec.initContainers
directly in the view.
app/views/_pod-template.html
Outdated
</div> | ||
</div> | ||
<!-- Prompt to add health checks if missing. --> | ||
<div ng-if="detailed && addHealthCheckUrl && !(podTemplate | hasHealthChecks)" class="alert alert-info"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't have the same health check warning twice.
app/views/_pod-template.html
Outdated
</div> | ||
</div> | ||
<div class="pod-template-container"> | ||
<div class="pod-template-block" ng-repeat="container in containers | orderBy:'name'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove orderBy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, related to comment above regarding display order for status containers.
app/views/_pod-template.html
Outdated
|
||
<div | ||
extension-point | ||
extension-name="container-links" | ||
extension-types="link dom" | ||
extension-args="[container, podTemplate]"></div> | ||
extension-args="[container, containers]"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't change as it might break extensions. We should still pass podTemplate
as the second arg.
app/views/_pod-template.html
Outdated
extension-point | ||
extension-name="container-links" | ||
extension-types="link dom" | ||
extension-args="[container, initContainers]"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, can't decide if we want / need the extension point for init containers. There's no way for the extension to know that it's an init container, so I'm inclined to leave it out.
--> | ||
|
||
<div class="pod-template"> | ||
<div class="component-label"><span ng-bind-template="{{labelPrefix}}:"></span> {{container.name}}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest just defaulting to "Container:" if no labelPrefix
was given.
9d862d0
to
8ca58a0
Compare
09da291
to
28d6591
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cdcabrera, a few more comments.
app/scripts/directives/resources.js
Outdated
link: function(scope) { | ||
scope.hasDebugTerminal = angular.isFunction(scope.startDebugTerminal); | ||
|
||
var isContainerTerminated = $filter('isContainerTerminatedSuccessfully'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep Successfully
in the name since this should return false if it terminated with a failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha
app/scripts/directives/resources.js
Outdated
scope.hasDebugTerminal = angular.isFunction(scope.startDebugTerminal); | ||
|
||
var isContainerTerminated = $filter('isContainerTerminatedSuccessfully'); | ||
var haveContainersTerminated = function(containerStatuses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe haveAllContainersTerminatedSuccessfully
. (A little long maybe, but precise.)
app/scripts/directives/resources.js
Outdated
|
||
var isContainerTerminated = $filter('isContainerTerminatedSuccessfully'); | ||
var haveContainersTerminated = function(containerStatuses) { | ||
return _.some(containerStatuses, isContainerTerminated); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be _.every
? We only want to collapse when they've all terminated.
app/views/_container-statuses.html
Outdated
<span flex> | ||
<span ng-if="initContainersTerminated"> {{pod.status.initContainerStatuses.length}}</span> | ||
<ng-pluralize count="pod.status.initContainerStatuses.length" | ||
when="{'1': 'Init Container','other': 'Init Containers'}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to use the container name when there's one.
Init container my-init-container completed successfully
or if more than one like you have
3 init containers completed successfully
We usually don't capitalize types in sentences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do
app/views/_container-statuses.html
Outdated
</span> | ||
<span ng-if="initContainersTerminated"> | ||
<a class="page-header-link" href="" ng-click="toggleInitContainer()" ng-if="!expandInitContainers">Show Details</a> | ||
<a class="page-header-link" href="" ng-click="toggleInitContainer()" ng-if="expandInitContainers">Hide Details</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest one a
element and just change the message inside since everything else is the same.
<a class="page-header-link" href="" ng-click="toggleInitContainer()">
<span ng-if="!expandInitContainers">Show</span>
<span ng-if="expandInitContainers">Hide</span>
Details
</a>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing
app/views/_pod-template.html
Outdated
<span ng-if="podTemplate.spec.containers.length === 1">This container has no health checks</span> | ||
<span ng-if="podTemplate.spec.containers.length > 1">Not all containers have health checks</span> | ||
<span ng-if="podTemplate.spec.initContainers.length === 1">This container has no health checks</span> | ||
<span ng-if="podTemplate.spec.initContainers.length > 1">Not all containers have health checks</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Init containers do not have health checks. We should still check spec.containers.length
here.
Maybe change This container
to Container <name> does not...
if there is only one container. Then it's clear "This container" does not refer to the init container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
giving it a shot
app/scripts/directives/resources.js
Outdated
restrict: 'E', | ||
scope: { | ||
pod: '=', | ||
startDebugTerminal: '=?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I suggested this name, but I think maybe onDebugTerminal
is better :) sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries, can do
28d6591
to
920bee8
Compare
@cdcabrera I noticed the style for container status is different than regular containers. We should be consistent: |
4374e04
to
63f12c3
Compare
Restyled for consistency, reduced the need for nested labels. @openshift/team-ux-review @spadgett |
app/views/_container-statuses.html
Outdated
|
||
<div class="animate-if" | ||
ng-if="expandInitContainers" | ||
ng-repeat="containerStatus in pod.status.initContainerStatuses" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid flicker:
ng-repeat="containerStatus in pod.status.initContainerStatuses track by containerStatus.name">
app/views/_container-statuses.html
Outdated
</div> | ||
</div> | ||
|
||
<div ng-repeat="containerStatus in pod.status.containerStatuses" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ng-repeat="containerStatus in pod.status.containerStatuses track by containerStatus.name">
ed2655b
to
07354d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @cdcabrera missed a couple things on previous review :/
app/scripts/directives/resources.js
Outdated
|
||
scope.showDebugAction = function (containerStatus) { | ||
|
||
if (_.get(scope.containerStatuses, 'status.phase') === 'Completed') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_.get(scope.pod, 'status.phase') === 'Completed'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do, when updated the scope property the old search and replace missed a couple
app/scripts/directives/resources.js
Outdated
return false; | ||
} | ||
|
||
if ($filter('annotation')(scope.containerStatuses, 'openshift.io/build.name')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$filter('annotation')(scope.pod, 'openshift.io/build.name')
app/scripts/directives/resources.js
Outdated
return false; | ||
} | ||
|
||
if ($filter('isDebugPod')(scope.containerStatuses)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$filter('isDebugPod')(scope.pod))
07354d6
to
c288842
Compare
@cdcabrera Sorry found one more bug... :( Init containers header showing up when there are none: |
app/views/_pod-template.html
Outdated
</div> | ||
</div> | ||
</div> | ||
<div ng-if="detailed"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div ng-if="detailed && podTemplate.spec.initContainers.length">
Update for pod template directive to allow displaying init containers
c288842
to
fef9211
Compare
[merge] |
Evaluated for origin web console merge up to fef9211 |
[Test]ing while waiting on the merge queue |
Evaluated for origin web console test up to fef9211 |
Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1522/) (Base Commit: 50bfbcc) |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1527/) (Base Commit: 871e99a) |
Update for displaying init containers... includes