Skip to content

Commit a60cd15

Browse files
author
OpenShift Bot
authored
Merge pull request #909 from jwforres/pod-duration
Merged by openshift-bot
2 parents cd4bfdc + 3b6d5ea commit a60cd15

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

app/scripts/filters/resources.js

+30
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,36 @@ angular.module('openshiftConsole')
11721172
return reason;
11731173
};
11741174
})
1175+
.filter('podStartTime', function() {
1176+
return function(pod) {
1177+
var earliestStartTime = null;
1178+
_.each(_.get(pod, 'status.containerStatuses'), function(containerStatus){
1179+
var status = _.get(containerStatus, 'state.running') || _.get(containerStatus, 'state.terminated');
1180+
if (!status) {
1181+
return;
1182+
}
1183+
if (!earliestStartTime || moment(status.startedAt).isBefore(earliestStartTime)) {
1184+
earliestStartTime = status.startedAt;
1185+
}
1186+
});
1187+
return earliestStartTime;
1188+
};
1189+
})
1190+
.filter('podCompletionTime', function() {
1191+
return function(pod) {
1192+
var lastFinishTime = null;
1193+
_.each(_.get(pod, 'status.containerStatuses'), function(containerStatus){
1194+
var status = _.get(containerStatus, 'state.terminated');
1195+
if (!status) {
1196+
return;
1197+
}
1198+
if (!lastFinishTime || moment(status.finishedAt).isAfter(lastFinishTime)) {
1199+
lastFinishTime = status.finishedAt;
1200+
}
1201+
});
1202+
return lastFinishTime;
1203+
};
1204+
})
11751205
.filter('routeIngressCondition', function() {
11761206
return function(ingress, type) {
11771207
if (!ingress) {

app/views/browse/_pod-details.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h3>
1212
<dt>Status:</dt>
1313
<dd>
1414
<status-icon status="pod | podStatus"></status-icon>
15-
{{pod | podStatus | sentenceCase}}
15+
{{pod | podStatus | sentenceCase}}<span ng-if="pod | podCompletionTime">, ran for {{(pod | podStartTime) | duration : (pod | podCompletionTime)}}</span>
1616
<span ng-if="pod.metadata.deletionTimestamp">(expires {{pod.metadata.deletionTimestamp | date : 'medium'}})</span>
1717
</dd>
1818
<dt ng-if-start="pod.metadata.deletionTimestamp && pod.spec.terminationGracePeriodSeconds">Grace Period:</dt>

dist/scripts/scripts.js

+16
Original file line numberDiff line numberDiff line change
@@ -13226,6 +13226,22 @@ var c, d, e = _.get(a, "state.waiting.reason") || _.get(a, "state.terminated.rea
1322613226
return e ? void (b = e) :(c = _.get(a, "state.terminated.signal")) ? void (b = "Signal: " + c) :(d = _.get(a, "state.terminated.exitCode"), void (d && (b = "Exit Code: " + d)));
1322713227
}), b;
1322813228
};
13229+
}).filter("podStartTime", function() {
13230+
return function(a) {
13231+
var b = null;
13232+
return _.each(_.get(a, "status.containerStatuses"), function(a) {
13233+
var c = _.get(a, "state.running") || _.get(a, "state.terminated");
13234+
c && (b && !moment(c.startedAt).isBefore(b) || (b = c.startedAt));
13235+
}), b;
13236+
};
13237+
}).filter("podCompletionTime", function() {
13238+
return function(a) {
13239+
var b = null;
13240+
return _.each(_.get(a, "status.containerStatuses"), function(a) {
13241+
var c = _.get(a, "state.terminated");
13242+
c && (b && !moment(c.finishedAt).isAfter(b) || (b = c.finishedAt));
13243+
}), b;
13244+
};
1322913245
}).filter("routeIngressCondition", function() {
1323013246
return function(a, b) {
1323113247
return a ? _.find(a.conditions, {

dist/scripts/templates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
11821182
"<dt>Status:</dt>\n" +
11831183
"<dd>\n" +
11841184
"<status-icon status=\"pod | podStatus\"></status-icon>\n" +
1185-
"{{pod | podStatus | sentenceCase}}\n" +
1185+
"{{pod | podStatus | sentenceCase}}<span ng-if=\"pod | podCompletionTime\">, ran for {{(pod | podStartTime) | duration : (pod | podCompletionTime)}}</span>\n" +
11861186
"<span ng-if=\"pod.metadata.deletionTimestamp\">(expires {{pod.metadata.deletionTimestamp | date : 'medium'}})</span>\n" +
11871187
"</dd>\n" +
11881188
"<dt ng-if-start=\"pod.metadata.deletionTimestamp && pod.spec.terminationGracePeriodSeconds\">Grace Period:</dt>\n" +

0 commit comments

Comments
 (0)