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
55 changes: 48 additions & 7 deletions app/scripts/controllers/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ angular.module('openshiftConsole')
},
{
kind: "Builds"
},
{
kind: "StatefulSets"
}
];
$scope.kindSelector = {
Expand All @@ -55,26 +58,30 @@ angular.module('openshiftConsole')
$scope.logOptions = {
pods: {},
replicationControllers: {},
builds: {}
builds: {},
statefulSets: {}
};

$scope.logCanRun = {
pods: {},
replicationControllers: {},
builds: {}
builds: {},
statefulSets: {}
};

$scope.logEmpty = {
pods: {},
replicationControllers: {},
builds: {}
builds: {},
statefulSets: {}
};

$scope.expanded = {
pods: {},
replicationControllers: {},
replicaSets: {},
builds: {}
builds: {},
statefulSets: {}
};

var isNil = $filter('isNil');
Expand All @@ -86,7 +93,6 @@ angular.module('openshiftConsole')

var ageFilteredBuilds, ageFilteredReplicationControllers, ageFilteredReplicaSets, ageFilteredPods;

// Check if the metrics service is available so we know when to show the tab.
MetricsService.isAvailable().then(function(available) {
$scope.metricsAvailable = available;
});
Expand All @@ -105,8 +111,18 @@ angular.module('openshiftConsole')
$scope.filteredReplicationControllers = KeywordService.filterForKeywords(ageFilteredReplicationControllers, filterFields, filterKeywords);
$scope.filteredReplicaSets = KeywordService.filterForKeywords(ageFilteredReplicaSets, filterFields, filterKeywords);
$scope.filteredBuilds = KeywordService.filterForKeywords(ageFilteredBuilds, filterFields, filterKeywords);
$scope.filteredStatefulSets = KeywordService.filterForKeywords(_.values($scope.statefulSets), filterFields, filterKeywords);
};

// TODO: logs for stateful sets will come later
// logging endpoint for stateful sets coming in the future.
// var setStatefulSetLogVars = function(set) {
// $scope.logOptions.statefulSets[set.metadata.name] = {
// container: set.spec.template.spec.containers[0].name
// };
// $scope.logCanRun.statefulSets[set.metadata.name] = !(_.includes(['New', 'Pending', 'Unknown'], set.status.phase));
// };

var setPodLogVars = function(pod) {
$scope.logOptions.pods[pod.metadata.name] = {
container: pod.spec.containers[0].name
Expand All @@ -128,6 +144,11 @@ angular.module('openshiftConsole')
$scope.logCanRun.builds[build.metadata.name] = !(_.includes(['New', 'Pending', 'Error'], build.status.phase));
};


var filterStatefulSets = function() {
$scope.filteredStatefulSets = KeywordService.filterForKeywords(_.values($scope.statefulSets), filterFields, filterKeywords);
};

var filterPods = function() {
ageFilteredPods = _.filter($scope.pods, function(pod) {
if (!$scope.filters.hideOlderResources) {
Expand Down Expand Up @@ -237,6 +258,12 @@ angular.module('openshiftConsole')
event = expanded ? 'event.resource.highlight' : 'event.resource.clear-highlight';
$rootScope.$emit(event, resource);
break;
case 'StatefulSet':
expanded = !$scope.expanded.statefulSets[resource.metadata.name];
$scope.expanded.statefulSets[resource.metadata.name] = expanded;
event = expanded ? 'event.resource.highlight' : 'event.resource.clear-highlight';
$rootScope.$emit(event, resource);
break;
}
};

Expand All @@ -249,11 +276,11 @@ angular.module('openshiftConsole')
};

var groupPods = function() {
if (!$scope.pods || !$scope.replicationControllers || !$scope.replicaSets) {
if (!$scope.pods || !$scope.replicationControllers || !$scope.replicaSets || !$scope.statefulSets) {
return;
}

var allOwners = _.toArray($scope.replicationControllers).concat(_.toArray($scope.replicaSets));
var allOwners = _.toArray($scope.replicationControllers).concat(_.toArray($scope.replicaSets)).concat(_.toArray($scope.statefulSets));
$scope.podsByOwnerUID = LabelsService.groupBySelector($scope.pods, allOwners, { key: 'metadata.uid' });
};

Expand All @@ -273,6 +300,19 @@ angular.module('openshiftConsole')
Logger.log("pods", $scope.pods);
});

DataService.watch({
resource: 'statefulsets',
group: 'apps',
version: 'v1beta1'
}, context, function(statefulSets) {
$scope.statefulSets = statefulSets.by("metadata.name");
groupPods();
$scope.statefulSetsLoaded = true;
// _.each($scope.statefulSets, setStatefulSetLogVars); // TODO: enable when we have the endpoint
filterStatefulSets();
Logger.log("statefulSets", $scope.statefulSets);
});

DataService.watch("replicationcontrollers", context, function(replicationControllers) {
$scope.replicationControllers = orderByDate(replicationControllers.by("metadata.name"), true);
groupPods();
Expand Down Expand Up @@ -308,6 +348,7 @@ angular.module('openshiftConsole')
filterBuilds();
filterDeployments();
filterReplicaSets();
filterStatefulSets();
var search = $location.search();
search.hideOlderResources = $scope.filters.hideOlderResources ? 'true' : 'false';
$location.replace().search(search);
Expand Down
69 changes: 69 additions & 0 deletions app/views/monitoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h1>
<alerts alerts="alerts"></alerts>
<div class="row">
<div class="col-md-12">

<div ng-if="kindSelector.selected.kind === 'All' || kindSelector.selected.kind === 'Pods'">
<h2>Pods</h2>
<div class="list-view-pf">
Expand Down Expand Up @@ -137,6 +138,7 @@ <h2>Pods</h2>
</div>
</div>
</div>

<div ng-if="kindSelector.selected.kind === 'All' || kindSelector.selected.kind === 'ReplicationControllers'">
<h2>Deployments</h2>
<div class="list-view-pf">
Expand Down Expand Up @@ -260,6 +262,73 @@ <h2>Deployments</h2>
</div>
</div>
</div>

<div ng-if="kindSelector.selected.kind === 'All' || kindSelector.selected.kind === 'StatefulSets'">
<h2>Stateful Sets</h2>
<div class="list-view-pf">
<div class="list-group-item" ng-if="!(filteredStatefulSets | hashSize)">
<div class="list-view-pf-main-info">
<ellipsis-pulser color="dark" size="sm" msg="Loading stateful sets" ng-if="!statefulSetsLoaded"></ellipsis-pulser>
<em>
<div ng-if="(statefulSets | hashSize) > 0">The current filters are hiding all stateful sets.</div>
<span ng-if="statefulSetsLoaded && (statefulSets | hashSize) === 0">There are no stateful sets in this project.</span>
</em>
</div>
</div>
<div class="list-group-item list-group-item-expandable"
ng-repeat-start="set in filteredStatefulSets track by (set | uid)"
ng-click="toggleItem($event, this, set)"
ng-class="{'expanded': expanded.statefulSets[set.metadata.name]}">
<div class="list-view-pf-checkbox">
<button class="sr-only">{{expanded.statefulSets[set.metadata.name] ? 'Collapse' : 'Expand'}}</button>
<span ng-if="expanded.statefulSets[set.metadata.name]">
<span class="fa fa-angle-down"></span>
</span>
<span ng-if="!expanded.statefulSets[set.metadata.name]">
<span class="fa fa-angle-right"></span>
</span>
</div>

<div class="list-view-pf-main-info">
<div class="list-view-pf-body">
<div class="list-view-pf-description">
<div class="list-group-item-heading">
<a ng-href="{{set | navigateResourceURL}}"><span ng-bind-html="set.metadata.name | highlightKeywords : filterKeywords"></span></a>
<small>created <span am-time-ago="set.metadata.creationTimestamp"></span></small>
</div>
<div class="list-group-item-text">
<status-icon status="set | deploymentStatus" disable-animation></status-icon>
{{set | deploymentStatus | sentenceCase}},
<span ng-if="(podsByOwnerUID[set.metadata.uid] | hashSize) !== set.spec.replicas">{{podsByOwnerUID[set.metadata.uid] | hashSize}}/</span>{{set.spec.replicas}} replica<span ng-if="set.spec.replicas != 1">s</span>
</div>
</div>
<div class="list-view-pf-additional-info">
<div class="list-view-pf-additional-info-item">
<span class="pficon fa-fw pficon-image"></span>
<image-names pod-template="set.spec.template" pods="podsByOwnerUID[set.metadata.uid]"></image-names>
</div>
</div>
</div>
</div>
</div>
<div ng-repeat-end ng-if="expanded.statefulSets[set.metadata.name]" class="list-group-expanded-section" ng-class="{'expanded': expanded.statefulSets[set.metadata.name]}">
Logs are not available for stateful sets.
<span ng-if="podsByOwnerUID[set.metadata.uid] | hashSize">
To see application logs, view the logs for one of the stateful sets's
<a href="" ng-click="viewPodsForReplicaSet(set)">pods</a>.
</span>
<div class="mar-top-lg" ng-if="metricsAvailable">
<deployment-metrics
pods="podsByOwnerUID[set.metadata.uid]"
containers="set.spec.template.spec.containers"
alerts="alerts">
</deployment-metrics>
</div>
</div>
</div>
</div>


<div ng-if="kindSelector.selected.kind === 'All' || kindSelector.selected.kind === 'Builds'">
<h2>Builds</h2>
<div class="list-view-pf">
Expand Down
58 changes: 38 additions & 20 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5098,27 +5098,33 @@ label:"Deployments",
kind:"ReplicationControllers"
}, {
kind:"Builds"
}, {
kind:"StatefulSets"
} ], c.kindSelector = {
selected:_.find(c.kinds, {
kind:a.kind
}) || _.head(c.kinds)
}, c.logOptions = {
pods:{},
replicationControllers:{},
builds:{}
builds:{},
statefulSets:{}
}, c.logCanRun = {
pods:{},
replicationControllers:{},
builds:{}
builds:{},
statefulSets:{}
}, c.logEmpty = {
pods:{},
replicationControllers:{},
builds:{}
builds:{},
statefulSets:{}
}, c.expanded = {
pods:{},
replicationControllers:{},
replicaSets:{},
builds:{}
builds:{},
statefulSets:{}
};
var q = d("isNil");
c.filters = {
Expand All @@ -5130,7 +5136,7 @@ k.isAvailable().then(function(a) {
c.metricsAvailable = a;
});
var v = d("orderObjectsByDate"), w = [ "metadata.name" ], x = [], y = function() {
c.filteredPods = h.filterForKeywords(u, w, x), c.filteredReplicationControllers = h.filterForKeywords(s, w, x), c.filteredReplicaSets = h.filterForKeywords(t, w, x), c.filteredBuilds = h.filterForKeywords(r, w, x);
c.filteredPods = h.filterForKeywords(u, w, x), c.filteredReplicationControllers = h.filterForKeywords(s, w, x), c.filteredReplicaSets = h.filterForKeywords(t, w, x), c.filteredBuilds = h.filterForKeywords(r, w, x), c.filteredStatefulSets = h.filterForKeywords(_.values(c.statefulSets), w, x);
}, z = function(a) {
c.logOptions.pods[a.metadata.name] = {
container:a.spec.containers[0].name
Expand All @@ -5142,22 +5148,24 @@ b && (c.logOptions.replicationControllers[a.metadata.name].version = b), c.logCa
}, B = function(a) {
c.logOptions.builds[a.metadata.name] = {}, c.logCanRun.builds[a.metadata.name] = !_.includes([ "New", "Pending", "Error" ], a.status.phase);
}, C = function() {
c.filteredStatefulSets = h.filterForKeywords(_.values(c.statefulSets), w, x);
}, D = function() {
u = _.filter(c.pods, function(a) {
return !c.filters.hideOlderResources || "Succeeded" !== a.status.phase && "Failed" !== a.status.phase;
}), c.filteredPods = h.filterForKeywords(u, w, x);
}, D = d("isIncompleteBuild"), E = d("buildConfigForBuild"), F = d("isRecentBuild"), G = function() {
}, E = d("isIncompleteBuild"), F = d("buildConfigForBuild"), G = d("isRecentBuild"), H = function() {
moment().subtract(5, "m");
r = _.filter(c.builds, function(a) {
if (!c.filters.hideOlderResources) return !0;
if (D(a)) return !0;
var b = E(a);
return b ? c.latestBuildByConfig[b].metadata.name === a.metadata.name :F(a);
if (E(a)) return !0;
var b = F(a);
return b ? c.latestBuildByConfig[b].metadata.name === a.metadata.name :G(a);
}), c.filteredBuilds = h.filterForKeywords(r, w, x);
}, H = d("deploymentStatus"), I = d("deploymentIsInProgress"), J = function() {
}, I = d("deploymentStatus"), J = d("deploymentIsInProgress"), K = function() {
s = _.filter(c.replicationControllers, function(a) {
return !c.filters.hideOlderResources || (I(a) || "Active" === H(a));
return !c.filters.hideOlderResources || (J(a) || "Active" === I(a));
}), c.filteredReplicationControllers = h.filterForKeywords(s, w, x);
}, K = function() {
}, L = function() {
t = _.filter(c.replicaSets, function(a) {
return !c.filters.hideOlderResources || _.get(a, "status.replicas");
}), c.filteredReplicaSets = h.filterForKeywords(t, w, x);
Expand Down Expand Up @@ -5194,35 +5202,45 @@ break;

case "Pod":
g = !c.expanded.pods[e.metadata.name], c.expanded.pods[e.metadata.name] = g, h = g ? "event.resource.highlight" :"event.resource.clear-highlight", o.$emit(h, e);
break;

case "StatefulSet":
g = !c.expanded.statefulSets[e.metadata.name], c.expanded.statefulSets[e.metadata.name] = g, h = g ? "event.resource.highlight" :"event.resource.clear-highlight", o.$emit(h, e);
}
}
}, c.viewPodsForReplicaSet = function(a) {
_.isEmpty(c.podsByOwnerUID[a.metadata.uid]) || l.toPodsForDeployment(a);
};
var L = function() {
if (c.pods && c.replicationControllers && c.replicaSets) {
var a = _.toArray(c.replicationControllers).concat(_.toArray(c.replicaSets));
var M = function() {
if (c.pods && c.replicationControllers && c.replicaSets && c.statefulSets) {
var a = _.toArray(c.replicationControllers).concat(_.toArray(c.replicaSets)).concat(_.toArray(c.statefulSets));
c.podsByOwnerUID = i.groupBySelector(c.pods, a, {
key:"metadata.uid"
});
}
};
n.get(a.project).then(_.spread(function(a, d) {
c.project = a, c.projectContext = d, f.watch("pods", d, function(a) {
c.podsByName = a.by("metadata.name"), c.pods = v(c.podsByName, !0), L(), c.podsLoaded = !0, _.each(c.pods, z), C(), j.log("pods", c.pods);
c.podsByName = a.by("metadata.name"), c.pods = v(c.podsByName, !0), M(), c.podsLoaded = !0, _.each(c.pods, z), D(), j.log("pods", c.pods);
}), f.watch({
resource:"statefulsets",
group:"apps",
version:"v1beta1"
}, d, function(a) {
c.statefulSets = a.by("metadata.name"), M(), c.statefulSetsLoaded = !0, C(), j.log("statefulSets", c.statefulSets);
}), f.watch("replicationcontrollers", d, function(a) {
c.replicationControllers = v(a.by("metadata.name"), !0), L(), c.replicationControllersLoaded = !0, _.each(c.replicationControllers, A), J(), j.log("replicationcontrollers", c.replicationControllers);
c.replicationControllers = v(a.by("metadata.name"), !0), M(), c.replicationControllersLoaded = !0, _.each(c.replicationControllers, A), K(), j.log("replicationcontrollers", c.replicationControllers);
}), f.watch("builds", d, function(a) {
c.builds = v(a.by("metadata.name"), !0), c.latestBuildByConfig = e.latestBuildByConfig(c.builds), c.buildsLoaded = !0, _.each(c.builds, B), G(), j.log("builds", c.builds);
c.builds = v(a.by("metadata.name"), !0), c.latestBuildByConfig = e.latestBuildByConfig(c.builds), c.buildsLoaded = !0, _.each(c.builds, B), H(), j.log("builds", c.builds);
}), f.watch({
group:"extensions",
resource:"replicasets"
}, d, function(a) {
c.replicaSets = v(a.by("metadata.name"), !0), L(), c.replicaSetsLoaded = !0, K(), j.log("replicasets", c.replicaSets);
c.replicaSets = v(a.by("metadata.name"), !0), M(), c.replicaSetsLoaded = !0, L(), j.log("replicasets", c.replicaSets);
}), c.$on("$destroy", function() {
f.unwatchAll(p);
}), c.$watch("filters.hideOlderResources", function() {
C(), G(), J(), K();
D(), H(), K(), L(), C();
var a = b.search();
a.hideOlderResources = c.filters.hideOlderResources ? "true" :"false", b.replace().search(a);
}), c.$watch("kindSelector.selected.kind", function() {
Expand Down
Loading