Skip to content

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

Merged
merged 1 commit into from
Jun 14, 2017
Merged

Init Containers #1560

merged 1 commit into from
Jun 14, 2017

Conversation

cdcabrera
Copy link
Contributor

@cdcabrera cdcabrera commented May 19, 2017

Update for displaying init containers... includes

  • status.initContainerStatuses
  • spec.initContainers

screen shot 2017-05-19 at 3 10 01 pm

@cdcabrera cdcabrera changed the title WIP, Init Containers [WIP] Init Containers May 19, 2017
@spadgett
Copy link
Member

@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.

@cdcabrera
Copy link
Contributor Author

Good catch on the sorting order, can do. And yes indeed on the code review

@spadgett spadgett self-requested a review May 20, 2017 18:11
@spadgett spadgett self-assigned this May 20, 2017
Copy link
Member

@spadgett spadgett left a 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.

restrict: 'E',
scope: {
podStatus: '=',
initStatus: '=?',
Copy link
Member

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

scope: {
podStatus: '=',
initStatus: '=?',
terminal: '=?'
Copy link
Member

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

},
templateUrl: 'views/_pod-status.html',
link: function(scope) {
scope.isTerminal = angular.isFunction(scope.terminal);
Copy link
Member

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?

@@ -24,10 +71,18 @@ angular.module('openshiftConsole')
imagesByDockerReference: '=',
builds: '=',
detailed: '=?',
initContainers: '=?',
Copy link
Member

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.

Copy link
Contributor Author

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.

templateUrl: 'views/_pod-template.html'
templateUrl: 'views/_pod-template.html',
link: function(scope) {
scope.podTemplateContainers = _.get(scope.podTemplate, 'spec.containers', []);
Copy link
Member

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

@@ -419,7 +419,7 @@ angular.module('openshiftConsole')
return running;
};

$scope.showDebugAction = function(containerStatus) {
/*$scope.showDebugAction = function(containerStatus) {
Copy link
Member

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.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 22, 2017
@cdcabrera cdcabrera force-pushed the init-containers branch 2 times, most recently from f01e52e to 9ce4398 Compare May 22, 2017 19:42
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 22, 2017
@@ -0,0 +1,48 @@
<!--
Copy link
Contributor

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?

Copy link
Contributor Author

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 @@
<!--
Copy link
Contributor

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.

Copy link
Contributor Author

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...

@cdcabrera
Copy link
Contributor Author

@spadgett links for hide/show on init container status added... originally planned to have single links associated with all init container statuses. Checked in individual links, as it was starting to appear like a title/label was going to be needed to break them apart, see screen shots... but can update towards grouped init container statuses

screen shot 2017-05-24 at 11 02 02 am

screen shot 2017-05-24 at 11 19 30 am

@cdcabrera cdcabrera force-pushed the init-containers branch 2 times, most recently from 1181054 to 32f480c Compare May 24, 2017 17:20
@spadgett
Copy link
Member

I was envisioning something like

✓ Init container my-init-container completed succesfully. <a href="">Show Details</a>

or

✓ 2 init containers completed successfully. <a href="">Show Details</a>

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.

@spadgett
Copy link
Member

"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.

@cdcabrera cdcabrera force-pushed the init-containers branch 3 times, most recently from b851f05 to c75329e Compare May 25, 2017 15:15
@cdcabrera
Copy link
Contributor Author

cdcabrera commented May 25, 2017

@spadgett updated screen captures for init container status... icon and some styling adjustments probably need to take place

screen shot 2017-05-25 at 10 22 01 am

screen shot 2017-05-25 at 10 23 06 am

scope.podContainerStatuses = _.get(scope.containerStatuses, 'status.containerStatuses', []);
scope.podContainerInitStatuses = _.get(scope.containerStatuses, 'status.initContainerStatuses', []);

scope.hasContainerFailed = function (containerStatus) {
Copy link
Member

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()

return $filter('isContainerFailed')(containerStatus) !== false;
};

scope.haveContainersFailed = function(containerStatuses) {
Copy link
Member

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);
};

https://lodash.com/docs/3.10.1#some

return {
restrict: 'E',
scope: {
containerStatuses: '=',
Copy link
Member

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

return true;
};

scope.expandInitContainers = scope.initContainersFailed = scope.haveContainersFailed(scope.podContainerInitStatuses);
Copy link
Member

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.

templateUrl: 'views/_pod-template.html',
link: function(scope) {
scope.containers = _.get(scope.podTemplate, 'spec.containers', []);
scope.initContainers = _.get(scope.podTemplate, 'spec.initContainers', []);
Copy link
Member

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.

</div>
</div>
<!-- Prompt to add health checks if missing. -->
<div ng-if="detailed && addHealthCheckUrl && !(podTemplate | hasHealthChecks)" class="alert alert-info">
Copy link
Member

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.

</div>
</div>
<div class="pod-template-container">
<div class="pod-template-block" ng-repeat="container in containers | orderBy:'name'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove orderBy

Copy link
Contributor Author

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.


<div
extension-point
extension-name="container-links"
extension-types="link dom"
extension-args="[container, podTemplate]"></div>
extension-args="[container, containers]"></div>
Copy link
Member

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.

extension-point
extension-name="container-links"
extension-types="link dom"
extension-args="[container, initContainers]"></div>
Copy link
Member

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.

@jwforres

-->

<div class="pod-template">
<div class="component-label"><span ng-bind-template="{{labelPrefix}}:"></span> {{container.name}}</div>
Copy link
Member

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.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2017
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 26, 2017
@cdcabrera cdcabrera force-pushed the init-containers branch 5 times, most recently from 09da291 to 28d6591 Compare June 1, 2017 15:36
Copy link
Member

@spadgett spadgett left a 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.

link: function(scope) {
scope.hasDebugTerminal = angular.isFunction(scope.startDebugTerminal);

var isContainerTerminated = $filter('isContainerTerminatedSuccessfully');
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha

scope.hasDebugTerminal = angular.isFunction(scope.startDebugTerminal);

var isContainerTerminated = $filter('isContainerTerminatedSuccessfully');
var haveContainersTerminated = function(containerStatuses) {
Copy link
Member

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.)


var isContainerTerminated = $filter('isContainerTerminatedSuccessfully');
var haveContainersTerminated = function(containerStatuses) {
return _.some(containerStatuses, isContainerTerminated);
Copy link
Member

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.

<span flex>
<span ng-if="initContainersTerminated"> &nbsp;{{pod.status.initContainerStatuses.length}}</span>
<ng-pluralize count="pod.status.initContainerStatuses.length"
when="{'1': 'Init Container','other': 'Init Containers'}">
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can do

</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>
Copy link
Member

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>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing

<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>
Copy link
Member

@spadgett spadgett Jun 2, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giving it a shot

restrict: 'E',
scope: {
pod: '=',
startDebugTerminal: '=?',
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries, can do

@spadgett
Copy link
Member

spadgett commented Jun 6, 2017

@cdcabrera I noticed the style for container status is different than regular containers. We should be consistent:

openshift web console 2017-06-06 08-31-04

@cdcabrera cdcabrera force-pushed the init-containers branch 3 times, most recently from 4374e04 to 63f12c3 Compare June 9, 2017 18:48
@cdcabrera
Copy link
Contributor Author

cdcabrera commented Jun 9, 2017

Restyled for consistency, reduced the need for nested labels. @openshift/team-ux-review @spadgett

init containers

Multiple init containers
multipleinitcontainers

And a single init container
singleinitcontainer


<div class="animate-if"
ng-if="expandInitContainers"
ng-repeat="containerStatus in pod.status.initContainerStatuses" >
Copy link
Member

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">

</div>
</div>

<div ng-repeat="containerStatus in pod.status.containerStatuses" >
Copy link
Member

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">

@cdcabrera cdcabrera force-pushed the init-containers branch 3 times, most recently from ed2655b to 07354d6 Compare June 13, 2017 14:39
Copy link
Member

@spadgett spadgett left a 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 :/


scope.showDebugAction = function (containerStatus) {

if (_.get(scope.containerStatuses, 'status.phase') === 'Completed') {
Copy link
Member

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'

Copy link
Contributor Author

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

return false;
}

if ($filter('annotation')(scope.containerStatuses, 'openshift.io/build.name')) {
Copy link
Member

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')

return false;
}

if ($filter('isDebugPod')(scope.containerStatuses)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$filter('isDebugPod')(scope.pod))

@spadgett
Copy link
Member

@cdcabrera Sorry found one more bug... :(

Init containers header showing up when there are none:

openshift web console 2017-06-13 15-57-15

</div>
</div>
</div>
<div ng-if="detailed">
Copy link
Member

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
@spadgett
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to fef9211

@openshift-bot
Copy link

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link

Evaluated for origin web console test up to fef9211

@openshift-bot
Copy link

Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1522/) (Base Commit: 50bfbcc)

@cdcabrera cdcabrera changed the title [WIP] Init Containers Init Containers Jun 13, 2017
@openshift-bot
Copy link

openshift-bot commented Jun 14, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1527/) (Base Commit: 871e99a)

@openshift-bot openshift-bot merged commit eae97da into openshift:master Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants