def DoPrepareManagedVms(gae_client):
    """Call an API to prepare the for managed VMs."""
    try:
        message = 'If this is your first deployment, this may take a while'
        with console_io.DelayedProgressTracker(message,
                                               _PREPARE_VM_MESSAGE_DELAY):
            # Note: this doesn't actually boot the VM, it just prepares some stuff
            # for the project via an undocumented Admin API.
            gae_client.PrepareVmRuntime()
        log.status.Print()
    except util.RPCError:
        log.warn('If this is your first deployment, please try again.')
        raise
Exemple #2
0
def DoPrepareManagedVms(gae_client):
  """Call an API to prepare the for App Engine Flexible."""
  try:
    message = 'If this is your first deployment, this may take a while'
    with console_io.DelayedProgressTracker(message,
                                           _PREPARE_VM_MESSAGE_DELAY):
      # Note: this doesn't actually boot the VM, it just prepares some stuff
      # for the project via an undocumented Admin API.
      gae_client.PrepareVmRuntime()
    log.status.Print()
  except util.RPCError:
    # Any failures due to an unprepared project will be noisy
    log.warn(
        "We couldn't validate that your project is ready to deploy to App "
        'Engine Flexible Environment. If deployment fails, please try again.')
Exemple #3
0
def BuildAndPushDockerImages(module_configs, version_id, client, cli, remote,
                             implicit_remote_build):
    # PrepareVmRuntime only needs to be called once per deployment.
    project = properties.VALUES.core.project.Get(required=True)

    if any(info.RequiresImage() for info in module_configs.values()):
        log.status.Print('Verifying that Managed VMs are enabled and ready.')
        message = 'If this is your first deployment, this may take a while'
        try:
            with console_io.DelayedProgressTracker(message,
                                                   _PREPARE_VM_MESSAGE_DELAY):
                client.PrepareVmRuntime()
            log.status.Print()
        except util.RPCError as err:
            log.warn('If this is your first deployment, please try again.')
            raise err

        for registry in constants.ALL_SUPPORTED_REGISTRIES:
            docker.UpdateDockerCredentials(registry)

        if remote and implicit_remote_build:
            # Test for presence of local Docker
            try:
                with docker_util.DockerHost(cli, version_id,
                                            False) as docker_client:
                    if os.environ.get('DOCKER_HOST'):
                        docker_client.ping()
                        log.warn(
                            'A hosted build is being performed, but a local Docker '
                            'was found. Specify `--docker-build=local` to use it, or '
                            '`--docker-build=remote` to silence this warning.')
            except containers.DockerDaemonConnectionError:
                pass

        with docker_util.DockerHost(cli, version_id, remote) as docker_client:
            # Build and push all images.
            for (module, info) in module_configs.iteritems():
                if info.RequiresImage():
                    log.status.Print(
                        'Building and pushing image for module [{module}]'.
                        format(module=module))
                    info.UpdateManagedVMConfig()
                    push.BuildAndPushDockerImage(info.file, project, module,
                                                 version_id, info.runtime,
                                                 docker_client)
        metric_name = _REMOTE_BUILD if remote else _BUILD
        metrics.CustomTimedEvent(metric_name)