Skip to content

Conversation

@rhamilto
Copy link
Member

@rhamilto rhamilto commented Jan 17, 2018

@rhamilto rhamilto requested a review from jwforres January 17, 2018 16:53
@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 17, 2018

if (containerReason) {
// only show containerReason if pod.status.phase is not 'Failed'
if (reason !== 'Failed' && containerReason) {
Copy link
Member

Choose a reason for hiding this comment

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

@spadgett can you think of a case where this isn't what we would want?

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 there might be specific reasons you'd want to see even for failed pods. Evicted? Deadline exceeded?

This logic was modeled after the CLI, so it would be good to stay consistent. I'm curious what the CLI shows for these pods.

Copy link
Member Author

Choose a reason for hiding this comment

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

NAME                READY     STATUS       RESTARTS   AGE
dancer-ex-1-build   0/1       Init:Error   0          1h

Copy link
Member

Choose a reason for hiding this comment

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

@jwforres Do we need to iterate over initContainerStatuses here too?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yeah i think that is probably the correct fix for this

Copy link
Member

Choose a reason for hiding this comment

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

Looks like CLI has special initializing logic.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 17, 2018
@rhamilto
Copy link
Member Author

Take 2. I didn't add all the initializing logic since it seems we only care about errors. Thoughts?

@spadgett
Copy link
Member

/hold
/assign

I'm not sure the logic is right. I'll follow up with a review, but hold for now.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2018
var initReason;

angular.forEach(pod.status.initContainerStatuses, function(initContainerStatus) {
var initContainerReason = _.get(initContainerStatus, 'state.terminated.reason');
Copy link
Member

Choose a reason for hiding this comment

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

It looks like there is a state.terminated.reason even for successful init containters. We probably need to check exitCode, too.

  initContainerStatuses:
    - containerID: >-
        docker://695625642cd6a776c8fe86a0ee530e0acbe04cfbb7187552c55b068f60df1333
      image: 'docker.io/openshift/origin-sti-builder:v3.9.0-alpha.3'
      imageID: >-
        docker-pullable://docker.io/openshift/origin-sti-builder@sha256:1120189696907b0451dcd081b39406be02c14b988cc7fc655af39002a0953ced
      lastState: {}
      name: git-clone
      ready: true
      restartCount: 0
      state:
        terminated:
          containerID: >-
            docker://695625642cd6a776c8fe86a0ee530e0acbe04cfbb7187552c55b068f60df1333
          exitCode: 0
          finishedAt: '2018-01-19T23:18:35Z'
          reason: Completed
          startedAt: '2018-01-19T23:18:33Z'

If there are multiple init containers and only the first init container has it, it looks like initContainerReason will be unset since we don't break the loop early.

@rhamilto
Copy link
Member Author

Take 3. No idea if this is right, but I gave it a go.

return;
if (initContainerState.terminated && initContainerState.terminated.exitCode === 0) {
// initialization is complete
return true;
Copy link
Member

Choose a reason for hiding this comment

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

return true will short-circuit here and skip the remaining init containers. Since this container was successful, it's not what we want. We want to short0circuit only when we find one that is not complete or failed.

I think you want just return;

var containerReason = _.get(containerStatus, 'state.waiting.reason') || _.get(containerStatus, 'state.terminated.reason'),
signal,
exitCode;
_.forEach(pod.status.initContainerStatuses, function(initContainerStatus) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: We try to consistently use _.each (alias to _.forEach) so we don't have a mix of one and the other. They're the same, but if you don't know that, it might be confusing to see both in the code.


// Print detailed container reasons if available. Only the last will be
// displayed if multiple containers have this detail.
_.forEach(pod.status.containerStatuses, 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.

nit: _.each

@rhamilto
Copy link
Member Author

Take 3 comments address.

if (!initializing) {
reason = pod.status.reason || pod.status.phase;

// Print detailed container reasons if available. Only the last will be
Copy link
Member

Choose a reason for hiding this comment

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

Update comment to say only first will be displayed if multiple containers have a reason. The comment no longer matches the code.


exitCode = _.get(containerStatus, 'state.terminated.exitCode');
if (exitCode) {
reason = "Exit Code: " + exitCode;
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 return true after this line, too, so we stop looking at other containers like the other checks above. Otherwise it'll keep iterating.

@rhamilto
Copy link
Member Author

Round 4. Thank you for your patience, @spadgett.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2018
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.

/lgtm

@spadgett
Copy link
Member

Sorry didn't realize this still had the hold label

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 30, 2018
@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants