Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminapetersen committed Jan 10, 2017
1 parent ecd6687 commit 851a739
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 58 deletions.
3 changes: 0 additions & 3 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,6 @@ angular
.when('/project/:project/browse/deployments-replicationcontrollers/:rc', {
redirectTo: '/project/:project/browse/rc/:rc'
})
.when('/project/:project/browse/pet-sets/:petset', {
redirectTo: '/project/:project/browse/stateful-sets/:statefulset'
})
.otherwise({
redirectTo: '/'
});
Expand Down
1 change: 0 additions & 1 deletion app/scripts/controllers/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ angular.module('openshiftConsole')
group: 'apps',
version: 'v1alpha1'
}, context, function(statefulSets) {
console.log('statefulSets?', statefulSets.by('metadata.name'));
$scope.statefulSets = statefulSets.by('metadata.name');
}));

Expand Down
70 changes: 35 additions & 35 deletions app/scripts/controllers/statefulSet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

// TODO: statefulSetController rename
// Kube docs: http://kubernetes.io/docs/user-guide/statefulSet/
angular
.module('openshiftConsole')
.controller('StatefulSetController', function(
Expand All @@ -14,15 +12,13 @@ angular
ProjectsService) {

$scope.projectName = $routeParams.project;
$scope.statefulSetName = $routeParams.statefulset || $routeParams.petset; // TODO: eliminate petset fallback
$scope.statefulSetName = $routeParams.statefulset;
$scope.forms = {};
$scope.alerts = {};
// TODO: update getBreadcrumbs, currently returns:
// Pet Sets > hello-statefulSet
// But the link for `Pet Sets` isn't valid. Where do we want these to live?
// TODO: StatefulSet isn't a thing, should fall back to Deployments?
$scope.breadcrumbs = BreadcrumbsService.getBreadcrumbs({
name: $scope.statefulSetName,
kind: 'statefulSet', // TODO: update to statefulSet
kind: 'statefulSet',
namespace: $routeParams.project
});
$scope.emptyMessage = "Loading...";
Expand All @@ -39,9 +35,7 @@ angular
if (!pods || !selector) {
return;
}
return _.filter(pods, function(pod) {
return selector.matches(pod);
});
return selector.select(pods);
};

var resourceGroupVersion = {
Expand All @@ -55,32 +49,38 @@ angular
.then(_.spread(function(project, context) {
projectContext = context;

watches.push(DataService.watchObject(resourceGroupVersion, $scope.statefulSetName, context, function(statefulSet) {
console.log('statefulSet', statefulSet);
angular.extend($scope, {
resourceGroupVersion: resourceGroupVersion,
statefulSet: statefulSet,
loaded: true,
projectContext: context
// TODO: support scaling
// scale: function() {},
// isScalable: function() { return true; }
DataService
.get(resourceGroupVersion, $scope.statefulSetName, context)
.then(function(statefulSet) {
angular.extend($scope, {
statefulSet: statefulSet,
projectContext: context,
loaded: true
});
watches.push(DataService.watchObject(resourceGroupVersion, $scope.statefulSetName, context, function(statefulSet) {
angular.extend($scope, {
resourceGroupVersion: resourceGroupVersion,
statefulSet: statefulSet
// TODO: support scaling
// scale: function() {},
// isScalable: function() { return true; }
});
var pods;
var selector;
$scope.$watch('statefulSet.spec.selector', function() {
selector = new LabelSelector($scope.statefulSet.spec.selector);
$scope.podsForStatefulSet = updatePods(pods, selector);
}, true);
// TODO: this is leaky. every time the outer watch updates,
// we are creating a new watch on pods:
// - console.log('# of watches?', watches.length); // steadily increments
// we have this in a lot of places...
watches.push(DataService.watch('pods', context, function(podData) {
pods = podData.by('metadata.name');
$scope.podsForStatefulSet = updatePods(pods, selector);
}));
}));
});
var pods;
var selector;
$scope.$watch('statefulSet.spec.selector', function() {
selector = new LabelSelector($scope.statefulSet.spec.selector);
$scope.podsForStatefulSet = updatePods(pods, selector);
}, true);
// TODO: this is leaky. every time the outer watch updates,
// we are creating a new watch on pods:
// - console.log('# of watches?', watches.length); // steadily increments
// we have this in a lot of places...
watches.push(DataService.watch('pods', context, function(podData) {
pods = podData.by('metadata.name');
$scope.podsForStatefulSet = updatePods(pods, selector);
}));
}));
}));

$scope.$on('$destroy', function(){
Expand Down
8 changes: 5 additions & 3 deletions app/scripts/filters/canI.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ angular
'projects': [
{group: '', resource: 'projects', verbs: ['delete', 'update']}
],
// todo: eliminate when we get the name change to statefulsets
'petsets': [
//resource: 'petsets',group: 'apps',version: 'v1alpha1'
// TODO: are the verbs right here? the others only have 2...
{group: 'apps', resource: 'petsets', verbs: ['create', 'update', 'delete']}
{group: 'apps', resource: 'petsets', verbs: ['update', 'delete']}
],
'statefulsets': [
{group: 'apps', resource: 'statefulsets', verbs: ['update', 'delete']}
]
};
return function(resource) {
Expand Down
14 changes: 7 additions & 7 deletions app/views/browse/stateful-set.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ <h1>
<i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span>
</a>
<ul class="dropdown-menu actions action-button">
<!-- TODO: kinda works, but cant seem to edit. neat. -->
<li ng-if="resourceGroupVersion | canI : 'update'">
<a ng-href="{{statefulSet | editYamlURL}}" role="button">Edit YAML</a>
</li>
Expand Down Expand Up @@ -78,16 +77,18 @@ <h1>
<dd ng-if-end>{{statefulSet | annotation:'deploymentStatusReason'}}</dd>
<dt>Replicas:</dt>
<dd>
<!-- Enable scaling if this is a plain replication controller or it's the active deployment,
as long as it doesn't have an HPA. -->
<!-- TODO: replicaSets have a donut to the right -->
<!--
statefulSets do not have history
& are always scalable unless there are HPAs involved
-->
<!-- TODO: DONUT -->
<replicas status="statefulSet.status.replicas"
spec="statefulSet.spec.replicas"
disable-scaling="!isScalable()"
scale-fn="scale(replicas)"
deployment="statefulSet">
</replicas>
<!-- Do we have autoscalers for these?
<!-- TODO: HPA as a follow-on PR
<span ng-if="autoscalers.length">(autoscaled)</span>
-->
</dd>
Expand Down Expand Up @@ -126,7 +127,6 @@ <h3>Container {{container.name}} Environment Variables</h3>
There are no environment variables for this container.
</span>
</p>
<!-- TODO: add the canI filter -->
<key-value-editor
entries="container.env"
key-placeholder="Name"
Expand All @@ -136,7 +136,6 @@ <h3>Container {{container.name}} Environment Variables</h3>
cannot-delete
cannot-sort
show-header></key-value-editor>

</div>
</ng-form>
</div>
Expand All @@ -159,6 +158,7 @@ <h3>Container {{container.name}} Environment Variables</h3>
<uib-tab active="selectedTab.events">
<uib-tab-heading>Events</uib-tab-heading>
<div class="resource-events">
<!-- TODO: resource-kind: StatefulSet update -->
<events
resource-kind="PetSet"
resource-name="{{statefulSet.metadata.name}}"
Expand Down
11 changes: 2 additions & 9 deletions app/views/deployments.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,23 @@ <h3>StatefulSets</h3>
<thead>
<tr>
<th>Name</th>
<th>Generation</th>
<th>Status</th>
<th>Created</th>
<th>Trigger</th>
</tr>
</thead>
<tbody ng-repeat="(statefulSetName, statefulSet) in statefulSets">
<tr>
<td data-title="Name">
<a ng-href="{{statefulSet | navigateResourceURL}}">{{statefulSet.metadata.name}}</a>
</td>
<td data-title="Generation">{{statefulSet.metadata.generation}}</td>
<td data-title="Status">
<status-icon status="statefulSet | deploymentStatus"></status-icon>
{{statefulSet | deploymentStatus}}
<span ng-if="(statefulSet | deploymentStatus) == 'Active' || (statefulSet | deploymentStatus) == 'Running'">,
<span ng-if="statefulSet.spec.replicas !== statefulSet.status.replicas">{{statefulSet.status.replicas}}/</span>
{{statefulSet.spec.replicas}} replica<span ng-if="statefulSet.spec.replicas != 1">s</span>
</span>
{{statefulSet | deploymentStatus}}<span ng-if="(statefulSet | deploymentStatus) === 'Active' || (statefulSet | deploymentStatus) === 'Running'">,
<span ng-if="statefulSet.spec.replicas !== statefulSet.status.replicas">{{statefulSet.status.replicas}}/</span>{{statefulSet.spec.replicas}} replica<span ng-if="statefulSet.spec.replicas !== 1">s</span></span>
</td>
<td data-title="Created">
<span am-time-ago="statefulSet.metadata.creationTimestamp"></span>
</td>
<td data-title="Trigger">-</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 851a739

Please sign in to comment.