Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from ipunkt/replace-upgrade
Browse files Browse the repository at this point in the history
Replace upgrade
  • Loading branch information
Sven Speckmaier authored Nov 27, 2017
2 parents d4049bb + b679a4c commit 8304d26
Show file tree
Hide file tree
Showing 39 changed files with 1,159 additions and 176 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ RUN cd /opt/rancherize-package \
&& curl -sSL "https://gist.githubusercontent.com/justb81/1006b89e41e41e1c848fe91969af7a0b/raw/c12faf968e659356ec1cb53f313e7f8383836be3/getcomposer.sh" | sh \
&& COMPOSER_ALLOW_SUPERUSER=1 ./composer.phar install \
&& rm composer.phar \
&& ln -s vendor/bin/rancherize
&& ln -s /opt/rancherize/vendor/bin/rancherize /opt/rancherize/rancherize

ENTRYPOINT ["/bin/sh", "/opt/rancherize/docker-entrypoint.sh"]
4 changes: 3 additions & 1 deletion app/Blueprint/Webserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ This blueprint creates infrastructures to support apps using php7.
| Option | Defaults to | Explanation |
| ------- |:-----------:| ------------ |
|`docker.base-image`| REQUIRED | Docker-Image to base the created app-image on. |
|`rancher.in-service`| false | Activates in-service upgrades instead of rolling upgrades between services. |
|`rancher.in-service`| false | Activates in-service upgrades instead of rolling upgrades between services. !DEPRECATED! use `rancher.upgrade-mode` |
|`rancher.upgrade-mode`| `rolling-upgrade` | Change upgrade mode between rolling upgrade, in-service upgrade and `replace` which deletes the service and CREATEs it again. Possible values: `rolling-upgrade`, `in-service`, `replace` |
|`rancher.create-mode`| `start` | Possible values: `start`, `create` |
|`service-name`| REQUIRED | The name of the created main service, will have the version appended to it in rancher |
|`use-app-container`| true | If set to false no service will be created to mount the app using a docker image |
|`mount-workdir`| false | If set to true then the project root will be mounted into the main app nginx. !Does not work when deploying into rancher! |
Expand Down
22 changes: 16 additions & 6 deletions app/Blueprint/Webserver/WebserverBlueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use Rancherize\Configuration\Services\ConfigurationFallback;
use Rancherize\Configuration\Services\ConfigurationInitializer;
use Rancherize\Docker\DockerAccount;
use Rancherize\RancherAccess\InServiceCheckerTrait;
use Rancherize\RancherAccess\UpgradeMode\RollingUpgradeChecker;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -56,8 +56,6 @@ class WebserverBlueprint implements Blueprint, TakesDockerAccount {

use CustomFilesTrait;

use InServiceCheckerTrait;

use ProjectNameTrait;

use SlashPrefixerTrait;
Expand All @@ -81,6 +79,18 @@ class WebserverBlueprint implements Blueprint, TakesDockerAccount {
* @var MailtrapService
*/
protected $mailtrapService;
/**
* @var RollingUpgradeChecker
*/
private $rollingUpgradeChecker;

/**
* WebserverBlueprint constructor.
* @param RollingUpgradeChecker $rollingUpgradeChecker
*/
public function __construct( RollingUpgradeChecker $rollingUpgradeChecker) {
$this->rollingUpgradeChecker = $rollingUpgradeChecker;
}

/**
* @param Configurable $configurable
Expand Down Expand Up @@ -205,7 +215,7 @@ public function build(Configuration $configuration, string $environment, string
$this->addAppContainer($version, $config, $serverService, $infrastructure);

$this->addVersionEnvironment($version, $config, $serverService);
$this->addVersionLabel($version, $config, $serverService);
$this->addVersionLabel($version, $serverService);


/**
Expand Down Expand Up @@ -425,7 +435,7 @@ protected function addVersionEnvironment($version, Configuration $config, Servic
* @param Configuration $config
* @param Service $serverService
*/
protected function addVersionLabel($version, Configuration $config, Service $serverService) {
protected function addVersionLabel($version, Service $serverService) {
$labelVersion = $version;
if($version === null)
$labelVersion = '';
Expand Down Expand Up @@ -520,7 +530,7 @@ protected function addQueueWorker(Configuration $config, Service $serverService,
*/
private function addVersionSuffix(Configuration $config, Service $serverService, $versionSuffix) {

if( $this->inServiceChecker->isInService($config) )
if( !$this->rollingUpgradeChecker->isRollingUpgrade($config) )
return;

/**
Expand Down
8 changes: 4 additions & 4 deletions app/Blueprint/Webserver/WebserverProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Rancherize\Blueprint\Factory\BlueprintFactory;
use Rancherize\Plugin\Provider;
use Rancherize\Plugin\ProviderTrait;
use Rancherize\RancherAccess\InServiceChecker;
use Rancherize\RancherAccess\UpgradeMode\RollingUpgradeChecker;

/**
* Class WebserverProvider
Expand All @@ -27,7 +27,9 @@ public function boot() {
*/
$blueprintFactory = $this->container[BlueprintFactory::class];
$blueprintFactory->add('webserver', function(Container $c) {
$webserverBlueprint = new WebserverBlueprint();
$webserverBlueprint = new WebserverBlueprint(
$c[RollingUpgradeChecker::class]
);

$webserverBlueprint->setArrayAdder( $c['config-array-adder'] );

Expand All @@ -37,8 +39,6 @@ public function boot() {

$webserverBlueprint->setSlashPrefixer( $c['slash-prefixer'] );

$webserverBlueprint->setInServiceChecker($c[InServiceChecker::class]);

return $webserverBlueprint;
});

Expand Down
16 changes: 9 additions & 7 deletions app/Commands/CommandsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
use Rancherize\Plugin\Loader\PluginLoader;
use Rancherize\Plugin\Provider;
use Rancherize\Plugin\ProviderTrait;
use Rancherize\RancherAccess\InServiceChecker;
use Rancherize\Push\CreateModeFactory\CreateModeFactory;
use Rancherize\Push\ModeFactory\PushModeFactory;
use Rancherize\RancherAccess\RancherAccessService;
use Rancherize\RancherAccess\RancherService;
use Rancherize\RancherAccess\UpgradeMode\InServiceChecker;
use Rancherize\RancherAccess\UpgradeMode\ReplaceUpgradeChecker;
use Rancherize\Services\BlueprintService;
use Rancherize\Services\BuildService;
use Rancherize\Services\DockerService;
Expand All @@ -31,19 +34,18 @@ class CommandsProvider implements Provider {
*/
public function register() {
$this->container['environment-version-command'] = function($c) {
$environmentVersionCommand = new EnvironmentVersionCommand( $c[BlueprintService::class], $c[RancherAccessService::class], $c[EnvironmentConfigurationService::class], $c[RancherService::class] );

$environmentVersionCommand->setInServiceChecker( $c[InServiceChecker::class] );
$environmentVersionCommand = new EnvironmentVersionCommand( $c[BlueprintService::class],
$c[RancherAccessService::class], $c[EnvironmentConfigurationService::class],
$c[RancherService::class], $c[InServiceChecker::class] );

return $environmentVersionCommand;
};

$this->container['command.push'] = function($c) {
$pushCommand = new PushCommand( $c[RancherAccessService::class], $c[DockerService::class],
$c[BuildService::class], $c[BlueprintService::class], $c[EnvironmentConfigurationService::class],
$c[DockerAccessService::class], $c[RancherService::class] );

$pushCommand->setInServiceChecker( $c[InServiceChecker::class] );
$c[DockerAccessService::class], $c[RancherService::class],
$c[ReplaceUpgradeChecker::class], $c[PushModeFactory::class], $c[CreateModeFactory::class] );

return $pushCommand;
};
Expand Down
11 changes: 8 additions & 3 deletions app/Commands/EnvironmentVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
use Rancherize\Configuration\LoadsConfiguration;
use Rancherize\Configuration\Services\EnvironmentConfigurationService;
use Rancherize\Configuration\Traits\LoadsConfigurationTrait;
use Rancherize\RancherAccess\InServiceCheckerTrait;
use Rancherize\RancherAccess\NameMatcher\CompleteNameMatcher;
use Rancherize\RancherAccess\NameMatcher\PrefixNameMatcher;
use Rancherize\RancherAccess\RancherAccessParsesConfiguration;
use Rancherize\RancherAccess\RancherAccessService;
use Rancherize\RancherAccess\RancherService;
use Rancherize\RancherAccess\UpgradeMode\InServiceChecker;
use Rancherize\Services\BlueprintService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -28,7 +28,6 @@ class EnvironmentVersionCommand extends Command implements LoadsConfiguration {
use LoadsConfigurationTrait;
use ValidateTrait;

use InServiceCheckerTrait;
/**
* @var BlueprintService
*/
Expand All @@ -45,21 +44,27 @@ class EnvironmentVersionCommand extends Command implements LoadsConfiguration {
* @var RancherService
*/
private $rancherService;
/**
* @var InServiceChecker
*/
private $inServiceChecker;

/**
* EnvironmentVersionCommand constructor.
* @param BlueprintService $blueprintService
* @param RancherAccessService $rancherAccessService
* @param EnvironmentConfigurationService $environmentConfigurationService
* @param RancherService $rancherService
* @param InServiceChecker $inServiceChecker
*/
public function __construct( BlueprintService $blueprintService, RancherAccessService $rancherAccessService,
EnvironmentConfigurationService $environmentConfigurationService, RancherService $rancherService) {
EnvironmentConfigurationService $environmentConfigurationService, RancherService $rancherService, InServiceChecker $inServiceChecker) {
parent::__construct();
$this->blueprintService = $blueprintService;
$this->rancherAccessService = $rancherAccessService;
$this->environmentConfigurationService = $environmentConfigurationService;
$this->rancherService = $rancherService;
$this->inServiceChecker = $inServiceChecker;
}

protected function configure() {
Expand Down
52 changes: 52 additions & 0 deletions app/Commands/Events/PushCommandCreateEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php namespace Rancherize\Commands\Events;

use Rancherize\Configuration\Configuration;
use Symfony\Component\EventDispatcher\Event;

/**
* Class PushCommandInServiceUpgradeEvent
* @package Rancherize\Commands\Events
*/
class PushCommandCreateEvent extends Event {

const NAME = 'push.create';

/**
* @var string[]
*/
protected $serviceNames;

/**
* @var Configuration
*/
protected $configuration;

/**
* @return \string[]
*/
public function getServiceNames(): array {
return $this->serviceNames;
}

/**
* @param \string[] $serviceNames
*/
public function setServiceNames( array $serviceNames ) {
$this->serviceNames = $serviceNames;
}

/**
* @return Configuration
*/
public function getConfiguration(): Configuration {
return $this->configuration;
}

/**
* @param Configuration $configuration
*/
public function setConfiguration( Configuration $configuration ) {
$this->configuration = $configuration;
}

}
Loading

0 comments on commit 8304d26

Please sign in to comment.