Skip to content

Commit

Permalink
perf(kubernetes): Send server group and firewall requests in parallel (
Browse files Browse the repository at this point in the history
…#8500)

Similar to the change I just made for instances, let's request the
details and the manifest at the same time so that we reduce the amount
of time the user has to wait.

For server group managers and load balancers, we are not making a
request for the details at all, so we don't need to make the same
change to those controllers.
  • Loading branch information
ezimanyi committed Aug 17, 2020
1 parent d599cfb commit 577d257
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IController, IScope, module } from 'angular';
import { IController, IQService, IScope, module } from 'angular';
import { IModalService } from 'angular-ui-bootstrap';
import { StateService } from '@uirouter/angularjs';

Expand Down Expand Up @@ -26,14 +26,23 @@ class KubernetesSecurityGroupDetailsController implements IController {
public securityGroup: IKubernetesSecurityGroup;
public manifest: IManifest;

public static $inject = ['$uibModal', '$state', '$scope', 'securityGroupReader', 'resolvedSecurityGroup', 'app'];
public static $inject = [
'$uibModal',
'$state',
'$scope',
'securityGroupReader',
'resolvedSecurityGroup',
'app',
'$q',
];
constructor(
private $uibModal: IModalService,
private $state: StateService,
private $scope: IScope,
private securityGroupReader: SecurityGroupReader,
resolvedSecurityGroup: ISecurityGroupFromStateParams,
private app: Application,
private $q: IQService,
) {
const dataSource = app.getDataSource('securityGroups');
dataSource
Expand Down Expand Up @@ -74,24 +83,25 @@ class KubernetesSecurityGroupDetailsController implements IController {
}

private extractSecurityGroup({ accountId, name, region }: ISecurityGroupFromStateParams): void {
this.securityGroupReader
.getSecurityGroupDetails(
this.app,
accountId,
'kubernetes',
region,
'', // unused vpc id
name,
)
.then((securityGroup: ISecurityGroupDetail) => {
this.$q
.all([
this.securityGroupReader.getSecurityGroupDetails(
this.app,
accountId,
'kubernetes',
region,
'', // unused vpc id
name,
),
ManifestReader.getManifest(accountId, region, name),
])
.then(([securityGroup, manifest]: [ISecurityGroupDetail, IManifest]) => {
if (!securityGroup) {
return this.autoClose();
}
ManifestReader.getManifest(accountId, region, name).then((manifest: IManifest) => {
this.securityGroup = securityGroup as IKubernetesSecurityGroup;
this.manifest = manifest;
this.state.loading = false;
});
this.securityGroup = securityGroup as IKubernetesSecurityGroup;
this.manifest = manifest;
this.state.loading = false;
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IController, IScope, module } from 'angular';
import { IController, IQService, IScope, module } from 'angular';
import { IModalService } from 'angular-ui-bootstrap';
import { StateService } from '@uirouter/angularjs';

Expand Down Expand Up @@ -31,13 +31,14 @@ class KubernetesServerGroupDetailsController implements IController {
public manifest: IManifest;
public entityTagTargets: IOwnerOption[];

public static $inject = ['serverGroup', 'app', '$uibModal', '$scope', '$state'];
public static $inject = ['serverGroup', 'app', '$uibModal', '$scope', '$state', '$q'];
constructor(
serverGroup: IServerGroupFromStateParams,
public app: Application,
private $uibModal: IModalService,
private $scope: IScope,
private $state: StateService,
private $q: IQService,
) {
const dataSource = this.app.getDataSource('serverGroups');
dataSource
Expand Down Expand Up @@ -177,20 +178,20 @@ class KubernetesServerGroupDetailsController implements IController {
}

private extractServerGroup({ accountId, name, region }: IServerGroupFromStateParams): void {
ServerGroupReader.getServerGroup(this.app.name, accountId, region, name).then(
(serverGroupDetails: IServerGroup) => {
this.$q
.all([
ServerGroupReader.getServerGroup(this.app.name, accountId, region, name),
ManifestReader.getManifest(accountId, region, name),
])
.then(([serverGroupDetails, manifest]: [IServerGroup, IManifest]) => {
if (!serverGroupDetails) {
return this.autoClose();
}

ManifestReader.getManifest(accountId, region, name).then((manifest: IManifest) => {
this.manifest = manifest;
this.serverGroup = serverGroupDetails as IKubernetesServerGroup;
this.entityTagTargets = this.configureEntityTagTargets();
this.state.loading = false;
});
},
);
this.serverGroup = serverGroupDetails as IKubernetesServerGroup;
this.entityTagTargets = this.configureEntityTagTargets();
this.manifest = manifest;
this.state.loading = false;
});
}

private configureEntityTagTargets(): IOwnerOption[] {
Expand Down

0 comments on commit 577d257

Please sign in to comment.