mirror of
https://github.com/docker/compose.git
synced 2026-08-03 22:27:30 +00:00
Prevent docker-compose scale to be used with a v2.2 config file
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
afb2b6c51c
commit
2ba4e5e8ec
6 changed files with 61 additions and 24 deletions
|
|
@ -26,6 +26,7 @@ from ..config import resolve_build_args
|
|||
from ..config.environment import Environment
|
||||
from ..config.serialize import serialize_config
|
||||
from ..config.types import VolumeSpec
|
||||
from ..const import COMPOSEFILE_V2_2 as V2_2
|
||||
from ..const import IS_WINDOWS_PLATFORM
|
||||
from ..errors import StreamParseError
|
||||
from ..progress_stream import StreamOutputError
|
||||
|
|
@ -771,6 +772,12 @@ class TopLevelCommand(object):
|
|||
"""
|
||||
timeout = timeout_from_opts(options)
|
||||
|
||||
if self.project.config_version == V2_2:
|
||||
raise UserError(
|
||||
'The scale command is incompatible with the v2.2 format. '
|
||||
'Use the up command with the --scale flag instead.'
|
||||
)
|
||||
|
||||
for service_name, num in parse_scale_args(options['SERVICE=NUM']).items():
|
||||
self.project.get_service(service_name).scale(num, timeout=timeout)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,12 +57,13 @@ class Project(object):
|
|||
"""
|
||||
A collection of services.
|
||||
"""
|
||||
def __init__(self, name, services, client, networks=None, volumes=None):
|
||||
def __init__(self, name, services, client, networks=None, volumes=None, config_version=None):
|
||||
self.name = name
|
||||
self.services = services
|
||||
self.client = client
|
||||
self.volumes = volumes or ProjectVolumes({})
|
||||
self.networks = networks or ProjectNetworks({}, False)
|
||||
self.config_version = config_version
|
||||
|
||||
def labels(self, one_off=OneOffFilter.exclude):
|
||||
labels = ['{0}={1}'.format(LABEL_PROJECT, self.name)]
|
||||
|
|
@ -82,7 +83,7 @@ class Project(object):
|
|||
networks,
|
||||
use_networking)
|
||||
volumes = ProjectVolumes.from_config(name, config_data, client)
|
||||
project = cls(name, [], client, project_networks, volumes)
|
||||
project = cls(name, [], client, project_networks, volumes, config_data.version)
|
||||
|
||||
for service_dict in config_data.services:
|
||||
service_dict = dict(service_dict)
|
||||
|
|
|
|||
|
|
@ -383,8 +383,8 @@ class Service(object):
|
|||
lambda n: self.get_container_name(n),
|
||||
"Creating"
|
||||
)
|
||||
if errors:
|
||||
raise OperationFailedError(errors.values()[0])
|
||||
for error in errors.values():
|
||||
raise OperationFailedError(error)
|
||||
|
||||
return containers
|
||||
|
||||
|
|
@ -404,8 +404,9 @@ class Service(object):
|
|||
lambda c: c.name,
|
||||
"Recreating"
|
||||
)
|
||||
if errors:
|
||||
raise OperationFailedError(errors.values()[0])
|
||||
for error in errors.values():
|
||||
raise OperationFailedError(error)
|
||||
|
||||
if len(containers) < scale:
|
||||
containers.extend(self._execute_convergence_create(
|
||||
scale - len(containers), detached, start
|
||||
|
|
@ -424,8 +425,8 @@ class Service(object):
|
|||
"Starting"
|
||||
)
|
||||
|
||||
if errors:
|
||||
raise OperationFailedError(errors.values()[0])
|
||||
for error in errors.values():
|
||||
raise OperationFailedError(error)
|
||||
|
||||
if len(containers) < scale:
|
||||
containers.extend(self._execute_convergence_create(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue