Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/app/scripts/directives/oscObjectDescriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ angular.module('openshiftConsole')
});

$(elem).on("mousemove.oscobject", function() {
if (scope.resource) {
if (scope.resource || $(this).hasClass("osc-object-stacked")) {
$(".osc-object-hover").not(this).removeClass("osc-object-hover");
$(this).addClass("osc-object-hover");
return false;
}
});

$(elem).on("mouseleave.oscobject", function() {
if (scope.resource) {
if (scope.resource || $(this).hasClass("osc-object-stacked")) {
$(this).removeClass("osc-object-hover");
}
});
Expand Down
20 changes: 20 additions & 0 deletions assets/app/scripts/directives/popups.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,24 @@ angular.module('openshiftConsole')
}
}
};
})
.directive('podWarnings', function(podWarningsFilter) {
return {
restrict:'E',
scope: {
pod: '='
},
link: function($scope, element) {
var warnings = podWarningsFilter($scope.pod);
var content = "";
angular.forEach(warnings, function(warning) {
content += warning.message + "<br>";
});
$('.pficon-layered', element)
.attr("data-content", content)
.popover("destroy")
.popover();
},
templateUrl: 'views/directives/_pod-warnings.html'
};
});
46 changes: 42 additions & 4 deletions assets/app/scripts/directives/resources.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

angular.module('openshiftConsole')
.directive('overviewDeployment', function() {
.directive('overviewDeployment', function($location, $timeout, LabelFilter) {
return {
restrict: 'E',
scope: {
Expand All @@ -18,7 +18,15 @@ angular.module('openshiftConsole')
// Pods
pods: '='
},
templateUrl: 'views/_overview-deployment.html'
templateUrl: 'views/_overview-deployment.html',
controller: function($scope) {
$scope.viewPodsForDeployment = function(deployment) {
$location.url("/project/" + deployment.metadata.namespace + "/browse/pods");
$timeout(function() {
LabelFilter.setLabelSelector(new LabelSelector(deployment.spec.selector, true));
}, 1);
};
}
};
})
.directive('overviewMonopod', function() {
Expand All @@ -45,11 +53,41 @@ angular.module('openshiftConsole')
return {
restrict: 'E',
scope: {
pods: '='
pods: '=',
projectName: '@?' //TODO optional for now
},
templateUrl: 'views/_pods.html'
templateUrl: 'views/_pods.html',
controller: function($scope) {
$scope.phases = [
"Failed",
"Pending",
"Running",
"Succeeded",
"Unknown"
];
$scope.expandedPhase = null;
$scope.warningsExpanded = false;
$scope.expandPhase = function(phase, warningsExpanded, $event) {
$scope.expandedPhase = phase;
Copy link
Member

Choose a reason for hiding this comment

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

If you have multiple deployments with collapsed pods, does this work properly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should only be that deployment. Each instance of a directive gets its own
scope.

On Thu, Sep 3, 2015 at 11:01 AM, Sam Padgett notifications@github.com
wrote:

In assets/app/scripts/directives/resources.js
#4486 (comment):

   },
  •  templateUrl: 'views/_pods.html'
    
  •  templateUrl: 'views/_pods.html',
    
  •  controller: function($scope) {
    
  •    $scope.phases = [
    
  •      "Failed",
    
  •      "Pending",
    
  •      "Running",
    
  •      "Succeeded",
    
  •      "Unknown"
    
  •    ];
    
  •    $scope.expandedPhase = null;
    
  •    $scope.warningsExpanded = false;
    
  •    $scope.expandPhase = function(phase, warningsExpanded, $event) {
    
  •      $scope.expandedPhase = phase;
    

If you have multiple deployments with collapsed pods, does this only
expand one or all?


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/4486/files#r38655537.

$scope.warningsExpanded = warningsExpanded;
if ($event) {
$event.stopPropagation();
}
};
}
};
})
.directive('podContent', function() {
// sub-directive used by the pods directive
return {
restrict: 'E',
scope: {
pod: '=',
troubled: '='
},
templateUrl: 'views/directives/_pod-content.html'
};
})
.directive('triggers', function() {
var hideBuildKey = function(build) {
return 'hide/build/' + build.metadata.namespace + '/' + build.metadata.name;
Expand Down
2 changes: 1 addition & 1 deletion assets/app/scripts/directives/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ angular.module('openshiftConsole')
},
templateUrl: 'views/directives/_custom-icon.html'
};
});
});
118 changes: 96 additions & 22 deletions assets/app/scripts/filters/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,56 +309,61 @@ angular.module('openshiftConsole')
return itemsArray;
};
})
.filter('isTroubledPod', function() {
// Scenario - Stuck Pod
// Check if the pod has been pending for a long time.
var isStuck = function(pod) {
.filter('isPodStuck', function() {
return function(pod) {
if (pod.status.phase !== 'Pending') {
return false;
}

// If this logic ever changes, update the message in podWarnings
var fiveMinutesAgo = moment().subtract(5, 'm');
var created = moment(pod.metadata.creationTimestamp);
return created.isBefore(fiveMinutesAgo);
return created.isBefore(fiveMinutesAgo);
};

// Scenario - Looping Container
// Check if the container is frequently restarting.
var isLooping = function(containerStatus) {
})
.filter('isContainerLooping', function() {
return function(containerStatus) {
if (containerStatus.restartCount < 3 ||
!containerStatus.state.running ||
!containerStatus.state.running.startedAt) {
return false;
}

// Only return true if the container has restarted recently.
// If this logic ever changes, update the message in podWarnings
var fiveMinutesAgo = moment().subtract(5, 'm');
var started = moment(containerStatus.state.running.startedAt);
return started.isAfter(fiveMinutesAgo);
};

// Scenario - Failed Container
// Check if the terminated container exited with a non-zero exit code
var isFailed = function(containerStatus) {
})
.filter('isContainerFailed', function() {
return function(containerStatus) {
// If this logic ever changes, update the message in podWarnings
return containerStatus.state.terminated && containerStatus.state.terminated.exitCode !== 0;
};

// Scenario - Unprepared Container
// Check if the container still isn't ready after a length of time.
var isUnprepared = function(containerStatus) {
})
.filter('isContainerUnprepared', function() {
return function(containerStatus) {
if (!containerStatus.state.running ||
containerStatus.ready !== false ||
!containerStatus.state.running.startedAt) {
return false;
}

// If this logic ever changes, update the message in podWarnings
var fiveMinutesAgo = moment().subtract(5, 'm');
var started = moment(containerStatus.state.running.startedAt);
return started.isBefore(fiveMinutesAgo);
};

})
.filter('isTroubledPod', function(isPodStuckFilter, isContainerLoopingFilter, isContainerFailedFilter, isContainerUnpreparedFilter) {
return function(pod) {
if (isStuck(pod)) {
if (pod.status.phase === 'Unknown') {
// We always show Unknown pods in a warning state
return true;
}

if (isPodStuckFilter(pod)) {
return true;
}

Expand All @@ -370,13 +375,13 @@ angular.module('openshiftConsole')
if (!containerStatus.state) {
continue;
}
if (isFailed(containerStatus)) {
if (isContainerFailedFilter(containerStatus)) {
return true;
}
if (isLooping(containerStatus)) {
if (isContainerLoopingFilter(containerStatus)) {
return true;
}
if (isUnprepared(containerStatus)) {
if (isContainerUnpreparedFilter(containerStatus)) {
return true;
}
}
Expand All @@ -385,6 +390,64 @@ angular.module('openshiftConsole')
return false;
};
})
.filter('podWarnings', function(isPodStuckFilter, isContainerLoopingFilter, isContainerFailedFilter, isContainerUnpreparedFilter) {
return function(pod) {
var warnings = [];

if (pod.status.phase === 'Unknown') {
// We always show Unknown pods in a warning state
warnings.push({reason: 'Unknown', message: 'The state of this pod could not be obtained. This is typically due to an error communicating with the host of the pod.'});
}

if (isPodStuckFilter(pod)) {
warnings.push({reason: "Stuck", message: "This pod has been stuck in the pending state for more than five minutes."});
}

if (pod.status.phase === 'Running' && pod.status.containerStatuses) {
// Check container statuses and short circuit when we find any problem.
var i;
for (i = 0; i < pod.status.containerStatuses.length; ++i) {
var containerStatus = pod.status.containerStatuses[i];
if (!containerStatus.state) {
continue;
}
if (isContainerFailedFilter(containerStatus)) {
warnings.push({reason: "Failed", message: "The container " + containerStatus.name + " failed with a non-zero exit code " + containerStatus.state.terminated.exitCode + "."});
}
if (isContainerLoopingFilter(containerStatus)) {
warnings.push({reason: "Looping", message: "The container " + containerStatus.name + " is restarting frequently, which usually indicates a problem. It has restarted " + containerStatus.restartCount + " times, and has restarted within the last five minutes."});
}
if (isContainerUnpreparedFilter(containerStatus)) {
warnings.push({reason: "Unprepared", message: "The container " + containerStatus.name + " has been running for more than five minutes and has not passed its readiness check."});
}
}
}

return warnings.length > 0 ? warnings : null;
};
})
.filter('troubledPods', function(isTroubledPodFilter) {
return function(pods) {
var troublePods = [];
angular.forEach(pods, function(pod){
if (isTroubledPodFilter(pod)) {
troublePods.push(pod);
}
});
return troublePods;
};
})
.filter('notTroubledPods', function(isTroubledPodFilter) {
return function(pods) {
var notTroublePods = [];
angular.forEach(pods, function(pod){
if (!isTroubledPodFilter(pod)) {
notTroublePods.push(pod);
}
});
return notTroublePods;
};
})
.filter('projectOverviewURL', function(Navigate) {
return function(projectName) {
return Navigate.projectOverviewURL(projectName);
Expand Down Expand Up @@ -546,4 +609,15 @@ angular.module('openshiftConsole')
// cluster.local suffix is customizable, so leave it off. <name>.<namespace>.svc resolves.
return service.metadata.name + '.' + service.metadata.namespace + '.svc';
};
})
.filter('podsForPhase', function() {
return function(pods, phase) {
var podsForPhase = [];
angular.forEach(pods, function(pod){
if (pod.status.phase === phase) {
podsForPhase.push(pod);
}
});
return podsForPhase;
};
});
Loading