feat(portal-api): create Service's before provisioning (#673)

This commit is contained in:
Sérgio Ramos 2017-09-13 19:11:20 +01:00 committed by Wyatt Preul
parent 2ce08bbe30
commit 1fe36f0e1b
7 changed files with 416 additions and 287 deletions

View File

@ -119,26 +119,21 @@ export const DeploymentGroupList = ({
}) => {
const _title = <Title>Deployment groups</Title>;
if (loading) {
if (loading && (!deploymentGroups || !deploymentGroups.length)) {
return (
<LayoutContainer center>
{_title}
<Loader />
</LayoutContainer>
);
}
if (error) {
return (
<LayoutContainer>
{_title}
<ErrorMessage
title="Ooops!"
message="An error occurred while loading your deployment groups."
/>
</LayoutContainer>
);
}
const _error =
error && (!deploymentGroups || !deploymentGroups.length) ? (
<ErrorMessage
title="Ooops!"
message="An error occurred while loading your deployment groups."
/>
) : null;
const groups = forceArray(deploymentGroups).map(({ slug, name }) => (
<Col xs={12} sm={4} md={3} lg={3} key={slug}>
@ -178,6 +173,7 @@ export const DeploymentGroupList = ({
return (
<LayoutContainer>
{_title}
{_error}
<DGsRows>
{groups}
{create}

View File

@ -10,10 +10,12 @@ import { Router } from '@mocks/';
import { NotFound } from '../';
it('renders <NotFound /> without throwing', () => {
const tree = renderer.create(
<Router>
<NotFound />
</Router>
).toJSON();
const tree = renderer
.create(
<Router>
<NotFound />
</Router>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

View File

@ -4,10 +4,7 @@ import { Img } from 'normalized-styled-components';
import remcalc from 'remcalc';
import Logo from '@assets/triton_logo.png';
import {
Header,
HeaderBrand,
} from 'joyent-ui-toolkit';
import { Header, HeaderBrand } from 'joyent-ui-toolkit';
const StyledLogo = Img.extend`
width: ${remcalc(87)};

View File

@ -2,8 +2,6 @@ import React from 'react';
import { Header as HeaderComponent } from '@components/navigation';
export const Header = () => (
<HeaderComponent />
);
export const Header = () => <HeaderComponent />;
export default Header;

View File

@ -1,4 +1,3 @@
const state = {}
const state = {};
export default state;
export default state;

View File

@ -1331,6 +1331,58 @@ class Data extends EventEmitter {
}, handleNewServices);
};
const handleConfigServicesCreation = (err) => {
if (err) {
return handleFailedProvision(err);
}
this._server.log(['debug'], `-> requesting docker-compose provision for DeploymentGroup ${ctx.currentDeploymentGroup.name}`);
this._dockerCompose.provision({
projectName: ctx.currentDeploymentGroup.name,
environment: clientManifest.environment,
files: internals.fromKeyValueToDict(clientManifest.files),
manifest: ctx.newManifest.raw
}, handleProvisionResponse);
};
const createConfigServices = () => {
VAsync.forEachParallel({
inputs: ctx.config,
func: ({ name, slug }, next) => {
this.getServices({
name,
deploymentGroupId: ctx.currentDeploymentGroup.id
}, (err, services = []) => {
if (!err) {
return next();
}
if (err && !internals.isNotFound(err)) {
return next(err);
}
this.createService({
deploymentGroupId: ctx.currentDeploymentGroup.id,
status: 'PROVISIONING',
name,
slug
}, next);
});
}
}, (err, result) => {
if (err) {
return handleFailedProvision(err);
}
this.updateDeploymentGroup({
id: ctx.currentDeploymentGroup.id,
status: 'PROVISIONING',
services: result.successes
}, handleConfigServicesCreation);
});
};
// 7. handle new version
// 8. call docker-compose to up dg
const handleNewVersion = (err, newVersion) => {
@ -1346,16 +1398,7 @@ class Data extends EventEmitter {
// CALLBACK
cb(null, ctx.newVersion);
setImmediate(() => {
this._server.log(['debug'], `-> requesting docker-compose provision for DeploymentGroup ${ctx.currentDeploymentGroup.name}`);
this._dockerCompose.provision({
projectName: ctx.currentDeploymentGroup.name,
environment: clientManifest.environment,
files: internals.fromKeyValueToDict(clientManifest.files),
manifest: ctx.newManifest.raw
}, handleProvisionResponse);
});
setImmediate(createConfigServices);
};
// 6. handle curent scale based on machines in triton

592
yarn.lock

File diff suppressed because it is too large Load Diff