Commit b91ed68a authored by finn's avatar finn
Browse files

Adding ref storage

parent b629e593
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ extension-pkg-whitelist=

# Add files or directories to the blacklist. They should be base names, not
# paths.
#ignore=tests,docs
#ignore=tests,doc

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
+10 −15
Original line number Diff line number Diff line
@@ -28,11 +28,11 @@ import logging
import click

from buildgrid.server import build_grid_server
from buildgrid.server.action_cache import ActionCache
from buildgrid.server.cas.storage.disk import DiskStorage
from buildgrid.server.cas.storage.lru_memory_cache import LRUMemoryCache
from buildgrid.server.cas.storage.s3 import S3Storage
from buildgrid.server.cas.storage.with_cache import WithCacheStorage
from buildgrid.server.execution.action_cache import ActionCache

from ..cli import pass_context

@@ -72,36 +72,31 @@ def cli(context):
def start(context, port, max_cached_actions, allow_uar, cas, **cas_args):
    context.logger.info("Starting on port {}".format(port))

    loop = asyncio.get_event_loop()

    cas_storage = _make_cas_storage(context, cas, cas_args)

    if cas_storage is None:
        context.logger.info("Running without CAS - action cache will be unavailable")
        action_cache = None

    else:
        action_cache = ActionCache(cas_storage, max_cached_actions)
        action_cache = ActionCache(cas_storage, max_cached_actions, allow_uar)

    server = build_grid_server.BuildGridServer(port,
                                               cas_storage=cas_storage,
                                               action_cache=action_cache,
                                               allow_update_action_result=allow_uar)

                                               action_cache=action_cache)
    loop = asyncio.get_event_loop()
    try:
        asyncio.ensure_future(server.start())
        server.start()
        loop.run_forever()

    except KeyboardInterrupt:
        pass

    finally:
        loop.run_until_complete(server.stop())
        server.stop()
        loop.close()


@cli.command('stop', short_help="Stops server")
@pass_context
def stop(context):
    context.logger.error("Not implemented yet")


def _make_cas_storage(context, cas_type, cas_args):
    """Returns the storage provider corresponding to the given `cas_type`,
    or None if the provider cannot be created.
+0 −0

Empty file added.

+0 −0

Empty file added.

+95 −0
Original line number Diff line number Diff line
// Copyright 2018 Codethink Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package buildstream.v2;

import "build/bazel/remote/execution/v2/remote_execution.proto";
import "google/api/annotations.proto";

service ReferenceStorage {
  // Retrieve a CAS [Directory][build.bazel.remote.execution.v2.Directory]
  // digest by name.
  //
  // Errors:
  // * `NOT_FOUND`: The requested reference is not in the cache.
  rpc GetReference(GetReferenceRequest) returns (GetReferenceResponse) {
    option (google.api.http) = { get: "/v2/{instance_name=**}/buildstream/refs/{key}" };
  }

  // Associate a name with a CAS [Directory][build.bazel.remote.execution.v2.Directory]
  // digest.
  //
  // Errors:
  // * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the
  //   entry to the cache.
  rpc UpdateReference(UpdateReferenceRequest) returns (UpdateReferenceResponse) {
    option (google.api.http) = { put: "/v2/{instance_name=**}/buildstream/refs/{key}" body: "digest" };
  }

  rpc Status(StatusRequest) returns (StatusResponse) {
    option (google.api.http) = { put: "/v2/{instance_name=**}/buildstream/refs:status" };
  }
}

message GetReferenceRequest {
  // The instance of the execution system to operate against. A server may
  // support multiple instances of the execution system (with their own workers,
  // storage, caches, etc.). The server MAY require use of this field to select
  // between them in an implementation-defined fashion, otherwise it can be
  // omitted.
  string instance_name = 1;

  // The name of the reference.
  string key = 2;
}

message GetReferenceResponse {
  // The digest of the CAS [Directory][build.bazel.remote.execution.v2.Directory].
  build.bazel.remote.execution.v2.Digest digest = 1;
}

message UpdateReferenceRequest {
  // The instance of the execution system to operate against. A server may
  // support multiple instances of the execution system (with their own workers,
  // storage, caches, etc.). The server MAY require use of this field to select
  // between them in an implementation-defined fashion, otherwise it can be
  // omitted.
  string instance_name = 1;

  // The name of the reference.
  repeated string keys = 2;

  // The digest of the CAS [Directory][build.bazel.remote.execution.v2.Directory]
  // to store in the cache.
  build.bazel.remote.execution.v2.Digest digest = 3;
}

message UpdateReferenceResponse {
}

message StatusRequest {
  // The instance of the execution system to operate against. A server may
  // support multiple instances of the execution system (with their own workers,
  // storage, caches, etc.). The server MAY require use of this field to select
  // between them in an implementation-defined fashion, otherwise it can be
  // omitted.
  string instance_name = 1;
}

message StatusResponse {
  // Whether reference updates are allowed for the connected client.
  bool allow_updates = 1;
}
Loading