Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Jun 16, 2022
2 parents fb74474 + 67a224c commit f6efe09
Show file tree
Hide file tree
Showing 19 changed files with 385 additions and 209 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.10.3
v2.10.4
13 changes: 6 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ gazelle_dependencies()

http_archive(
name = "aspect_rules_js",
#sha256 = "ac67010f1c150a70d7ebf0026754b8a754f3be6d899b699f97be3c046a951c6a",
# ALMOST 1.0.0
strip_prefix = "rules_js-6a2a3477fcbcd819cd7f44d5bfd47f2fed30add4",
url = "https://github.com/aspect-build/rules_js/archive/6a2a3477fcbcd819cd7f44d5bfd47f2fed30add4.tar.gz",
sha256 = "e7a21d8eec5565da01417bc809213405271a818e870890c2d3bb3dde5e808bcc",
strip_prefix = "rules_js-1.0.0-beta.0",
url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.0.0-beta.0.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
Expand Down Expand Up @@ -310,9 +309,9 @@ swc_register_toolchains(

http_archive(
name = "aspect_rules_ts",
#sha256 = "b79eca71668f1d5e318c25a25a5f9a150d351cbfab1ea9e225b0ee7a9f16763d",
strip_prefix = "rules_ts-d4a70a7389a51dbd2c1a2a06c99c38e6acd4e7e0",
url = "https://github.com/aspect-build/rules_ts/archive/d4a70a7389a51dbd2c1a2a06c99c38e6acd4e7e0.tar.gz",
sha256 = "991a5ccad5fd276164ea64c01ae0b67820a5d514fbf37ae3f7ac8701a84b9f5a",
strip_prefix = "rules_ts-0.7.0",
url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v0.7.0.tar.gz",
)

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,11 @@ func (r *Registration) Check(ctx context.Context) error {
return errors.New("not registered to scheduler yet")
}

func (r *Registration) processWorkStream(ctx context.Context, stream scpb.Scheduler_RegisterAndStreamWorkClient, schedulerMsgs chan *scpb.RegisterAndStreamWorkResponse) (bool, error) {
func (r *Registration) processWorkStream(ctx context.Context, stream scpb.Scheduler_RegisterAndStreamWorkClient, schedulerMsgs chan *scpb.RegisterAndStreamWorkResponse, registrationTicker *time.Ticker) (bool, error) {
registrationMsg := &scpb.RegisterAndStreamWorkRequest{
RegisterExecutorRequest: &scpb.RegisterExecutorRequest{Node: r.node},
}

idleTimer := time.NewTimer(schedulerCheckInInterval)
defer idleTimer.Stop()

select {
case <-ctx.Done():
log.Debugf("Context cancelled, cancelling node registration.")
Expand Down Expand Up @@ -157,9 +154,9 @@ func (r *Registration) processWorkStream(ctx context.Context, stream scpb.Schedu
if err := stream.Send(rspMsg); err != nil {
return false, status.UnavailableErrorf("could not send task reservation response: %s", err)
}
case <-idleTimer.C:
case <-registrationTicker.C:
if err := stream.Send(registrationMsg); err != nil {
return false, status.UnavailableErrorf("could not send idle registration message: %s", err)
return false, status.UnavailableErrorf("could not send registration message: %s", err)
}
}
return false, nil
Expand Down Expand Up @@ -207,8 +204,9 @@ func (r *Registration) maintainRegistrationAndStreamWork(ctx context.Context) {
}
}()

registrationTicker := time.NewTicker(schedulerCheckInInterval)
for {
done, err := r.processWorkStream(ctx, stream, schedulerMsgs)
done, err := r.processWorkStream(ctx, stream, schedulerMsgs, registrationTicker)
if err != nil {
_ = stream.CloseSend()
log.Warningf("Error maintaining registration with scheduler, will retry: %s", err)
Expand Down
1 change: 1 addition & 0 deletions enterprise/server/scheduling/scheduler_server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go_library(
"@org_golang_google_grpc//peer",
"@org_golang_google_protobuf//encoding/prototext",
"@org_golang_google_protobuf//proto",
"@org_golang_google_protobuf//types/known/timestamppb",
],
)

Expand Down
16 changes: 16 additions & 0 deletions enterprise/server/scheduling/scheduler_server/scheduler_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"google.golang.org/grpc/peer"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"

remote_execution_config "github.com/buildbuddy-io/buildbuddy/enterprise/server/remote_execution/config"
scheduler_server_config "github.com/buildbuddy-io/buildbuddy/enterprise/server/scheduling/scheduler_server/config"
Expand All @@ -41,6 +42,7 @@ var (
defaultPoolName = flag.String("remote_execution.default_pool_name", "", "The default executor pool to use if one is not specified.")
sharedExecutorPoolGroupID = flag.String("remote_execution.shared_executor_pool_group_id", "", "Group ID that owns the shared executor pool.")
requireExecutorAuthorization = flag.Bool("remote_execution.require_executor_authorization", false, "If true, executors connecting to this server must provide a valid executor API key.")
removeStaleExecutors = flag.Bool("remote_execution.remove_stale_executors", false, "If true, executors are removed if they are not heard from for a prolonged amount of time.")
)

const (
Expand All @@ -60,6 +62,10 @@ const (
// was fetched more than this duration ago, they will be re-fetched.
maxAllowedExecutionNodesStaleness = 10 * time.Second

// An executor is removed if it does not refresh its registration within
// this amount of time.
executorMaxRegistrationStaleness = 10 * time.Minute

// The maximum number of times a task may be re-enqueued.
maxTaskAttemptCount = 5

Expand Down Expand Up @@ -440,6 +446,15 @@ func (np *nodePool) fetchExecutionNodes(ctx context.Context) ([]*executionNode,
if err != nil {
return nil, err
}

if *removeStaleExecutors && time.Since(node.GetLastPingTime().AsTime()) > executorMaxRegistrationStaleness {
log.Infof("Removing stale executor %q from pool %+v", id, np.key)
if err := np.rdb.HDel(ctx, np.key.redisPoolKey(), id).Err(); err != nil {
log.Warningf("could not remove stale executor: %s", err)
}
continue
}

executors = append(executors, &executionNode{
executorID: id,
schedulerHostPort: node.GetSchedulerHostPort(),
Expand Down Expand Up @@ -900,6 +915,7 @@ func (s *SchedulerServer) insertOrUpdateNode(ctx context.Context, executorHandle
SchedulerHostPort: s.ownHostPort,
GroupId: groupID,
Acl: acl,
LastPingTime: timestamppb.Now(),
}
b, err := proto.Marshal(r)
if err != nil {
Expand Down
10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,19 @@
"@types/react-modal": "^3.10.6",
"@types/react-virtualized": "^9.21.9",
"@types/uuid": "^8.3.0",
"chalk": "^4.0.0",
"clang-format": "^1.4.0",
"concurrently": "^5.3.0",
"dagre-d3-react": "^0.2.4",
"date-fns": "^2.23.0",
"diff": "^5.0.0",
"diff-match-patch": "^1.0.5",
"escodegen": "^2.0.0",
"espree": "^7.0.0",
"estraverse": "^5.1.0",
"events": "^3.2.0",
"glob": "^7.1.4",
"google-protobuf": "^3.14.0",
"grpc-web": "^1.2.1",
"jasmine": "^4.1.0",
"jsdoc": "^3.6.2",
"lint-staged": "^10.2.13",
"long": "^4.0.0",
"lucide-react": "^0.16.29",
"minimist": "^1.2.6",
"moment": "^2.29.2",
"monaco-editor": "^0.25.2",
"octokit": "^1.1.0",
Expand All @@ -62,11 +55,8 @@
"recharts": "^2.1.9",
"rollup-plugin-replace": "^2.2.0",
"rxjs": "^6.6.3",

"tmp": "^0.2.0",
"tslib": "^2.1.0",
"typescript": "4.7.3",
"uglify-js": "^3.6.0",
"uuid": "^8.3.0"
},
"resolutions": {
Expand Down
31 changes: 0 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ proto_library(
":acl_proto",
":context_proto",
":trace_proto",
"@com_google_protobuf//:timestamp_proto",
],
)

Expand Down
45 changes: 8 additions & 37 deletions proto/defs.bzl
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

# TODO switch to protobufjs-cli when its published
# https://github.com/protobufjs/protobuf.js/commit/da34f43ccd51ad97017e139f137521782f5ef119
load("@npm//protobufjs:package_json.bzl", "bin")
load("@rules_proto//proto:defs.bzl", "ProtoInfo")

# protobuf.js relies on these packages, but does not list them as dependencies
# in its package.json.
# Instead they are listed under "cliDependencies"
# (see https://unpkg.com/protobufjs@6.10.2/package.json)
# When run, the CLI attempts to run `npm install` at runtime to get them.
# This fails under Bazel as it tries to access the npm cache outside of the sandbox.
# Per Bazel semantics, all dependencies should be pre-declared.
# Note, you'll also need to install all of these in your package.json!
# (This should be fixed when we switch to protobufjs-cli)
# NOTE: this is unused since pnpm.packageExtensions in package.json fixes this right within build graph.
_PROTOBUFJS_CLI_DEPS = ["//:node_modules/%s" % s for s in [
"chalk",
"escodegen",
"espree",
"estraverse",
"glob",
"jsdoc",
"minimist",
"semver",
"tmp",
"uglify-js",
]]

def _proto_sources_impl(ctx):
return DefaultInfo(files = ctx.attr.proto[ProtoInfo].transitive_sources)
Expand All @@ -40,7 +15,7 @@ _proto_sources = rule(
attrs = {"proto": attr.label(providers = [ProtoInfo])},
)

def ts_proto_library(name, proto, **kwargs):
def ts_proto_library(name, proto, deps = [], **kwargs):
"""Minimal wrapper macro around pbjs/pbts tooling
Args:
Expand Down Expand Up @@ -69,7 +44,9 @@ def ts_proto_library(name, proto, **kwargs):
name = js_target,
srcs = [":" + proto_target],
copy_srcs_to_bin = False,
chdir = "../../../",
env = {
"BAZEL_BINDIR": "."
},
# Arguments documented at
# https://github.com/protobufjs/protobuf.js/tree/6.8.8#pbjs-for-javascript
args = [
Expand All @@ -88,7 +65,9 @@ def ts_proto_library(name, proto, **kwargs):
name = ts_target,
srcs = [js_target],
copy_srcs_to_bin = False,
chdir = "../../../",
env = {
"BAZEL_BINDIR": "."
},
# Arguments documented at
# https://github.com/protobufjs/protobuf.js/tree/6.8.8#pbts-for-typescript
args = [
Expand All @@ -98,21 +77,13 @@ def ts_proto_library(name, proto, **kwargs):
outs = [ts_out],
)

# umd_bundle(
# name = name + "__umd",
# package_name = name,
# entry_point = ":" + js_out,
# )

# Expose the results as js_library which provides DeclarationInfo for interop with other rules
if "deps" not in kwargs:
kwargs["deps"] = []
kwargs["deps"].append("//:node_modules/protobufjs")
js_library(
name = name,
srcs = [
js_target,
ts_target,
],
deps = deps + ["//:node_modules/protobufjs"],
**kwargs
)
2 changes: 2 additions & 0 deletions proto/scheduler.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax = "proto3";

import "google/protobuf/timestamp.proto";
import "proto/acl.proto";
import "proto/context.proto";
import "proto/trace.proto";
Expand Down Expand Up @@ -238,4 +239,5 @@ message RegisteredExecutionNode {
string scheduler_host_port = 2;
string group_id = 3;
acl.ACL acl = 4;
google.protobuf.Timestamp last_ping_time = 5;
}
Loading

0 comments on commit f6efe09

Please sign in to comment.