From 96fecb43269e604639df1113bdb67b81ed6bd3cd Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Fri, 4 Dec 2026 10:32:58 +0100 Subject: [PATCH 1/5] cli/command/job: add `docker job ls` and `logs` commands Add the `docker job` command group. It reaches the daemon's jobs extension point through github.com/moby/extensions/client, dialed lazily on first use because the command tree is built before the CLI is initialized. - `ls` lists jobs: trigger, state, paused flag, latest run, exit code and next fire. - `logs [-f] JOB` reads the logs of a job's most recent run from the container logs API with the run's container ID (the Jobs API does not proxy logs). When the latest run has no readable container (removed, still pending, or failed before its container was created) it falls back to the most recent run that has one and says so on stderr. With -f on a schedule job it keeps following across runs; on a manual job it returns once the logs end. Jobs API status codes become actionable errors instead of raw gRPC dumps: Unimplemented points at `--extension-enable org.mobyproject.jobs.v0`, Unavailable is reported as retryable, the other codes show the daemon's message, and a cancelled context (Ctrl-C) stays recognisable so the CLI exits quietly. The jobs contract comes from github.com/moby/moby/extpoints, the standalone module of moby's extension points, so it is vendored along with github.com/moby/extensions, which its generated code builds on. This bumps google.golang.org/grpc to v1.85.0, as required by extpoints, and makes it a direct dependency together with github.com/moby/extensions. Signed-off-by: Guillaume Lours --- cli/command/commands/commands.go | 1 + cli/command/job/client.go | 84 + cli/command/job/client_test.go | 103 + cli/command/job/cmd.go | 106 + cli/command/job/cmd_test.go | 19 + cli/command/job/list.go | 128 + cli/command/job/list_test.go | 383 +++ cli/command/job/logs.go | 211 ++ cli/command/job/logs_followswitch_test.go | 471 ++++ cli/command/job/logs_resolve_test.go | 134 ++ cli/command/job/logs_test.go | 316 +++ vendor.mod | 10 +- vendor.sum | 20 +- .../grpc-gateway/v2/runtime/BUILD.bazel | 2 + .../grpc-gateway/v2/runtime/context.go | 19 +- .../grpc-gateway/v2/runtime/convert.go | 8 +- .../grpc-gateway/v2/runtime/marshal_jsonpb.go | 7 + .../grpc-gateway/v2/runtime/mux.go | 10 +- .../grpc-gateway/v2/runtime/pattern.go | 10 + .../grpc-gateway/v2/runtime/query.go | 11 +- .../github.com/moby/extensions/.golangci.yml | 25 + vendor/github.com/moby/extensions/LICENSE | 202 ++ vendor/github.com/moby/extensions/Makefile | 68 + vendor/github.com/moby/extensions/README.md | 163 ++ .../moby/extensions/client/client.go | 229 ++ .../extensions/clientpoint/clientpoint.go | 23 + vendor/github.com/moby/extensions/core.go | 336 +++ vendor/github.com/moby/extensions/fanout.go | 99 + .../extensions/serverpoint/serverpoint.go | 21 + vendor/github.com/moby/moby/extpoints/LICENSE | 202 ++ .../moby/moby/extpoints/jobs/api/v0/README.md | 86 + .../moby/moby/extpoints/jobs/api/v0/jobs.go | 551 +++++ .../moby/extpoints/jobs/api/v0/jobs.proto | 249 ++ .../extpoints/jobs/api/v0/protogen/jobs.pb.go | 2129 +++++++++++++++++ .../jobs/api/v0/protogen/wire.gen.go | 1344 +++++++++++ .../metrics/v1/metrics_service.pb.go | 176 +- .../metrics/v1/metrics_service.pb.gw.go | 78 +- .../metrics/v1/metrics_service_grpc.pb.go | 58 +- .../collector/trace/v1/trace_service.pb.go | 172 +- .../collector/trace/v1/trace_service.pb.gw.go | 78 +- .../trace/v1/trace_service_grpc.pb.go | 58 +- .../proto/otlp/common/v1/common.pb.go | 382 ++- .../proto/otlp/metrics/v1/metrics.pb.go | 1217 ++++------ .../proto/otlp/resource/v1/resource.pb.go | 93 +- .../proto/otlp/trace/v1/trace.pb.go | 488 ++-- vendor/google.golang.org/grpc/CONTRIBUTING.md | 23 + .../endpointsharding/endpointsharding.go | 339 ++- .../grpc/balancer/pickfirst/pickfirst.go | 50 +- .../grpc_binarylog_v1/binarylog.pb.go | 8 +- vendor/google.golang.org/grpc/clientconn.go | 6 + .../grpc/health/grpc_health_v1/health.pb.go | 2 +- .../grpc/internal/binarylog/method_logger.go | 2 +- .../grpc/internal/buffer/unbounded.go | 32 +- .../grpc/internal/envconfig/envconfig.go | 13 +- .../grpc/internal/envconfig/xds.go | 5 + .../internal/grpcsync/callback_serializer.go | 6 +- .../grpc/internal/grpcsync/refcounted.go | 109 + .../grpc/internal/internal.go | 4 + .../grpc/internal/resolver/config_selector.go | 15 +- .../grpc/internal/transport/bdp_estimator.go | 5 +- .../grpc/internal/transport/controlbuf.go | 175 +- .../grpc/internal/transport/handler_server.go | 5 +- .../grpc/internal/transport/http2_client.go | 88 +- .../grpc/internal/transport/http2_server.go | 44 +- .../grpc/internal/transport/http_util.go | 53 +- .../grpc/internal/transport/transport.go | 22 +- .../grpc/metadata/metadata.go | 131 + .../grpc/resolver_wrapper.go | 2 +- vendor/google.golang.org/grpc/rpc_util.go | 4 +- vendor/google.golang.org/grpc/server.go | 494 +--- vendor/google.golang.org/grpc/stats/stats.go | 3 + vendor/google.golang.org/grpc/stream.go | 277 ++- vendor/google.golang.org/grpc/version.go | 2 +- .../protobuf/types/known/emptypb/empty.pb.go | 142 ++ vendor/modules.txt | 25 +- 75 files changed, 9971 insertions(+), 2695 deletions(-) create mode 100644 cli/command/job/client.go create mode 100644 cli/command/job/client_test.go create mode 100644 cli/command/job/cmd.go create mode 100644 cli/command/job/cmd_test.go create mode 100644 cli/command/job/list.go create mode 100644 cli/command/job/list_test.go create mode 100644 cli/command/job/logs.go create mode 100644 cli/command/job/logs_followswitch_test.go create mode 100644 cli/command/job/logs_resolve_test.go create mode 100644 cli/command/job/logs_test.go create mode 100644 vendor/github.com/moby/extensions/.golangci.yml create mode 100644 vendor/github.com/moby/extensions/LICENSE create mode 100644 vendor/github.com/moby/extensions/Makefile create mode 100644 vendor/github.com/moby/extensions/README.md create mode 100644 vendor/github.com/moby/extensions/client/client.go create mode 100644 vendor/github.com/moby/extensions/clientpoint/clientpoint.go create mode 100644 vendor/github.com/moby/extensions/core.go create mode 100644 vendor/github.com/moby/extensions/fanout.go create mode 100644 vendor/github.com/moby/extensions/serverpoint/serverpoint.go create mode 100644 vendor/github.com/moby/moby/extpoints/LICENSE create mode 100644 vendor/github.com/moby/moby/extpoints/jobs/api/v0/README.md create mode 100644 vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.go create mode 100644 vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.proto create mode 100644 vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/jobs.pb.go create mode 100644 vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/wire.gen.go create mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/refcounted.go create mode 100644 vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go diff --git a/cli/command/commands/commands.go b/cli/command/commands/commands.go index 2b375938c9ec..7866aa49f838 100644 --- a/cli/command/commands/commands.go +++ b/cli/command/commands/commands.go @@ -8,6 +8,7 @@ import ( _ "github.com/docker/cli/cli/command/container" _ "github.com/docker/cli/cli/command/context" _ "github.com/docker/cli/cli/command/image" + _ "github.com/docker/cli/cli/command/job" _ "github.com/docker/cli/cli/command/manifest" _ "github.com/docker/cli/cli/command/network" _ "github.com/docker/cli/cli/command/node" diff --git a/cli/command/job/client.go b/cli/command/job/client.go new file mode 100644 index 000000000000..945ef471bdf3 --- /dev/null +++ b/cli/command/job/client.go @@ -0,0 +1,84 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.26 + +package job + +import ( + "context" + "errors" + "fmt" + + "github.com/docker/cli/cli/command" + extensionclient "github.com/moby/extensions/client" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/moby/moby/extpoints/jobs/api/v0/protogen" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// jobsClient is the subset of the jobsv0.Jobs contract consumed by the +// `docker job` commands. It is intentionally narrow: jobsv0.Jobs (the real +// implementation, obtained through github.com/moby/extensions/client against +// the daemon's jobs extension point) already satisfies it structurally, so no +// adapter type is needed in production code -- see the var _ jobsClient +// assertion in client_test.go. Do not widen it speculatively. +type jobsClient interface { + List(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) + + // Inspect returns a job with its latest run summary. + Inspect(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) + + // ListRuns returns a job's runs, most recent first. Used as the + // fallback when the latest run's container is gone. + ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) +} + +// newJobsClient dials the daemon's jobs extension point and returns a +// jobsClient backed by github.com/moby/extensions/client, plus a closer for +// the underlying connection that callers must invoke once done with it. +// +// Resolve is lazy: a daemon without the feature only surfaces +// codes.Unimplemented on the first RPC call (e.g. the first List), not on +// newJobsClient itself. +func newJobsClient(dockerCli command.Cli) (jobsClient, func() error, error) { + exts, err := extensionclient.New(dockerCli.Client(), extensionclient.WithGRPCPoint(protogen.ClientPoint)) + if err != nil { + return nil, nil, err + } + client, err := extensionclient.Resolve(exts, jobsv0.Point) + if err != nil { + _ = exts.Close() + return nil, nil, err + } + return client, exts.Close, nil +} + +// enableJobsFlag is the dockerd option enabling the daemon's jobs extension. +const enableJobsFlag = "--extension-enable org.mobyproject.jobs.v0" + +// wrapJobsError turns the gRPC status errors of the Jobs API into actionable +// CLI errors instead of raw `rpc error: code = ...` dumps. Unimplemented means +// the extension is not enabled; Unavailable means the daemon is still starting +// (or the extension failed to activate), or cannot be reached at all, which is +// worth a retry. The other codes the contract defines carry their own message. +// Any other error (including nil) is returned unchanged. +func wrapJobsError(err error) error { + st, ok := status.FromError(err) + if !ok { + return err + } + switch st.Code() { //nolint:exhaustive // only the codes defined by the Jobs API contract are mapped + case codes.Unimplemented: + return errors.New("the daemon does not support jobs; start dockerd with " + enableJobsFlag + ` (or set "extensions.enable" in daemon.json)`) + case codes.Canceled: + // A cancelled context (Ctrl-C) must stay recognisable as such, so that the + // CLI exits quietly like it does for the other commands. + return context.Canceled + case codes.Unavailable: + return fmt.Errorf("the jobs API is unavailable (the daemon may be starting or unreachable), retry in a moment: %s", st.Message()) + case codes.NotFound, codes.AlreadyExists, codes.FailedPrecondition, codes.InvalidArgument: + return errors.New(st.Message()) + default: + return err + } +} diff --git a/cli/command/job/client_test.go b/cli/command/job/client_test.go new file mode 100644 index 000000000000..80a7b4cf23b3 --- /dev/null +++ b/cli/command/job/client_test.go @@ -0,0 +1,103 @@ +package job + +import ( + "context" + "errors" + "testing" + + "github.com/containerd/errdefs" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// jobsv0.Jobs must keep satisfying jobsClient structurally: this line stops +// compiling the day the real interface no longer matches what the job +// package expects from it. +var _ jobsClient = jobsv0.Jobs(nil) + +// fakeClient is a test double for jobsClient, following the fakeClient +// pattern used across cli/command/* (see cli/command/volume/client_test.go): +// one Func field per method, a nil field falling back to a harmless +// zero-value response. +type fakeClient struct { + listFunc func(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) + inspectFunc func(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) + listRunsFunc func(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) +} + +func (c *fakeClient) List(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) { + if c.listFunc != nil { + return c.listFunc(ctx, req) + } + return &jobsv0.ListReply{}, nil +} + +func (c *fakeClient) Inspect(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + if c.inspectFunc != nil { + return c.inspectFunc(ctx, req) + } + return &jobsv0.InspectReply{}, nil +} + +func (c *fakeClient) ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + if c.listRunsFunc != nil { + return c.listRunsFunc(ctx, req) + } + return &jobsv0.ListRunsReply{}, nil +} + +var _ jobsClient = (*fakeClient)(nil) + +func TestWrapJobsError(t *testing.T) { + plain := errors.New("boom") + + testCases := []struct { + doc string + err error + want string // exact message; empty means the error is returned unchanged + }{ + {doc: "nil"}, + {doc: "non-status error", err: plain}, + { + doc: "unimplemented points at the enable flag", + err: status.Error(codes.Unimplemented, "unknown service"), + want: `the daemon does not support jobs; start dockerd with --extension-enable org.mobyproject.jobs.v0 (or set "extensions.enable" in daemon.json)`, + }, + { + doc: "unavailable is retryable and keeps the daemon message", + err: status.Error(codes.Unavailable, "reconciling runs"), + want: "the jobs API is unavailable (the daemon may be starting or unreachable), retry in a moment: reconciling runs", + }, + {doc: "not found", err: status.Error(codes.NotFound, `job "backup" not found`), want: `job "backup" not found`}, + {doc: "already exists", err: status.Error(codes.AlreadyExists, "name taken"), want: "name taken"}, + {doc: "failed precondition", err: status.Error(codes.FailedPrecondition, "job is already running"), want: "job is already running"}, + {doc: "invalid argument", err: status.Error(codes.InvalidArgument, "bad runs_removal"), want: "bad runs_removal"}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + got := wrapJobsError(tc.err) + + switch { + case tc.err == nil: + assert.NilError(t, got) + case tc.want == "": + assert.Check(t, is.Equal(got, tc.err)) + default: + assert.Error(t, got, tc.want) + } + }) + } +} + +// A cancelled context (Ctrl-C during a blocking call such as `docker job wait`) +// comes back from gRPC as a Canceled status, which the CLI's main only +// silences when it is recognisable as a cancellation. +func TestWrapJobsErrorCanceledIsRecognisedAsCancellation(t *testing.T) { + got := wrapJobsError(status.FromContextError(context.Canceled).Err()) + + assert.Check(t, errdefs.IsCanceled(got), "got %v", got) +} diff --git a/cli/command/job/cmd.go b/cli/command/job/cmd.go new file mode 100644 index 000000000000..81ccc431751c --- /dev/null +++ b/cli/command/job/cmd.go @@ -0,0 +1,106 @@ +package job + +import ( + "context" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + "github.com/docker/cli/internal/commands" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +func init() { + commands.Register(newJobCommand) +} + +// newJobCommand returns a cobra command for `job` subcommands. +func newJobCommand(dockerCli command.Cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "job COMMAND", + Short: "Manage jobs", + Long: "Manage jobs, one-shot or scheduled containers run by the daemon.\n\n" + + "This requires the daemon's jobs extension, which is disabled by default: start\n" + + "dockerd with " + enableJobsFlag + ".", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.57"}, + DisableFlagsInUseLine: true, + } + jobs := newLazyJobsClient(dockerCli) + cmd.PersistentPostRunE = func(*cobra.Command, []string) error { + return jobs.Close() + } + cmd.AddCommand( + newListCommand(dockerCli, jobs), + newLogsCommand(dockerCli, jobs), + ) + return cmd +} + +// lazyJobsClient defers newJobsClient(dockerCli) -- and therefore +// dockerCli.Client() -- until a jobsClient method is actually invoked from a +// subcommand's RunE. `docker job` subcommands are registered while the +// cobra command tree is built, which happens before dockerCli.Initialize(); +// dialing eagerly at that point would call dockerCli.Client() too early and +// abort the whole process (Client() calls os.Exit(1) on failure), breaking +// every command, not just `job`. +// +// The dial is memoized: a single command invocation may call more than one +// jobsClient method (e.g. `docker job logs` falling back from Inspect to +// ListRuns), and each should reuse the same connection rather than dialing +// again. newJobCommand closes it after the invoked subcommand's RunE +// succeeds (cobra skips PersistentPostRunE on error, and the process exits +// right after). +type lazyJobsClient struct { + dockerCli command.Cli + + client jobsClient + closer func() error +} + +func newLazyJobsClient(dockerCli command.Cli) *lazyJobsClient { + return &lazyJobsClient{dockerCli: dockerCli} +} + +func (c *lazyJobsClient) resolve() (jobsClient, error) { + if c.client == nil { + client, closer, err := newJobsClient(c.dockerCli) + if err != nil { + return nil, err + } + c.client, c.closer = client, closer + } + return c.client, nil +} + +func (c *lazyJobsClient) Close() error { + if c.closer == nil { + return nil + } + return c.closer() +} + +func (c *lazyJobsClient) List(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.List(ctx, req) +} + +func (c *lazyJobsClient) Inspect(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.Inspect(ctx, req) +} + +func (c *lazyJobsClient) ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.ListRuns(ctx, req) +} diff --git a/cli/command/job/cmd_test.go b/cli/command/job/cmd_test.go new file mode 100644 index 000000000000..3887c6b62968 --- /dev/null +++ b/cli/command/job/cmd_test.go @@ -0,0 +1,19 @@ +package job + +import ( + "testing" + + "github.com/docker/cli/internal/test" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// The jobs extension shipped with Engine API 1.57: the CLI hides the group and +// refuses it with a "requires API version" error on older daemons, instead of +// suggesting an --extension-enable flag they do not have. +func TestNewJobCommandRequiresAPIVersion(t *testing.T) { + cmd := newJobCommand(test.NewFakeCli(nil)) + + assert.Check(t, is.Equal(cmd.Annotations["version"], "1.57")) + assert.Check(t, is.Contains(cmd.Long, "--extension-enable org.mobyproject.jobs.v0")) +} diff --git a/cli/command/job/list.go b/cli/command/job/list.go new file mode 100644 index 000000000000..a0e6d3c175a9 --- /dev/null +++ b/cli/command/job/list.go @@ -0,0 +1,128 @@ +package job + +import ( + "context" + "fmt" + "sort" + "strconv" + "time" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/command/formatter/tabwriter" + units "github.com/docker/go-units" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// jobRow is one formatted row of `docker job ls`, matching the columns +// NAME TRIGGER STATE PAUSED LAST RUN EXIT NEXT FIRE. +type jobRow struct { + Name string + Trigger string + State string + Paused string + LastRun string + Exit string + NextFire string +} + +// newJobRow formats j into a jobRow. now is the reference time used to +// humanize durations (LAST RUN age, NEXT FIRE delay) with +// github.com/docker/go-units HumanDuration; production code passes +// time.Now(), tests inject a fixed value to stay deterministic. +func newJobRow(j jobsv0.Job, now time.Time) jobRow { + row := jobRow{ + Name: j.Name, + Trigger: jobTrigger(j), + State: j.State, + Paused: strconv.FormatBool(j.Paused), + LastRun: "-", + Exit: "-", + NextFire: "-", + } + + if j.LatestRun != nil { + row.LastRun = fmt.Sprintf("%s (%s ago)", j.LatestRun.State, units.HumanDuration(now.Sub(runAge(j.LatestRun)))) + if j.LatestRun.ExitCode != nil { + row.Exit = strconv.FormatInt(j.LatestRun.ExitCode.Value, 10) + } + } + + if !j.Paused && j.NextFireAtNano != 0 { + row.NextFire = "in " + units.HumanDuration(time.Unix(0, j.NextFireAtNano).Sub(now)) + } + + return row +} + +// jobTrigger returns the manual shorthand unless the job declares a schedule +// trigger, in which case it returns the raw cron expression. +func jobTrigger(j jobsv0.Job) string { + if isScheduled(&j) { + return j.Spec.Trigger.Schedule.Cron + } + return jobsv0.TriggerKindManual +} + +// isScheduled reports whether j declares a schedule trigger, as opposed to +// the manual shorthand. +func isScheduled(j *jobsv0.Job) bool { + return j.Spec != nil && j.Spec.Trigger != nil && j.Spec.Trigger.Schedule != nil +} + +// runAge returns the timestamp to compute a run's age from, in priority +// order: FinishedAtNano, StartedAtNano, CreatedAtNano. +func runAge(run *jobsv0.Run) time.Time { + nano := run.FinishedAtNano + if nano == 0 { + nano = run.StartedAtNano + } + if nano == 0 { + nano = run.CreatedAtNano + } + return time.Unix(0, nano) +} + +// newListCommand wires the `docker job ls` cobra command. client is injected +// explicitly (rather than dialed from dockerCli internally) so that it can be +// swapped for a fake in tests without touching gRPC; the real client is the +// lazy one built by the `docker job` parent command (see cmd.go) and threaded +// down to each subcommand constructor. +func newListCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + return &cobra.Command{ + Use: "ls [OPTIONS]", + Aliases: []string{"list"}, + Short: "List jobs", + Args: cli.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + return runList(cmd.Context(), dockerCli, client) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } +} + +// runList calls client.List, sorts the result by Name, and renders it as a +// tabwriter table to dockerCli.Out(). +func runList(ctx context.Context, dockerCli command.Cli, client jobsClient) error { + reply, err := client.List(ctx, &jobsv0.ListRequest{}) + if err != nil { + return wrapJobsError(err) + } + + jobs := reply.Jobs + sort.Slice(jobs, func(i, j int) bool { + return jobs[i].Name < jobs[j].Name + }) + + now := time.Now() + w := tabwriter.NewWriter(dockerCli.Out(), 0, 4, 2, ' ', 0) + _, _ = fmt.Fprintln(w, "NAME\tTRIGGER\tSTATE\tPAUSED\tLAST RUN\tEXIT\tNEXT FIRE") + for _, j := range jobs { + row := newJobRow(j, now) + _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + row.Name, row.Trigger, row.State, row.Paused, row.LastRun, row.Exit, row.NextFire) + } + return w.Flush() +} diff --git a/cli/command/job/list_test.go b/cli/command/job/list_test.go new file mode 100644 index 000000000000..e5af3582c0a8 --- /dev/null +++ b/cli/command/job/list_test.go @@ -0,0 +1,383 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + "time" + + "github.com/docker/cli/internal/test" + "github.com/docker/go-units" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// jobsHeaderColumns is the exact header line expected on `docker job ls`: NAME TRIGGER STATE PAUSED LAST RUN EXIT NEXT FIRE. +var jobsHeaderColumns = []string{"NAME", "TRIGGER", "STATE", "PAUSED", "LAST RUN", "EXIT", "NEXT FIRE"} + +func TestNewJobRow(t *testing.T) { + now := time.Date(2024, 3, 10, 15, 0, 0, 0, time.UTC) + + testCases := []struct { + doc string + job jobsv0.Job + expected jobRow + }{ + { + doc: "manual job, never run", + job: jobsv0.Job{ + Name: "migrate", + State: jobsv0.JobStateIdle, + Spec: &jobsv0.JobSpec{ + Trigger: &jobsv0.Trigger{Manual: true}, + }, + }, + expected: jobRow{ + Name: "migrate", + Trigger: "manual", + State: "idle", + Paused: "false", + LastRun: "-", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "nil Spec is the manual shorthand", + job: jobsv0.Job{ + Name: "migrate", + State: jobsv0.JobStateIdle, + Spec: nil, + }, + expected: jobRow{ + Name: "migrate", + Trigger: "manual", + State: "idle", + Paused: "false", + LastRun: "-", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "nil Trigger on a Spec is also the manual shorthand", + job: jobsv0.Job{ + Name: "migrate", + State: jobsv0.JobStateIdle, + Spec: &jobsv0.JobSpec{Trigger: nil}, + }, + expected: jobRow{ + Name: "migrate", + Trigger: "manual", + State: "idle", + Paused: "false", + LastRun: "-", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "cron job, armed, not paused", + job: jobsv0.Job{ + Name: "backup", + State: jobsv0.JobStateIdle, + Spec: &jobsv0.JobSpec{ + Trigger: &jobsv0.Trigger{ + Schedule: &jobsv0.ScheduleTrigger{Cron: "*/5 * * * *"}, + }, + }, + NextFireAtNano: now.Add(5 * time.Minute).UnixNano(), + }, + expected: jobRow{ + Name: "backup", + Trigger: "*/5 * * * *", + State: "idle", + Paused: "false", + LastRun: "-", + Exit: "-", + NextFire: "in 5 minutes", + }, + }, + { + doc: "paused cron job with a stale NextFireAtNano must show NEXT FIRE -, not a computed value", + job: jobsv0.Job{ + Name: "backup", + State: jobsv0.JobStateIdle, + Paused: true, + Spec: &jobsv0.JobSpec{ + Trigger: &jobsv0.Trigger{ + Schedule: &jobsv0.ScheduleTrigger{Cron: "* * * * *"}, + }, + }, + // Residual/stale value from before the job was paused: must + // be ignored, not rendered. + NextFireAtNano: now.Add(3 * time.Minute).UnixNano(), + }, + expected: jobRow{ + Name: "backup", + Trigger: "* * * * *", + State: "idle", + Paused: "true", + LastRun: "-", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "unpaused cron job currently running has NextFireAtNano == 0 -> NEXT FIRE -", + job: jobsv0.Job{ + Name: "backup", + State: jobsv0.JobStateRunning, + Spec: &jobsv0.JobSpec{ + Trigger: &jobsv0.Trigger{ + Schedule: &jobsv0.ScheduleTrigger{Cron: "* * * * *"}, + }, + }, + NextFireAtNano: 0, + }, + expected: jobRow{ + Name: "backup", + Trigger: "* * * * *", + State: "running", + Paused: "false", + LastRun: "-", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "job never ran: LAST RUN and EXIT are both -", + job: jobsv0.Job{ + Name: "migrate", + State: jobsv0.JobStateIdle, + Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}, + LatestRun: nil, + }, + expected: jobRow{ + Name: "migrate", + Trigger: "manual", + State: "idle", + Paused: "false", + LastRun: "-", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "run in flight: ExitCode nil -> EXIT -, LAST RUN uses StartedAtNano since FinishedAtNano is zero", + job: jobsv0.Job{ + Name: "backup", + State: jobsv0.JobStateRunning, + Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}, + LatestRun: &jobsv0.Run{ + State: jobsv0.RunStateRunning, + StartedAtNano: now.Add(-30 * time.Second).UnixNano(), + ExitCode: nil, + }, + }, + expected: jobRow{ + Name: "backup", + Trigger: "manual", + State: "running", + Paused: "false", + LastRun: "running (30 seconds ago)", + Exit: "-", + NextFire: "-", + }, + }, + { + doc: "successful run with exit code zero: EXIT must be 0, NOT - (no-exit-code vs exit-code-zero trap)", + job: jobsv0.Job{ + Name: "backup", + State: jobsv0.JobStateIdle, + Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}, + LatestRun: &jobsv0.Run{ + State: jobsv0.RunStateSucceeded, + FinishedAtNano: now.Add(-2 * time.Minute).UnixNano(), + ExitCode: &jobsv0.ExitCode{Value: 0}, + }, + }, + expected: jobRow{ + Name: "backup", + Trigger: "manual", + State: "idle", + Paused: "false", + LastRun: "succeeded (2 minutes ago)", + Exit: "0", + NextFire: "-", + }, + }, + { + doc: "failed run with a nonzero exit code", + job: jobsv0.Job{ + Name: "backup", + State: jobsv0.JobStateIdle, + Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}, + LatestRun: &jobsv0.Run{ + State: jobsv0.RunStateFailed, + FinishedAtNano: now.Add(-1 * time.Hour).UnixNano(), + ExitCode: &jobsv0.ExitCode{Value: 137}, + }, + }, + expected: jobRow{ + Name: "backup", + Trigger: "manual", + State: "idle", + Paused: "false", + LastRun: "failed (About an hour ago)", + Exit: "137", + NextFire: "-", + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + row := newJobRow(tc.job, now) + assert.Check(t, is.DeepEqual(row, tc.expected)) + }) + } +} + +// TestNewJobRowNextFireUsesHumanDuration guards against hardcoding a +// human-readable string that only happens to match go-units' current +// implementation: it recomputes the expected string through +// units.HumanDuration itself, so the test tracks the library rather than a +// magic string. +func TestNewJobRowNextFireUsesHumanDuration(t *testing.T) { + now := time.Date(2024, 3, 10, 15, 0, 0, 0, time.UTC) + delay := 42 * time.Second + j := jobsv0.Job{ + Name: "backup", + Spec: &jobsv0.JobSpec{ + Trigger: &jobsv0.Trigger{Schedule: &jobsv0.ScheduleTrigger{Cron: "* * * * *"}}, + }, + NextFireAtNano: now.Add(delay).UnixNano(), + } + + row := newJobRow(j, now) + + assert.Check(t, is.Equal(row.NextFire, "in "+units.HumanDuration(delay))) +} + +func TestNewListCommandSortsByName(t *testing.T) { + cli := test.NewFakeCli(nil) + client := &fakeClient{ + listFunc: func(context.Context, *jobsv0.ListRequest) (*jobsv0.ListReply, error) { + return &jobsv0.ListReply{Jobs: []jobsv0.Job{ + {Name: "zeta", Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}}, + {Name: "alpha", Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}}, + {Name: "mike", Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}}, + }}, nil + }, + } + + cmd := newListCommand(cli, client) + cmd.SetOut(io.Discard) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + iAlpha := strings.Index(out, "alpha") + iMike := strings.Index(out, "mike") + iZeta := strings.Index(out, "zeta") + assert.Check(t, iAlpha >= 0 && iMike >= 0 && iZeta >= 0, "all three job names must appear in output:\n%s", out) + assert.Check(t, iAlpha < iMike, "expected alpha before mike:\n%s", out) + assert.Check(t, iMike < iZeta, "expected mike before zeta:\n%s", out) +} + +func TestNewListCommandHeader(t *testing.T) { + cli := test.NewFakeCli(nil) + client := &fakeClient{} + + cmd := newListCommand(cli, client) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + for _, col := range jobsHeaderColumns { + assert.Check(t, strings.Contains(out, col), "expected header column %q in output:\n%s", col, out) + } +} + +func TestNewListCommandRendersJobFields(t *testing.T) { + cli := test.NewFakeCli(nil) + client := &fakeClient{ + listFunc: func(context.Context, *jobsv0.ListRequest) (*jobsv0.ListReply, error) { + return &jobsv0.ListReply{Jobs: []jobsv0.Job{ + { + Name: "backup", + State: jobsv0.JobStateIdle, + Paused: true, + Spec: &jobsv0.JobSpec{ + Trigger: &jobsv0.Trigger{Schedule: &jobsv0.ScheduleTrigger{Cron: "* * * * *"}}, + }, + LatestRun: &jobsv0.Run{ + State: jobsv0.RunStateSucceeded, + ExitCode: &jobsv0.ExitCode{Value: 0}, + }, + }, + }}, nil + }, + } + + cmd := newListCommand(cli, client) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + assert.Check(t, is.Contains(out, "backup")) + assert.Check(t, is.Contains(out, "* * * * *")) + assert.Check(t, is.Contains(out, "idle")) + assert.Check(t, is.Contains(out, "true")) // Paused column + assert.Check(t, is.Contains(out, "succeeded")) + // The exit code column must show the literal 0, not a "-" placeholder. + assert.Check(t, hasTableCell(out, "0"), "expected a table cell with the exit code 0, not '-':\n%s", out) +} + +func TestNewListCommandUnimplementedIsActionable(t *testing.T) { + cli := test.NewFakeCli(nil) + client := &fakeClient{ + listFunc: func(context.Context, *jobsv0.ListRequest) (*jobsv0.ListReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + + cmd := newListCommand(cli, client) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewListCommandOtherErrorsPassThrough(t *testing.T) { + cli := test.NewFakeCli(nil) + client := &fakeClient{ + listFunc: func(context.Context, *jobsv0.ListRequest) (*jobsv0.ListReply, error) { + return nil, errors.New("connection refused") + }, + } + + cmd := newListCommand(cli, client) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "connection refused") +} + +// hasTableCell reports whether out contains a whitespace-delimited cell +// equal to want. It exists because a plain strings.Contains(out, "0") would +// also match inside unrelated substrings (job names, cron fields, etc.). +func hasTableCell(out, want string) bool { + for _, field := range strings.Fields(out) { + if field == want { + return true + } + } + return false +} diff --git a/cli/command/job/logs.go b/cli/command/job/logs.go new file mode 100644 index 000000000000..9eab4cbbeb5e --- /dev/null +++ b/cli/command/job/logs.go @@ -0,0 +1,211 @@ +package job + +import ( + "context" + "errors" + "fmt" + "io" + "time" + + "github.com/containerd/errdefs" + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + "github.com/moby/moby/api/pkg/stdcopy" + dockerclient "github.com/moby/moby/client" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// pollInterval is how often waitForNextRun polls the job for a new run while +// following logs across cron occurrences. +const pollInterval = 2 * time.Second + +// logsOptions holds the parsed flags/args of `docker job logs`. +type logsOptions struct { + follow bool + job string +} + +// newLogsCommand wires the `docker job logs [-f] JOB` cobra command. client +// is injected explicitly, following the same pattern as newListCommand (see +// list.go). +func newLogsCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts logsOptions + + cmd := &cobra.Command{ + Use: "logs [OPTIONS] JOB", + Short: "Fetch the logs of a job's most recent run", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + opts.job = args[0] + return runLogs(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output") + return cmd +} + +// runLogs resolves opts.job through client.Inspect, picks the run to read +// logs from via resolveLogsRun -- calling client.ListRuns as its listRuns +// fallback when needed -- then streams its container's logs via +// streamRunLogs. When opts.follow is set and the run's container exits +// (streamRunLogs returns after a clean EOF), runLogs polls the job via +// waitForNextRun until the next cron occurrence starts and re-attaches to +// it, so `docker job logs -f` keeps following across runs instead of +// exiting. A context cancellation (e.g. Ctrl-C) while waiting for the next +// run ends the loop cleanly, with no error surfaced to the user. +func runLogs(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *logsOptions) error { + inspectJob := func() (*jobsv0.Job, error) { + reply, err := client.Inspect(ctx, &jobsv0.InspectRequest{JobRef: opts.job}) + if err != nil { + return nil, err + } + return reply.Job, nil + } + + job, err := inspectJob() + if err != nil { + return wrapJobsError(err) + } + + run, err := resolveLogsRun(job, func() (*jobsv0.ListRunsReply, error) { + return client.ListRuns(ctx, &jobsv0.ListRunsRequest{JobRef: opts.job}) + }) + if err != nil { + return wrapJobsError(err) + } + if run.ID != job.LatestRun.ID { + _, _ = fmt.Fprintf(dockerCli.Err(), "Note: the container of the latest run %s is not available; showing the logs of run %s\n", job.LatestRun.ID, run.ID) + } + + // Only a schedule job can produce a next run on its own. + followNext := opts.follow && isScheduled(job) + for { + if err := streamRunLogs(ctx, dockerCli, run.ContainerID, opts.follow); err != nil { + return err + } + if !followNext { + return nil + } + + run, err = waitForNextRun(ctx, run.ID, inspectJob, sleepOrCancel) + if err != nil { + if ctx.Err() != nil { + return nil + } + return wrapJobsError(err) + } + } +} + +// streamRunLogs attaches to containerID's logs and demultiplexes them onto +// dockerCli.Out()/dockerCli.Err(), following the pattern of +// cli/command/container/logs.go's runLogs. It returns nil once the log +// stream ends with a clean EOF. +func streamRunLogs(ctx context.Context, dockerCli command.Cli, containerID string, follow bool) error { + c, err := dockerCli.Client().ContainerInspect(ctx, containerID, dockerclient.ContainerInspectOptions{}) + if errdefs.IsNotFound(err) { + // The container was removed (history eviction, job removal) after + // the run was looked up. + return errors.New("logs are no longer available: the run's container was removed") + } + if err != nil { + return err + } + + resp, err := dockerCli.Client().ContainerLogs(ctx, containerID, dockerclient.ContainerLogsOptions{ + ShowStdout: true, + ShowStderr: true, + Follow: follow, + }) + if err != nil { + return err + } + defer func() { _ = resp.Close() }() + + if c.Container.Config.Tty { + _, err = io.Copy(dockerCli.Out(), resp) + } else { + _, err = stdcopy.StdCopy(dockerCli.Out(), dockerCli.Err(), resp) + } + return err +} + +// waitForNextRun polls inspect() until job.LatestRun's ID differs from +// currentRunID and its logs can be read (see hasContainer), returning that new +// run. A run is visible before its container is created (and never gets one if +// creation fails), and a fast job's container may already be gone by the time +// it is noticed: such runs are skipped rather than returned. +// +// It checks ctx.Err() before every poll so an already-cancelled (or +// cancelled-while-sleeping) context returns immediately, and tolerates +// job.LatestRun being nil (a job that hasn't run again yet) by continuing to +// poll instead of panicking. sleep is called between polls and its error +// (e.g. context cancellation) is propagated. +func waitForNextRun(ctx context.Context, currentRunID string, inspect func() (*jobsv0.Job, error), sleep func(context.Context) error) (*jobsv0.Run, error) { + for { + if err := ctx.Err(); err != nil { + return nil, err + } + + job, err := inspect() + if err != nil { + return nil, err + } + + if job.LatestRun != nil && job.LatestRun.ID != currentRunID && hasContainer(job.LatestRun) { + return job.LatestRun, nil + } + + if err := sleep(ctx); err != nil { + return nil, err + } + } +} + +// sleepOrCancel is waitForNextRun's production sleep: it waits pollInterval +// between polls, returning early with ctx.Err() if the context is cancelled +// first. +func sleepOrCancel(ctx context.Context) error { + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(pollInterval): + return nil + } +} + +// resolveLogsRun picks the run whose container `docker job logs` should read +// from: job.LatestRun when its logs can be read, otherwise the most recent run +// of the job's history (via listRuns, called lazily) that still has a +// container. job is the already-inspected job; this function does no I/O of +// its own. +func resolveLogsRun(job *jobsv0.Job, listRuns func() (*jobsv0.ListRunsReply, error)) (*jobsv0.Run, error) { + if job.LatestRun == nil { + return nil, fmt.Errorf("job %q has never run", job.Name) + } + if hasContainer(job.LatestRun) { + return job.LatestRun, nil + } + + reply, err := listRuns() + if err != nil { + return nil, err + } + for i := range reply.Runs { + if hasContainer(&reply.Runs[i]) { + return &reply.Runs[i], nil + } + } + return nil, fmt.Errorf("no logs available for job %q", job.Name) +} + +// hasContainer reports whether run's logs can still be read: its container +// has been created and not removed. +func hasContainer(run *jobsv0.Run) bool { + return run.ContainerID != "" && !run.ContainerGone +} diff --git a/cli/command/job/logs_followswitch_test.go b/cli/command/job/logs_followswitch_test.go new file mode 100644 index 000000000000..de85a9f8199b --- /dev/null +++ b/cli/command/job/logs_followswitch_test.go @@ -0,0 +1,471 @@ +package job + +import ( + "context" + "errors" + "sync/atomic" + "testing" + + "github.com/containerd/errdefs" + "github.com/docker/cli/internal/test" + dockerclient "github.com/moby/moby/client" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// This file covers the `docker job logs -f` follow-switch behavior: once the +// container backing the followed run exits (ContainerLogs' stream ends with +// a clean EOF), `docker job logs -f` on a schedule job polls the job until a +// new run appears and re-attaches to it, instead of exiting. +// +// waitForNextRun takes an injectable sleep/inspect so its tests run in +// milliseconds with zero real time.Sleep. + +// ----------------------------------------------------------------------- +// streamRunLogs +// ----------------------------------------------------------------------- + +func TestStreamRunLogsWritesTTYOutputToStdout(t *testing.T) { + docker := &fakeDockerAPIClient{ + inspectFunc: func(containerID string) (dockerclient.ContainerInspectResult, error) { + assert.Check(t, is.Equal(containerID, "abc123")) + return ttyInspectResult(), nil + }, + logFunc: func(containerID string, _ dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + assert.Check(t, is.Equal(containerID, "abc123")) + return mockJobContainerLogsResult("hello\n"), nil + }, + } + cli := test.NewFakeCli(docker) + + err := streamRunLogs(context.Background(), cli, "abc123", false) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "hello\n")) +} + +func TestStreamRunLogsForwardsFollowFlag(t *testing.T) { + var gotFollow bool + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(_ string, opts dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + gotFollow = opts.Follow + return mockJobContainerLogsResult(""), nil + }, + } + cli := test.NewFakeCli(docker) + + assert.NilError(t, streamRunLogs(context.Background(), cli, "abc123", true)) + assert.Check(t, gotFollow) +} + +func TestStreamRunLogsPropagatesContainerInspectError(t *testing.T) { + wantErr := errors.New("boom") + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { + return dockerclient.ContainerInspectResult{}, wantErr + }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + t.Fatal("ContainerLogs must not be called when ContainerInspect fails") + return nil, nil + }, + } + cli := test.NewFakeCli(docker) + + err := streamRunLogs(context.Background(), cli, "abc123", false) + + assert.ErrorIs(t, err, wantErr) +} + +func TestStreamRunLogsPropagatesContainerLogsError(t *testing.T) { + wantErr := errors.New("boom") + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return nil, wantErr + }, + } + cli := test.NewFakeCli(docker) + + err := streamRunLogs(context.Background(), cli, "abc123", false) + + assert.ErrorIs(t, err, wantErr) +} + +// ----------------------------------------------------------------------- +// waitForNextRun +// ----------------------------------------------------------------------- + +func TestWaitForNextRunReturnsImmediatelyWhenRunAlreadyChanged(t *testing.T) { + inspectCalls := 0 + inspect := func() (*jobsv0.Job, error) { + inspectCalls++ + return &jobsv0.Job{LatestRun: &jobsv0.Run{ID: "run-2", ContainerID: "c2"}}, nil + } + sleepCalls := 0 + sleep := func(context.Context) error { sleepCalls++; return nil } + + run, err := waitForNextRun(context.Background(), "run-1", inspect, sleep) + + assert.NilError(t, err) + assert.Check(t, is.Equal(run.ID, "run-2")) + assert.Check(t, is.Equal(inspectCalls, 1)) + assert.Check(t, is.Equal(sleepCalls, 0), "sleep must not be called when the run already changed on the first poll") +} + +func TestWaitForNextRunPollsUntilRunChanges(t *testing.T) { + jobs := []*jobsv0.Job{ + {LatestRun: &jobsv0.Run{ID: "run-1"}}, + {LatestRun: &jobsv0.Run{ID: "run-1"}}, + {LatestRun: &jobsv0.Run{ID: "run-2", ContainerID: "c2"}}, + } + inspectCalls := 0 + inspect := func() (*jobsv0.Job, error) { + job := jobs[inspectCalls] + inspectCalls++ + return job, nil + } + sleepCalls := 0 + sleep := func(context.Context) error { sleepCalls++; return nil } + + run, err := waitForNextRun(context.Background(), "run-1", inspect, sleep) + + assert.NilError(t, err) + assert.Check(t, is.Equal(run.ID, "run-2")) + assert.Check(t, is.Equal(inspectCalls, 3)) + assert.Check(t, is.Equal(sleepCalls, 2)) +} + +func TestWaitForNextRunReturnsImmediatelyWhenContextAlreadyCancelled(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + cancel() + + inspectCalled := false + inspect := func() (*jobsv0.Job, error) { + inspectCalled = true + return &jobsv0.Job{}, nil + } + sleep := func(context.Context) error { + t.Fatal("sleep must not be called when the context is already cancelled") + return nil + } + + run, err := waitForNextRun(ctx, "run-1", inspect, sleep) + + assert.Check(t, is.Nil(run)) + assert.ErrorIs(t, err, context.Canceled) + assert.Check(t, !inspectCalled, "inspect must not be called when the context is already cancelled") +} + +func TestWaitForNextRunPropagatesCancellationDuringSleep(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + inspect := func() (*jobsv0.Job, error) { + return &jobsv0.Job{LatestRun: &jobsv0.Run{ID: "run-1"}}, nil + } + sleep := func(ctx context.Context) error { + cancel() + return ctx.Err() + } + + run, err := waitForNextRun(ctx, "run-1", inspect, sleep) + + assert.Check(t, is.Nil(run)) + assert.ErrorIs(t, err, context.Canceled) +} + +func TestWaitForNextRunPropagatesInspectError(t *testing.T) { + wantErr := errors.New("connection refused") + inspect := func() (*jobsv0.Job, error) { return nil, wantErr } + sleep := func(context.Context) error { + t.Fatal("sleep must not be called when inspect fails") + return nil + } + + run, err := waitForNextRun(context.Background(), "run-1", inspect, sleep) + + assert.Check(t, is.Nil(run)) + assert.ErrorIs(t, err, wantErr) +} + +func TestWaitForNextRunKeepsPollingWhenLatestRunIsNil(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + inspectCalls := 0 + inspect := func() (*jobsv0.Job, error) { + inspectCalls++ + // A job that never ran again yet (e.g. a manually-triggered job) + // reports no LatestRun; polling must not panic on the nil deref + // and must keep going. + return &jobsv0.Job{LatestRun: nil}, nil + } + sleepCalls := 0 + sleep := func(ctx context.Context) error { + sleepCalls++ + if sleepCalls >= 3 { + cancel() + return ctx.Err() + } + return nil + } + + run, err := waitForNextRun(ctx, "run-1", inspect, sleep) + + assert.Check(t, is.Nil(run)) + assert.ErrorIs(t, err, context.Canceled) + assert.Check(t, inspectCalls >= 3, "expected polling to continue while LatestRun is nil, got %d inspect calls", inspectCalls) +} + +// ----------------------------------------------------------------------- +// runLogs: follow-switch integration +// ----------------------------------------------------------------------- + +func TestRunLogsWithoutFollowDoesNotPollForNextRun(t *testing.T) { + var inspectCalls int32 + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + atomic.AddInt32(&inspectCalls, 1) + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "c1"}, + }}, nil + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done\n"), nil + }, + } + cli := test.NewFakeCli(docker) + + err := runLogs(context.Background(), cli, jobs, &logsOptions{job: "backup", follow: false}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done\n")) + assert.Check(t, is.Equal(atomic.LoadInt32(&inspectCalls), int32(1))) +} + +// TestRunLogsFollowSwitchesToNextRunOnContainerStop drives two full cron +// occurrences through runLogs(follow=true): run-1's container exits (clean +// ContainerLogs EOF), runLogs polls the job and re-attaches to run-2 as soon +// as it appears, then run-2's container also exits and the context is +// cancelled (simulating Ctrl-C) so the otherwise-infinite follow loop +// terminates. +func TestRunLogsFollowSwitchesToNextRunOnContainerStop(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + var inspectCalls int32 + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + switch atomic.AddInt32(&inspectCalls, 1) { + case 1: + // Initial resolution in runLogs, before the first attach. + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "c1"}, + }}, nil + case 2: + // First waitForNextRun poll, after run-1's container exits: + // run-2 already exists, switch immediately. + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-2", ContainerID: "c2"}, + }}, nil + default: + // Second waitForNextRun poll, after run-2's container + // exits: no new run yet. Cancel the context here to end + // the test the same way a Ctrl-C would. + cancel() + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-2", ContainerID: "c2"}, + }}, nil + } + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(containerID string, opts dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + assert.Check(t, opts.Follow, "runLogs must request Follow on the docker API when opts.follow is set") + switch containerID { + case "c1": + return mockJobContainerLogsResult("[backup] run-1 done\n"), nil + case "c2": + return mockJobContainerLogsResult("[backup] run-2 done\n"), nil + default: + t.Fatalf("unexpected containerID %q", containerID) + return nil, nil + } + }, + } + cli := test.NewFakeCli(docker) + + err := runLogs(ctx, cli, jobs, &logsOptions{job: "backup", follow: true}) + + assert.NilError(t, err, "runLogs must exit cleanly (nil error) when the context is cancelled while waiting for the next run") + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] run-1 done\n[backup] run-2 done\n")) + assert.Check(t, is.Equal(atomic.LoadInt32(&inspectCalls), int32(3))) +} + +// TestRunLogsFollowSkipsRunsWhoseContainerIsAlreadyGone covers the case where +// waitForNextRun picks up a new run whose container has already been removed +// (e.g. a fast job cleaned up right after a successful exit -- observed for +// real against a daemon where Compose removes successful run containers). +// runLogs must keep polling for the run after it instead of trying (and +// failing) to attach to the gone container. +func TestRunLogsFollowSkipsRunsWhoseContainerIsAlreadyGone(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + var inspectCalls int32 + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + switch atomic.AddInt32(&inspectCalls, 1) { + case 1: + // Initial resolution in runLogs, before the first attach. + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "c1"}, + }}, nil + case 2: + // First waitForNextRun poll: run-2 exists but its container + // is already gone -- runLogs must NOT attach to it, and + // must NOT surface an error either; it keeps polling. + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-2", ContainerID: "should-not-be-attached", ContainerGone: true}, + }}, nil + case 3: + // Second poll: run-3 has a live container, switch to it. + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-3", ContainerID: "c3"}, + }}, nil + default: + // Third poll, after run-3's container exits: no new run + // yet. Cancel the context here to end the test the same + // way a Ctrl-C would. + cancel() + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: scheduledSpec(), + LatestRun: &jobsv0.Run{ID: "run-3", ContainerID: "c3"}, + }}, nil + } + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(containerID string) (dockerclient.ContainerInspectResult, error) { + if containerID == "should-not-be-attached" { + t.Fatalf("ContainerInspect must not be called for a run whose container is already gone") + } + return ttyInspectResult(), nil + }, + logFunc: func(containerID string, opts dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + if containerID == "should-not-be-attached" { + t.Fatalf("ContainerLogs must not be called for a run whose container is already gone") + } + switch containerID { + case "c1": + return mockJobContainerLogsResult("[backup] run-1 done\n"), nil + case "c3": + return mockJobContainerLogsResult("[backup] run-3 done\n"), nil + default: + t.Fatalf("unexpected containerID %q", containerID) + return nil, nil + } + }, + } + cli := test.NewFakeCli(docker) + + err := runLogs(ctx, cli, jobs, &logsOptions{job: "backup", follow: true}) + + assert.NilError(t, err, "runLogs must exit cleanly (nil error) when the context is cancelled while waiting for the next run") + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] run-1 done\n[backup] run-3 done\n")) + assert.Check(t, is.Equal(atomic.LoadInt32(&inspectCalls), int32(4))) +} + +// scheduledSpec is the spec of a job with a cron schedule, the only kind of +// job `logs -f` can follow past the end of a run. +func scheduledSpec() *jobsv0.JobSpec { + return &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Schedule: &jobsv0.ScheduleTrigger{Cron: "* * * * *"}}} +} + +// A manual job only runs on an explicit `docker job run`: once its run's +// container exits, `logs -f` has nothing left to follow and must return +// instead of polling forever. +func TestRunLogsFollowReturnsAfterStreamForManualJob(t *testing.T) { + var inspectCalls int32 + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + atomic.AddInt32(&inspectCalls, 1) + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + Spec: &jobsv0.JobSpec{Trigger: &jobsv0.Trigger{Manual: true}}, + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "c1"}, + }}, nil + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done\n"), nil + }, + } + cli := test.NewFakeCli(docker) + + err := runLogs(context.Background(), cli, jobs, &logsOptions{job: "backup", follow: true}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done\n")) + assert.Check(t, is.Equal(atomic.LoadInt32(&inspectCalls), int32(1)), "a manual job must not be polled for a next run") +} + +// A new run is visible as soon as its record is written, before its container +// exists. Attaching then would fail on an empty container ID, so the next run +// is only picked up once its container does exist. +func TestWaitForNextRunWaitsForTheRunContainer(t *testing.T) { + polls := []*jobsv0.Run{ + {ID: "run-2", State: jobsv0.RunStatePending}, + {ID: "run-2", State: jobsv0.RunStateRunning, ContainerID: "c2"}, + } + i := 0 + inspect := func() (*jobsv0.Job, error) { + run := polls[i] + i++ + return &jobsv0.Job{LatestRun: run}, nil + } + sleepCalls := 0 + sleep := func(context.Context) error { sleepCalls++; return nil } + + run, err := waitForNextRun(context.Background(), "run-1", inspect, sleep) + + assert.NilError(t, err) + assert.Check(t, is.Equal(run.ID, "run-2")) + assert.Check(t, is.Equal(run.ContainerID, "c2")) + assert.Check(t, is.Equal(sleepCalls, 1)) +} + +func TestStreamRunLogsReportsRemovedContainerAsUnavailableLogs(t *testing.T) { + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { + return dockerclient.ContainerInspectResult{}, errdefs.ErrNotFound.WithMessage("No such container: abc123") + }, + } + cli := test.NewFakeCli(docker) + + err := streamRunLogs(context.Background(), cli, "abc123", false) + + assert.ErrorContains(t, err, "logs are no longer available") +} diff --git a/cli/command/job/logs_resolve_test.go b/cli/command/job/logs_resolve_test.go new file mode 100644 index 000000000000..1e150d955079 --- /dev/null +++ b/cli/command/job/logs_resolve_test.go @@ -0,0 +1,134 @@ +package job + +import ( + "errors" + "testing" + + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +func TestResolveLogsRunNeverRun(t *testing.T) { + job := &jobsv0.Job{Name: "migrate", LatestRun: nil} + fallbackCalled := false + listRuns := func() (*jobsv0.ListRunsReply, error) { + fallbackCalled = true + return &jobsv0.ListRunsReply{}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.Check(t, is.Nil(run)) + assert.ErrorContains(t, err, `job "migrate" has never run`) + assert.Check(t, !fallbackCalled, "listRuns must not be called when the job never ran") +} + +func TestResolveLogsRunReturnsLatestRunWhenContainerPresent(t *testing.T) { + latest := &jobsv0.Run{ID: "run-3", ContainerID: "abc123", ContainerGone: false} + job := &jobsv0.Job{Name: "backup", LatestRun: latest} + fallbackCalled := false + listRuns := func() (*jobsv0.ListRunsReply, error) { + fallbackCalled = true + return &jobsv0.ListRunsReply{}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.NilError(t, err) + assert.Check(t, is.Equal(run.ID, "run-3")) + assert.Check(t, is.Equal(run.ContainerID, "abc123")) + assert.Check(t, !fallbackCalled, "listRuns must not be called when LatestRun's container is not gone") +} + +func TestResolveLogsRunFallsBackToListRunsWhenContainerGone(t *testing.T) { + latest := &jobsv0.Run{ID: "run-3", ContainerGone: true} + job := &jobsv0.Job{Name: "backup", LatestRun: latest} + listRuns := func() (*jobsv0.ListRunsReply, error) { + // Most recent first, matching ListRuns's documented ordering: + // run-3 (the gone latest run) is included in history too, run-2's + // container was also removed, run-1's container is still around. + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {ID: "run-3", ContainerGone: true}, + {ID: "run-2", ContainerGone: true}, + {ID: "run-1", ContainerID: "def456", ContainerGone: false}, + }}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.NilError(t, err) + assert.Check(t, is.Equal(run.ID, "run-1")) + assert.Check(t, is.Equal(run.ContainerID, "def456")) +} + +func TestResolveLogsRunNoLogsAvailableWhenNoRunHasContainer(t *testing.T) { + latest := &jobsv0.Run{ID: "run-2", ContainerGone: true} + job := &jobsv0.Job{Name: "backup", LatestRun: latest} + listRuns := func() (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {ID: "run-2", ContainerGone: true}, + {ID: "run-1", ContainerGone: true}, + }}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.Check(t, is.Nil(run)) + assert.ErrorContains(t, err, `no logs available for job "backup"`) +} + +func TestResolveLogsRunNoLogsAvailableWhenHistoryEmpty(t *testing.T) { + latest := &jobsv0.Run{ID: "run-1", ContainerGone: true} + job := &jobsv0.Job{Name: "backup", LatestRun: latest} + listRuns := func() (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.Check(t, is.Nil(run)) + assert.ErrorContains(t, err, `no logs available for job "backup"`) +} + +func TestResolveLogsRunPropagatesListRunsError(t *testing.T) { + latest := &jobsv0.Run{ID: "run-1", ContainerGone: true} + job := &jobsv0.Job{Name: "backup", LatestRun: latest} + listRuns := func() (*jobsv0.ListRunsReply, error) { + return nil, errors.New("connection refused") + } + + run, err := resolveLogsRun(job, listRuns) + + assert.Check(t, is.Nil(run)) + assert.ErrorContains(t, err, "connection refused") +} + +func TestResolveLogsRunFallsBackWhenLatestRunHasNoContainerYet(t *testing.T) { + // A pending run, or one that failed before its container was created, has + // neither a ContainerID nor ContainerGone set. + job := &jobsv0.Job{Name: "backup", LatestRun: &jobsv0.Run{ID: "run-2", State: jobsv0.RunStateFailed, Error: "no such image"}} + listRuns := func() (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {ID: "run-2", State: jobsv0.RunStateFailed}, + {ID: "run-1", ContainerID: "def456"}, + }}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.NilError(t, err) + assert.Check(t, is.Equal(run.ID, "run-1")) +} + +func TestResolveLogsRunNoLogsAvailableWhenNoRunEverHadContainer(t *testing.T) { + job := &jobsv0.Job{Name: "backup", LatestRun: &jobsv0.Run{ID: "run-1", State: jobsv0.RunStatePending}} + listRuns := func() (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{{ID: "run-1", State: jobsv0.RunStatePending}}}, nil + } + + run, err := resolveLogsRun(job, listRuns) + + assert.Check(t, is.Nil(run)) + assert.ErrorContains(t, err, `no logs available for job "backup"`) +} diff --git a/cli/command/job/logs_test.go b/cli/command/job/logs_test.go new file mode 100644 index 000000000000..5ca04dd1d1cb --- /dev/null +++ b/cli/command/job/logs_test.go @@ -0,0 +1,316 @@ +package job + +import ( + "context" + "io" + "strings" + "testing" + "time" + + "github.com/docker/cli/internal/test" + "github.com/moby/moby/api/types/container" + dockerclient "github.com/moby/moby/client" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// fakeDockerAPIClient is a test double for the subset of client.APIClient +// consumed by `docker job logs` (ContainerInspect, ContainerLogs), following +// the same embedding pattern as cli/command/container's fakeClient: embed +// the zero-value concrete dockerclient.Client (which satisfies +// client.APIClient) and override only what the command under test calls. +type fakeDockerAPIClient struct { + dockerclient.Client + inspectFunc func(containerID string) (dockerclient.ContainerInspectResult, error) + logFunc func(containerID string, opts dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) +} + +func (f *fakeDockerAPIClient) ContainerInspect(_ context.Context, containerID string, _ dockerclient.ContainerInspectOptions) (dockerclient.ContainerInspectResult, error) { + if f.inspectFunc != nil { + return f.inspectFunc(containerID) + } + return dockerclient.ContainerInspectResult{}, nil +} + +func (f *fakeDockerAPIClient) ContainerLogs(_ context.Context, containerID string, opts dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + if f.logFunc != nil { + return f.logFunc(containerID, opts) + } + return mockJobContainerLogsResult(""), nil +} + +func mockJobContainerLogsResult(content string) dockerclient.ContainerLogsResult { + return io.NopCloser(strings.NewReader(content)) +} + +// ttyInspectResult is a ContainerInspect result for a TTY container, the +// only demux path exercised here -- see the FIXME in +// cli/command/container/logs_test.go about mocking the non-TTY stdcopy +// stream; this test suite follows the same simplification. +func ttyInspectResult() dockerclient.ContainerInspectResult { + return dockerclient.ContainerInspectResult{ + Container: container.InspectResponse{ + Config: &container.Config{Tty: true}, + }, + } +} + +func TestNewLogsCommandFollowFlagForwarded(t *testing.T) { + testCases := []struct { + doc string + args []string + wantFollow bool + }{ + {doc: "long flag", args: []string{"backup", "--follow"}, wantFollow: true}, + {doc: "short flag", args: []string{"backup", "-f"}, wantFollow: true}, + {doc: "flag omitted defaults to false", args: []string{"backup"}, wantFollow: false}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + var gotOpts dockerclient.ContainerLogsOptions + jobs := &fakeClient{ + inspectFunc: func(_ context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + assert.Check(t, is.Equal(req.JobRef, "backup")) + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "abc123"}, + }}, nil + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(containerID string, opts dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + gotOpts = opts + return mockJobContainerLogsResult("[backup] done"), nil + }, + } + cli := test.NewFakeCli(docker) + + // A follow=true run only returns once its context is done: after + // streaming the current run to completion, `logs -f` waits for + // the job's next run to appear (see waitForNextRun) rather than + // returning, exactly like `docker logs -f` waits on a live + // container. This test only cares that the flag reaches + // ContainerLogsOptions, which happens on the first attach, so a + // short timeout stands in for the Ctrl-C that would normally end + // a real `-f` session. + ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) + defer cancel() + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs(tc.args) + cmd.SetOut(io.Discard) + assert.NilError(t, cmd.ExecuteContext(ctx)) + + assert.Check(t, is.Equal(gotOpts.Follow, tc.wantFollow)) + }) + } +} + +func TestNewLogsCommandResolvesContainerIDFromLatestRun(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(_ context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "abc123", ContainerGone: false}, + }}, nil + }, + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + t.Fatal("ListRuns must not be called when LatestRun's container is not gone") + return nil, nil + }, + } + var gotContainerID string + docker := &fakeDockerAPIClient{ + inspectFunc: func(containerID string) (dockerclient.ContainerInspectResult, error) { + gotContainerID = containerID + return ttyInspectResult(), nil + }, + logFunc: func(containerID string, _ dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done"), nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(gotContainerID, "abc123")) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done")) +} + +func TestNewLogsCommandFallsBackWhenContainerGone(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(_ context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-2", ContainerGone: true}, + }}, nil + }, + listRunsFunc: func(_ context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + assert.Check(t, is.Equal(req.JobRef, "backup")) + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {ID: "run-2", ContainerGone: true}, + {ID: "run-1", ContainerID: "def456", ContainerGone: false}, + }}, nil + }, + } + var gotContainerID string + docker := &fakeDockerAPIClient{ + inspectFunc: func(containerID string) (dockerclient.ContainerInspectResult, error) { + gotContainerID = containerID + return ttyInspectResult(), nil + }, + logFunc: func(containerID string, _ dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done"), nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(gotContainerID, "def456")) +} + +func TestNewLogsCommandNeverRunError(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{Name: "migrate", LatestRun: nil}}, nil + }, + } + docker := &fakeDockerAPIClient{ + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + t.Fatal("ContainerLogs must not be called when the job never ran") + return nil, nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"migrate"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `job "migrate" has never run`) +} + +func TestNewLogsCommandNoLogsAvailableError(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-1", ContainerGone: true}, + }}, nil + }, + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{{ID: "run-1", ContainerGone: true}}}, nil + }, + } + docker := &fakeDockerAPIClient{ + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + t.Fatal("ContainerLogs must not be called when no run has a container") + return nil, nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `no logs available for job "backup"`) +} + +func TestNewLogsCommandUnimplementedIsActionable(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(&fakeDockerAPIClient{}) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewLogsCommandStreamsContainerOutput(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-1", ContainerID: "abc123"}, + }}, nil + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done\n"), nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done\n")) + assert.Check(t, is.Equal(cli.ErrBuffer().String(), "")) +} + +func TestNewLogsCommandNotesFallbackToOlderRun(t *testing.T) { + testCases := []struct { + doc string + latest jobsv0.Run + wantNoteOn []string // substrings expected on stderr; none means stderr stays empty + }{ + {doc: "latest run has logs", latest: jobsv0.Run{ID: "run-2", ContainerID: "def456"}}, + {doc: "latest run's container is gone", latest: jobsv0.Run{ID: "run-2", ContainerGone: true}, wantNoteOn: []string{"run-1", "run-2"}}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{Name: "backup", LatestRun: &tc.latest}}, nil + }, + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{tc.latest, {ID: "run-1", ContainerID: "abc123"}}}, nil + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done"), nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done"), "the note must not pollute stdout") + if len(tc.wantNoteOn) == 0 { + assert.Check(t, is.Equal(cli.ErrBuffer().String(), "")) + } + for _, want := range tc.wantNoteOn { + assert.Check(t, is.Contains(cli.ErrBuffer().String(), want)) + } + }) + } +} diff --git a/vendor.mod b/vendor.mod index 4bb31bb6438b..f8329d7774cc 100644 --- a/vendor.mod +++ b/vendor.mod @@ -32,9 +32,11 @@ require ( github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.6.0 github.com/mattn/go-runewidth v0.0.31 + github.com/moby/extensions v0.0.0-20261120190433-fb779cf107cd github.com/moby/go-archive v0.3.3 github.com/moby/moby/api v1.57.0 github.com/moby/moby/client v0.6.3 + github.com/moby/moby/extpoints v0.0.0-20261204092146-b33fe34839ba github.com/moby/patternmatcher v0.6.1 github.com/moby/swarmkit/v2 v2.1.3 github.com/moby/sys/atomicwriter v0.1.0 @@ -65,6 +67,7 @@ require ( golang.org/x/sys v0.50.0 golang.org/x/term v0.48.0 golang.org/x/text v0.44.0 + google.golang.org/grpc v1.85.0 gotest.tools/v3 v3.5.2 tags.cncf.io/container-device-interface v1.1.2 ) @@ -85,7 +88,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/gorilla/mux v1.8.1 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.31.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/klauspost/compress v1.20.2 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect @@ -101,12 +104,11 @@ require ( go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect go.opentelemetry.io/otel/log v1.47.0 // indirect - go.opentelemetry.io/proto/otlp v1.11.0 // indirect + go.opentelemetry.io/proto/otlp v1.11.1 // indirect golang.org/x/mod v0.43.0 // indirect golang.org/x/net v0.63.0 // indirect golang.org/x/time v0.16.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc // indirect - google.golang.org/grpc v1.83.2 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect google.golang.org/protobuf v1.36.12 // indirect ) diff --git a/vendor.sum b/vendor.sum index 2c5c9957c17e..f9f17b6b25fb 100644 --- a/vendor.sum +++ b/vendor.sum @@ -72,8 +72,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 h1:/Tnpcb2E0Pz/tN9s3bfEY2Q8ePCEX9iuS+cneUwncnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0/go.mod h1:zOBXOsUaBSjKgmH4OGzV1esUpR3oUSCPYVd2cUBjKYY= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.31.0 h1:Bd7KaOxzULLxtZ/K5s1aLbWhR0+5RToO65TXHsf3bqQ= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.31.0/go.mod h1:nN7ts3dFXKtCZWc//yfkpcQNKJABg16/uDVAZpLDalo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -86,12 +86,16 @@ github.com/mattn/go-runewidth v0.0.31 h1:1oCV4ReTlosDBc6rYRw5cL8S/4y8iv5oRl4SJ5I github.com/mattn/go-runewidth v0.0.31/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/extensions v0.0.0-20261120190433-fb779cf107cd h1:voCyJ2uEbRhz9AAoyaRaqiJJA4CsUioM/H3N6NiZuTc= +github.com/moby/extensions v0.0.0-20261120190433-fb779cf107cd/go.mod h1:5OTGReLaEAAQ0XoeIQzL6Ep+J3kwlFVTRSP86RwVoso= github.com/moby/go-archive v0.3.3 h1:OxxR9paxsluYi+zDUEXTTaIxtkK3viymW+Ka7vRhhME= github.com/moby/go-archive v0.3.3/go.mod h1:Npdv43fFqlhZW7Xo8fbm3ZMYFvAGNviUPqX21VERbcE= github.com/moby/moby/api v1.57.0 h1:K2ykv5UZjwFCtmtL486T+SUEVrQ46w3v7isf214RCcw= github.com/moby/moby/api v1.57.0/go.mod h1:pRZ1QRtx6AVhdckeFYo4DUX4ASNF0SCllhyY6aj2mgg= github.com/moby/moby/client v0.6.3 h1:XJn2T8YdXBdMgQl7JrOx09NEBuzIpVXcsN2KDHufAKY= github.com/moby/moby/client v0.6.3/go.mod h1:7CXNAnAhcwwqjwjXqLembJczRorLfM+5mu0d5363lCc= +github.com/moby/moby/extpoints v0.0.0-20261204092146-b33fe34839ba h1:0bK6tiU/0aiFuJu+qEYBI1073IqV9HQzGEfr++dSSOk= +github.com/moby/moby/extpoints v0.0.0-20261204092146-b33fe34839ba/go.mod h1:5p9N98dZWv9RjYByb1dZiNkIaurJrRZ/BUO3NixFV8c= github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/swarmkit/v2 v2.1.3 h1:UcwtwkIRjr75qSgUWCTIuzKUzAXlidxsiqVMnyxSF1w= @@ -177,8 +181,8 @@ go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= -go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk= -go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E= +go.opentelemetry.io/proto/otlp v1.11.1 h1:SCrPqH9NE5CmBrOqpjNCiT0X5mGwMyGERXdogfR7Yjw= +go.opentelemetry.io/proto/otlp v1.11.1/go.mod h1:wq8W4aSf6bOy8RZyESOeQFr9Pu7wydWX/TY4sgvrTPg= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= @@ -228,10 +232,10 @@ gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc h1:rZHRz0ogq4Pid1IKtA/ivHi8XONVF5tqUQXA2TtgpkE= google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc/go.mod h1:K/n0XLazCJHjD73YuMyNJsN38BPPy1kfFnKxUXaThFU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc h1:4bNTbnb44EqGVy9HaQxSY2jnafSUdgV3qHtedvNpDKg= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= -google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= -google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 h1:QG6hS4zFplRZvOQedzei4t2pT/zkQc3VR1u+S9/rcAw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= +google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/BUILD.bazel b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/BUILD.bazel index 04b4bebf3d55..3964ec00aab7 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/BUILD.bazel +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/BUILD.bazel @@ -38,6 +38,7 @@ go_library( "@org_golang_google_protobuf//reflect/protoreflect", "@org_golang_google_protobuf//reflect/protoregistry", "@org_golang_google_protobuf//types/known/durationpb", + "@org_golang_google_protobuf//types/known/emptypb", "@org_golang_google_protobuf//types/known/fieldmaskpb", "@org_golang_google_protobuf//types/known/structpb", "@org_golang_google_protobuf//types/known/timestamppb", @@ -49,6 +50,7 @@ go_test( name = "runtime_test", size = "small", srcs = [ + "context_internal_test.go", "context_test.go", "convert_test.go", "errors_test.go", diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go index 00b2228a1de5..5d0c91d330c5 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "fmt" + "math" "net" "net/http" "net/textproto" @@ -157,7 +158,7 @@ func annotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcM for _, val := range vals { // For backwards-compatibility, pass through 'authorization' header with no prefix. - if key == "Authorization" { + if key == "Authorization" && isValidGRPCMetadataTextValue(val) { pairs = append(pairs, "authorization", val) } if h, ok := mux.incomingHeaderMatcher(key); ok { @@ -182,9 +183,9 @@ func annotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcM } } } - if host := req.Header.Get(xForwardedHost); host != "" { + if host := req.Header.Get(xForwardedHost); host != "" && isValidGRPCMetadataTextValue(host) { pairs = append(pairs, strings.ToLower(xForwardedHost), host) - } else if req.Host != "" { + } else if req.Host != "" && isValidGRPCMetadataTextValue(req.Host) { pairs = append(pairs, strings.ToLower(xForwardedHost), req.Host) } @@ -195,7 +196,9 @@ func annotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcM } } if len(xff) > 0 { - pairs = append(pairs, strings.ToLower(xForwardedFor), strings.Join(xff, ", ")) + if value := strings.Join(xff, ", "); isValidGRPCMetadataTextValue(value) { + pairs = append(pairs, strings.ToLower(xForwardedFor), value) + } } if timeout != 0 { @@ -302,10 +305,16 @@ func timeoutDecode(s string) (time.Duration, error) { if !ok { return 0, fmt.Errorf("timeout unit is not recognized: %q", s) } - t, err := strconv.ParseInt(s[:size-1], 10, 64) + t, err := strconv.ParseUint(s[:size-1], 10, 64) if err != nil { return 0, err } + // Guard against overflowing time.Duration, which is an int64 nanosecond + // count: without this a large value wraps to a bogus (often negative) + // deadline instead of the long timeout the client asked for. + if t > uint64(math.MaxInt64)/uint64(d) { + return time.Duration(math.MaxInt64), nil + } return d * time.Duration(t), nil } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/convert.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/convert.go index 2e50082ad116..2bb7c8fa6064 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/convert.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/convert.go @@ -90,7 +90,7 @@ func Float32Slice(val, sep string) ([]float32, error) { // Int64 converts the given string representation of an integer into int64. func Int64(val string) (int64, error) { - return strconv.ParseInt(val, 0, 64) + return strconv.ParseInt(val, 10, 64) } // Int64Slice converts 'val' where individual integers are separated by @@ -110,7 +110,7 @@ func Int64Slice(val, sep string) ([]int64, error) { // Int32 converts the given string representation of an integer into int32. func Int32(val string) (int32, error) { - i, err := strconv.ParseInt(val, 0, 32) + i, err := strconv.ParseInt(val, 10, 32) if err != nil { return 0, err } @@ -134,7 +134,7 @@ func Int32Slice(val, sep string) ([]int32, error) { // Uint64 converts the given string representation of an integer into uint64. func Uint64(val string) (uint64, error) { - return strconv.ParseUint(val, 0, 64) + return strconv.ParseUint(val, 10, 64) } // Uint64Slice converts 'val' where individual integers are separated by @@ -154,7 +154,7 @@ func Uint64Slice(val, sep string) ([]uint64, error) { // Uint32 converts the given string representation of an integer into uint32. func Uint32(val string) (uint32, error) { - i, err := strconv.ParseUint(val, 0, 32) + i, err := strconv.ParseUint(val, 10, 32) if err != nil { return 0, err } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go index 3d07063007d5..43b30f5874ab 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "math" "reflect" "strconv" @@ -311,6 +312,12 @@ func decodeNonProtoField(d *json.Decoder, unmarshaler protojson.UnmarshalOptions // TODO(yugui) Should use proto.StructProperties? return fmt.Errorf("unmarshaling of symbolic enum %q not supported: %T", repr, rv.Interface()) case float64: + // Enum values are int32 on the wire. A fractional or out-of-range + // number would otherwise be silently truncated/wrapped into a bogus + // enum here, unlike protojson which rejects it, so reject it too. + if v != math.Trunc(v) || v < math.MinInt32 || v > math.MaxInt32 { + return fmt.Errorf("%v is not a valid value for enum %T", repr, rv.Interface()) + } rv.Set(reflect.ValueOf(int32(v)).Convert(rv.Type())) return nil default: diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/mux.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/mux.go index 69edf5eff8da..3b4586be19b0 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/mux.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/mux.go @@ -158,7 +158,15 @@ func DefaultHeaderMatcher(key string) (string, bool) { case isPermanentHTTPHeader(key): return MetadataPrefix + key, true case strings.HasPrefix(key, MetadataHeaderPrefix): - return key[len(MetadataHeaderPrefix):], true + mdKey := key[len(MetadataHeaderPrefix):] + // The grpcgateway- namespace is reserved for permanent HTTP headers the + // gateway maps itself, so refuse to forward a Grpc-Metadata- header that + // strips into it. Otherwise Grpc-Metadata-grpcgateway-host lets a client + // inject a value indistinguishable from the gateway-set grpcgateway-host. + if strings.HasPrefix(strings.ToLower(mdKey), MetadataPrefix) { + return "", false + } + return mdKey, true } return "", false } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go index e54507145b66..48cab90f814c 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go @@ -196,6 +196,16 @@ func (p Pattern) MatchAndEscape(components []string, verb string, unescapingMode return nil, ErrNotMatch } end -= p.tailLen + if pos > 0 && pos == end { + // A deep wildcard ("**") is allowed to match zero path segments when it is + // the first thing being matched in the pattern (pos == 0). But once a literal + // or variable segment has already consumed a component, "**" needs the request + // path to continue past that segment — it cannot succeed with nothing left to + // consume at all (though an empty trailing segment, e.g. from a trailing slash, + // still counts as a real component and is fine). + // See https://github.com/grpc-ecosystem/grpc-gateway/issues/5771. + return nil, ErrNotMatch + } c := strings.Join(components[pos:end], "/") if c, err = unescape(c, unescapingMode, true); err != nil { return nil, err diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/query.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/query.go index 8549dfb97afb..4f9221a09468 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/query.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/query.go @@ -16,6 +16,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/emptypb" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" @@ -224,7 +225,7 @@ func parseField(fieldDescriptor protoreflect.FieldDescriptor, value string) (pro // Look for enum by name v := enum.Descriptor().Values().ByName(protoreflect.Name(value)) if v == nil { - i, err := strconv.Atoi(value) + i, err := strconv.ParseInt(value, 10, 32) if err != nil { return protoreflect.Value{}, fmt.Errorf("%q is not a valid value", value) } @@ -370,6 +371,14 @@ func parseMessage(msgDescriptor protoreflect.MessageDescriptor, value string) (p return protoreflect.Value{}, err } msg = &v + case "google.protobuf.Empty": + // An Empty carries nothing, so the only thing the value can say is that the + // field is present. Accept the two spellings of "no content" and reject + // anything else, rather than silently ignoring it. + if value != "" && value != "{}" { + return protoreflect.Value{}, fmt.Errorf("expected an empty value or %q, got %q", "{}", value) + } + msg = &emptypb.Empty{} default: return protoreflect.Value{}, fmt.Errorf("unsupported message type: %q", string(msgDescriptor.FullName())) } diff --git a/vendor/github.com/moby/extensions/.golangci.yml b/vendor/github.com/moby/extensions/.golangci.yml new file mode 100644 index 000000000000..b32d85604ffb --- /dev/null +++ b/vendor/github.com/moby/extensions/.golangci.yml @@ -0,0 +1,25 @@ +version: "2" + +linters: + default: none + enable: + - contextcheck + - copyloopvar + - errcheck + - intrange + - mirror + - perfsprint + - usestdlibvars + - usetesting # Reports uses of functions with replacement inside the testing package. + + settings: + usetesting: + context-background: true + context-todo: true + +issues: + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 diff --git a/vendor/github.com/moby/extensions/LICENSE b/vendor/github.com/moby/extensions/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/vendor/github.com/moby/extensions/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/moby/extensions/Makefile b/vendor/github.com/moby/extensions/Makefile new file mode 100644 index 000000000000..bf5e1f53bb4b --- /dev/null +++ b/vendor/github.com/moby/extensions/Makefile @@ -0,0 +1,68 @@ +GO ?= go +DOCKER ?= docker +LINT_CACHE_VOLUME ?= moby-extensions-lint-cache +LINT_WORKDIR := /workspace + +GO_VERSION ?= $(shell awk '/^go / { print $$2 }' go.mod) +# renovate: depName=github.com/rhysd/actionlint +ACTIONLINT_VERSION ?= v1.7.12 +# renovate: depName=golang.org/x/tools +MODERNIZE_VERSION ?= v0.53.0 +# renovate: depName=github.com/golangci/golangci-lint/v2 +GOLANGCI_LINT_VERSION ?= v2.12.2 +LINT_IMAGE ?= golang:$(GO_VERSION) + +.PHONY: ci +ci: lint validate + +.PHONY: lint +lint: lint-license + @if [ -z "$(GO_VERSION)" ] || \ + [ -z "$(ACTIONLINT_VERSION)" ] || \ + [ -z "$(MODERNIZE_VERSION)" ] || \ + [ -z "$(GOLANGCI_LINT_VERSION)" ]; then \ + echo "lint versions must not be empty" >&2; \ + exit 1; \ + fi + $(DOCKER) run --rm -i \ + --mount "type=bind,source=$(CURDIR),target=$(LINT_WORKDIR),readonly" \ + --mount "type=volume,source=$(LINT_CACHE_VOLUME),target=/root/.cache" \ + --env ACTIONLINT_VERSION=$(ACTIONLINT_VERSION) \ + --env MODERNIZE_VERSION=$(MODERNIZE_VERSION) \ + --env GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) \ + --env GOCACHE=/root/.cache/go-build \ + --env GOMODCACHE=/root/.cache/go-mod \ + --env GOLANGCI_LINT_CACHE=/root/.cache/golangci-lint \ + --env GOFLAGS=-buildvcs=false \ + --env GIT_CONFIG_COUNT=1 \ + --env GIT_CONFIG_KEY_0=safe.directory \ + --env GIT_CONFIG_VALUE_0=$(LINT_WORKDIR) \ + --workdir $(LINT_WORKDIR) \ + $(LINT_IMAGE) \ + make host-lint + +.PHONY: lint-license +lint-license: + bash hack/lint-license.sh + +.PHONY: host-lint +host-lint: lint-generate + $(GO) run github.com/rhysd/actionlint/cmd/actionlint@$(ACTIONLINT_VERSION) + $(GO) run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@$(MODERNIZE_VERSION) ./... + $(GO) run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run ./... + +.PHONY: lint-generate +lint-generate: + GO="$(GO)" bash hack/lint-generate.sh + +.PHONY: validate +validate: + @set -e; \ + files="$$(gofmt -s -l .)"; \ + files="$$(printf '%s\n' "$$files" | sed '/^vendor\//d')"; \ + if [ -n "$$files" ]; then \ + echo "::error::these files are not gofmt-ed:"; \ + echo "$$files"; \ + exit 1; \ + fi + $(GO) vet ./... diff --git a/vendor/github.com/moby/extensions/README.md b/vendor/github.com/moby/extensions/README.md new file mode 100644 index 000000000000..dd320547478f --- /dev/null +++ b/vendor/github.com/moby/extensions/README.md @@ -0,0 +1,163 @@ +# Extensions + +> [!WARNING] +> This project is still a work in progress. + +Moby extensions provide a common model for extending engine behavior. +They are intended to replace the separate plugin systems currently used by network, volume, and logging drivers. + +An extension can run inside the Host process or as a separate process. +In both cases, it implements the same Go interface. + +See the [authoring guide](./docs/AUTHORING.md) for examples and setup instructions. +For details about the architecture, wire protocol, current limitations, and discovery security, see the [design guide](./docs/DESIGN.md). + +## How it works + +Extensions are built around Points. +A Point is an interface that describes a capability, such as running a workload. +Providers implement Points, and consumers call them. +The Host registers these components, connects consumers to providers, and manages their lifecycle. + +For example, a daemon can expose its workload runtime as a Point. +An extension can then use that capability without depending on the daemon's internal runtime implementation. +The same mechanism is used for daemon-owned capabilities and communication between extensions. + +To add an extension: + +1. **Define the contract.** + + A Point assigns a namespaced, versioned identity to a Go interface and its message types. + +2. **Declare what the extension provides and depends on.** + + Providers implement Points. + Consumers declare their dependencies using `Point.Dependency()`. + +3. **Register the extension with the Host.** + + The daemon or application decides which extensions to load and supplies any generated wiring required for cross-process calls. + Merely importing an extension package does not activate it. + +4. **Resolve dependencies during initialization.** + + In `Declaration.Init`, consumers resolve their declared dependencies using `Point.Single`, `Point.All`, or `Point.ByExtension`. + The resolved implementation is not automatically assigned to a field. + +5. **Call the Point interface.** + + Consumers retain and call the resolved interface rather than a concrete Host or daemon type. + Calls go directly to an in-process provider or through generated gRPC code when the provider runs in another process. + +The Host initializes providers before their consumers and shuts them down in the opposite order. +A provider must be ready for use when its `Init` method returns. + +Keep the Host returned by `host.New` and call `Shutdown` when the application exits so that lifecycle resources are released. + +Breaking changes require a new Point version. +The `.v0` suffix identifies an experimental contract. +For fan-out calls, provider order is unspecified unless the Point defines its own ordering rules. + +## Running extensions + +A Point defines an interface, not where its implementation runs. +In-process consumers call the Go implementation directly. +Cross-process consumers use generated gRPC wiring. + +Because the same contract may cross a process boundary, Point interfaces and messages should not contain Host types, internal backend structures, callbacks, or channels. + +The `mobyextgen` generator creates the required wire code: + +* `ServerPoint` exposes a Point implementation over gRPC. +* `ClientPoint` presents the remote implementation through the same typed Go interface. + +The exact setup depends on where the consumer and provider run: + +* Register in-process extensions with `host.WithExtensions`. +* When the Host calls a provider in a launched process, configure the Host with `host.WithClientProviders` and the generated `ClientPoint`. + The provider registers its generated `ServerPoint` with the SDK. +* When a launched consumer calls a Host provider, configure the Host with `host.WithDependencyProviders` and the generated `ServerPoint`. + In the consumer, pass the generated `ClientPoint` to `Server.Depends`. + +The last case exposes an existing Host provider to the launched process. +The consumer must still declare the dependency itself. + +A dependency callback currently exposes one effective provider for each Point. +Do not retain and call that dependency during `Shutdown`, because the SDK closes the connection before shutdown begins. + +For launched processes, the `ready\n` handshake only confirms that the listener is ready. +It does not mean that the extension's `Init` method has completed. + +See the [authoring guide](./docs/AUTHORING.md) for complete examples covering code generation, SDK registration, dependency resolution, and deployment. + +## Publishing services + +Implementing a Point makes it available within the extension system, but does not automatically expose it to external callers. + +Publishing a Point requires three things: + +* The extension offers it using `servicev0.Offer`. +* Host policy permits it through `host.WithProviderPolicy`. +* The generated server wiring is registered. + +For an in-process provider, supply the server wiring through `host.WithPointServers`. +A provider running in a separate process registers its `ServerPoint` with the SDK. + +An offer is only a request to publish a Point; it does not grant access or register the transport. +If no provider policy is configured, external publication is disabled, while providers remain available to internal consumers. + +Published services are responsible for enforcing their own access control. + +See the [publication examples](./docs/AUTHORING.md#publishing-an-ordinary-point) for complete configurations and generated client usage. + +## Glossary + +### Point + +A named and versioned Go interface, together with its message types. +It describes a capability independently of its implementation or location. + +### Extension + +A component that can provide Points, depend on other Points or extensions, and perform initialization and shutdown work. +It may run inside the Host or in a separate process. + +### Host + +The framework component embedded in a daemon or application. +It registers extensions, resolves their dependencies, and manages their lifecycle. + +### Provider + +An extension that implements a Point. + +### Consumer + +Code that resolves and calls a Point. +An extension may be both a consumer and a provider. + +### Dependency + +A declared requirement for a Point provider or another extension. +The Host uses dependencies to verify that requirements are available and to determine initialization order. + +### Host capability + +Functionality owned by the daemon or application and exposed as a Point through an in-process extension. + +### ClientPoint / ServerPoint + +Generated code used to call a Point across a process boundary. +`ClientPoint` presents the Point's Go interface to the consumer, while `ServerPoint` forwards incoming calls to the implementation. + +### Offer + +A request from an extension to make one or more of its Points available to external callers. + +### Publication + +The Host exposing an offered Point to external callers after applying its policy and registering the required server wiring. + +## License + +Licensed under the [Apache License, Version 2.0](LICENSE). diff --git a/vendor/github.com/moby/extensions/client/client.go b/vendor/github.com/moby/extensions/client/client.go new file mode 100644 index 000000000000..78b1082c36ab --- /dev/null +++ b/vendor/github.com/moby/extensions/client/client.go @@ -0,0 +1,229 @@ +// SPDX-FileCopyrightText: Copyright The Moby Authors +// SPDX-License-Identifier: Apache-2.0 + +// Package client provides typed, lazy clients for extension points. +// +// Generated wire bindings expose a ClientPoint registration containing the +// runtime gRPC adapter factory. +// A handwritten extensions.Point supplies the compile-time result type used by +// Resolve. +// Each Client owns a separate lazy connection derived from an Engine dialer. +// Resolve only constructs a local proxy, so unavailable or unpublished services +// report errors when a resolved method is invoked rather than during Resolve. +// +// A generated greeter binding can be configured and resolved as follows: +// +// extensions, err := client.New( +// engine, +// client.WithGRPCPoint(greeterpb.ClientPoint), +// ) +// if err != nil { +// return err +// } +// defer extensions.Close() +// +// greeter, err := client.Resolve(extensions, greeterv0.Point) +// if err != nil { +// return err +// } +// +// reply, err := greeter.Greet( +// ctx, +// &greeterv0.HelloRequest{Name: "world"}, +// ) +package client + +import ( + "context" + "errors" + "fmt" + "net" + "reflect" + "sync" + + "github.com/moby/extensions" + "github.com/moby/extensions/clientpoint" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +const engineTarget = "passthrough:///moby-engine" + +// Engine supplies the engine connection dialer used by a Client. +// +// The dialer is kept lazy by the client and is invoked by gRPC only when the +// client is used. +type Engine interface { + Dialer() func(context.Context) (net.Conn, error) +} + +// Opt configures a Client. +type Opt func(*config) error + +type config struct { + points map[extensions.PointID]clientpoint.Registration +} + +// WithGRPCPoint configures the generated ClientPoint registration for a point. +// Generated wire packages expose ClientPoint as the host-side gRPC wiring; +// Resolve receives the handwritten typed extensions.Point separately so its Go +// interface type remains available to the caller. +// Registration.Single is host cardinality metadata and is intentionally ignored +// by this client. +func WithGRPCPoint(registration clientpoint.Registration) Opt { + return func(cfg *config) error { + if cfg == nil { + return errors.New("client: nil configuration") + } + if err := extensions.ValidatePointID(registration.Point); err != nil { + return fmt.Errorf("client: invalid gRPC point registration: %w", err) + } + if registration.Provider == nil { + return fmt.Errorf("client: point %q has nil provider", registration.Point) + } + if cfg.points == nil { + cfg.points = make(map[extensions.PointID]clientpoint.Registration) + } + if _, exists := cfg.points[registration.Point]; exists { + return fmt.Errorf("client: duplicate gRPC point registration for point %q", registration.Point) + } + cfg.points[registration.Point] = registration + return nil + } +} + +type pointState struct { + registration clientpoint.Registration + provider extensions.Provider + ready bool +} + +// Client owns one lazy gRPC connection to the engine and the configured point +// adapters. The connection is private to the Client and is never borrowed from +// or closed by the Engine. +type Client struct { + mu sync.Mutex + conn *grpc.ClientConn + points map[extensions.PointID]*pointState + closed bool + closeErr error +} + +// New creates a Client without dialing the engine. +// +// The connection is separately owned by the returned Client and remains lazy; +// availability errors therefore occur when a resolved provider is invoked, not +// during construction. New performs no speculative transport connection or +// preflight. +func New(engine Engine, opts ...Opt) (*Client, error) { + if isNil(engine) { + return nil, errors.New("client: engine is nil") + } + + cfg := config{points: make(map[extensions.PointID]clientpoint.Registration)} + for _, opt := range opts { + if opt == nil { + return nil, errors.New("client: nil option") + } + if err := opt(&cfg); err != nil { + return nil, err + } + } + dialer := engine.Dialer() + if dialer == nil { + return nil, errors.New("client: engine dialer is nil") + } + + conn, err := grpc.NewClient( + engineTarget, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) { + return dialer(ctx) + }), + ) + if err != nil { + return nil, fmt.Errorf("client: create gRPC client: %w", err) + } + + points := make(map[extensions.PointID]*pointState, len(cfg.points)) + for point, registration := range cfg.points { + points[point] = &pointState{registration: registration} + } + return &Client{conn: conn, points: points}, nil +} + +// Resolve returns the typed provider registered for point. +// +// The generated ClientPoint registration and handwritten extensions.Point are +// intentionally separate: ClientPoint supplies the gRPC adapter, while point +// supplies the compile-time provider interface type. The adapter is invoked at +// most once and only when this point is first resolved. Provider construction +// does not preflight the engine, so transport availability errors are returned +// by the provider's method invocation. +func Resolve[T any](client *Client, point extensions.Point[T]) (T, error) { + var zero T + if client == nil { + return zero, errors.New("client: client is nil") + } + + pointID := point.ID() + client.mu.Lock() + defer client.mu.Unlock() + + if client.closed { + return zero, errors.New("client: client is closed") + } + state, configured := client.points[pointID] + if !configured { + return zero, fmt.Errorf("client: point %q is not configured", pointID) + } + if !state.ready { + state.ready = true + state.provider = state.registration.Provider(client.conn) + } + + provider := state.provider + if provider.Point != pointID { + return zero, fmt.Errorf("client: provider point %q does not match requested point %q", provider.Point, pointID) + } + impl, ok := provider.Impl.(T) + if !ok { + return zero, fmt.Errorf("client: provider for point %q has implementation type %T, want %v", pointID, provider.Impl, reflect.TypeFor[T]()) + } + return impl, nil +} + +// Close closes the Client's private gRPC connection. +// +// Close is nil-safe and idempotent. It waits for an in-progress Resolve before +// closing, and later Resolve calls fail without invoking another adapter. +func (client *Client) Close() error { + if client == nil { + return nil + } + + client.mu.Lock() + defer client.mu.Unlock() + if client.closed { + return client.closeErr + } + client.closed = true + if client.conn == nil { + return nil + } + client.closeErr = client.conn.Close() + return client.closeErr +} + +func isNil(value any) bool { + if value == nil { + return true + } + v := reflect.ValueOf(value) + switch v.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice: + return v.IsNil() + default: + return false + } +} diff --git a/vendor/github.com/moby/extensions/clientpoint/clientpoint.go b/vendor/github.com/moby/extensions/clientpoint/clientpoint.go new file mode 100644 index 000000000000..7ea34d65534d --- /dev/null +++ b/vendor/github.com/moby/extensions/clientpoint/clientpoint.go @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: Copyright The Moby Authors +// SPDX-License-Identifier: Apache-2.0 + +// Package clientpoint defines the host-side registration for generated +// out-of-process point providers. It has no dependency on the host runtime so +// generated code can reference it. +package clientpoint + +import ( + "github.com/moby/extensions" + "google.golang.org/grpc" +) + +// Provider builds an in-broker provider from a gRPC connection. +type Provider func(grpc.ClientConnInterface) extensions.Provider + +// Registration pairs a point id with its client provider. Single records the +// contract's one-provider cardinality. +type Registration struct { + Point extensions.PointID + Provider Provider + Single bool +} diff --git a/vendor/github.com/moby/extensions/core.go b/vendor/github.com/moby/extensions/core.go new file mode 100644 index 000000000000..39af0b085310 --- /dev/null +++ b/vendor/github.com/moby/extensions/core.go @@ -0,0 +1,336 @@ +// SPDX-FileCopyrightText: Copyright The Moby Authors +// SPDX-License-Identifier: Apache-2.0 + +package extensions + +import ( + "context" + "errors" + "fmt" + "regexp" + "strings" + "sync" +) + +// ExtensionID identifies a deployable extension. +type ExtensionID string + +// ExtensionOriginKind identifies how the host obtained an extension. +type ExtensionOriginKind string + +const ( + // ExtensionOriginBuiltin identifies an extension compiled into the host. + ExtensionOriginBuiltin ExtensionOriginKind = "builtin" + // ExtensionOriginExecutable identifies an extension launched as an + // executable. + ExtensionOriginExecutable ExtensionOriginKind = "executable" +) + +// ExtensionOrigin identifies how the host obtained an extension and its +// kind-specific attested details. +type ExtensionOrigin struct { + Kind ExtensionOriginKind + Executable *ExecutableOrigin +} + +// ExecutableOrigin contains host-attested details for an executable origin. +type ExecutableOrigin struct { + // Path is the exact path the host executed, as discovered from the + // extension directory. It is not normalized: a relative directory or a + // symlink yields that relative or symlink path. + Path string +} + +// ExtensionIdentity is the host-attested identity of an extension. +// The extension declares ID, but the host supplies and validates the complete +// identity, including Origin. +type ExtensionIdentity struct { + ID ExtensionID + Origin ExtensionOrigin +} + +// ValidateExtensionIdentity returns an error unless identity contains a valid +// extension ID and a recognized host-attested origin. +func ValidateExtensionIdentity(identity ExtensionIdentity) error { + if err := ValidateExtensionID(identity.ID); err != nil { + return err + } + switch identity.Origin.Kind { + case "": + return errors.New("extension origin kind is required") + case ExtensionOriginBuiltin: + if identity.Origin.Executable != nil { + return errors.New("builtin extension origin must not include executable payload") + } + case ExtensionOriginExecutable: + if identity.Origin.Executable == nil { + return errors.New("executable extension origin requires executable payload") + } + if identity.Origin.Executable.Path == "" { + return errors.New("executable origin path is required") + } + default: + return fmt.Errorf("invalid extension origin kind %q: want %q or %q", identity.Origin.Kind, ExtensionOriginBuiltin, ExtensionOriginExecutable) + } + return nil +} + +// PointID identifies an extension point contract. +type PointID string + +// IsMetadataPoint reports whether point carries framework metadata rather than +// a callable capability. +// Host provider admission skips metadata points; the servicev0 marker controls +// publication. +// Currently the servicev0 offer marker is the only metadata point; its package +// tests keep this ID in sync with the point definition. +func IsMetadataPoint(point PointID) bool { + return point == "org.mobyproject.extension.service.v0" +} + +// Name returns the point's short name, the segment before its version. +func (id PointID) Name() string { + segments := strings.Split(string(id), ".") + if len(segments) < 2 { + return string(id) + } + return segments[len(segments)-2] +} + +// pointIDPattern requires a lowercase reverse-DNS-style id ending in a vN +// version. Segments may contain digits, hyphens, and underscores. +var pointIDPattern = lazyRegexp(`^[a-z][a-z0-9]*(\.[a-z0-9_-]+)+\.v[0-9]+$`) + +// ValidatePointID reports whether id is a well-formed, versioned Point ID. +func ValidatePointID(id PointID) error { + if id == "" { + return errors.New("point id is required") + } + if !pointIDPattern().MatchString(string(id)) { + return fmt.Errorf("invalid point id %q: want a versioned reverse-DNS name like org.example.api.v1", id) + } + return nil +} + +// extensionIDPattern requires a lowercase reverse-DNS name with a mandatory vN +// version. The version is a namespace element, not a semantic version: changing +// com.foo.v1 to com.foo.v2 creates a new extension, binary, and configuration. +// The restricted characters also make the id safe as a config key and filename. +var extensionIDPattern = lazyRegexp(`^[a-z0-9]+(-[a-z0-9]+)*(\.[a-z0-9]+(-[a-z0-9]+)*)+\.v[0-9]+$`) + +// ValidateExtensionID reports whether id is well-formed before it is used as a +// configuration key or binary name. +func ValidateExtensionID(id ExtensionID) error { + if id == "" { + return errors.New("extension id is required") + } + if !extensionIDPattern().MatchString(string(id)) { + return fmt.Errorf("invalid extension id %q: want a versioned reverse-DNS name like org.example.myext.v1, lowercase, no path-hostile characters", id) + } + return nil +} + +func lazyRegexp(pattern string) func() *regexp.Regexp { + return sync.OnceValue(func() *regexp.Regexp { + re, err := regexp.Compile(pattern) + if err != nil { + panic(err) + } + return re + }) +} + +// Dependency declares one extension dependency. +type Dependency struct { + Point PointID + Extension ExtensionID + Optional bool +} + +// Provider declares an in-process implementation for a point. +type Provider struct { + Point PointID + Impl any +} + +// ResolvedProvider is a provider returned from a lookup with its host-attested +// extension identity. +type ResolvedProvider struct { + Identity ExtensionIdentity + Impl any +} + +// EffectiveProviders applies origin precedence for single-provider resolution. +// Built-ins are used only when no executable provider exists. +// Fan-out and by-id lookups do not apply this precedence. +func EffectiveProviders(providers []ResolvedProvider) []ResolvedProvider { + var executables, builtins []ResolvedProvider + for _, p := range providers { + if p.Identity.Origin.Kind == ExtensionOriginBuiltin { + builtins = append(builtins, p) + } else { + executables = append(executables, p) + } + } + if len(executables) == 0 { + return builtins + } + return executables +} + +// TypedProvider is a provider returned through a typed point handle. +type TypedProvider[T any] struct { + Identity ExtensionIdentity + Impl T +} + +// Point binds a point ID to the Go interface implemented by its providers. +type Point[T any] struct { + id PointID +} + +// DefinePoint binds id to provider interface T and panics for an invalid point +// id. Point ids are fixed in source, so invalid ids are programming errors. +func DefinePoint[T any](id PointID) Point[T] { + if ValidatePointID(id) != nil { + panic(fmt.Sprintf("extensions: invalid point id %q: want ....vN, e.g. org.mobyproject.extension.volume.driver.v1", id)) + } + return Point[T]{id: id} +} + +// DefineSinglePoint declares a point with one deciding provider instead of a +// fan-out. The wire generator carries this cardinality into ClientPoint so the +// host can reject multiple executable providers at startup. +func DefineSinglePoint[T any](id PointID) Point[T] { + return DefinePoint[T](id) +} + +// ID returns the point identifier. +func (p Point[T]) ID() PointID { + return p.id +} + +// Provide returns a provider declaration for impl. +func (p Point[T]) Provide(impl T) Provider { + return Provider{Point: p.id, Impl: impl} +} + +// Dependency returns a required dependency declaration for the point: at least +// one provider must exist before the dependent initializes. +func (p Point[T]) Dependency() Dependency { + return Dependency{Point: p.id} +} + +// OptionalDependency returns an optional dependency declaration for the point: +// the dependent still initializes, ordered after any providers, when none exist. +func (p Point[T]) OptionalDependency() Dependency { + return Dependency{Point: p.id, Optional: true} +} + +// ByExtension returns the point provider implemented by extension. +func (p Point[T]) ByExtension(r Resolver, extension ExtensionID) (T, error) { + provider, err := r.Provider(p.id, extension) + if err != nil { + var zero T + return zero, err + } + return typedProvider[T](p.id, extension, provider) +} + +// Single returns the only point provider, after origin precedence +// ([EffectiveProviders]): a built-in provider does not count against the +// one-provider limit, it stands in when no executable provider exists. +func (p Point[T]) Single(r Resolver) (T, error) { + providers := EffectiveProviders(r.Providers(p.id)) + var zero T + switch len(providers) { + case 0: + return zero, fmt.Errorf("point %q has no providers", p.id) + case 1: + return typedProvider[T](p.id, providers[0].Identity.ID, providers[0].Impl) + default: + return zero, fmt.Errorf("point %q has multiple providers", p.id) + } +} + +// Enabled reports whether any extension provides the point. +func (p Point[T]) Enabled(r Resolver) bool { + return len(r.Providers(p.id)) > 0 +} + +// All returns all point providers, including built-in and executable providers. +func (p Point[T]) All(r Resolver) ([]TypedProvider[T], error) { + providers := r.Providers(p.id) + typed := make([]TypedProvider[T], 0, len(providers)) + for _, provider := range providers { + impl, err := typedProvider[T](p.id, provider.Identity.ID, provider.Impl) + if err != nil { + return nil, err + } + typed = append(typed, TypedProvider[T]{Identity: provider.Identity, Impl: impl}) + } + return typed, nil +} + +func typedProvider[T any](point PointID, extension ExtensionID, provider any) (T, error) { + typed, ok := provider.(T) + if ok { + return typed, nil + } + var zero T + if extension == "" { + return zero, fmt.Errorf("point %q provider has type %T", point, provider) + } + return zero, fmt.Errorf("extension %q provider for point %q has type %T", extension, point, provider) +} + +// Resolver exposes provider lookup to extension initializers. Selection and +// cardinality are handled by the typed [Point] accessors. +type Resolver interface { + Provider(PointID, ExtensionID) (any, error) + Providers(PointID) []ResolvedProvider +} + +// Registrar registers extensions. +type Registrar interface { + Register(Extension) error +} + +// RegisterAll registers exts with registrar. +func RegisterAll(registrar Registrar, exts ...Extension) error { + for _, ext := range exts { + if err := registrar.Register(ext); err != nil { + return err + } + } + return nil +} + +// Config is parsed per-extension configuration delivered by id to Init or the +// out-of-process startup handshake. +type Config = map[string]any + +// Extension is a host-managed extension declaration. +type Extension interface { + // Declaration returns the extension's id, providers, dependencies, and + // conflicts, plus its optional Init and Shutdown. + Declaration() Declaration +} + +// Declaration declares an extension, its providers and dependencies, and its +// optional lifecycle callbacks. +type Declaration struct { + ID ExtensionID + Providers []Provider + Dependencies []Dependency + Conflicts []ExtensionID + Init func(context.Context, Config, Resolver) error + Shutdown func(context.Context) error +} + +// New wraps a static Declaration as an [Extension]. +func New(d Declaration) Extension { return staticExtension{d} } + +type staticExtension struct{ decl Declaration } + +func (e staticExtension) Declaration() Declaration { return e.decl } diff --git a/vendor/github.com/moby/extensions/fanout.go b/vendor/github.com/moby/extensions/fanout.go new file mode 100644 index 000000000000..6cdb69cfa6eb --- /dev/null +++ b/vendor/github.com/moby/extensions/fanout.go @@ -0,0 +1,99 @@ +// SPDX-FileCopyrightText: Copyright The Moby Authors +// SPDX-License-Identifier: Apache-2.0 + +package extensions + +import ( + "context" + "fmt" + "time" + + "github.com/containerd/log" +) + +// Policy controls provider deadlines and error handling for [Each] and [Fold]. +type Policy struct { + // Timeout bounds each provider call independently. Zero leaves the calls + // bounded only by the caller's context. + // + // It is enforced for out-of-process providers, which receive the deadline + // over gRPC. An in-process provider is passed the same context but only + // trusted to honor it: abandoning a direct Go call would leave the provider + // mutating shared engine state after the caller moved on. State a + // fail-closed point's guarantee accordingly. + Timeout time.Duration + + // FailOpen continues with the remaining providers when one returns an error. + // Veto points should leave it false. + FailOpen bool + + // Action names what the provider's error did to the operation, for the + // wrapped error: ` provider "" : `. Leave it empty + // for a plain failure. + Action string +} + +// wrap attributes err to the extension that produced it. +func (p Policy) wrap(point PointID, extension ExtensionID, err error) error { + if p.Action == "" { + return fmt.Errorf("%s provider %q: %w", point.Name(), extension, err) + } + return fmt.Errorf("%s provider %q %s: %w", point.Name(), extension, p.Action, err) +} + +// Each calls fn once per provider of p under policy. Use it for validation, +// veto, or notification points. +// +// Fan-out order is unspecified. A point that needs a defined order must define +// it (see the guidance in the extensions authoring guide). +func Each[T any](ctx context.Context, p Point[T], r Resolver, policy Policy, fn func(context.Context, T) error) error { + _, err := Fold(ctx, p, r, policy, struct{}{}, func(ctx context.Context, impl T, _ struct{}) (struct{}, error) { + return struct{}{}, fn(ctx, impl) + }) + return err +} + +// Fold threads acc through every provider of p and returns the final value under +// policy. Each provider sees the value produced by its predecessors. +// +// A provider that fails under a fail-closed policy aborts the fold and its +// partial value is discarded; under a fail-open one its contribution is dropped +// and the fold continues from the value it was given. +func Fold[T, A any](ctx context.Context, p Point[T], r Resolver, policy Policy, acc A, fn func(context.Context, T, A) (A, error)) (A, error) { + providers, err := p.All(r) + if err != nil { + return acc, err + } + for _, provider := range providers { + next, err := callProvider(ctx, p.id, policy, provider, acc, fn) + if err != nil { + if !policy.FailOpen { + // Discard the partial value rather than hand back a half-applied + // one: for a composing point such as the create-spec hook that + // would be an OCI spec carrying some providers' changes but not + // the rest, which is worse than no answer. + var zero A + return zero, err + } + log.G(ctx).WithError(err).Warn("extensions: skipping failed provider") + continue + } + acc = next + } + return acc, nil +} + +// callProvider gives each provider its own timeout and releases it when the +// call returns. +func callProvider[T, A any](ctx context.Context, point PointID, policy Policy, provider TypedProvider[T], acc A, fn func(context.Context, T, A) (A, error)) (A, error) { + if policy.Timeout > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, policy.Timeout) + defer cancel() + } + next, err := fn(ctx, provider.Impl, acc) + if err != nil { + return acc, policy.wrap(point, provider.Identity.ID, err) + } + return next, nil +} diff --git a/vendor/github.com/moby/extensions/serverpoint/serverpoint.go b/vendor/github.com/moby/extensions/serverpoint/serverpoint.go new file mode 100644 index 000000000000..8a16f9abfa34 --- /dev/null +++ b/vendor/github.com/moby/extensions/serverpoint/serverpoint.go @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: Copyright The Moby Authors +// SPDX-License-Identifier: Apache-2.0 + +// Package serverpoint defines the SDK-side registration for generated +// out-of-process point providers. It has no dependency on the SDK server so +// generated code can reference it. +package serverpoint + +import ( + "github.com/moby/extensions" + "google.golang.org/grpc" +) + +// Register registers a point's gRPC service on r. +type Register func(r grpc.ServiceRegistrar, impl any) + +// Registration pairs a point id with its server registration. +type Registration struct { + Point extensions.PointID + Register Register +} diff --git a/vendor/github.com/moby/moby/extpoints/LICENSE b/vendor/github.com/moby/moby/extpoints/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/vendor/github.com/moby/moby/extpoints/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/moby/moby/extpoints/jobs/api/v0/README.md b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/README.md new file mode 100644 index 000000000000..4a7eaa9fa823 --- /dev/null +++ b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/README.md @@ -0,0 +1,86 @@ +# Jobs API + +Jobs are one-shot workloads managed by the daemon. +A job is a container spec plus a trigger declaration, and every execution is a run with a durable identity that survives container removal and daemon restarts. +Jobs fire manually or on a cron schedule evaluated by the daemon, so scheduled work keeps firing while no client is connected. + +The builtin `org.mobyproject.jobs.v0` extension provides this point and offers it for publication, so the daemon serves it as a gRPC service on its socket. +The API is experimental and may change between releases. +See [jobs.go](jobs.go) for the full contract; [jobs.proto](jobs.proto) is generated from it. + +## Enabling the extension + +The extension ships with the daemon but is disabled by default: + +```console +$ dockerd --extension-enable org.mobyproject.jobs.v0 +``` + +or in `daemon.json`: + +```json +{ + "extensions": { + "enable": ["org.mobyproject.jobs.v0"] + } +} +``` + +When the extension is not enabled, calls fail with `Unimplemented`. +While the daemon is starting, calls fail with `Unavailable` until the extension has reconciled its runs. + +Authorization plugins are not supported yet. +They do not evaluate gRPC calls on the daemon socket, so Jobs API calls bypass them. +The extension also drives run containers through the daemon API anonymously, so a plugin that denies anonymous requests keeps the Jobs API unavailable. +Do not enable the extension on a daemon that relies on authorization plugins. + +## Calling the API + +Go clients resolve the point through the extensions client: + +```go +extensions, err := extensionclient.New(apiClient, extensionclient.WithGRPCPoint(protogen.ClientPoint)) +if err != nil { + return err +} +jobs, err := extensionclient.Resolve(extensions, jobsv0.Point) +``` + +Any gRPC client works, for example grpcurl: + +```console +$ grpcurl -plaintext -unix -proto extpoints/jobs/api/v0/jobs.proto \ + -d '{"name": "backup", "spec": {"container_spec": "eyJJbWFnZSI6ICJidXN5Ym94In0="}}' \ + /var/run/docker.sock org.mobyproject.extension.jobs.api.v0.Jobs/Create +``` + +`container_spec` is a JSON container-create request body; unknown fields are rejected. + +## Semantics + +- `Create` registers a job and arms its trigger without starting a run. + It is idempotent on a canonical spec hash; the same name with a different spec fails with `AlreadyExists`. + Specs are immutable: remove and re-create a job to change it. +- Schedule triggers take five-field cron expressions (numbers, lists, ranges and steps) evaluated in the job's IANA timezone, UTC by default. + Daylight-saving changes follow crontab(5) semantics: a fixed-time schedule whose occurrence falls in a skipped span fires right after the transition and fires only once in a repeated span, while a schedule with a wildcard minute or hour field follows the wall clock. +- When a schedule fires during a run, `forbid` (default) drops the fire and `queue` defers one. + An explicit `Run` on a running job fails with `FailedPrecondition`. +- After daemon downtime, `one` (default) fires a single catch-up run and `skip` drops missed fires. +- The run record is persisted before its container is created, so a failure or crash always leaves a record. + Runs end `succeeded`, `failed`, `timed_out` or `cancelled`, and terminal runs never change. +- Run history is capped per job (10000 by default) and kept when a job is removed, unless the removal asks otherwise. + After removal, use the original job ID with `ListRuns` or `InspectRun` to read retained history, or with `Remove` and `runs_removal: "remove"` to purge it. + Names resolve only to live jobs; `Wait` also requires a live job. + +## Run containers + +Run containers carry the `com.docker.job.id` and `com.docker.job.run-id` labels. +A run container lives as long as its run record: it is removed when history eviction drops the run, or when `Remove` drops the job's runs. +The Jobs API does not proxy logs; read them with the container logs API using the run's `container_id`. +`remove_on_success` and `remove_on_failure` remove the container as soon as the run ends, trading its logs for earlier cleanup; the run record keeps the exit code and error. + +## Restarts + +Jobs and runs persist through the storage point. +On startup the extension reconciles runs left in flight by an unclean stop before re-arming schedules: +a run whose container exited is resolved with its exit code, a still-running container is re-attached, timeouts are re-armed from the original start, and a run whose start was never recorded is failed. diff --git a/vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.go b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.go new file mode 100644 index 000000000000..34145607318c --- /dev/null +++ b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.go @@ -0,0 +1,551 @@ +//go:generate go tool mobyextgen + +// Package jobsv0 defines the extension point through which the jobs extension +// exposes its client-facing API on the daemon socket. +// +// A Job is a daemon-managed resource holding a container spec plus a trigger +// declaration; each execution is a Run with a stable identity that survives +// container removal. Jobs fire manually or on a cron schedule; the daemon +// evaluates schedule triggers on its own clock, so scheduled work keeps firing +// while no client is connected. +// +// Wire-format conventions, constrained by the mobyextgen generator (no enums, +// oneof, or well-known types): +// - enumerations are documented strings (see the *State and policy constants); +// - timestamps are int64 Unix nanoseconds, zero meaning "not set"; +// - the container definition travels as a JSON payload (see JobSpec.ContainerSpec); +// - trigger kinds are mutually exclusive fields on a single message, and a +// trigger declaring no known kind is rejected rather than interpreted +// (see Trigger). +package jobsv0 + +import ( + "context" + + "github.com/moby/extensions" +) + +// Jobs is the jobs service. All methods are unary; blocking semantics +// (Wait) hold the request open until the condition is met. +// +// Errors are returned as gRPC status codes: InvalidArgument for a spec that +// fails validation, NotFound for an unknown job or run, AlreadyExists for a +// Create whose name is taken by a different spec (the message mentions both +// spec hashes for diagnostics only; the code is the contract), and +// FailedPrecondition for an execution refused by the concurrency policy. +type Jobs interface { + // Create registers a job without ever starting a run. It is idempotent on + // the spec hash: re-submitting the same name+spec is a no-op (Created is + // false), a new name registers the job (Created is true), and an existing + // name with a different spec fails with AlreadyExists. Registering a + // schedule job arms its trigger. + Create(ctx context.Context, req *CreateRequest) (*CreateReply, error) + + // Run executes an existing job, creating the next run. It fails with + // FailedPrecondition if the job is already running and its concurrency + // policy forbids overlap. + Run(ctx context.Context, req *RunRequest) (*RunReply, error) + + // CreateAndRun atomically registers a job if needed and starts a run. + // At least one of Name and Spec must be set; a missing name is generated + // by the daemon. Only manual jobs are served: a manual-trigger spec (or + // the nil-Trigger shorthand) is required, and a Name resolving to an + // existing schedule job is rejected with InvalidArgument. The name/spec + // resolution matrix mirrors Create: + // same spec runs the existing job, a different spec for an existing name + // fails with AlreadyExists. + CreateAndRun(ctx context.Context, req *CreateAndRunRequest) (*CreateAndRunReply, error) + + // Inspect returns a job with its latest run summary. + Inspect(ctx context.Context, req *InspectRequest) (*InspectReply, error) + + // List returns jobs matching all the given filters. + List(ctx context.Context, req *ListRequest) (*ListReply, error) + + // Pause suppresses a job's schedule trigger and discards a fire deferred + // by the queue concurrency policy. An in-flight run is not affected, and + // explicit Run calls still work. Idempotent; a no-op for manual jobs. + Pause(ctx context.Context, req *PauseRequest) error + + // Resume re-arms a paused job's schedule trigger from the next cron tick. + // Fires missed while paused are not backfilled. Idempotent. + Resume(ctx context.Context, req *ResumeRequest) error + + // Cancel stops the job's in-flight run. Triggers keep firing; use Pause + // to suppress them. + Cancel(ctx context.Context, req *CancelRequest) (*CancelReply, error) + + // Remove deletes a job, cancelling its in-flight run and disarming its + // trigger. Run history retention is controlled by RunsRemoval; for + // retention purposes the run cancelled by Remove itself counts as + // in-flight, so remove-finished keeps its record. + // The ID of an already removed job whose runs were kept is accepted with + // RunsRemoval remove, which purges that history. + Remove(ctx context.Context, req *RemoveRequest) error + + // Prune removes idle manual jobs. Schedule jobs are never pruned: an + // idle schedule job is armed, not abandoned. + Prune(ctx context.Context, req *PruneRequest) (*PruneReply, error) + + // ListRuns returns a job's runs, most recent first. + ListRuns(ctx context.Context, req *ListRunsRequest) (*ListRunsReply, error) + + // InspectRun returns a single run. + InspectRun(ctx context.Context, req *InspectRunRequest) (*InspectRunReply, error) + + // Wait blocks until the run satisfies the requested condition and + // returns the run as it is then. A run that jumps past the condition + // still satisfies it: waiting for running on a run that went straight + // from pending to a terminal state returns that terminal run. It returns + // immediately when the condition is already met. Cancelling the request + // context detaches the caller without affecting the run. + Wait(ctx context.Context, req *WaitRequest) (*WaitReply, error) +} + +// Point is single-cardinality: the jobs API has one authoritative provider, +// and the host rejects a second one at startup. +var Point = extensions.DefineSinglePoint[Jobs]("org.mobyproject.extension.jobs.api.v0") + +// Job states. A job is a trigger declaration: it is idle between fires, even +// when it has never run. Whether the last execution worked lives on the run. +const ( + // JobStateIdle means no run is currently executing. + JobStateIdle = "idle" + // JobStateRunning means a run is pending or running. + JobStateRunning = "running" +) + +// Run states. Terminal states (succeeded, failed, timed_out, cancelled) are +// sticky: a terminal run never changes again, re-execution creates a new run. +const ( + // RunStatePending covers the window between run-record creation and + // container start. A run that fails to create its container goes from + // pending straight to failed, with Error set and no exit code. + RunStatePending = "pending" + // RunStateRunning means the container is executing. + RunStateRunning = "running" + // RunStateSucceeded means the container exited zero. + RunStateSucceeded = "succeeded" + // RunStateFailed means the container exited nonzero after its restart + // policy was exhausted, or its creation failed. + RunStateFailed = "failed" + // RunStateTimedOut means the run exceeded JobSpec.TimeoutSeconds and was + // stopped by the daemon. + RunStateTimedOut = "timed_out" + // RunStateCancelled means the run was stopped by Cancel or by removing + // its job. + RunStateCancelled = "cancelled" +) + +// Concurrency policies, applied when a trigger fires while a run is already +// in flight. An empty value defaults to forbid. +const ( + // ConcurrencyForbid drops the new fire. + ConcurrencyForbid = "forbid" + // ConcurrencyQueue defers a single fire until the current run ends; + // further fires while one is queued are dropped. Pausing or removing + // the job discards the deferred fire. + ConcurrencyQueue = "queue" +) + +// Missed-fire policies, applied when the daemon starts up after schedule +// fires were missed. An empty value defaults to one. +const ( + // MissedFiresOne fires a single catch-up run, then re-arms from the next + // cron tick. + MissedFiresOne = "one" + // MissedFiresSkip drops missed fires and re-arms from the next cron tick. + MissedFiresSkip = "skip" +) + +// Trigger kinds, as recorded on run evidence and used in list filters. +const ( + // TriggerKindManual identifies jobs fired only by explicit Run calls. + TriggerKindManual = "manual" + // TriggerKindSchedule identifies jobs fired by the cron scheduler. + TriggerKindSchedule = "schedule" +) + +// Run-history removal modes for Remove. An empty value defaults to keep. +const ( + // RunsKeep retains all run records of the removed job, and their + // containers. + RunsKeep = "keep" + // RunsRemove drops all run records, including terminal ones, and + // removes their containers; the in-flight run's container is removed + // once it exits. + RunsRemove = "remove" + // RunsRemoveFinished drops terminal run records and their containers, + // and keeps in-flight ones. + RunsRemoveFinished = "remove-finished" +) + +// Wait conditions. An empty value defaults to terminal. +const ( + // WaitConditionTerminal waits until the run reaches a terminal state. + WaitConditionTerminal = "terminal" + // WaitConditionRunning waits until the run leaves pending. + WaitConditionRunning = "running" +) + +// JobSpec is the immutable definition of a job. The daemon canonicalizes the +// spec (applying defaults) before hashing it; the resulting hash is the job's +// identity for idempotent re-registration. +type JobSpec struct { + // ContainerSpec is the JSON-encoded container definition, in the exact + // format of the container-create API request body (Config, HostConfig, + // NetworkingConfig). It is decoded and validated by the same path as the + // container API; unknown fields are rejected. HostConfig.AutoRemove and + // the always/unless-stopped restart policies are rejected: run outcome + // capture requires the container to outlive its exit, and a job is + // expected to terminate. + ContainerSpec []byte `pb:"1"` + // Trigger declares what fires the job. A nil Trigger is the manual + // shorthand; a non-nil Trigger must declare exactly one kind (see + // Trigger). + Trigger *Trigger `pb:"2"` + // Labels are applied to the job itself, not to run containers. Run + // containers carry the reserved com.docker.job.id and + // com.docker.job.run-id labels instead. + Labels map[string]string `pb:"3"` + // TimeoutSeconds bounds a run's execution; past the deadline the daemon + // stops the container and the run ends timed_out. Zero means no timeout. + TimeoutSeconds int64 `pb:"4"` + // RemoveOnSuccess removes the run container after a successful exit, + // before the terminal run record is written, so the record reports + // ContainerGone. Logs are lost with the container; exit code and error + // are preserved on the run record. + RemoveOnSuccess bool `pb:"5"` + // RemoveOnFailure removes the run container after a failed exit. False + // by default so failed containers are kept for postmortem, until + // history eviction or Remove drops their run record. + RemoveOnFailure bool `pb:"6"` + // RunHistoryLimit caps retained run records, evicting the oldest + // terminal runs first, along with their containers. The in-flight run + // is never evicted. Zero means the daemon default of 10000; retaining + // no history is deliberately not supported. + RunHistoryLimit uint32 `pb:"7"` +} + +// Trigger declares what fires a job. Exactly one field must be set. +// +// A nil Trigger on the JobSpec is the manual shorthand; a non-nil Trigger +// that declares no known kind is rejected with InvalidArgument rather than +// interpreted. This is deliberate: protobuf silently drops fields it does not +// know, so a spec using a trigger kind from a newer contract version must +// fail loudly on an older daemon instead of silently registering as a manual +// job that never fires. Future trigger kinds (events) are added as new +// fields under this rule. +type Trigger struct { + // Manual declares that the job fires only on explicit Run calls. + // Mutually exclusive with Schedule. + Manual bool `pb:"1"` + // Schedule fires the job on a cron schedule. Mutually exclusive with + // Manual. + Schedule *ScheduleTrigger `pb:"2"` +} + +// ScheduleTrigger fires a job on the daemon's clock. +type ScheduleTrigger struct { + // Cron is a strict five-field crontab expression of numbers, lists, + // ranges, and steps. Names and shortcuts such as @daily are not + // accepted on the wire; clients expand them. Daylight-saving changes + // follow crontab(5) semantics; see the package README for details. + Cron string `pb:"1"` + // Timezone is an IANA timezone name for evaluating the expression. + // Empty means UTC, never the daemon host's local timezone, so a spec + // evaluates identically on every host. + Timezone string `pb:"2"` + // Concurrency is the policy applied when the schedule fires while a run + // is in flight. See the Concurrency constants; empty means forbid. + Concurrency string `pb:"3"` + // MissedFires is the policy applied to fires missed while the daemon was + // down. See the MissedFires constants; empty means one. + MissedFires string `pb:"4"` +} + +// Job is a registered job and its current state. +type Job struct { + // ID is the daemon-generated stable identifier. + ID string `pb:"1"` + // Name is unique across all jobs on the daemon. + Name string `pb:"2"` + // Spec is the job definition as submitted, before canonicalization. + Spec *JobSpec `pb:"3"` + // SpecHash is the canonical hash of the spec after daemon-side + // canonicalization. Callers can compare hashes to check spec equality + // before a Create. It is computed when the job is registered; another + // daemon version may hash the same spec differently, and Create + // compares specs with the running daemon's canonicalization. + SpecHash string `pb:"4"` + // State is the job's execution state. See the JobState constants. + State string `pb:"5"` + // Paused reports whether the schedule trigger is suppressed. + Paused bool `pb:"6"` + // NextFireAtNano is the next scheduled fire in Unix nanoseconds. Zero + // when the job is manual, paused, or currently running. + NextFireAtNano int64 `pb:"7"` + // CreatedAtNano is the registration time in Unix nanoseconds. + CreatedAtNano int64 `pb:"8"` + // UpdatedAtNano is the last state-change time in Unix nanoseconds. + UpdatedAtNano int64 `pb:"9"` + // LatestRun is the most recent run, nil if the job never ran. + LatestRun *Run `pb:"10"` +} + +// Run is a single execution attempt of a job. +type Run struct { + // ID is the daemon-generated stable identifier, valid across container + // removal and daemon restarts. + ID string `pb:"1"` + // JobID identifies the owning job. + JobID string `pb:"2"` + // Iteration is the 1-indexed position of this run in the job's history. + Iteration uint64 `pb:"3"` + // ContainerID is the container backing this run. Consumers read run logs + // from the standard container logs API using this ID; the jobs service + // does not proxy logs. + ContainerID string `pb:"4"` + // ContainerGone reports that the container was removed while the run + // record was kept; its logs are no longer available. + ContainerGone bool `pb:"5"` + // State is the run's execution state. See the RunState constants. + State string `pb:"6"` + // CreatedAtNano is the run-record creation time in Unix nanoseconds. The + // record is written before the container is created, so a run exists + // even when container creation fails. + CreatedAtNano int64 `pb:"7"` + // StartedAtNano is the container start time in Unix nanoseconds, zero if + // the container never started. + StartedAtNano int64 `pb:"8"` + // FinishedAtNano is the terminal-transition time in Unix nanoseconds, + // zero while the run is in flight. + FinishedAtNano int64 `pb:"9"` + // ExitCode is the container's exit code, nil while in flight or when the + // container never ran. + ExitCode *ExitCode `pb:"10"` + // Error describes why a run failed outside the container's own exit, + // such as a container-create failure or a container lost across a daemon + // restart. + Error string `pb:"11"` + // Trigger records what fired this run. + Trigger *TriggerEvidence `pb:"12"` +} + +// ExitCode wraps an exit code so that absence (run never exited) is +// distinguishable from zero (run exited successfully). +type ExitCode struct { + // Value is the container's exit code. + Value int64 `pb:"1"` +} + +// TriggerEvidence records what fired a run. +type TriggerEvidence struct { + // Kind is the trigger kind. See the TriggerKind constants. + Kind string `pb:"1"` + // ScheduledAtNano is the cron time the fire was due, in Unix + // nanoseconds. Zero for manual fires. + ScheduledAtNano int64 `pb:"2"` + // FiredAtNano is when the daemon actually fired the run, in Unix + // nanoseconds. + FiredAtNano int64 `pb:"3"` +} + +// CreateRequest registers a job. +type CreateRequest struct { + // Name is the job name, unique across the daemon. Required. + Name string `pb:"1"` + // Spec is the job definition. Required. + Spec *JobSpec `pb:"2"` +} + +// CreateReply reports the registered job. +type CreateReply struct { + // Job is the registered (or pre-existing identical) job. + Job *Job `pb:"1"` + // Created is false when an identical job already existed and the call + // was a no-op. + Created bool `pb:"2"` +} + +// RunRequest executes an existing job. +type RunRequest struct { + // JobRef is the job's ID or name. + JobRef string `pb:"1"` + // Reschedule makes this fire stand in for the job's next scheduled + // occurrence, which is skipped; later occurrences keep the cron + // alignment. Rejected for jobs without a schedule trigger. + Reschedule bool `pb:"2"` +} + +// RunReply reports the created run. +type RunReply struct { + // Run is the newly created run. ContainerID is set once the container + // is created. + Run *Run `pb:"1"` +} + +// CreateAndRunRequest atomically registers a job if needed and runs it. +type CreateAndRunRequest struct { + // Name is the job name. Optional when Spec is set; the daemon then + // generates one. + Name string `pb:"1"` + // Spec is the job definition. Optional when Name refers to an existing + // job. + Spec *JobSpec `pb:"2"` +} + +// CreateAndRunReply reports the resolved job and its new run. +type CreateAndRunReply struct { + // Job is the resolved job, carrying the daemon-generated name when the + // request had none. + Job *Job `pb:"1"` + // Run is the newly created run. + Run *Run `pb:"2"` + // Created is false when the job already existed. + Created bool `pb:"3"` +} + +// InspectRequest fetches one job. +type InspectRequest struct { + // JobRef is the job's ID or name. + JobRef string `pb:"1"` +} + +// InspectReply carries the inspected job. +type InspectReply struct { + // Job is the inspected job. + Job *Job `pb:"1"` +} + +// ListRequest filters jobs. All filters are conjunctive; within one filter, +// values are disjunctive, matching the filter semantics of the container API. +type ListRequest struct { + // Names filters on exact job names. + Names []string `pb:"1"` + // Labels filters on job labels, each entry either "key" or "key=value". + Labels []string `pb:"2"` + // States filters on job states. See the JobState constants. + States []string `pb:"3"` + // TriggerKinds filters on trigger kinds. See the TriggerKind constants. + TriggerKinds []string `pb:"4"` + // Paused filters on the paused flag: "true", "false", or empty for both. + Paused string `pb:"5"` + // LatestRunStates filters on the state of each job's latest run. See the + // RunState constants. + LatestRunStates []string `pb:"6"` +} + +// ListReply carries the matching jobs. +type ListReply struct { + // Jobs are the matching jobs. LatestRun is not trimmed: each entry + // carries the same fields as Inspect. + Jobs []Job `pb:"1"` +} + +// PauseRequest suppresses a job's schedule trigger. +type PauseRequest struct { + // JobRef is the job's ID or name. + JobRef string `pb:"1"` +} + +// ResumeRequest re-arms a paused job's schedule trigger. +type ResumeRequest struct { + // JobRef is the job's ID or name. + JobRef string `pb:"1"` +} + +// CancelRequest stops a job's in-flight run. +type CancelRequest struct { + // JobRef is the job's ID or name. + JobRef string `pb:"1"` +} + +// CancelReply reports the cancelled run. +type CancelReply struct { + // RunID is the ID of the run that was cancelled, empty if no run was in + // flight. + RunID string `pb:"1"` +} + +// RemoveRequest deletes a job. +type RemoveRequest struct { + // JobRef is the job's ID or name, or the ID of a removed job whose runs + // were kept (see Jobs.Remove). + JobRef string `pb:"1"` + // RunsRemoval controls run-history retention. See the Runs constants; + // empty means keep. + RunsRemoval string `pb:"2"` +} + +// PruneRequest removes idle manual jobs. +type PruneRequest struct { + // Labels restricts pruning to jobs matching all entries, each either + // "key" or "key=value". + Labels []string `pb:"1"` +} + +// PruneReply reports what was pruned. +type PruneReply struct { + // RemovedJobIDs are the IDs of the removed jobs. + RemovedJobIDs []string `pb:"1"` +} + +// ListRunsRequest pages through a job's runs, most recent first. +type ListRunsRequest struct { + // JobRef is the job's ID or name, or the ID of a removed job whose runs + // were kept. Names resolve only to live jobs. + JobRef string `pb:"1"` + // Limit caps the page size. Zero means the daemon default of 20; a + // negative value is rejected with InvalidArgument. + Limit int32 `pb:"2"` + // Before restricts the page to runs older than the given cursor; pass + // the previous reply's NextCursor to fetch the next page. + Before string `pb:"3"` +} + +// ListRunsReply carries one page of runs. +type ListRunsReply struct { + // Runs are the page's runs, most recent first. + Runs []Run `pb:"1"` + // NextCursor resumes the listing on the next call, empty on the last + // page. + NextCursor string `pb:"2"` + // CursorStale reports that the requested Before cursor was evicted from + // history; the listing restarted from the most recent run. + CursorStale bool `pb:"3"` +} + +// InspectRunRequest fetches one run. +type InspectRunRequest struct { + // JobRef is the job's ID or name, or the ID of a removed job whose runs + // were kept. Names resolve only to live jobs. + JobRef string `pb:"1"` + // RunRef is the run's ID, or "latest" for the most recent run. + RunRef string `pb:"2"` +} + +// InspectRunReply carries the inspected run. +type InspectRunReply struct { + // Run is the inspected run. + Run *Run `pb:"1"` +} + +// WaitRequest blocks until a run reaches a condition. +type WaitRequest struct { + // JobRef is the job's ID or name. + JobRef string `pb:"1"` + // RunRef is the run's ID, or "latest" (also the default when empty). + // For a schedule job with no runs yet, "latest" resolves to the next + // run to fire, so the call may block until the next cron tick. + RunRef string `pb:"2"` + // Condition is the state to wait for. See the WaitCondition constants; + // empty means terminal. + Condition string `pb:"3"` +} + +// WaitReply carries the run in its awaited state. +type WaitReply struct { + // Run is the run that reached the condition. + Run *Run `pb:"1"` +} diff --git a/vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.proto b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.proto new file mode 100644 index 000000000000..ee7a78887db9 --- /dev/null +++ b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/jobs.proto @@ -0,0 +1,249 @@ +// Code generated by mobyextgen. DO NOT EDIT. + +syntax = "proto3"; + +package org.mobyproject.extension.jobs.api.v0; + +option go_package = "github.com/moby/moby/extpoints/jobs/api/v0/protogen"; + +// Jobs is the jobs service. All methods are unary; blocking semantics +// (Wait) hold the request open until the condition is met. +// +// Errors are returned as gRPC status codes: InvalidArgument for a spec that +// fails validation, NotFound for an unknown job or run, AlreadyExists for a +// Create whose name is taken by a different spec (the message mentions both +// spec hashes for diagnostics only; the code is the contract), and +// FailedPrecondition for an execution refused by the concurrency policy. +service Jobs { + // Create registers a job without ever starting a run. It is idempotent on + // the spec hash: re-submitting the same name+spec is a no-op (Created is + // false), a new name registers the job (Created is true), and an existing + // name with a different spec fails with AlreadyExists. Registering a + // schedule job arms its trigger. + rpc Create(CreateRequest) returns (CreateReply); + // Run executes an existing job, creating the next run. It fails with + // FailedPrecondition if the job is already running and its concurrency + // policy forbids overlap. + rpc Run(RunRequest) returns (RunReply); + // CreateAndRun atomically registers a job if needed and starts a run. + // At least one of Name and Spec must be set; a missing name is generated + // by the daemon. Only manual jobs are served: a manual-trigger spec (or + // the nil-Trigger shorthand) is required, and a Name resolving to an + // existing schedule job is rejected with InvalidArgument. The name/spec + // resolution matrix mirrors Create: + // same spec runs the existing job, a different spec for an existing name + // fails with AlreadyExists. + rpc CreateAndRun(CreateAndRunRequest) returns (CreateAndRunReply); + // Inspect returns a job with its latest run summary. + rpc Inspect(InspectRequest) returns (InspectReply); + // List returns jobs matching all the given filters. + rpc List(ListRequest) returns (ListReply); + // Pause suppresses a job's schedule trigger and discards a fire deferred + // by the queue concurrency policy. An in-flight run is not affected, and + // explicit Run calls still work. Idempotent; a no-op for manual jobs. + rpc Pause(PauseRequest) returns (PauseResponse); + // Resume re-arms a paused job's schedule trigger from the next cron tick. + // Fires missed while paused are not backfilled. Idempotent. + rpc Resume(ResumeRequest) returns (ResumeResponse); + // Cancel stops the job's in-flight run. Triggers keep firing; use Pause + // to suppress them. + rpc Cancel(CancelRequest) returns (CancelReply); + // Remove deletes a job, cancelling its in-flight run and disarming its + // trigger. Run history retention is controlled by RunsRemoval; for + // retention purposes the run cancelled by Remove itself counts as + // in-flight, so remove-finished keeps its record. + // The ID of an already removed job whose runs were kept is accepted with + // RunsRemoval remove, which purges that history. + rpc Remove(RemoveRequest) returns (RemoveResponse); + // Prune removes idle manual jobs. Schedule jobs are never pruned: an + // idle schedule job is armed, not abandoned. + rpc Prune(PruneRequest) returns (PruneReply); + // ListRuns returns a job's runs, most recent first. + rpc ListRuns(ListRunsRequest) returns (ListRunsReply); + // InspectRun returns a single run. + rpc InspectRun(InspectRunRequest) returns (InspectRunReply); + // Wait blocks until the run satisfies the requested condition and + // returns the run as it is then. A run that jumps past the condition + // still satisfies it: waiting for running on a run that went straight + // from pending to a terminal state returns that terminal run. It returns + // immediately when the condition is already met. Cancelling the request + // context detaches the caller without affecting the run. + rpc Wait(WaitRequest) returns (WaitReply); +} + +message CancelReply { + string run_id = 1; +} + +message CancelRequest { + string job_ref = 1; +} + +message CreateAndRunReply { + Job job = 1; + Run run = 2; + bool created = 3; +} + +message CreateAndRunRequest { + string name = 1; + JobSpec spec = 2; +} + +message CreateReply { + Job job = 1; + bool created = 2; +} + +message CreateRequest { + string name = 1; + JobSpec spec = 2; +} + +message ExitCode { + int64 value = 1; +} + +message InspectReply { + Job job = 1; +} + +message InspectRequest { + string job_ref = 1; +} + +message InspectRunReply { + Run run = 1; +} + +message InspectRunRequest { + string job_ref = 1; + string run_ref = 2; +} + +message Job { + string id = 1; + string name = 2; + JobSpec spec = 3; + string spec_hash = 4; + string state = 5; + bool paused = 6; + int64 next_fire_at_nano = 7; + int64 created_at_nano = 8; + int64 updated_at_nano = 9; + Run latest_run = 10; +} + +message JobSpec { + bytes container_spec = 1; + Trigger trigger = 2; + map labels = 3; + int64 timeout_seconds = 4; + bool remove_on_success = 5; + bool remove_on_failure = 6; + uint32 run_history_limit = 7; +} + +message ListReply { + repeated Job jobs = 1; +} + +message ListRequest { + repeated string names = 1; + repeated string labels = 2; + repeated string states = 3; + repeated string trigger_kinds = 4; + string paused = 5; + repeated string latest_run_states = 6; +} + +message ListRunsReply { + repeated Run runs = 1; + string next_cursor = 2; + bool cursor_stale = 3; +} + +message ListRunsRequest { + string job_ref = 1; + int32 limit = 2; + string before = 3; +} + +message PauseRequest { + string job_ref = 1; +} + +message PruneReply { + repeated string removed_job_ids = 1; +} + +message PruneRequest { + repeated string labels = 1; +} + +message RemoveRequest { + string job_ref = 1; + string runs_removal = 2; +} + +message ResumeRequest { + string job_ref = 1; +} + +message Run { + string id = 1; + string job_id = 2; + uint64 iteration = 3; + string container_id = 4; + bool container_gone = 5; + string state = 6; + int64 created_at_nano = 7; + int64 started_at_nano = 8; + int64 finished_at_nano = 9; + ExitCode exit_code = 10; + string error = 11; + TriggerEvidence trigger = 12; +} + +message RunReply { + Run run = 1; +} + +message RunRequest { + string job_ref = 1; + bool reschedule = 2; +} + +message ScheduleTrigger { + string cron = 1; + string timezone = 2; + string concurrency = 3; + string missed_fires = 4; +} + +message Trigger { + bool manual = 1; + ScheduleTrigger schedule = 2; +} + +message TriggerEvidence { + string kind = 1; + int64 scheduled_at_nano = 2; + int64 fired_at_nano = 3; +} + +message WaitReply { + Run run = 1; +} + +message WaitRequest { + string job_ref = 1; + string run_ref = 2; + string condition = 3; +} + +message PauseResponse {} + +message ResumeResponse {} + +message RemoveResponse {} diff --git a/vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/jobs.pb.go b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/jobs.pb.go new file mode 100644 index 000000000000..bbc9142d5222 --- /dev/null +++ b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/jobs.pb.go @@ -0,0 +1,2129 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.12 +// protoc (unknown) +// source: jobs/api/v0/jobs.proto + +package protogen + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type CancelReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + RunId string `protobuf:"bytes,1,opt,name=run_id,json=runId,proto3" json:"run_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CancelReply) Reset() { + *x = CancelReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CancelReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CancelReply) ProtoMessage() {} + +func (x *CancelReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CancelReply.ProtoReflect.Descriptor instead. +func (*CancelReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{0} +} + +func (x *CancelReply) GetRunId() string { + if x != nil { + return x.RunId + } + return "" +} + +type CancelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CancelRequest) Reset() { + *x = CancelRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CancelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CancelRequest) ProtoMessage() {} + +func (x *CancelRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CancelRequest.ProtoReflect.Descriptor instead. +func (*CancelRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{1} +} + +func (x *CancelRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +type CreateAndRunReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Job *Job `protobuf:"bytes,1,opt,name=job,proto3" json:"job,omitempty"` + Run *Run `protobuf:"bytes,2,opt,name=run,proto3" json:"run,omitempty"` + Created bool `protobuf:"varint,3,opt,name=created,proto3" json:"created,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateAndRunReply) Reset() { + *x = CreateAndRunReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateAndRunReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateAndRunReply) ProtoMessage() {} + +func (x *CreateAndRunReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateAndRunReply.ProtoReflect.Descriptor instead. +func (*CreateAndRunReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateAndRunReply) GetJob() *Job { + if x != nil { + return x.Job + } + return nil +} + +func (x *CreateAndRunReply) GetRun() *Run { + if x != nil { + return x.Run + } + return nil +} + +func (x *CreateAndRunReply) GetCreated() bool { + if x != nil { + return x.Created + } + return false +} + +type CreateAndRunRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Spec *JobSpec `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateAndRunRequest) Reset() { + *x = CreateAndRunRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateAndRunRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateAndRunRequest) ProtoMessage() {} + +func (x *CreateAndRunRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateAndRunRequest.ProtoReflect.Descriptor instead. +func (*CreateAndRunRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateAndRunRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateAndRunRequest) GetSpec() *JobSpec { + if x != nil { + return x.Spec + } + return nil +} + +type CreateReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Job *Job `protobuf:"bytes,1,opt,name=job,proto3" json:"job,omitempty"` + Created bool `protobuf:"varint,2,opt,name=created,proto3" json:"created,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateReply) Reset() { + *x = CreateReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateReply) ProtoMessage() {} + +func (x *CreateReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateReply.ProtoReflect.Descriptor instead. +func (*CreateReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateReply) GetJob() *Job { + if x != nil { + return x.Job + } + return nil +} + +func (x *CreateReply) GetCreated() bool { + if x != nil { + return x.Created + } + return false +} + +type CreateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Spec *JobSpec `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateRequest) Reset() { + *x = CreateRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateRequest) ProtoMessage() {} + +func (x *CreateRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateRequest.ProtoReflect.Descriptor instead. +func (*CreateRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateRequest) GetSpec() *JobSpec { + if x != nil { + return x.Spec + } + return nil +} + +type ExitCode struct { + state protoimpl.MessageState `protogen:"open.v1"` + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExitCode) Reset() { + *x = ExitCode{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExitCode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExitCode) ProtoMessage() {} + +func (x *ExitCode) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExitCode.ProtoReflect.Descriptor instead. +func (*ExitCode) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{6} +} + +func (x *ExitCode) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 +} + +type InspectReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Job *Job `protobuf:"bytes,1,opt,name=job,proto3" json:"job,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InspectReply) Reset() { + *x = InspectReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InspectReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InspectReply) ProtoMessage() {} + +func (x *InspectReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InspectReply.ProtoReflect.Descriptor instead. +func (*InspectReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{7} +} + +func (x *InspectReply) GetJob() *Job { + if x != nil { + return x.Job + } + return nil +} + +type InspectRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InspectRequest) Reset() { + *x = InspectRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InspectRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InspectRequest) ProtoMessage() {} + +func (x *InspectRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InspectRequest.ProtoReflect.Descriptor instead. +func (*InspectRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{8} +} + +func (x *InspectRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +type InspectRunReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Run *Run `protobuf:"bytes,1,opt,name=run,proto3" json:"run,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InspectRunReply) Reset() { + *x = InspectRunReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InspectRunReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InspectRunReply) ProtoMessage() {} + +func (x *InspectRunReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InspectRunReply.ProtoReflect.Descriptor instead. +func (*InspectRunReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{9} +} + +func (x *InspectRunReply) GetRun() *Run { + if x != nil { + return x.Run + } + return nil +} + +type InspectRunRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + RunRef string `protobuf:"bytes,2,opt,name=run_ref,json=runRef,proto3" json:"run_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InspectRunRequest) Reset() { + *x = InspectRunRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InspectRunRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InspectRunRequest) ProtoMessage() {} + +func (x *InspectRunRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InspectRunRequest.ProtoReflect.Descriptor instead. +func (*InspectRunRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{10} +} + +func (x *InspectRunRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +func (x *InspectRunRequest) GetRunRef() string { + if x != nil { + return x.RunRef + } + return "" +} + +type Job struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Spec *JobSpec `protobuf:"bytes,3,opt,name=spec,proto3" json:"spec,omitempty"` + SpecHash string `protobuf:"bytes,4,opt,name=spec_hash,json=specHash,proto3" json:"spec_hash,omitempty"` + State string `protobuf:"bytes,5,opt,name=state,proto3" json:"state,omitempty"` + Paused bool `protobuf:"varint,6,opt,name=paused,proto3" json:"paused,omitempty"` + NextFireAtNano int64 `protobuf:"varint,7,opt,name=next_fire_at_nano,json=nextFireAtNano,proto3" json:"next_fire_at_nano,omitempty"` + CreatedAtNano int64 `protobuf:"varint,8,opt,name=created_at_nano,json=createdAtNano,proto3" json:"created_at_nano,omitempty"` + UpdatedAtNano int64 `protobuf:"varint,9,opt,name=updated_at_nano,json=updatedAtNano,proto3" json:"updated_at_nano,omitempty"` + LatestRun *Run `protobuf:"bytes,10,opt,name=latest_run,json=latestRun,proto3" json:"latest_run,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Job) Reset() { + *x = Job{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Job) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Job) ProtoMessage() {} + +func (x *Job) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Job.ProtoReflect.Descriptor instead. +func (*Job) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{11} +} + +func (x *Job) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Job) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Job) GetSpec() *JobSpec { + if x != nil { + return x.Spec + } + return nil +} + +func (x *Job) GetSpecHash() string { + if x != nil { + return x.SpecHash + } + return "" +} + +func (x *Job) GetState() string { + if x != nil { + return x.State + } + return "" +} + +func (x *Job) GetPaused() bool { + if x != nil { + return x.Paused + } + return false +} + +func (x *Job) GetNextFireAtNano() int64 { + if x != nil { + return x.NextFireAtNano + } + return 0 +} + +func (x *Job) GetCreatedAtNano() int64 { + if x != nil { + return x.CreatedAtNano + } + return 0 +} + +func (x *Job) GetUpdatedAtNano() int64 { + if x != nil { + return x.UpdatedAtNano + } + return 0 +} + +func (x *Job) GetLatestRun() *Run { + if x != nil { + return x.LatestRun + } + return nil +} + +type JobSpec struct { + state protoimpl.MessageState `protogen:"open.v1"` + ContainerSpec []byte `protobuf:"bytes,1,opt,name=container_spec,json=containerSpec,proto3" json:"container_spec,omitempty"` + Trigger *Trigger `protobuf:"bytes,2,opt,name=trigger,proto3" json:"trigger,omitempty"` + Labels map[string]string `protobuf:"bytes,3,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + TimeoutSeconds int64 `protobuf:"varint,4,opt,name=timeout_seconds,json=timeoutSeconds,proto3" json:"timeout_seconds,omitempty"` + RemoveOnSuccess bool `protobuf:"varint,5,opt,name=remove_on_success,json=removeOnSuccess,proto3" json:"remove_on_success,omitempty"` + RemoveOnFailure bool `protobuf:"varint,6,opt,name=remove_on_failure,json=removeOnFailure,proto3" json:"remove_on_failure,omitempty"` + RunHistoryLimit uint32 `protobuf:"varint,7,opt,name=run_history_limit,json=runHistoryLimit,proto3" json:"run_history_limit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *JobSpec) Reset() { + *x = JobSpec{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *JobSpec) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*JobSpec) ProtoMessage() {} + +func (x *JobSpec) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use JobSpec.ProtoReflect.Descriptor instead. +func (*JobSpec) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{12} +} + +func (x *JobSpec) GetContainerSpec() []byte { + if x != nil { + return x.ContainerSpec + } + return nil +} + +func (x *JobSpec) GetTrigger() *Trigger { + if x != nil { + return x.Trigger + } + return nil +} + +func (x *JobSpec) GetLabels() map[string]string { + if x != nil { + return x.Labels + } + return nil +} + +func (x *JobSpec) GetTimeoutSeconds() int64 { + if x != nil { + return x.TimeoutSeconds + } + return 0 +} + +func (x *JobSpec) GetRemoveOnSuccess() bool { + if x != nil { + return x.RemoveOnSuccess + } + return false +} + +func (x *JobSpec) GetRemoveOnFailure() bool { + if x != nil { + return x.RemoveOnFailure + } + return false +} + +func (x *JobSpec) GetRunHistoryLimit() uint32 { + if x != nil { + return x.RunHistoryLimit + } + return 0 +} + +type ListReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Jobs []*Job `protobuf:"bytes,1,rep,name=jobs,proto3" json:"jobs,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListReply) Reset() { + *x = ListReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListReply) ProtoMessage() {} + +func (x *ListReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListReply.ProtoReflect.Descriptor instead. +func (*ListReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{13} +} + +func (x *ListReply) GetJobs() []*Job { + if x != nil { + return x.Jobs + } + return nil +} + +type ListRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Names []string `protobuf:"bytes,1,rep,name=names,proto3" json:"names,omitempty"` + Labels []string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty"` + States []string `protobuf:"bytes,3,rep,name=states,proto3" json:"states,omitempty"` + TriggerKinds []string `protobuf:"bytes,4,rep,name=trigger_kinds,json=triggerKinds,proto3" json:"trigger_kinds,omitempty"` + Paused string `protobuf:"bytes,5,opt,name=paused,proto3" json:"paused,omitempty"` + LatestRunStates []string `protobuf:"bytes,6,rep,name=latest_run_states,json=latestRunStates,proto3" json:"latest_run_states,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRequest) Reset() { + *x = ListRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequest) ProtoMessage() {} + +func (x *ListRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{14} +} + +func (x *ListRequest) GetNames() []string { + if x != nil { + return x.Names + } + return nil +} + +func (x *ListRequest) GetLabels() []string { + if x != nil { + return x.Labels + } + return nil +} + +func (x *ListRequest) GetStates() []string { + if x != nil { + return x.States + } + return nil +} + +func (x *ListRequest) GetTriggerKinds() []string { + if x != nil { + return x.TriggerKinds + } + return nil +} + +func (x *ListRequest) GetPaused() string { + if x != nil { + return x.Paused + } + return "" +} + +func (x *ListRequest) GetLatestRunStates() []string { + if x != nil { + return x.LatestRunStates + } + return nil +} + +type ListRunsReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Runs []*Run `protobuf:"bytes,1,rep,name=runs,proto3" json:"runs,omitempty"` + NextCursor string `protobuf:"bytes,2,opt,name=next_cursor,json=nextCursor,proto3" json:"next_cursor,omitempty"` + CursorStale bool `protobuf:"varint,3,opt,name=cursor_stale,json=cursorStale,proto3" json:"cursor_stale,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRunsReply) Reset() { + *x = ListRunsReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRunsReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRunsReply) ProtoMessage() {} + +func (x *ListRunsReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRunsReply.ProtoReflect.Descriptor instead. +func (*ListRunsReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{15} +} + +func (x *ListRunsReply) GetRuns() []*Run { + if x != nil { + return x.Runs + } + return nil +} + +func (x *ListRunsReply) GetNextCursor() string { + if x != nil { + return x.NextCursor + } + return "" +} + +func (x *ListRunsReply) GetCursorStale() bool { + if x != nil { + return x.CursorStale + } + return false +} + +type ListRunsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` + Before string `protobuf:"bytes,3,opt,name=before,proto3" json:"before,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRunsRequest) Reset() { + *x = ListRunsRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRunsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRunsRequest) ProtoMessage() {} + +func (x *ListRunsRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListRunsRequest.ProtoReflect.Descriptor instead. +func (*ListRunsRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{16} +} + +func (x *ListRunsRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +func (x *ListRunsRequest) GetLimit() int32 { + if x != nil { + return x.Limit + } + return 0 +} + +func (x *ListRunsRequest) GetBefore() string { + if x != nil { + return x.Before + } + return "" +} + +type PauseRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PauseRequest) Reset() { + *x = PauseRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PauseRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PauseRequest) ProtoMessage() {} + +func (x *PauseRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PauseRequest.ProtoReflect.Descriptor instead. +func (*PauseRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{17} +} + +func (x *PauseRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +type PruneReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + RemovedJobIds []string `protobuf:"bytes,1,rep,name=removed_job_ids,json=removedJobIds,proto3" json:"removed_job_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PruneReply) Reset() { + *x = PruneReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PruneReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PruneReply) ProtoMessage() {} + +func (x *PruneReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PruneReply.ProtoReflect.Descriptor instead. +func (*PruneReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{18} +} + +func (x *PruneReply) GetRemovedJobIds() []string { + if x != nil { + return x.RemovedJobIds + } + return nil +} + +type PruneRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Labels []string `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PruneRequest) Reset() { + *x = PruneRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PruneRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PruneRequest) ProtoMessage() {} + +func (x *PruneRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PruneRequest.ProtoReflect.Descriptor instead. +func (*PruneRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{19} +} + +func (x *PruneRequest) GetLabels() []string { + if x != nil { + return x.Labels + } + return nil +} + +type RemoveRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + RunsRemoval string `protobuf:"bytes,2,opt,name=runs_removal,json=runsRemoval,proto3" json:"runs_removal,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RemoveRequest) Reset() { + *x = RemoveRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RemoveRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveRequest) ProtoMessage() {} + +func (x *RemoveRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveRequest.ProtoReflect.Descriptor instead. +func (*RemoveRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{20} +} + +func (x *RemoveRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +func (x *RemoveRequest) GetRunsRemoval() string { + if x != nil { + return x.RunsRemoval + } + return "" +} + +type ResumeRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResumeRequest) Reset() { + *x = ResumeRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResumeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResumeRequest) ProtoMessage() {} + +func (x *ResumeRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResumeRequest.ProtoReflect.Descriptor instead. +func (*ResumeRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{21} +} + +func (x *ResumeRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +type Run struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + JobId string `protobuf:"bytes,2,opt,name=job_id,json=jobId,proto3" json:"job_id,omitempty"` + Iteration uint64 `protobuf:"varint,3,opt,name=iteration,proto3" json:"iteration,omitempty"` + ContainerId string `protobuf:"bytes,4,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + ContainerGone bool `protobuf:"varint,5,opt,name=container_gone,json=containerGone,proto3" json:"container_gone,omitempty"` + State string `protobuf:"bytes,6,opt,name=state,proto3" json:"state,omitempty"` + CreatedAtNano int64 `protobuf:"varint,7,opt,name=created_at_nano,json=createdAtNano,proto3" json:"created_at_nano,omitempty"` + StartedAtNano int64 `protobuf:"varint,8,opt,name=started_at_nano,json=startedAtNano,proto3" json:"started_at_nano,omitempty"` + FinishedAtNano int64 `protobuf:"varint,9,opt,name=finished_at_nano,json=finishedAtNano,proto3" json:"finished_at_nano,omitempty"` + ExitCode *ExitCode `protobuf:"bytes,10,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + Error string `protobuf:"bytes,11,opt,name=error,proto3" json:"error,omitempty"` + Trigger *TriggerEvidence `protobuf:"bytes,12,opt,name=trigger,proto3" json:"trigger,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Run) Reset() { + *x = Run{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Run) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Run) ProtoMessage() {} + +func (x *Run) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Run.ProtoReflect.Descriptor instead. +func (*Run) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{22} +} + +func (x *Run) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Run) GetJobId() string { + if x != nil { + return x.JobId + } + return "" +} + +func (x *Run) GetIteration() uint64 { + if x != nil { + return x.Iteration + } + return 0 +} + +func (x *Run) GetContainerId() string { + if x != nil { + return x.ContainerId + } + return "" +} + +func (x *Run) GetContainerGone() bool { + if x != nil { + return x.ContainerGone + } + return false +} + +func (x *Run) GetState() string { + if x != nil { + return x.State + } + return "" +} + +func (x *Run) GetCreatedAtNano() int64 { + if x != nil { + return x.CreatedAtNano + } + return 0 +} + +func (x *Run) GetStartedAtNano() int64 { + if x != nil { + return x.StartedAtNano + } + return 0 +} + +func (x *Run) GetFinishedAtNano() int64 { + if x != nil { + return x.FinishedAtNano + } + return 0 +} + +func (x *Run) GetExitCode() *ExitCode { + if x != nil { + return x.ExitCode + } + return nil +} + +func (x *Run) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *Run) GetTrigger() *TriggerEvidence { + if x != nil { + return x.Trigger + } + return nil +} + +type RunReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Run *Run `protobuf:"bytes,1,opt,name=run,proto3" json:"run,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RunReply) Reset() { + *x = RunReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RunReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunReply) ProtoMessage() {} + +func (x *RunReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RunReply.ProtoReflect.Descriptor instead. +func (*RunReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{23} +} + +func (x *RunReply) GetRun() *Run { + if x != nil { + return x.Run + } + return nil +} + +type RunRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + Reschedule bool `protobuf:"varint,2,opt,name=reschedule,proto3" json:"reschedule,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RunRequest) Reset() { + *x = RunRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RunRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunRequest) ProtoMessage() {} + +func (x *RunRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RunRequest.ProtoReflect.Descriptor instead. +func (*RunRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{24} +} + +func (x *RunRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +func (x *RunRequest) GetReschedule() bool { + if x != nil { + return x.Reschedule + } + return false +} + +type ScheduleTrigger struct { + state protoimpl.MessageState `protogen:"open.v1"` + Cron string `protobuf:"bytes,1,opt,name=cron,proto3" json:"cron,omitempty"` + Timezone string `protobuf:"bytes,2,opt,name=timezone,proto3" json:"timezone,omitempty"` + Concurrency string `protobuf:"bytes,3,opt,name=concurrency,proto3" json:"concurrency,omitempty"` + MissedFires string `protobuf:"bytes,4,opt,name=missed_fires,json=missedFires,proto3" json:"missed_fires,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ScheduleTrigger) Reset() { + *x = ScheduleTrigger{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ScheduleTrigger) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ScheduleTrigger) ProtoMessage() {} + +func (x *ScheduleTrigger) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ScheduleTrigger.ProtoReflect.Descriptor instead. +func (*ScheduleTrigger) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{25} +} + +func (x *ScheduleTrigger) GetCron() string { + if x != nil { + return x.Cron + } + return "" +} + +func (x *ScheduleTrigger) GetTimezone() string { + if x != nil { + return x.Timezone + } + return "" +} + +func (x *ScheduleTrigger) GetConcurrency() string { + if x != nil { + return x.Concurrency + } + return "" +} + +func (x *ScheduleTrigger) GetMissedFires() string { + if x != nil { + return x.MissedFires + } + return "" +} + +type Trigger struct { + state protoimpl.MessageState `protogen:"open.v1"` + Manual bool `protobuf:"varint,1,opt,name=manual,proto3" json:"manual,omitempty"` + Schedule *ScheduleTrigger `protobuf:"bytes,2,opt,name=schedule,proto3" json:"schedule,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Trigger) Reset() { + *x = Trigger{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Trigger) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Trigger) ProtoMessage() {} + +func (x *Trigger) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Trigger.ProtoReflect.Descriptor instead. +func (*Trigger) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{26} +} + +func (x *Trigger) GetManual() bool { + if x != nil { + return x.Manual + } + return false +} + +func (x *Trigger) GetSchedule() *ScheduleTrigger { + if x != nil { + return x.Schedule + } + return nil +} + +type TriggerEvidence struct { + state protoimpl.MessageState `protogen:"open.v1"` + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + ScheduledAtNano int64 `protobuf:"varint,2,opt,name=scheduled_at_nano,json=scheduledAtNano,proto3" json:"scheduled_at_nano,omitempty"` + FiredAtNano int64 `protobuf:"varint,3,opt,name=fired_at_nano,json=firedAtNano,proto3" json:"fired_at_nano,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TriggerEvidence) Reset() { + *x = TriggerEvidence{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TriggerEvidence) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TriggerEvidence) ProtoMessage() {} + +func (x *TriggerEvidence) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TriggerEvidence.ProtoReflect.Descriptor instead. +func (*TriggerEvidence) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{27} +} + +func (x *TriggerEvidence) GetKind() string { + if x != nil { + return x.Kind + } + return "" +} + +func (x *TriggerEvidence) GetScheduledAtNano() int64 { + if x != nil { + return x.ScheduledAtNano + } + return 0 +} + +func (x *TriggerEvidence) GetFiredAtNano() int64 { + if x != nil { + return x.FiredAtNano + } + return 0 +} + +type WaitReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Run *Run `protobuf:"bytes,1,opt,name=run,proto3" json:"run,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WaitReply) Reset() { + *x = WaitReply{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WaitReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WaitReply) ProtoMessage() {} + +func (x *WaitReply) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[28] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WaitReply.ProtoReflect.Descriptor instead. +func (*WaitReply) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{28} +} + +func (x *WaitReply) GetRun() *Run { + if x != nil { + return x.Run + } + return nil +} + +type WaitRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + JobRef string `protobuf:"bytes,1,opt,name=job_ref,json=jobRef,proto3" json:"job_ref,omitempty"` + RunRef string `protobuf:"bytes,2,opt,name=run_ref,json=runRef,proto3" json:"run_ref,omitempty"` + Condition string `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WaitRequest) Reset() { + *x = WaitRequest{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WaitRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WaitRequest) ProtoMessage() {} + +func (x *WaitRequest) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[29] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WaitRequest.ProtoReflect.Descriptor instead. +func (*WaitRequest) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{29} +} + +func (x *WaitRequest) GetJobRef() string { + if x != nil { + return x.JobRef + } + return "" +} + +func (x *WaitRequest) GetRunRef() string { + if x != nil { + return x.RunRef + } + return "" +} + +func (x *WaitRequest) GetCondition() string { + if x != nil { + return x.Condition + } + return "" +} + +type PauseResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PauseResponse) Reset() { + *x = PauseResponse{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PauseResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PauseResponse) ProtoMessage() {} + +func (x *PauseResponse) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[30] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PauseResponse.ProtoReflect.Descriptor instead. +func (*PauseResponse) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{30} +} + +type ResumeResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResumeResponse) Reset() { + *x = ResumeResponse{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResumeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResumeResponse) ProtoMessage() {} + +func (x *ResumeResponse) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[31] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResumeResponse.ProtoReflect.Descriptor instead. +func (*ResumeResponse) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{31} +} + +type RemoveResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RemoveResponse) Reset() { + *x = RemoveResponse{} + mi := &file_jobs_api_v0_jobs_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RemoveResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveResponse) ProtoMessage() {} + +func (x *RemoveResponse) ProtoReflect() protoreflect.Message { + mi := &file_jobs_api_v0_jobs_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveResponse.ProtoReflect.Descriptor instead. +func (*RemoveResponse) Descriptor() ([]byte, []int) { + return file_jobs_api_v0_jobs_proto_rawDescGZIP(), []int{32} +} + +var File_jobs_api_v0_jobs_proto protoreflect.FileDescriptor + +const file_jobs_api_v0_jobs_proto_rawDesc = "" + + "\n" + + "\x16jobs/api/v0/jobs.proto\x12%org.mobyproject.extension.jobs.api.v0\"$\n" + + "\vCancelReply\x12\x15\n" + + "\x06run_id\x18\x01 \x01(\tR\x05runId\"(\n" + + "\rCancelRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\"\xa9\x01\n" + + "\x11CreateAndRunReply\x12<\n" + + "\x03job\x18\x01 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.JobR\x03job\x12<\n" + + "\x03run\x18\x02 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.RunR\x03run\x12\x18\n" + + "\acreated\x18\x03 \x01(\bR\acreated\"m\n" + + "\x13CreateAndRunRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12B\n" + + "\x04spec\x18\x02 \x01(\v2..org.mobyproject.extension.jobs.api.v0.JobSpecR\x04spec\"e\n" + + "\vCreateReply\x12<\n" + + "\x03job\x18\x01 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.JobR\x03job\x12\x18\n" + + "\acreated\x18\x02 \x01(\bR\acreated\"g\n" + + "\rCreateRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12B\n" + + "\x04spec\x18\x02 \x01(\v2..org.mobyproject.extension.jobs.api.v0.JobSpecR\x04spec\" \n" + + "\bExitCode\x12\x14\n" + + "\x05value\x18\x01 \x01(\x03R\x05value\"L\n" + + "\fInspectReply\x12<\n" + + "\x03job\x18\x01 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.JobR\x03job\")\n" + + "\x0eInspectRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\"O\n" + + "\x0fInspectRunReply\x12<\n" + + "\x03run\x18\x01 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.RunR\x03run\"E\n" + + "\x11InspectRunRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\x12\x17\n" + + "\arun_ref\x18\x02 \x01(\tR\x06runRef\"\xfe\x02\n" + + "\x03Job\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12B\n" + + "\x04spec\x18\x03 \x01(\v2..org.mobyproject.extension.jobs.api.v0.JobSpecR\x04spec\x12\x1b\n" + + "\tspec_hash\x18\x04 \x01(\tR\bspecHash\x12\x14\n" + + "\x05state\x18\x05 \x01(\tR\x05state\x12\x16\n" + + "\x06paused\x18\x06 \x01(\bR\x06paused\x12)\n" + + "\x11next_fire_at_nano\x18\a \x01(\x03R\x0enextFireAtNano\x12&\n" + + "\x0fcreated_at_nano\x18\b \x01(\x03R\rcreatedAtNano\x12&\n" + + "\x0fupdated_at_nano\x18\t \x01(\x03R\rupdatedAtNano\x12I\n" + + "\n" + + "latest_run\x18\n" + + " \x01(\v2*.org.mobyproject.extension.jobs.api.v0.RunR\tlatestRun\"\xb6\x03\n" + + "\aJobSpec\x12%\n" + + "\x0econtainer_spec\x18\x01 \x01(\fR\rcontainerSpec\x12H\n" + + "\atrigger\x18\x02 \x01(\v2..org.mobyproject.extension.jobs.api.v0.TriggerR\atrigger\x12R\n" + + "\x06labels\x18\x03 \x03(\v2:.org.mobyproject.extension.jobs.api.v0.JobSpec.LabelsEntryR\x06labels\x12'\n" + + "\x0ftimeout_seconds\x18\x04 \x01(\x03R\x0etimeoutSeconds\x12*\n" + + "\x11remove_on_success\x18\x05 \x01(\bR\x0fremoveOnSuccess\x12*\n" + + "\x11remove_on_failure\x18\x06 \x01(\bR\x0fremoveOnFailure\x12*\n" + + "\x11run_history_limit\x18\a \x01(\rR\x0frunHistoryLimit\x1a9\n" + + "\vLabelsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"K\n" + + "\tListReply\x12>\n" + + "\x04jobs\x18\x01 \x03(\v2*.org.mobyproject.extension.jobs.api.v0.JobR\x04jobs\"\xbc\x01\n" + + "\vListRequest\x12\x14\n" + + "\x05names\x18\x01 \x03(\tR\x05names\x12\x16\n" + + "\x06labels\x18\x02 \x03(\tR\x06labels\x12\x16\n" + + "\x06states\x18\x03 \x03(\tR\x06states\x12#\n" + + "\rtrigger_kinds\x18\x04 \x03(\tR\ftriggerKinds\x12\x16\n" + + "\x06paused\x18\x05 \x01(\tR\x06paused\x12*\n" + + "\x11latest_run_states\x18\x06 \x03(\tR\x0flatestRunStates\"\x93\x01\n" + + "\rListRunsReply\x12>\n" + + "\x04runs\x18\x01 \x03(\v2*.org.mobyproject.extension.jobs.api.v0.RunR\x04runs\x12\x1f\n" + + "\vnext_cursor\x18\x02 \x01(\tR\n" + + "nextCursor\x12!\n" + + "\fcursor_stale\x18\x03 \x01(\bR\vcursorStale\"X\n" + + "\x0fListRunsRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\x12\x14\n" + + "\x05limit\x18\x02 \x01(\x05R\x05limit\x12\x16\n" + + "\x06before\x18\x03 \x01(\tR\x06before\"'\n" + + "\fPauseRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\"4\n" + + "\n" + + "PruneReply\x12&\n" + + "\x0fremoved_job_ids\x18\x01 \x03(\tR\rremovedJobIds\"&\n" + + "\fPruneRequest\x12\x16\n" + + "\x06labels\x18\x01 \x03(\tR\x06labels\"K\n" + + "\rRemoveRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\x12!\n" + + "\fruns_removal\x18\x02 \x01(\tR\vrunsRemoval\"(\n" + + "\rResumeRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\"\xda\x03\n" + + "\x03Run\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x15\n" + + "\x06job_id\x18\x02 \x01(\tR\x05jobId\x12\x1c\n" + + "\titeration\x18\x03 \x01(\x04R\titeration\x12!\n" + + "\fcontainer_id\x18\x04 \x01(\tR\vcontainerId\x12%\n" + + "\x0econtainer_gone\x18\x05 \x01(\bR\rcontainerGone\x12\x14\n" + + "\x05state\x18\x06 \x01(\tR\x05state\x12&\n" + + "\x0fcreated_at_nano\x18\a \x01(\x03R\rcreatedAtNano\x12&\n" + + "\x0fstarted_at_nano\x18\b \x01(\x03R\rstartedAtNano\x12(\n" + + "\x10finished_at_nano\x18\t \x01(\x03R\x0efinishedAtNano\x12L\n" + + "\texit_code\x18\n" + + " \x01(\v2/.org.mobyproject.extension.jobs.api.v0.ExitCodeR\bexitCode\x12\x14\n" + + "\x05error\x18\v \x01(\tR\x05error\x12P\n" + + "\atrigger\x18\f \x01(\v26.org.mobyproject.extension.jobs.api.v0.TriggerEvidenceR\atrigger\"H\n" + + "\bRunReply\x12<\n" + + "\x03run\x18\x01 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.RunR\x03run\"E\n" + + "\n" + + "RunRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\x12\x1e\n" + + "\n" + + "reschedule\x18\x02 \x01(\bR\n" + + "reschedule\"\x86\x01\n" + + "\x0fScheduleTrigger\x12\x12\n" + + "\x04cron\x18\x01 \x01(\tR\x04cron\x12\x1a\n" + + "\btimezone\x18\x02 \x01(\tR\btimezone\x12 \n" + + "\vconcurrency\x18\x03 \x01(\tR\vconcurrency\x12!\n" + + "\fmissed_fires\x18\x04 \x01(\tR\vmissedFires\"u\n" + + "\aTrigger\x12\x16\n" + + "\x06manual\x18\x01 \x01(\bR\x06manual\x12R\n" + + "\bschedule\x18\x02 \x01(\v26.org.mobyproject.extension.jobs.api.v0.ScheduleTriggerR\bschedule\"u\n" + + "\x0fTriggerEvidence\x12\x12\n" + + "\x04kind\x18\x01 \x01(\tR\x04kind\x12*\n" + + "\x11scheduled_at_nano\x18\x02 \x01(\x03R\x0fscheduledAtNano\x12\"\n" + + "\rfired_at_nano\x18\x03 \x01(\x03R\vfiredAtNano\"I\n" + + "\tWaitReply\x12<\n" + + "\x03run\x18\x01 \x01(\v2*.org.mobyproject.extension.jobs.api.v0.RunR\x03run\"]\n" + + "\vWaitRequest\x12\x17\n" + + "\ajob_ref\x18\x01 \x01(\tR\x06jobRef\x12\x17\n" + + "\arun_ref\x18\x02 \x01(\tR\x06runRef\x12\x1c\n" + + "\tcondition\x18\x03 \x01(\tR\tcondition\"\x0f\n" + + "\rPauseResponse\"\x10\n" + + "\x0eResumeResponse\"\x10\n" + + "\x0eRemoveResponse2\x80\f\n" + + "\x04Jobs\x12r\n" + + "\x06Create\x124.org.mobyproject.extension.jobs.api.v0.CreateRequest\x1a2.org.mobyproject.extension.jobs.api.v0.CreateReply\x12i\n" + + "\x03Run\x121.org.mobyproject.extension.jobs.api.v0.RunRequest\x1a/.org.mobyproject.extension.jobs.api.v0.RunReply\x12\x84\x01\n" + + "\fCreateAndRun\x12:.org.mobyproject.extension.jobs.api.v0.CreateAndRunRequest\x1a8.org.mobyproject.extension.jobs.api.v0.CreateAndRunReply\x12u\n" + + "\aInspect\x125.org.mobyproject.extension.jobs.api.v0.InspectRequest\x1a3.org.mobyproject.extension.jobs.api.v0.InspectReply\x12l\n" + + "\x04List\x122.org.mobyproject.extension.jobs.api.v0.ListRequest\x1a0.org.mobyproject.extension.jobs.api.v0.ListReply\x12r\n" + + "\x05Pause\x123.org.mobyproject.extension.jobs.api.v0.PauseRequest\x1a4.org.mobyproject.extension.jobs.api.v0.PauseResponse\x12u\n" + + "\x06Resume\x124.org.mobyproject.extension.jobs.api.v0.ResumeRequest\x1a5.org.mobyproject.extension.jobs.api.v0.ResumeResponse\x12r\n" + + "\x06Cancel\x124.org.mobyproject.extension.jobs.api.v0.CancelRequest\x1a2.org.mobyproject.extension.jobs.api.v0.CancelReply\x12u\n" + + "\x06Remove\x124.org.mobyproject.extension.jobs.api.v0.RemoveRequest\x1a5.org.mobyproject.extension.jobs.api.v0.RemoveResponse\x12o\n" + + "\x05Prune\x123.org.mobyproject.extension.jobs.api.v0.PruneRequest\x1a1.org.mobyproject.extension.jobs.api.v0.PruneReply\x12x\n" + + "\bListRuns\x126.org.mobyproject.extension.jobs.api.v0.ListRunsRequest\x1a4.org.mobyproject.extension.jobs.api.v0.ListRunsReply\x12~\n" + + "\n" + + "InspectRun\x128.org.mobyproject.extension.jobs.api.v0.InspectRunRequest\x1a6.org.mobyproject.extension.jobs.api.v0.InspectRunReply\x12l\n" + + "\x04Wait\x122.org.mobyproject.extension.jobs.api.v0.WaitRequest\x1a0.org.mobyproject.extension.jobs.api.v0.WaitReplyB5Z3github.com/moby/moby/extpoints/jobs/api/v0/protogenb\x06proto3" + +var ( + file_jobs_api_v0_jobs_proto_rawDescOnce sync.Once + file_jobs_api_v0_jobs_proto_rawDescData []byte +) + +func file_jobs_api_v0_jobs_proto_rawDescGZIP() []byte { + file_jobs_api_v0_jobs_proto_rawDescOnce.Do(func() { + file_jobs_api_v0_jobs_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_jobs_api_v0_jobs_proto_rawDesc), len(file_jobs_api_v0_jobs_proto_rawDesc))) + }) + return file_jobs_api_v0_jobs_proto_rawDescData +} + +var file_jobs_api_v0_jobs_proto_msgTypes = make([]protoimpl.MessageInfo, 34) +var file_jobs_api_v0_jobs_proto_goTypes = []any{ + (*CancelReply)(nil), // 0: org.mobyproject.extension.jobs.api.v0.CancelReply + (*CancelRequest)(nil), // 1: org.mobyproject.extension.jobs.api.v0.CancelRequest + (*CreateAndRunReply)(nil), // 2: org.mobyproject.extension.jobs.api.v0.CreateAndRunReply + (*CreateAndRunRequest)(nil), // 3: org.mobyproject.extension.jobs.api.v0.CreateAndRunRequest + (*CreateReply)(nil), // 4: org.mobyproject.extension.jobs.api.v0.CreateReply + (*CreateRequest)(nil), // 5: org.mobyproject.extension.jobs.api.v0.CreateRequest + (*ExitCode)(nil), // 6: org.mobyproject.extension.jobs.api.v0.ExitCode + (*InspectReply)(nil), // 7: org.mobyproject.extension.jobs.api.v0.InspectReply + (*InspectRequest)(nil), // 8: org.mobyproject.extension.jobs.api.v0.InspectRequest + (*InspectRunReply)(nil), // 9: org.mobyproject.extension.jobs.api.v0.InspectRunReply + (*InspectRunRequest)(nil), // 10: org.mobyproject.extension.jobs.api.v0.InspectRunRequest + (*Job)(nil), // 11: org.mobyproject.extension.jobs.api.v0.Job + (*JobSpec)(nil), // 12: org.mobyproject.extension.jobs.api.v0.JobSpec + (*ListReply)(nil), // 13: org.mobyproject.extension.jobs.api.v0.ListReply + (*ListRequest)(nil), // 14: org.mobyproject.extension.jobs.api.v0.ListRequest + (*ListRunsReply)(nil), // 15: org.mobyproject.extension.jobs.api.v0.ListRunsReply + (*ListRunsRequest)(nil), // 16: org.mobyproject.extension.jobs.api.v0.ListRunsRequest + (*PauseRequest)(nil), // 17: org.mobyproject.extension.jobs.api.v0.PauseRequest + (*PruneReply)(nil), // 18: org.mobyproject.extension.jobs.api.v0.PruneReply + (*PruneRequest)(nil), // 19: org.mobyproject.extension.jobs.api.v0.PruneRequest + (*RemoveRequest)(nil), // 20: org.mobyproject.extension.jobs.api.v0.RemoveRequest + (*ResumeRequest)(nil), // 21: org.mobyproject.extension.jobs.api.v0.ResumeRequest + (*Run)(nil), // 22: org.mobyproject.extension.jobs.api.v0.Run + (*RunReply)(nil), // 23: org.mobyproject.extension.jobs.api.v0.RunReply + (*RunRequest)(nil), // 24: org.mobyproject.extension.jobs.api.v0.RunRequest + (*ScheduleTrigger)(nil), // 25: org.mobyproject.extension.jobs.api.v0.ScheduleTrigger + (*Trigger)(nil), // 26: org.mobyproject.extension.jobs.api.v0.Trigger + (*TriggerEvidence)(nil), // 27: org.mobyproject.extension.jobs.api.v0.TriggerEvidence + (*WaitReply)(nil), // 28: org.mobyproject.extension.jobs.api.v0.WaitReply + (*WaitRequest)(nil), // 29: org.mobyproject.extension.jobs.api.v0.WaitRequest + (*PauseResponse)(nil), // 30: org.mobyproject.extension.jobs.api.v0.PauseResponse + (*ResumeResponse)(nil), // 31: org.mobyproject.extension.jobs.api.v0.ResumeResponse + (*RemoveResponse)(nil), // 32: org.mobyproject.extension.jobs.api.v0.RemoveResponse + nil, // 33: org.mobyproject.extension.jobs.api.v0.JobSpec.LabelsEntry +} +var file_jobs_api_v0_jobs_proto_depIdxs = []int32{ + 11, // 0: org.mobyproject.extension.jobs.api.v0.CreateAndRunReply.job:type_name -> org.mobyproject.extension.jobs.api.v0.Job + 22, // 1: org.mobyproject.extension.jobs.api.v0.CreateAndRunReply.run:type_name -> org.mobyproject.extension.jobs.api.v0.Run + 12, // 2: org.mobyproject.extension.jobs.api.v0.CreateAndRunRequest.spec:type_name -> org.mobyproject.extension.jobs.api.v0.JobSpec + 11, // 3: org.mobyproject.extension.jobs.api.v0.CreateReply.job:type_name -> org.mobyproject.extension.jobs.api.v0.Job + 12, // 4: org.mobyproject.extension.jobs.api.v0.CreateRequest.spec:type_name -> org.mobyproject.extension.jobs.api.v0.JobSpec + 11, // 5: org.mobyproject.extension.jobs.api.v0.InspectReply.job:type_name -> org.mobyproject.extension.jobs.api.v0.Job + 22, // 6: org.mobyproject.extension.jobs.api.v0.InspectRunReply.run:type_name -> org.mobyproject.extension.jobs.api.v0.Run + 12, // 7: org.mobyproject.extension.jobs.api.v0.Job.spec:type_name -> org.mobyproject.extension.jobs.api.v0.JobSpec + 22, // 8: org.mobyproject.extension.jobs.api.v0.Job.latest_run:type_name -> org.mobyproject.extension.jobs.api.v0.Run + 26, // 9: org.mobyproject.extension.jobs.api.v0.JobSpec.trigger:type_name -> org.mobyproject.extension.jobs.api.v0.Trigger + 33, // 10: org.mobyproject.extension.jobs.api.v0.JobSpec.labels:type_name -> org.mobyproject.extension.jobs.api.v0.JobSpec.LabelsEntry + 11, // 11: org.mobyproject.extension.jobs.api.v0.ListReply.jobs:type_name -> org.mobyproject.extension.jobs.api.v0.Job + 22, // 12: org.mobyproject.extension.jobs.api.v0.ListRunsReply.runs:type_name -> org.mobyproject.extension.jobs.api.v0.Run + 6, // 13: org.mobyproject.extension.jobs.api.v0.Run.exit_code:type_name -> org.mobyproject.extension.jobs.api.v0.ExitCode + 27, // 14: org.mobyproject.extension.jobs.api.v0.Run.trigger:type_name -> org.mobyproject.extension.jobs.api.v0.TriggerEvidence + 22, // 15: org.mobyproject.extension.jobs.api.v0.RunReply.run:type_name -> org.mobyproject.extension.jobs.api.v0.Run + 25, // 16: org.mobyproject.extension.jobs.api.v0.Trigger.schedule:type_name -> org.mobyproject.extension.jobs.api.v0.ScheduleTrigger + 22, // 17: org.mobyproject.extension.jobs.api.v0.WaitReply.run:type_name -> org.mobyproject.extension.jobs.api.v0.Run + 5, // 18: org.mobyproject.extension.jobs.api.v0.Jobs.Create:input_type -> org.mobyproject.extension.jobs.api.v0.CreateRequest + 24, // 19: org.mobyproject.extension.jobs.api.v0.Jobs.Run:input_type -> org.mobyproject.extension.jobs.api.v0.RunRequest + 3, // 20: org.mobyproject.extension.jobs.api.v0.Jobs.CreateAndRun:input_type -> org.mobyproject.extension.jobs.api.v0.CreateAndRunRequest + 8, // 21: org.mobyproject.extension.jobs.api.v0.Jobs.Inspect:input_type -> org.mobyproject.extension.jobs.api.v0.InspectRequest + 14, // 22: org.mobyproject.extension.jobs.api.v0.Jobs.List:input_type -> org.mobyproject.extension.jobs.api.v0.ListRequest + 17, // 23: org.mobyproject.extension.jobs.api.v0.Jobs.Pause:input_type -> org.mobyproject.extension.jobs.api.v0.PauseRequest + 21, // 24: org.mobyproject.extension.jobs.api.v0.Jobs.Resume:input_type -> org.mobyproject.extension.jobs.api.v0.ResumeRequest + 1, // 25: org.mobyproject.extension.jobs.api.v0.Jobs.Cancel:input_type -> org.mobyproject.extension.jobs.api.v0.CancelRequest + 20, // 26: org.mobyproject.extension.jobs.api.v0.Jobs.Remove:input_type -> org.mobyproject.extension.jobs.api.v0.RemoveRequest + 19, // 27: org.mobyproject.extension.jobs.api.v0.Jobs.Prune:input_type -> org.mobyproject.extension.jobs.api.v0.PruneRequest + 16, // 28: org.mobyproject.extension.jobs.api.v0.Jobs.ListRuns:input_type -> org.mobyproject.extension.jobs.api.v0.ListRunsRequest + 10, // 29: org.mobyproject.extension.jobs.api.v0.Jobs.InspectRun:input_type -> org.mobyproject.extension.jobs.api.v0.InspectRunRequest + 29, // 30: org.mobyproject.extension.jobs.api.v0.Jobs.Wait:input_type -> org.mobyproject.extension.jobs.api.v0.WaitRequest + 4, // 31: org.mobyproject.extension.jobs.api.v0.Jobs.Create:output_type -> org.mobyproject.extension.jobs.api.v0.CreateReply + 23, // 32: org.mobyproject.extension.jobs.api.v0.Jobs.Run:output_type -> org.mobyproject.extension.jobs.api.v0.RunReply + 2, // 33: org.mobyproject.extension.jobs.api.v0.Jobs.CreateAndRun:output_type -> org.mobyproject.extension.jobs.api.v0.CreateAndRunReply + 7, // 34: org.mobyproject.extension.jobs.api.v0.Jobs.Inspect:output_type -> org.mobyproject.extension.jobs.api.v0.InspectReply + 13, // 35: org.mobyproject.extension.jobs.api.v0.Jobs.List:output_type -> org.mobyproject.extension.jobs.api.v0.ListReply + 30, // 36: org.mobyproject.extension.jobs.api.v0.Jobs.Pause:output_type -> org.mobyproject.extension.jobs.api.v0.PauseResponse + 31, // 37: org.mobyproject.extension.jobs.api.v0.Jobs.Resume:output_type -> org.mobyproject.extension.jobs.api.v0.ResumeResponse + 0, // 38: org.mobyproject.extension.jobs.api.v0.Jobs.Cancel:output_type -> org.mobyproject.extension.jobs.api.v0.CancelReply + 32, // 39: org.mobyproject.extension.jobs.api.v0.Jobs.Remove:output_type -> org.mobyproject.extension.jobs.api.v0.RemoveResponse + 18, // 40: org.mobyproject.extension.jobs.api.v0.Jobs.Prune:output_type -> org.mobyproject.extension.jobs.api.v0.PruneReply + 15, // 41: org.mobyproject.extension.jobs.api.v0.Jobs.ListRuns:output_type -> org.mobyproject.extension.jobs.api.v0.ListRunsReply + 9, // 42: org.mobyproject.extension.jobs.api.v0.Jobs.InspectRun:output_type -> org.mobyproject.extension.jobs.api.v0.InspectRunReply + 28, // 43: org.mobyproject.extension.jobs.api.v0.Jobs.Wait:output_type -> org.mobyproject.extension.jobs.api.v0.WaitReply + 31, // [31:44] is the sub-list for method output_type + 18, // [18:31] is the sub-list for method input_type + 18, // [18:18] is the sub-list for extension type_name + 18, // [18:18] is the sub-list for extension extendee + 0, // [0:18] is the sub-list for field type_name +} + +func init() { file_jobs_api_v0_jobs_proto_init() } +func file_jobs_api_v0_jobs_proto_init() { + if File_jobs_api_v0_jobs_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeFor[x]().PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_jobs_api_v0_jobs_proto_rawDesc), len(file_jobs_api_v0_jobs_proto_rawDesc)), + NumEnums: 0, + NumMessages: 34, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_jobs_api_v0_jobs_proto_goTypes, + DependencyIndexes: file_jobs_api_v0_jobs_proto_depIdxs, + MessageInfos: file_jobs_api_v0_jobs_proto_msgTypes, + }.Build() + File_jobs_api_v0_jobs_proto = out.File + file_jobs_api_v0_jobs_proto_goTypes = nil + file_jobs_api_v0_jobs_proto_depIdxs = nil +} diff --git a/vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/wire.gen.go b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/wire.gen.go new file mode 100644 index 000000000000..5f986cf0d89b --- /dev/null +++ b/vendor/github.com/moby/moby/extpoints/jobs/api/v0/protogen/wire.gen.go @@ -0,0 +1,1344 @@ +// Code generated by mobyextgen. DO NOT EDIT. +package protogen + +import ( + context "context" + extensions "github.com/moby/extensions" + clientpoint "github.com/moby/extensions/clientpoint" + serverpoint "github.com/moby/extensions/serverpoint" + mobyextcontract "github.com/moby/moby/extpoints/jobs/api/v0" + grpc "google.golang.org/grpc" +) + +// serviceName is the point's fully-qualified gRPC service name. +const serviceName = "org.mobyproject.extension.jobs.api.v0.Jobs" + +const ( + methodCreate = "/" + serviceName + "/Create" + methodRun = "/" + serviceName + "/Run" + methodCreateAndRun = "/" + serviceName + "/CreateAndRun" + methodInspect = "/" + serviceName + "/Inspect" + methodList = "/" + serviceName + "/List" + methodPause = "/" + serviceName + "/Pause" + methodResume = "/" + serviceName + "/Resume" + methodCancel = "/" + serviceName + "/Cancel" + methodRemove = "/" + serviceName + "/Remove" + methodPrune = "/" + serviceName + "/Prune" + methodListRuns = "/" + serviceName + "/ListRuns" + methodInspectRun = "/" + serviceName + "/InspectRun" + methodWait = "/" + serviceName + "/Wait" +) + +// JobsServer is the server side of the point's gRPC service. It is the +// proto-level shape of the point, not the point's Go interface: a contract +// method returning a bare error returns an empty response message here. +type JobsServer interface { + // Create registers a job without ever starting a run. It is idempotent on + // the spec hash: re-submitting the same name+spec is a no-op (Created is + // false), a new name registers the job (Created is true), and an existing + // name with a different spec fails with AlreadyExists. Registering a + // schedule job arms its trigger. + Create(context.Context, *CreateRequest) (*CreateReply, error) + // Run executes an existing job, creating the next run. It fails with + // FailedPrecondition if the job is already running and its concurrency + // policy forbids overlap. + Run(context.Context, *RunRequest) (*RunReply, error) + // CreateAndRun atomically registers a job if needed and starts a run. + // At least one of Name and Spec must be set; a missing name is generated + // by the daemon. Only manual jobs are served: a manual-trigger spec (or + // the nil-Trigger shorthand) is required, and a Name resolving to an + // existing schedule job is rejected with InvalidArgument. The name/spec + // resolution matrix mirrors Create: + // same spec runs the existing job, a different spec for an existing name + // fails with AlreadyExists. + CreateAndRun(context.Context, *CreateAndRunRequest) (*CreateAndRunReply, error) + // Inspect returns a job with its latest run summary. + Inspect(context.Context, *InspectRequest) (*InspectReply, error) + // List returns jobs matching all the given filters. + List(context.Context, *ListRequest) (*ListReply, error) + // Pause suppresses a job's schedule trigger and discards a fire deferred + // by the queue concurrency policy. An in-flight run is not affected, and + // explicit Run calls still work. Idempotent; a no-op for manual jobs. + Pause(context.Context, *PauseRequest) (*PauseResponse, error) + // Resume re-arms a paused job's schedule trigger from the next cron tick. + // Fires missed while paused are not backfilled. Idempotent. + Resume(context.Context, *ResumeRequest) (*ResumeResponse, error) + // Cancel stops the job's in-flight run. Triggers keep firing; use Pause + // to suppress them. + Cancel(context.Context, *CancelRequest) (*CancelReply, error) + // Remove deletes a job, cancelling its in-flight run and disarming its + // trigger. Run history retention is controlled by RunsRemoval; for + // retention purposes the run cancelled by Remove itself counts as + // in-flight, so remove-finished keeps its record. + // The ID of an already removed job whose runs were kept is accepted with + // RunsRemoval remove, which purges that history. + Remove(context.Context, *RemoveRequest) (*RemoveResponse, error) + // Prune removes idle manual jobs. Schedule jobs are never pruned: an + // idle schedule job is armed, not abandoned. + Prune(context.Context, *PruneRequest) (*PruneReply, error) + // ListRuns returns a job's runs, most recent first. + ListRuns(context.Context, *ListRunsRequest) (*ListRunsReply, error) + // InspectRun returns a single run. + InspectRun(context.Context, *InspectRunRequest) (*InspectRunReply, error) + // Wait blocks until the run satisfies the requested condition and + // returns the run as it is then. A run that jumps past the condition + // still satisfies it: waiting for running on a run that went straight + // from pending to a terminal state returns that terminal run. It returns + // immediately when the condition is already met. Cancelling the request + // context detaches the caller without affecting the run. + Wait(context.Context, *WaitRequest) (*WaitReply, error) +} + +// serviceDesc describes the point's gRPC service to a server. HandlerType is +// what a registrar type-checks an implementation against, so registering the +// wrong provider for this point is caught at registration. +var serviceDesc = grpc.ServiceDesc{ + ServiceName: serviceName, + HandlerType: (*JobsServer)(nil), + Metadata: "jobs/api/v0/jobs.proto", + Methods: []grpc.MethodDesc{ + {MethodName: "Create", Handler: handleCreate}, + {MethodName: "Run", Handler: handleRun}, + {MethodName: "CreateAndRun", Handler: handleCreateAndRun}, + {MethodName: "Inspect", Handler: handleInspect}, + {MethodName: "List", Handler: handleList}, + {MethodName: "Pause", Handler: handlePause}, + {MethodName: "Resume", Handler: handleResume}, + {MethodName: "Cancel", Handler: handleCancel}, + {MethodName: "Remove", Handler: handleRemove}, + {MethodName: "Prune", Handler: handlePrune}, + {MethodName: "ListRuns", Handler: handleListRuns}, + {MethodName: "InspectRun", Handler: handleInspectRun}, + {MethodName: "Wait", Handler: handleWait}, + }, +} + +func handleCreate(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(CreateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Create(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodCreate} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Create(ctx, req.(*CreateRequest)) + }) +} + +func handleRun(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(RunRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Run(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodRun} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Run(ctx, req.(*RunRequest)) + }) +} + +func handleCreateAndRun(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(CreateAndRunRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).CreateAndRun(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodCreateAndRun} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).CreateAndRun(ctx, req.(*CreateAndRunRequest)) + }) +} + +func handleInspect(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(InspectRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Inspect(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodInspect} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Inspect(ctx, req.(*InspectRequest)) + }) +} + +func handleList(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(ListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodList} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).List(ctx, req.(*ListRequest)) + }) +} + +func handlePause(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(PauseRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Pause(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodPause} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Pause(ctx, req.(*PauseRequest)) + }) +} + +func handleResume(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(ResumeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Resume(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodResume} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Resume(ctx, req.(*ResumeRequest)) + }) +} + +func handleCancel(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(CancelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Cancel(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodCancel} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Cancel(ctx, req.(*CancelRequest)) + }) +} + +func handleRemove(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(RemoveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Remove(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodRemove} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Remove(ctx, req.(*RemoveRequest)) + }) +} + +func handlePrune(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(PruneRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Prune(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodPrune} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Prune(ctx, req.(*PruneRequest)) + }) +} + +func handleListRuns(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(ListRunsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).ListRuns(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodListRuns} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).ListRuns(ctx, req.(*ListRunsRequest)) + }) +} + +func handleInspectRun(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(InspectRunRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).InspectRun(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodInspectRun} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).InspectRun(ctx, req.(*InspectRunRequest)) + }) +} + +func handleWait(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(WaitRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(JobsServer).Wait(ctx, in) + } + info := &grpc.UnaryServerInfo{Server: srv, FullMethod: methodWait} + return interceptor(ctx, in, info, func(ctx context.Context, req any) (any, error) { + return srv.(JobsServer).Wait(ctx, req.(*WaitRequest)) + }) +} + +// JobsClient calls the point's gRPC service. It is exported so a client +// outside the framework - one calling a service an extension publishes on the +// API socket - can reach it with a plain gRPC client. +type JobsClient interface { + // Create registers a job without ever starting a run. It is idempotent on + // the spec hash: re-submitting the same name+spec is a no-op (Created is + // false), a new name registers the job (Created is true), and an existing + // name with a different spec fails with AlreadyExists. Registering a + // schedule job arms its trigger. + Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateReply, error) + // Run executes an existing job, creating the next run. It fails with + // FailedPrecondition if the job is already running and its concurrency + // policy forbids overlap. + Run(ctx context.Context, in *RunRequest, opts ...grpc.CallOption) (*RunReply, error) + // CreateAndRun atomically registers a job if needed and starts a run. + // At least one of Name and Spec must be set; a missing name is generated + // by the daemon. Only manual jobs are served: a manual-trigger spec (or + // the nil-Trigger shorthand) is required, and a Name resolving to an + // existing schedule job is rejected with InvalidArgument. The name/spec + // resolution matrix mirrors Create: + // same spec runs the existing job, a different spec for an existing name + // fails with AlreadyExists. + CreateAndRun(ctx context.Context, in *CreateAndRunRequest, opts ...grpc.CallOption) (*CreateAndRunReply, error) + // Inspect returns a job with its latest run summary. + Inspect(ctx context.Context, in *InspectRequest, opts ...grpc.CallOption) (*InspectReply, error) + // List returns jobs matching all the given filters. + List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListReply, error) + // Pause suppresses a job's schedule trigger and discards a fire deferred + // by the queue concurrency policy. An in-flight run is not affected, and + // explicit Run calls still work. Idempotent; a no-op for manual jobs. + Pause(ctx context.Context, in *PauseRequest, opts ...grpc.CallOption) (*PauseResponse, error) + // Resume re-arms a paused job's schedule trigger from the next cron tick. + // Fires missed while paused are not backfilled. Idempotent. + Resume(ctx context.Context, in *ResumeRequest, opts ...grpc.CallOption) (*ResumeResponse, error) + // Cancel stops the job's in-flight run. Triggers keep firing; use Pause + // to suppress them. + Cancel(ctx context.Context, in *CancelRequest, opts ...grpc.CallOption) (*CancelReply, error) + // Remove deletes a job, cancelling its in-flight run and disarming its + // trigger. Run history retention is controlled by RunsRemoval; for + // retention purposes the run cancelled by Remove itself counts as + // in-flight, so remove-finished keeps its record. + // The ID of an already removed job whose runs were kept is accepted with + // RunsRemoval remove, which purges that history. + Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error) + // Prune removes idle manual jobs. Schedule jobs are never pruned: an + // idle schedule job is armed, not abandoned. + Prune(ctx context.Context, in *PruneRequest, opts ...grpc.CallOption) (*PruneReply, error) + // ListRuns returns a job's runs, most recent first. + ListRuns(ctx context.Context, in *ListRunsRequest, opts ...grpc.CallOption) (*ListRunsReply, error) + // InspectRun returns a single run. + InspectRun(ctx context.Context, in *InspectRunRequest, opts ...grpc.CallOption) (*InspectRunReply, error) + // Wait blocks until the run satisfies the requested condition and + // returns the run as it is then. A run that jumps past the condition + // still satisfies it: waiting for running on a run that went straight + // from pending to a terminal state returns that terminal run. It returns + // immediately when the condition is already met. Cancelling the request + // context detaches the caller without affecting the run. + Wait(ctx context.Context, in *WaitRequest, opts ...grpc.CallOption) (*WaitReply, error) +} + +// NewJobsClient returns a client for the point's gRPC service on cc. +func NewJobsClient(cc grpc.ClientConnInterface) JobsClient { return &serviceClient{cc: cc} } + +type serviceClient struct{ cc grpc.ClientConnInterface } + +func (c *serviceClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateReply, error) { + out := new(CreateReply) + if err := c.cc.Invoke(ctx, methodCreate, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Run(ctx context.Context, in *RunRequest, opts ...grpc.CallOption) (*RunReply, error) { + out := new(RunReply) + if err := c.cc.Invoke(ctx, methodRun, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) CreateAndRun(ctx context.Context, in *CreateAndRunRequest, opts ...grpc.CallOption) (*CreateAndRunReply, error) { + out := new(CreateAndRunReply) + if err := c.cc.Invoke(ctx, methodCreateAndRun, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Inspect(ctx context.Context, in *InspectRequest, opts ...grpc.CallOption) (*InspectReply, error) { + out := new(InspectReply) + if err := c.cc.Invoke(ctx, methodInspect, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListReply, error) { + out := new(ListReply) + if err := c.cc.Invoke(ctx, methodList, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Pause(ctx context.Context, in *PauseRequest, opts ...grpc.CallOption) (*PauseResponse, error) { + out := new(PauseResponse) + if err := c.cc.Invoke(ctx, methodPause, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Resume(ctx context.Context, in *ResumeRequest, opts ...grpc.CallOption) (*ResumeResponse, error) { + out := new(ResumeResponse) + if err := c.cc.Invoke(ctx, methodResume, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Cancel(ctx context.Context, in *CancelRequest, opts ...grpc.CallOption) (*CancelReply, error) { + out := new(CancelReply) + if err := c.cc.Invoke(ctx, methodCancel, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error) { + out := new(RemoveResponse) + if err := c.cc.Invoke(ctx, methodRemove, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Prune(ctx context.Context, in *PruneRequest, opts ...grpc.CallOption) (*PruneReply, error) { + out := new(PruneReply) + if err := c.cc.Invoke(ctx, methodPrune, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) ListRuns(ctx context.Context, in *ListRunsRequest, opts ...grpc.CallOption) (*ListRunsReply, error) { + out := new(ListRunsReply) + if err := c.cc.Invoke(ctx, methodListRuns, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) InspectRun(ctx context.Context, in *InspectRunRequest, opts ...grpc.CallOption) (*InspectRunReply, error) { + out := new(InspectRunReply) + if err := c.cc.Invoke(ctx, methodInspectRun, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Wait(ctx context.Context, in *WaitRequest, opts ...grpc.CallOption) (*WaitReply, error) { + out := new(WaitReply) + if err := c.cc.Invoke(ctx, methodWait, in, out, append([]grpc.CallOption{grpc.StaticMethod()}, opts...)...); err != nil { + return nil, err + } + return out, nil +} + +// ServerPoint serves the Jobs point: it registers the point's gRPC service for +// a provider with an SDK server. A binary passes it to (*sdk.Server).Register. +var ServerPoint = serverpoint.Registration{ + Point: mobyextcontract.Point.ID(), + Register: func(r grpc.ServiceRegistrar, impl any) { + r.RegisterService(&serviceDesc, &grpcServer{impl: impl.(mobyextcontract.Jobs)}) + }, +} + +// ClientProvider builds a broker provider for the Jobs point from an +// out-of-process gRPC connection. +func ClientProvider(conn grpc.ClientConnInterface) extensions.Provider { + return mobyextcontract.Point.Provide(NewClient(conn)) +} + +// ClientPoint registers ClientProvider for the Jobs point with a host. +// Single carries the contract's cardinality: the point admits one provider. +var ClientPoint = clientpoint.Registration{Point: mobyextcontract.Point.ID(), Provider: ClientProvider, Single: true} + +// NewClient returns a mobyextcontract.Jobs that calls the Jobs point over conn. +func NewClient(conn grpc.ClientConnInterface) mobyextcontract.Jobs { + return &grpcClient{client: NewJobsClient(conn)} +} + +// grpcServer serves an implementation of the contract's Go interface. +type grpcServer struct { + impl mobyextcontract.Jobs +} + +func (s *grpcServer) Create(ctx context.Context, req *CreateRequest) (*CreateReply, error) { + resp, err := s.impl.Create(ctx, createRequestFromProto(req)) + if err != nil { + return nil, err + } + return createReplyToProto(resp), nil +} + +func (s *grpcServer) Run(ctx context.Context, req *RunRequest) (*RunReply, error) { + resp, err := s.impl.Run(ctx, runRequestFromProto(req)) + if err != nil { + return nil, err + } + return runReplyToProto(resp), nil +} + +func (s *grpcServer) CreateAndRun(ctx context.Context, req *CreateAndRunRequest) (*CreateAndRunReply, error) { + resp, err := s.impl.CreateAndRun(ctx, createAndRunRequestFromProto(req)) + if err != nil { + return nil, err + } + return createAndRunReplyToProto(resp), nil +} + +func (s *grpcServer) Inspect(ctx context.Context, req *InspectRequest) (*InspectReply, error) { + resp, err := s.impl.Inspect(ctx, inspectRequestFromProto(req)) + if err != nil { + return nil, err + } + return inspectReplyToProto(resp), nil +} + +func (s *grpcServer) List(ctx context.Context, req *ListRequest) (*ListReply, error) { + resp, err := s.impl.List(ctx, listRequestFromProto(req)) + if err != nil { + return nil, err + } + return listReplyToProto(resp), nil +} + +func (s *grpcServer) Pause(ctx context.Context, req *PauseRequest) (*PauseResponse, error) { + if err := s.impl.Pause(ctx, pauseRequestFromProto(req)); err != nil { + return nil, err + } + return &PauseResponse{}, nil +} + +func (s *grpcServer) Resume(ctx context.Context, req *ResumeRequest) (*ResumeResponse, error) { + if err := s.impl.Resume(ctx, resumeRequestFromProto(req)); err != nil { + return nil, err + } + return &ResumeResponse{}, nil +} + +func (s *grpcServer) Cancel(ctx context.Context, req *CancelRequest) (*CancelReply, error) { + resp, err := s.impl.Cancel(ctx, cancelRequestFromProto(req)) + if err != nil { + return nil, err + } + return cancelReplyToProto(resp), nil +} + +func (s *grpcServer) Remove(ctx context.Context, req *RemoveRequest) (*RemoveResponse, error) { + if err := s.impl.Remove(ctx, removeRequestFromProto(req)); err != nil { + return nil, err + } + return &RemoveResponse{}, nil +} + +func (s *grpcServer) Prune(ctx context.Context, req *PruneRequest) (*PruneReply, error) { + resp, err := s.impl.Prune(ctx, pruneRequestFromProto(req)) + if err != nil { + return nil, err + } + return pruneReplyToProto(resp), nil +} + +func (s *grpcServer) ListRuns(ctx context.Context, req *ListRunsRequest) (*ListRunsReply, error) { + resp, err := s.impl.ListRuns(ctx, listRunsRequestFromProto(req)) + if err != nil { + return nil, err + } + return listRunsReplyToProto(resp), nil +} + +func (s *grpcServer) InspectRun(ctx context.Context, req *InspectRunRequest) (*InspectRunReply, error) { + resp, err := s.impl.InspectRun(ctx, inspectRunRequestFromProto(req)) + if err != nil { + return nil, err + } + return inspectRunReplyToProto(resp), nil +} + +func (s *grpcServer) Wait(ctx context.Context, req *WaitRequest) (*WaitReply, error) { + resp, err := s.impl.Wait(ctx, waitRequestFromProto(req)) + if err != nil { + return nil, err + } + return waitReplyToProto(resp), nil +} + +type grpcClient struct { + client JobsClient +} + +func (c *grpcClient) Create(ctx context.Context, req *mobyextcontract.CreateRequest) (*mobyextcontract.CreateReply, error) { + resp, err := c.client.Create(ctx, createRequestToProto(req)) + if err != nil { + return nil, err + } + return createReplyFromProto(resp), nil +} + +func (c *grpcClient) Run(ctx context.Context, req *mobyextcontract.RunRequest) (*mobyextcontract.RunReply, error) { + resp, err := c.client.Run(ctx, runRequestToProto(req)) + if err != nil { + return nil, err + } + return runReplyFromProto(resp), nil +} + +func (c *grpcClient) CreateAndRun(ctx context.Context, req *mobyextcontract.CreateAndRunRequest) (*mobyextcontract.CreateAndRunReply, error) { + resp, err := c.client.CreateAndRun(ctx, createAndRunRequestToProto(req)) + if err != nil { + return nil, err + } + return createAndRunReplyFromProto(resp), nil +} + +func (c *grpcClient) Inspect(ctx context.Context, req *mobyextcontract.InspectRequest) (*mobyextcontract.InspectReply, error) { + resp, err := c.client.Inspect(ctx, inspectRequestToProto(req)) + if err != nil { + return nil, err + } + return inspectReplyFromProto(resp), nil +} + +func (c *grpcClient) List(ctx context.Context, req *mobyextcontract.ListRequest) (*mobyextcontract.ListReply, error) { + resp, err := c.client.List(ctx, listRequestToProto(req)) + if err != nil { + return nil, err + } + return listReplyFromProto(resp), nil +} + +func (c *grpcClient) Pause(ctx context.Context, req *mobyextcontract.PauseRequest) error { + _, err := c.client.Pause(ctx, pauseRequestToProto(req)) + return err +} + +func (c *grpcClient) Resume(ctx context.Context, req *mobyextcontract.ResumeRequest) error { + _, err := c.client.Resume(ctx, resumeRequestToProto(req)) + return err +} + +func (c *grpcClient) Cancel(ctx context.Context, req *mobyextcontract.CancelRequest) (*mobyextcontract.CancelReply, error) { + resp, err := c.client.Cancel(ctx, cancelRequestToProto(req)) + if err != nil { + return nil, err + } + return cancelReplyFromProto(resp), nil +} + +func (c *grpcClient) Remove(ctx context.Context, req *mobyextcontract.RemoveRequest) error { + _, err := c.client.Remove(ctx, removeRequestToProto(req)) + return err +} + +func (c *grpcClient) Prune(ctx context.Context, req *mobyextcontract.PruneRequest) (*mobyextcontract.PruneReply, error) { + resp, err := c.client.Prune(ctx, pruneRequestToProto(req)) + if err != nil { + return nil, err + } + return pruneReplyFromProto(resp), nil +} + +func (c *grpcClient) ListRuns(ctx context.Context, req *mobyextcontract.ListRunsRequest) (*mobyextcontract.ListRunsReply, error) { + resp, err := c.client.ListRuns(ctx, listRunsRequestToProto(req)) + if err != nil { + return nil, err + } + return listRunsReplyFromProto(resp), nil +} + +func (c *grpcClient) InspectRun(ctx context.Context, req *mobyextcontract.InspectRunRequest) (*mobyextcontract.InspectRunReply, error) { + resp, err := c.client.InspectRun(ctx, inspectRunRequestToProto(req)) + if err != nil { + return nil, err + } + return inspectRunReplyFromProto(resp), nil +} + +func (c *grpcClient) Wait(ctx context.Context, req *mobyextcontract.WaitRequest) (*mobyextcontract.WaitReply, error) { + resp, err := c.client.Wait(ctx, waitRequestToProto(req)) + if err != nil { + return nil, err + } + return waitReplyFromProto(resp), nil +} + +func cancelReplyToProto(in *mobyextcontract.CancelReply) *CancelReply { + if in == nil { + return nil + } + out := &CancelReply{} + out.RunId = in.RunID + return out +} + +func cancelReplyFromProto(in *CancelReply) *mobyextcontract.CancelReply { + if in == nil { + return nil + } + out := &mobyextcontract.CancelReply{} + out.RunID = in.GetRunId() + return out +} + +func cancelRequestToProto(in *mobyextcontract.CancelRequest) *CancelRequest { + if in == nil { + return nil + } + out := &CancelRequest{} + out.JobRef = in.JobRef + return out +} + +func cancelRequestFromProto(in *CancelRequest) *mobyextcontract.CancelRequest { + if in == nil { + return nil + } + out := &mobyextcontract.CancelRequest{} + out.JobRef = in.GetJobRef() + return out +} + +func createAndRunReplyToProto(in *mobyextcontract.CreateAndRunReply) *CreateAndRunReply { + if in == nil { + return nil + } + out := &CreateAndRunReply{} + out.Job = jobToProto(in.Job) + out.Run = runToProto(in.Run) + out.Created = in.Created + return out +} + +func createAndRunReplyFromProto(in *CreateAndRunReply) *mobyextcontract.CreateAndRunReply { + if in == nil { + return nil + } + out := &mobyextcontract.CreateAndRunReply{} + out.Job = jobFromProto(in.GetJob()) + out.Run = runFromProto(in.GetRun()) + out.Created = in.GetCreated() + return out +} + +func createAndRunRequestToProto(in *mobyextcontract.CreateAndRunRequest) *CreateAndRunRequest { + if in == nil { + return nil + } + out := &CreateAndRunRequest{} + out.Name = in.Name + out.Spec = jobSpecToProto(in.Spec) + return out +} + +func createAndRunRequestFromProto(in *CreateAndRunRequest) *mobyextcontract.CreateAndRunRequest { + if in == nil { + return nil + } + out := &mobyextcontract.CreateAndRunRequest{} + out.Name = in.GetName() + out.Spec = jobSpecFromProto(in.GetSpec()) + return out +} + +func createReplyToProto(in *mobyextcontract.CreateReply) *CreateReply { + if in == nil { + return nil + } + out := &CreateReply{} + out.Job = jobToProto(in.Job) + out.Created = in.Created + return out +} + +func createReplyFromProto(in *CreateReply) *mobyextcontract.CreateReply { + if in == nil { + return nil + } + out := &mobyextcontract.CreateReply{} + out.Job = jobFromProto(in.GetJob()) + out.Created = in.GetCreated() + return out +} + +func createRequestToProto(in *mobyextcontract.CreateRequest) *CreateRequest { + if in == nil { + return nil + } + out := &CreateRequest{} + out.Name = in.Name + out.Spec = jobSpecToProto(in.Spec) + return out +} + +func createRequestFromProto(in *CreateRequest) *mobyextcontract.CreateRequest { + if in == nil { + return nil + } + out := &mobyextcontract.CreateRequest{} + out.Name = in.GetName() + out.Spec = jobSpecFromProto(in.GetSpec()) + return out +} + +func exitCodeToProto(in *mobyextcontract.ExitCode) *ExitCode { + if in == nil { + return nil + } + out := &ExitCode{} + out.Value = in.Value + return out +} + +func exitCodeFromProto(in *ExitCode) *mobyextcontract.ExitCode { + if in == nil { + return nil + } + out := &mobyextcontract.ExitCode{} + out.Value = in.GetValue() + return out +} + +func inspectReplyToProto(in *mobyextcontract.InspectReply) *InspectReply { + if in == nil { + return nil + } + out := &InspectReply{} + out.Job = jobToProto(in.Job) + return out +} + +func inspectReplyFromProto(in *InspectReply) *mobyextcontract.InspectReply { + if in == nil { + return nil + } + out := &mobyextcontract.InspectReply{} + out.Job = jobFromProto(in.GetJob()) + return out +} + +func inspectRequestToProto(in *mobyextcontract.InspectRequest) *InspectRequest { + if in == nil { + return nil + } + out := &InspectRequest{} + out.JobRef = in.JobRef + return out +} + +func inspectRequestFromProto(in *InspectRequest) *mobyextcontract.InspectRequest { + if in == nil { + return nil + } + out := &mobyextcontract.InspectRequest{} + out.JobRef = in.GetJobRef() + return out +} + +func inspectRunReplyToProto(in *mobyextcontract.InspectRunReply) *InspectRunReply { + if in == nil { + return nil + } + out := &InspectRunReply{} + out.Run = runToProto(in.Run) + return out +} + +func inspectRunReplyFromProto(in *InspectRunReply) *mobyextcontract.InspectRunReply { + if in == nil { + return nil + } + out := &mobyextcontract.InspectRunReply{} + out.Run = runFromProto(in.GetRun()) + return out +} + +func inspectRunRequestToProto(in *mobyextcontract.InspectRunRequest) *InspectRunRequest { + if in == nil { + return nil + } + out := &InspectRunRequest{} + out.JobRef = in.JobRef + out.RunRef = in.RunRef + return out +} + +func inspectRunRequestFromProto(in *InspectRunRequest) *mobyextcontract.InspectRunRequest { + if in == nil { + return nil + } + out := &mobyextcontract.InspectRunRequest{} + out.JobRef = in.GetJobRef() + out.RunRef = in.GetRunRef() + return out +} + +func jobToProto(in *mobyextcontract.Job) *Job { + if in == nil { + return nil + } + out := &Job{} + out.Id = in.ID + out.Name = in.Name + out.Spec = jobSpecToProto(in.Spec) + out.SpecHash = in.SpecHash + out.State = in.State + out.Paused = in.Paused + out.NextFireAtNano = in.NextFireAtNano + out.CreatedAtNano = in.CreatedAtNano + out.UpdatedAtNano = in.UpdatedAtNano + out.LatestRun = runToProto(in.LatestRun) + return out +} + +func jobFromProto(in *Job) *mobyextcontract.Job { + if in == nil { + return nil + } + out := &mobyextcontract.Job{} + out.ID = in.GetId() + out.Name = in.GetName() + out.Spec = jobSpecFromProto(in.GetSpec()) + out.SpecHash = in.GetSpecHash() + out.State = in.GetState() + out.Paused = in.GetPaused() + out.NextFireAtNano = in.GetNextFireAtNano() + out.CreatedAtNano = in.GetCreatedAtNano() + out.UpdatedAtNano = in.GetUpdatedAtNano() + out.LatestRun = runFromProto(in.GetLatestRun()) + return out +} + +func jobSpecToProto(in *mobyextcontract.JobSpec) *JobSpec { + if in == nil { + return nil + } + out := &JobSpec{} + out.ContainerSpec = in.ContainerSpec + out.Trigger = triggerToProto(in.Trigger) + out.Labels = in.Labels + out.TimeoutSeconds = in.TimeoutSeconds + out.RemoveOnSuccess = in.RemoveOnSuccess + out.RemoveOnFailure = in.RemoveOnFailure + out.RunHistoryLimit = in.RunHistoryLimit + return out +} + +func jobSpecFromProto(in *JobSpec) *mobyextcontract.JobSpec { + if in == nil { + return nil + } + out := &mobyextcontract.JobSpec{} + out.ContainerSpec = in.GetContainerSpec() + out.Trigger = triggerFromProto(in.GetTrigger()) + out.Labels = in.GetLabels() + out.TimeoutSeconds = in.GetTimeoutSeconds() + out.RemoveOnSuccess = in.GetRemoveOnSuccess() + out.RemoveOnFailure = in.GetRemoveOnFailure() + out.RunHistoryLimit = in.GetRunHistoryLimit() + return out +} + +func listReplyToProto(in *mobyextcontract.ListReply) *ListReply { + if in == nil { + return nil + } + out := &ListReply{} + for i := range in.Jobs { + out.Jobs = append(out.Jobs, jobToProto(&in.Jobs[i])) + } + return out +} + +func listReplyFromProto(in *ListReply) *mobyextcontract.ListReply { + if in == nil { + return nil + } + out := &mobyextcontract.ListReply{} + for _, e := range in.GetJobs() { + out.Jobs = append(out.Jobs, *jobFromProto(e)) + } + return out +} + +func listRequestToProto(in *mobyextcontract.ListRequest) *ListRequest { + if in == nil { + return nil + } + out := &ListRequest{} + out.Names = in.Names + out.Labels = in.Labels + out.States = in.States + out.TriggerKinds = in.TriggerKinds + out.Paused = in.Paused + out.LatestRunStates = in.LatestRunStates + return out +} + +func listRequestFromProto(in *ListRequest) *mobyextcontract.ListRequest { + if in == nil { + return nil + } + out := &mobyextcontract.ListRequest{} + out.Names = in.GetNames() + out.Labels = in.GetLabels() + out.States = in.GetStates() + out.TriggerKinds = in.GetTriggerKinds() + out.Paused = in.GetPaused() + out.LatestRunStates = in.GetLatestRunStates() + return out +} + +func listRunsReplyToProto(in *mobyextcontract.ListRunsReply) *ListRunsReply { + if in == nil { + return nil + } + out := &ListRunsReply{} + for i := range in.Runs { + out.Runs = append(out.Runs, runToProto(&in.Runs[i])) + } + out.NextCursor = in.NextCursor + out.CursorStale = in.CursorStale + return out +} + +func listRunsReplyFromProto(in *ListRunsReply) *mobyextcontract.ListRunsReply { + if in == nil { + return nil + } + out := &mobyextcontract.ListRunsReply{} + for _, e := range in.GetRuns() { + out.Runs = append(out.Runs, *runFromProto(e)) + } + out.NextCursor = in.GetNextCursor() + out.CursorStale = in.GetCursorStale() + return out +} + +func listRunsRequestToProto(in *mobyextcontract.ListRunsRequest) *ListRunsRequest { + if in == nil { + return nil + } + out := &ListRunsRequest{} + out.JobRef = in.JobRef + out.Limit = in.Limit + out.Before = in.Before + return out +} + +func listRunsRequestFromProto(in *ListRunsRequest) *mobyextcontract.ListRunsRequest { + if in == nil { + return nil + } + out := &mobyextcontract.ListRunsRequest{} + out.JobRef = in.GetJobRef() + out.Limit = in.GetLimit() + out.Before = in.GetBefore() + return out +} + +func pauseRequestToProto(in *mobyextcontract.PauseRequest) *PauseRequest { + if in == nil { + return nil + } + out := &PauseRequest{} + out.JobRef = in.JobRef + return out +} + +func pauseRequestFromProto(in *PauseRequest) *mobyextcontract.PauseRequest { + if in == nil { + return nil + } + out := &mobyextcontract.PauseRequest{} + out.JobRef = in.GetJobRef() + return out +} + +func pruneReplyToProto(in *mobyextcontract.PruneReply) *PruneReply { + if in == nil { + return nil + } + out := &PruneReply{} + out.RemovedJobIds = in.RemovedJobIDs + return out +} + +func pruneReplyFromProto(in *PruneReply) *mobyextcontract.PruneReply { + if in == nil { + return nil + } + out := &mobyextcontract.PruneReply{} + out.RemovedJobIDs = in.GetRemovedJobIds() + return out +} + +func pruneRequestToProto(in *mobyextcontract.PruneRequest) *PruneRequest { + if in == nil { + return nil + } + out := &PruneRequest{} + out.Labels = in.Labels + return out +} + +func pruneRequestFromProto(in *PruneRequest) *mobyextcontract.PruneRequest { + if in == nil { + return nil + } + out := &mobyextcontract.PruneRequest{} + out.Labels = in.GetLabels() + return out +} + +func removeRequestToProto(in *mobyextcontract.RemoveRequest) *RemoveRequest { + if in == nil { + return nil + } + out := &RemoveRequest{} + out.JobRef = in.JobRef + out.RunsRemoval = in.RunsRemoval + return out +} + +func removeRequestFromProto(in *RemoveRequest) *mobyextcontract.RemoveRequest { + if in == nil { + return nil + } + out := &mobyextcontract.RemoveRequest{} + out.JobRef = in.GetJobRef() + out.RunsRemoval = in.GetRunsRemoval() + return out +} + +func resumeRequestToProto(in *mobyextcontract.ResumeRequest) *ResumeRequest { + if in == nil { + return nil + } + out := &ResumeRequest{} + out.JobRef = in.JobRef + return out +} + +func resumeRequestFromProto(in *ResumeRequest) *mobyextcontract.ResumeRequest { + if in == nil { + return nil + } + out := &mobyextcontract.ResumeRequest{} + out.JobRef = in.GetJobRef() + return out +} + +func runToProto(in *mobyextcontract.Run) *Run { + if in == nil { + return nil + } + out := &Run{} + out.Id = in.ID + out.JobId = in.JobID + out.Iteration = in.Iteration + out.ContainerId = in.ContainerID + out.ContainerGone = in.ContainerGone + out.State = in.State + out.CreatedAtNano = in.CreatedAtNano + out.StartedAtNano = in.StartedAtNano + out.FinishedAtNano = in.FinishedAtNano + out.ExitCode = exitCodeToProto(in.ExitCode) + out.Error = in.Error + out.Trigger = triggerEvidenceToProto(in.Trigger) + return out +} + +func runFromProto(in *Run) *mobyextcontract.Run { + if in == nil { + return nil + } + out := &mobyextcontract.Run{} + out.ID = in.GetId() + out.JobID = in.GetJobId() + out.Iteration = in.GetIteration() + out.ContainerID = in.GetContainerId() + out.ContainerGone = in.GetContainerGone() + out.State = in.GetState() + out.CreatedAtNano = in.GetCreatedAtNano() + out.StartedAtNano = in.GetStartedAtNano() + out.FinishedAtNano = in.GetFinishedAtNano() + out.ExitCode = exitCodeFromProto(in.GetExitCode()) + out.Error = in.GetError() + out.Trigger = triggerEvidenceFromProto(in.GetTrigger()) + return out +} + +func runReplyToProto(in *mobyextcontract.RunReply) *RunReply { + if in == nil { + return nil + } + out := &RunReply{} + out.Run = runToProto(in.Run) + return out +} + +func runReplyFromProto(in *RunReply) *mobyextcontract.RunReply { + if in == nil { + return nil + } + out := &mobyextcontract.RunReply{} + out.Run = runFromProto(in.GetRun()) + return out +} + +func runRequestToProto(in *mobyextcontract.RunRequest) *RunRequest { + if in == nil { + return nil + } + out := &RunRequest{} + out.JobRef = in.JobRef + out.Reschedule = in.Reschedule + return out +} + +func runRequestFromProto(in *RunRequest) *mobyextcontract.RunRequest { + if in == nil { + return nil + } + out := &mobyextcontract.RunRequest{} + out.JobRef = in.GetJobRef() + out.Reschedule = in.GetReschedule() + return out +} + +func scheduleTriggerToProto(in *mobyextcontract.ScheduleTrigger) *ScheduleTrigger { + if in == nil { + return nil + } + out := &ScheduleTrigger{} + out.Cron = in.Cron + out.Timezone = in.Timezone + out.Concurrency = in.Concurrency + out.MissedFires = in.MissedFires + return out +} + +func scheduleTriggerFromProto(in *ScheduleTrigger) *mobyextcontract.ScheduleTrigger { + if in == nil { + return nil + } + out := &mobyextcontract.ScheduleTrigger{} + out.Cron = in.GetCron() + out.Timezone = in.GetTimezone() + out.Concurrency = in.GetConcurrency() + out.MissedFires = in.GetMissedFires() + return out +} + +func triggerToProto(in *mobyextcontract.Trigger) *Trigger { + if in == nil { + return nil + } + out := &Trigger{} + out.Manual = in.Manual + out.Schedule = scheduleTriggerToProto(in.Schedule) + return out +} + +func triggerFromProto(in *Trigger) *mobyextcontract.Trigger { + if in == nil { + return nil + } + out := &mobyextcontract.Trigger{} + out.Manual = in.GetManual() + out.Schedule = scheduleTriggerFromProto(in.GetSchedule()) + return out +} + +func triggerEvidenceToProto(in *mobyextcontract.TriggerEvidence) *TriggerEvidence { + if in == nil { + return nil + } + out := &TriggerEvidence{} + out.Kind = in.Kind + out.ScheduledAtNano = in.ScheduledAtNano + out.FiredAtNano = in.FiredAtNano + return out +} + +func triggerEvidenceFromProto(in *TriggerEvidence) *mobyextcontract.TriggerEvidence { + if in == nil { + return nil + } + out := &mobyextcontract.TriggerEvidence{} + out.Kind = in.GetKind() + out.ScheduledAtNano = in.GetScheduledAtNano() + out.FiredAtNano = in.GetFiredAtNano() + return out +} + +func waitReplyToProto(in *mobyextcontract.WaitReply) *WaitReply { + if in == nil { + return nil + } + out := &WaitReply{} + out.Run = runToProto(in.Run) + return out +} + +func waitReplyFromProto(in *WaitReply) *mobyextcontract.WaitReply { + if in == nil { + return nil + } + out := &mobyextcontract.WaitReply{} + out.Run = runFromProto(in.GetRun()) + return out +} + +func waitRequestToProto(in *mobyextcontract.WaitRequest) *WaitRequest { + if in == nil { + return nil + } + out := &WaitRequest{} + out.JobRef = in.JobRef + out.RunRef = in.RunRef + out.Condition = in.Condition + return out +} + +func waitRequestFromProto(in *WaitRequest) *mobyextcontract.WaitRequest { + if in == nil { + return nil + } + out := &mobyextcontract.WaitRequest{} + out.JobRef = in.GetJobRef() + out.RunRef = in.GetRunRef() + out.Condition = in.GetCondition() + return out +} diff --git a/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.go b/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.go index 8e13d157c2c7..eb7fbc67b271 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.6 +// protoc-gen-go v1.36.11 +// protoc v7.35.0 // source: opentelemetry/proto/collector/metrics/v1/metrics_service.proto package v1 @@ -26,6 +26,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -36,25 +37,22 @@ const ( ) type ExportMetricsServiceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // An array of ResourceMetrics. // For data coming from a single resource this array will typically contain one // element. Intermediary nodes (such as OpenTelemetry Collector) that receive // data from multiple origins typically batch the data before forwarding further and // in that case this array will contain multiple elements. ResourceMetrics []*v1.ResourceMetrics `protobuf:"bytes,1,rep,name=resource_metrics,json=resourceMetrics,proto3" json:"resource_metrics,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExportMetricsServiceRequest) Reset() { *x = ExportMetricsServiceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExportMetricsServiceRequest) String() string { @@ -65,7 +63,7 @@ func (*ExportMetricsServiceRequest) ProtoMessage() {} func (x *ExportMetricsServiceRequest) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -88,10 +86,7 @@ func (x *ExportMetricsServiceRequest) GetResourceMetrics() []*v1.ResourceMetrics } type ExportMetricsServiceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The details of a partially successful export request. // // If the request is only partially accepted @@ -108,15 +103,15 @@ type ExportMetricsServiceResponse struct { // `error_message` = "") is equivalent to it not being set/present. Senders // SHOULD interpret it the same way as in the full success case. PartialSuccess *ExportMetricsPartialSuccess `protobuf:"bytes,1,opt,name=partial_success,json=partialSuccess,proto3" json:"partial_success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExportMetricsServiceResponse) Reset() { *x = ExportMetricsServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExportMetricsServiceResponse) String() string { @@ -127,7 +122,7 @@ func (*ExportMetricsServiceResponse) ProtoMessage() {} func (x *ExportMetricsServiceResponse) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -150,10 +145,7 @@ func (x *ExportMetricsServiceResponse) GetPartialSuccess() *ExportMetricsPartial } type ExportMetricsPartialSuccess struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The number of rejected data points. // // A `rejected_` field holding a `0` value indicates that the @@ -166,16 +158,16 @@ type ExportMetricsPartialSuccess struct { // // error_message is an optional field. An error_message with an empty value // is equivalent to it not being set. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` + ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExportMetricsPartialSuccess) Reset() { *x = ExportMetricsPartialSuccess{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExportMetricsPartialSuccess) String() string { @@ -186,7 +178,7 @@ func (*ExportMetricsPartialSuccess) ProtoMessage() {} func (x *ExportMetricsPartialSuccess) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -217,79 +209,34 @@ func (x *ExportMetricsPartialSuccess) GetErrorMessage() string { var File_opentelemetry_proto_collector_metrics_v1_metrics_service_proto protoreflect.FileDescriptor -var file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc = []byte{ - 0x0a, 0x3e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2f, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x28, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x2c, 0x6f, 0x70, 0x65, 0x6e, - 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x79, 0x0a, 0x1b, 0x45, 0x78, 0x70, 0x6f, - 0x72, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x5a, 0x0a, 0x10, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x2f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x73, 0x22, 0x8e, 0x01, 0x0a, 0x1c, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x0f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, - 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x45, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x4d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x52, 0x0e, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x22, 0x74, 0x0a, 0x1b, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, - 0x64, 0x61, 0x74, 0x61, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x50, - 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0xac, 0x01, 0x0a, 0x0e, 0x4d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x99, 0x01, - 0x0a, 0x06, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x45, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, - 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, - 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x46, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, - 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xa4, 0x01, 0x0a, 0x2b, 0x69, 0x6f, - 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x13, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x33, 0x67, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x74, 0x6c, 0x70, - 0x2f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x2f, 0x76, 0x31, 0xaa, 0x02, 0x28, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x65, 0x6c, 0x65, - 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc = "" + + "\n" + + ">opentelemetry/proto/collector/metrics/v1/metrics_service.proto\x12(opentelemetry.proto.collector.metrics.v1\x1a,opentelemetry/proto/metrics/v1/metrics.proto\"y\n" + + "\x1bExportMetricsServiceRequest\x12Z\n" + + "\x10resource_metrics\x18\x01 \x03(\v2/.opentelemetry.proto.metrics.v1.ResourceMetricsR\x0fresourceMetrics\"\x8e\x01\n" + + "\x1cExportMetricsServiceResponse\x12n\n" + + "\x0fpartial_success\x18\x01 \x01(\v2E.opentelemetry.proto.collector.metrics.v1.ExportMetricsPartialSuccessR\x0epartialSuccess\"t\n" + + "\x1bExportMetricsPartialSuccess\x120\n" + + "\x14rejected_data_points\x18\x01 \x01(\x03R\x12rejectedDataPoints\x12#\n" + + "\rerror_message\x18\x02 \x01(\tR\ferrorMessage2\xac\x01\n" + + "\x0eMetricsService\x12\x99\x01\n" + + "\x06Export\x12E.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest\x1aF.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse\"\x00B\xa4\x01\n" + + "+io.opentelemetry.proto.collector.metrics.v1B\x13MetricsServiceProtoP\x01Z3go.opentelemetry.io/proto/otlp/collector/metrics/v1\xaa\x02(OpenTelemetry.Proto.Collector.Metrics.V1b\x06proto3" var ( file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescOnce sync.Once - file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescData = file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc + file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescData []byte ) func file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescGZIP() []byte { file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescOnce.Do(func() { - file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescData) + file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc), len(file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc))) }) return file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDescData } var file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_goTypes = []interface{}{ +var file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_goTypes = []any{ (*ExportMetricsServiceRequest)(nil), // 0: opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest (*ExportMetricsServiceResponse)(nil), // 1: opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse (*ExportMetricsPartialSuccess)(nil), // 2: opentelemetry.proto.collector.metrics.v1.ExportMetricsPartialSuccess @@ -312,49 +259,11 @@ func file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_init() if File_opentelemetry_proto_collector_metrics_v1_metrics_service_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExportMetricsServiceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExportMetricsServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExportMetricsPartialSuccess); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc), len(file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc)), NumEnums: 0, NumMessages: 3, NumExtensions: 0, @@ -365,7 +274,6 @@ func file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_init() MessageInfos: file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_msgTypes, }.Build() File_opentelemetry_proto_collector_metrics_v1_metrics_service_proto = out.File - file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_rawDesc = nil file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_goTypes = nil file_opentelemetry_proto_collector_metrics_v1_metrics_service_proto_depIdxs = nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.gw.go b/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.gw.go index c42f1454ed2d..3da3d6f5d6f5 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.gw.go +++ b/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service.pb.gw.go @@ -10,6 +10,7 @@ package v1 import ( "context" + "errors" "io" "net/http" @@ -24,62 +25,56 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) func request_MetricsService_Export_0(ctx context.Context, marshaler runtime.Marshaler, client MetricsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ExportMetricsServiceRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ExportMetricsServiceRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.Export(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_MetricsService_Export_0(ctx context.Context, marshaler runtime.Marshaler, server MetricsServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ExportMetricsServiceRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ExportMetricsServiceRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Export(ctx, &protoReq) return msg, metadata, err - } // RegisterMetricsServiceHandlerServer registers the http handlers for service MetricsService to "mux". // UnaryRPC :call MetricsServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMetricsServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterMetricsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MetricsServiceServer) error { - - mux.Handle("POST", pattern_MetricsService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_MetricsService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", runtime.WithHTTPPathPattern("/v1/metrics")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", runtime.WithHTTPPathPattern("/v1/metrics")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -91,9 +86,7 @@ func RegisterMetricsServiceHandlerServer(ctx context.Context, mux *runtime.Serve runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_MetricsService_Export_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -102,25 +95,24 @@ func RegisterMetricsServiceHandlerServer(ctx context.Context, mux *runtime.Serve // RegisterMetricsServiceHandlerFromEndpoint is same as RegisterMetricsServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterMetricsServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() - return RegisterMetricsServiceHandler(ctx, mux, conn) } @@ -134,16 +126,13 @@ func RegisterMetricsServiceHandler(ctx context.Context, mux *runtime.ServeMux, c // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MetricsServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MetricsServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MetricsServiceClient" to call the correct interceptors. +// "MetricsServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterMetricsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MetricsServiceClient) error { - - mux.Handle("POST", pattern_MetricsService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_MetricsService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", runtime.WithHTTPPathPattern("/v1/metrics")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", runtime.WithHTTPPathPattern("/v1/metrics")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -154,11 +143,8 @@ func RegisterMetricsServiceHandlerClient(ctx context.Context, mux *runtime.Serve runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_MetricsService_Export_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service_grpc.pb.go b/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service_grpc.pb.go index fc668643c119..328b74a12a02 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service_grpc.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/collector/metrics/v1/metrics_service_grpc.pb.go @@ -1,7 +1,21 @@ +// Copyright 2019, OpenTelemetry Authors +// +// 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. + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.1.0 -// - protoc v3.21.6 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v7.35.0 // source: opentelemetry/proto/collector/metrics/v1/metrics_service.proto package v1 @@ -15,12 +29,20 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + MetricsService_Export_FullMethodName = "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export" +) // MetricsServiceClient is the client API for MetricsService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Service that can be used to push metrics between one Application +// instrumented with OpenTelemetry and a collector, or between a collector and a +// central collector. type MetricsServiceClient interface { Export(ctx context.Context, in *ExportMetricsServiceRequest, opts ...grpc.CallOption) (*ExportMetricsServiceResponse, error) } @@ -34,8 +56,9 @@ func NewMetricsServiceClient(cc grpc.ClientConnInterface) MetricsServiceClient { } func (c *metricsServiceClient) Export(ctx context.Context, in *ExportMetricsServiceRequest, opts ...grpc.CallOption) (*ExportMetricsServiceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExportMetricsServiceResponse) - err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", in, out, opts...) + err := c.cc.Invoke(ctx, MetricsService_Export_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -44,20 +67,28 @@ func (c *metricsServiceClient) Export(ctx context.Context, in *ExportMetricsServ // MetricsServiceServer is the server API for MetricsService service. // All implementations must embed UnimplementedMetricsServiceServer -// for forward compatibility +// for forward compatibility. +// +// Service that can be used to push metrics between one Application +// instrumented with OpenTelemetry and a collector, or between a collector and a +// central collector. type MetricsServiceServer interface { Export(context.Context, *ExportMetricsServiceRequest) (*ExportMetricsServiceResponse, error) mustEmbedUnimplementedMetricsServiceServer() } -// UnimplementedMetricsServiceServer must be embedded to have forward compatible implementations. -type UnimplementedMetricsServiceServer struct { -} +// UnimplementedMetricsServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMetricsServiceServer struct{} func (UnimplementedMetricsServiceServer) Export(context.Context, *ExportMetricsServiceRequest) (*ExportMetricsServiceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") } func (UnimplementedMetricsServiceServer) mustEmbedUnimplementedMetricsServiceServer() {} +func (UnimplementedMetricsServiceServer) testEmbeddedByValue() {} // UnsafeMetricsServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to MetricsServiceServer will @@ -67,6 +98,13 @@ type UnsafeMetricsServiceServer interface { } func RegisterMetricsServiceServer(s grpc.ServiceRegistrar, srv MetricsServiceServer) { + // If the following call pancis, it indicates UnimplementedMetricsServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&MetricsService_ServiceDesc, srv) } @@ -80,7 +118,7 @@ func _MetricsService_Export_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", + FullMethod: MetricsService_Export_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MetricsServiceServer).Export(ctx, req.(*ExportMetricsServiceRequest)) diff --git a/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.go b/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.go index c1af04e84e51..2234be22dd76 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.6 +// protoc-gen-go v1.36.11 +// protoc v7.35.0 // source: opentelemetry/proto/collector/trace/v1/trace_service.proto package v1 @@ -26,6 +26,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -36,25 +37,22 @@ const ( ) type ExportTraceServiceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // An array of ResourceSpans. // For data coming from a single resource this array will typically contain one // element. Intermediary nodes (such as OpenTelemetry Collector) that receive // data from multiple origins typically batch the data before forwarding further and // in that case this array will contain multiple elements. ResourceSpans []*v1.ResourceSpans `protobuf:"bytes,1,rep,name=resource_spans,json=resourceSpans,proto3" json:"resource_spans,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExportTraceServiceRequest) Reset() { *x = ExportTraceServiceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExportTraceServiceRequest) String() string { @@ -65,7 +63,7 @@ func (*ExportTraceServiceRequest) ProtoMessage() {} func (x *ExportTraceServiceRequest) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -88,10 +86,7 @@ func (x *ExportTraceServiceRequest) GetResourceSpans() []*v1.ResourceSpans { } type ExportTraceServiceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The details of a partially successful export request. // // If the request is only partially accepted @@ -108,15 +103,15 @@ type ExportTraceServiceResponse struct { // `error_message` = "") is equivalent to it not being set/present. Senders // SHOULD interpret it the same way as in the full success case. PartialSuccess *ExportTracePartialSuccess `protobuf:"bytes,1,opt,name=partial_success,json=partialSuccess,proto3" json:"partial_success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExportTraceServiceResponse) Reset() { *x = ExportTraceServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExportTraceServiceResponse) String() string { @@ -127,7 +122,7 @@ func (*ExportTraceServiceResponse) ProtoMessage() {} func (x *ExportTraceServiceResponse) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -150,10 +145,7 @@ func (x *ExportTraceServiceResponse) GetPartialSuccess() *ExportTracePartialSucc } type ExportTracePartialSuccess struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The number of rejected spans. // // A `rejected_` field holding a `0` value indicates that the @@ -166,16 +158,16 @@ type ExportTracePartialSuccess struct { // // error_message is an optional field. An error_message with an empty value // is equivalent to it not being set. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` + ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExportTracePartialSuccess) Reset() { *x = ExportTracePartialSuccess{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExportTracePartialSuccess) String() string { @@ -186,7 +178,7 @@ func (*ExportTracePartialSuccess) ProtoMessage() {} func (x *ExportTracePartialSuccess) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -217,75 +209,34 @@ func (x *ExportTracePartialSuccess) GetErrorMessage() string { var File_opentelemetry_proto_collector_trace_v1_trace_service_proto protoreflect.FileDescriptor -var file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc = []byte{ - 0x0a, 0x3a, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2f, - 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x26, 0x6f, 0x70, - 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x74, 0x72, 0x61, 0x63, - 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x28, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, - 0x76, 0x31, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6f, - 0x0a, 0x19, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x72, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x52, 0x0a, 0x0e, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, - 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x22, - 0x88, 0x01, 0x0a, 0x1a, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x72, 0x61, 0x63, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6a, - 0x0a, 0x0f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, - 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x72, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x74, - 0x69, 0x61, 0x6c, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x0e, 0x70, 0x61, 0x72, 0x74, - 0x69, 0x61, 0x6c, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x67, 0x0a, 0x19, 0x45, 0x78, - 0x70, 0x6f, 0x72, 0x74, 0x54, 0x72, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, - 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x6a, 0x65, 0x63, - 0x74, 0x65, 0x64, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0d, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x12, 0x23, - 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x32, 0xa2, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x91, 0x01, 0x0a, 0x06, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x12, - 0x41, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, - 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x54, - 0x72, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x42, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, - 0x72, 0x74, 0x54, 0x72, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x9c, 0x01, 0x0a, 0x29, 0x69, 0x6f, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x11, 0x54, 0x72, 0x61, 0x63, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x6f, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x69, 0x6f, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x74, 0x6c, 0x70, 0x2f, 0x63, 0x6f, 0x6c, 0x6c, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, 0x76, 0x31, 0xaa, 0x02, - 0x26, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x54, - 0x72, 0x61, 0x63, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc = "" + + "\n" + + ":opentelemetry/proto/collector/trace/v1/trace_service.proto\x12&opentelemetry.proto.collector.trace.v1\x1a(opentelemetry/proto/trace/v1/trace.proto\"o\n" + + "\x19ExportTraceServiceRequest\x12R\n" + + "\x0eresource_spans\x18\x01 \x03(\v2+.opentelemetry.proto.trace.v1.ResourceSpansR\rresourceSpans\"\x88\x01\n" + + "\x1aExportTraceServiceResponse\x12j\n" + + "\x0fpartial_success\x18\x01 \x01(\v2A.opentelemetry.proto.collector.trace.v1.ExportTracePartialSuccessR\x0epartialSuccess\"g\n" + + "\x19ExportTracePartialSuccess\x12%\n" + + "\x0erejected_spans\x18\x01 \x01(\x03R\rrejectedSpans\x12#\n" + + "\rerror_message\x18\x02 \x01(\tR\ferrorMessage2\xa2\x01\n" + + "\fTraceService\x12\x91\x01\n" + + "\x06Export\x12A.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest\x1aB.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse\"\x00B\x9c\x01\n" + + ")io.opentelemetry.proto.collector.trace.v1B\x11TraceServiceProtoP\x01Z1go.opentelemetry.io/proto/otlp/collector/trace/v1\xaa\x02&OpenTelemetry.Proto.Collector.Trace.V1b\x06proto3" var ( file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescOnce sync.Once - file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescData = file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc + file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescData []byte ) func file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescGZIP() []byte { file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescOnce.Do(func() { - file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescData) + file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc), len(file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc))) }) return file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDescData } var file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_opentelemetry_proto_collector_trace_v1_trace_service_proto_goTypes = []interface{}{ +var file_opentelemetry_proto_collector_trace_v1_trace_service_proto_goTypes = []any{ (*ExportTraceServiceRequest)(nil), // 0: opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest (*ExportTraceServiceResponse)(nil), // 1: opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse (*ExportTracePartialSuccess)(nil), // 2: opentelemetry.proto.collector.trace.v1.ExportTracePartialSuccess @@ -308,49 +259,11 @@ func file_opentelemetry_proto_collector_trace_v1_trace_service_proto_init() { if File_opentelemetry_proto_collector_trace_v1_trace_service_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExportTraceServiceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExportTraceServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExportTracePartialSuccess); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc), len(file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc)), NumEnums: 0, NumMessages: 3, NumExtensions: 0, @@ -361,7 +274,6 @@ func file_opentelemetry_proto_collector_trace_v1_trace_service_proto_init() { MessageInfos: file_opentelemetry_proto_collector_trace_v1_trace_service_proto_msgTypes, }.Build() File_opentelemetry_proto_collector_trace_v1_trace_service_proto = out.File - file_opentelemetry_proto_collector_trace_v1_trace_service_proto_rawDesc = nil file_opentelemetry_proto_collector_trace_v1_trace_service_proto_goTypes = nil file_opentelemetry_proto_collector_trace_v1_trace_service_proto_depIdxs = nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.gw.go b/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.gw.go index bb1bd261ed83..b2cf91e2f6d2 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.gw.go +++ b/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service.pb.gw.go @@ -10,6 +10,7 @@ package v1 import ( "context" + "errors" "io" "net/http" @@ -24,62 +25,56 @@ import ( ) // Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = metadata.Join +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) func request_TraceService_Export_0(ctx context.Context, marshaler runtime.Marshaler, client TraceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ExportTraceServiceRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ExportTraceServiceRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.Export(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err - } func local_request_TraceService_Export_0(ctx context.Context, marshaler runtime.Marshaler, server TraceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ExportTraceServiceRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + var ( + protoReq ExportTraceServiceRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Export(ctx, &protoReq) return msg, metadata, err - } // RegisterTraceServiceHandlerServer registers the http handlers for service TraceService to "mux". // UnaryRPC :call TraceServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTraceServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterTraceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TraceServiceServer) error { - - mux.Handle("POST", pattern_TraceService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_TraceService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", runtime.WithHTTPPathPattern("/v1/traces")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", runtime.WithHTTPPathPattern("/v1/traces")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -91,9 +86,7 @@ func RegisterTraceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_TraceService_Export_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) return nil @@ -102,25 +95,24 @@ func RegisterTraceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu // RegisterTraceServiceHandlerFromEndpoint is same as RegisterTraceServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterTraceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() - return RegisterTraceServiceHandler(ctx, mux, conn) } @@ -134,16 +126,13 @@ func RegisterTraceServiceHandler(ctx context.Context, mux *runtime.ServeMux, con // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TraceServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TraceServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "TraceServiceClient" to call the correct interceptors. +// "TraceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterTraceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TraceServiceClient) error { - - mux.Handle("POST", pattern_TraceService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_TraceService_Export_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", runtime.WithHTTPPathPattern("/v1/traces")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", runtime.WithHTTPPathPattern("/v1/traces")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -154,11 +143,8 @@ func RegisterTraceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_TraceService_Export_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service_grpc.pb.go b/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service_grpc.pb.go index 892864ea6295..0c93f2da4c25 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service_grpc.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/collector/trace/v1/trace_service_grpc.pb.go @@ -1,7 +1,21 @@ +// Copyright 2019, OpenTelemetry Authors +// +// 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. + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.1.0 -// - protoc v3.21.6 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v7.35.0 // source: opentelemetry/proto/collector/trace/v1/trace_service.proto package v1 @@ -15,12 +29,20 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + TraceService_Export_FullMethodName = "/opentelemetry.proto.collector.trace.v1.TraceService/Export" +) // TraceServiceClient is the client API for TraceService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Service that can be used to push spans between one Application instrumented with +// OpenTelemetry and a collector, or between a collector and a central collector (in this +// case spans are sent/received to/from multiple Applications). type TraceServiceClient interface { Export(ctx context.Context, in *ExportTraceServiceRequest, opts ...grpc.CallOption) (*ExportTraceServiceResponse, error) } @@ -34,8 +56,9 @@ func NewTraceServiceClient(cc grpc.ClientConnInterface) TraceServiceClient { } func (c *traceServiceClient) Export(ctx context.Context, in *ExportTraceServiceRequest, opts ...grpc.CallOption) (*ExportTraceServiceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExportTraceServiceResponse) - err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", in, out, opts...) + err := c.cc.Invoke(ctx, TraceService_Export_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -44,20 +67,28 @@ func (c *traceServiceClient) Export(ctx context.Context, in *ExportTraceServiceR // TraceServiceServer is the server API for TraceService service. // All implementations must embed UnimplementedTraceServiceServer -// for forward compatibility +// for forward compatibility. +// +// Service that can be used to push spans between one Application instrumented with +// OpenTelemetry and a collector, or between a collector and a central collector (in this +// case spans are sent/received to/from multiple Applications). type TraceServiceServer interface { Export(context.Context, *ExportTraceServiceRequest) (*ExportTraceServiceResponse, error) mustEmbedUnimplementedTraceServiceServer() } -// UnimplementedTraceServiceServer must be embedded to have forward compatible implementations. -type UnimplementedTraceServiceServer struct { -} +// UnimplementedTraceServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedTraceServiceServer struct{} func (UnimplementedTraceServiceServer) Export(context.Context, *ExportTraceServiceRequest) (*ExportTraceServiceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") } func (UnimplementedTraceServiceServer) mustEmbedUnimplementedTraceServiceServer() {} +func (UnimplementedTraceServiceServer) testEmbeddedByValue() {} // UnsafeTraceServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TraceServiceServer will @@ -67,6 +98,13 @@ type UnsafeTraceServiceServer interface { } func RegisterTraceServiceServer(s grpc.ServiceRegistrar, srv TraceServiceServer) { + // If the following call pancis, it indicates UnimplementedTraceServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&TraceService_ServiceDesc, srv) } @@ -80,7 +118,7 @@ func _TraceService_Export_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/opentelemetry.proto.collector.trace.v1.TraceService/Export", + FullMethod: TraceService_Export_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TraceServiceServer).Export(ctx, req.(*ExportTraceServiceRequest)) diff --git a/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go b/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go index cef3580008e7..626d8c600e9a 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/common/v1/common.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.6 +// protoc-gen-go v1.36.11 +// protoc v7.35.0 // source: opentelemetry/proto/common/v1/common.proto package v1 @@ -25,6 +25,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -38,14 +39,12 @@ const ( // primitive value such as a string or integer or it may contain an arbitrary nested // object containing arrays, key-value lists and primitives. type AnyValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The value is one of the listed fields. It is valid for all values to be unspecified // in which case this AnyValue is considered to be "empty". // - // Types that are assignable to Value: + // Types that are valid to be assigned to Value: + // // *AnyValue_StringValue // *AnyValue_BoolValue // *AnyValue_IntValue @@ -54,16 +53,16 @@ type AnyValue struct { // *AnyValue_KvlistValue // *AnyValue_BytesValue // *AnyValue_StringValueStrindex - Value isAnyValue_Value `protobuf_oneof:"value"` + Value isAnyValue_Value `protobuf_oneof:"value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *AnyValue) Reset() { *x = AnyValue{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AnyValue) String() string { @@ -74,7 +73,7 @@ func (*AnyValue) ProtoMessage() {} func (x *AnyValue) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -89,65 +88,81 @@ func (*AnyValue) Descriptor() ([]byte, []int) { return file_opentelemetry_proto_common_v1_common_proto_rawDescGZIP(), []int{0} } -func (m *AnyValue) GetValue() isAnyValue_Value { - if m != nil { - return m.Value +func (x *AnyValue) GetValue() isAnyValue_Value { + if x != nil { + return x.Value } return nil } func (x *AnyValue) GetStringValue() string { - if x, ok := x.GetValue().(*AnyValue_StringValue); ok { - return x.StringValue + if x != nil { + if x, ok := x.Value.(*AnyValue_StringValue); ok { + return x.StringValue + } } return "" } func (x *AnyValue) GetBoolValue() bool { - if x, ok := x.GetValue().(*AnyValue_BoolValue); ok { - return x.BoolValue + if x != nil { + if x, ok := x.Value.(*AnyValue_BoolValue); ok { + return x.BoolValue + } } return false } func (x *AnyValue) GetIntValue() int64 { - if x, ok := x.GetValue().(*AnyValue_IntValue); ok { - return x.IntValue + if x != nil { + if x, ok := x.Value.(*AnyValue_IntValue); ok { + return x.IntValue + } } return 0 } func (x *AnyValue) GetDoubleValue() float64 { - if x, ok := x.GetValue().(*AnyValue_DoubleValue); ok { - return x.DoubleValue + if x != nil { + if x, ok := x.Value.(*AnyValue_DoubleValue); ok { + return x.DoubleValue + } } return 0 } func (x *AnyValue) GetArrayValue() *ArrayValue { - if x, ok := x.GetValue().(*AnyValue_ArrayValue); ok { - return x.ArrayValue + if x != nil { + if x, ok := x.Value.(*AnyValue_ArrayValue); ok { + return x.ArrayValue + } } return nil } func (x *AnyValue) GetKvlistValue() *KeyValueList { - if x, ok := x.GetValue().(*AnyValue_KvlistValue); ok { - return x.KvlistValue + if x != nil { + if x, ok := x.Value.(*AnyValue_KvlistValue); ok { + return x.KvlistValue + } } return nil } func (x *AnyValue) GetBytesValue() []byte { - if x, ok := x.GetValue().(*AnyValue_BytesValue); ok { - return x.BytesValue + if x != nil { + if x, ok := x.Value.(*AnyValue_BytesValue); ok { + return x.BytesValue + } } return nil } func (x *AnyValue) GetStringValueStrindex() int32 { - if x, ok := x.GetValue().(*AnyValue_StringValueStrindex); ok { - return x.StringValueStrindex + if x != nil { + if x, ok := x.Value.(*AnyValue_StringValueStrindex); ok { + return x.StringValueStrindex + } } return 0 } @@ -195,6 +210,8 @@ type AnyValue_StringValueStrindex struct { // empty, ignoring its semantic content for the non-Profiling signal. // // Status: [Alpha] + // + // [Since v1.10.0] StringValueStrindex int32 `protobuf:"varint,8,opt,name=string_value_strindex,json=stringValueStrindex,proto3,oneof"` } @@ -217,21 +234,18 @@ func (*AnyValue_StringValueStrindex) isAnyValue_Value() {} // ArrayValue is a list of AnyValue messages. We need ArrayValue as a message // since oneof in AnyValue does not allow repeated fields. type ArrayValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Array of values. The array may be empty (contain 0 elements). - Values []*AnyValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + Values []*AnyValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ArrayValue) Reset() { *x = ArrayValue{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ArrayValue) String() string { @@ -242,7 +256,7 @@ func (*ArrayValue) ProtoMessage() {} func (x *ArrayValue) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -270,26 +284,23 @@ func (x *ArrayValue) GetValues() []*AnyValue { // avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches // are semantically equivalent. type KeyValueList struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // A collection of key/value pairs of key-value pairs. The list may be empty (may // contain 0 elements). // // The keys MUST be unique (it is not allowed to have more than one // value with the same key). // The behavior of software that receives duplicated keys can be unpredictable. - Values []*KeyValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + Values []*KeyValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *KeyValueList) Reset() { *x = KeyValueList{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *KeyValueList) String() string { @@ -300,7 +311,7 @@ func (*KeyValueList) ProtoMessage() {} func (x *KeyValueList) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -325,10 +336,7 @@ func (x *KeyValueList) GetValues() []*KeyValue { // Represents a key-value pair that is used to store Span attributes, Link // attributes, etc. type KeyValue struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The key name of the pair. // key_strindex MUST NOT be set if key is used. Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` @@ -345,16 +353,18 @@ type KeyValue struct { // empty, ignoring its semantic content for the non-Profiling signal. // // Status: [Alpha] - KeyStrindex int32 `protobuf:"varint,3,opt,name=key_strindex,json=keyStrindex,proto3" json:"key_strindex,omitempty"` + // + // [Since v1.10.0] + KeyStrindex int32 `protobuf:"varint,3,opt,name=key_strindex,json=keyStrindex,proto3" json:"key_strindex,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *KeyValue) Reset() { *x = KeyValue{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *KeyValue) String() string { @@ -365,7 +375,7 @@ func (*KeyValue) ProtoMessage() {} func (x *KeyValue) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -404,10 +414,7 @@ func (x *KeyValue) GetKeyStrindex() int32 { // InstrumentationScope is a message representing the instrumentation scope information // such as the fully qualified name and version. type InstrumentationScope struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // A name denoting the Instrumentation scope. // An empty instrumentation scope name means the name is unknown. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -423,15 +430,15 @@ type InstrumentationScope struct { // can be discarded because their keys are too long or because there are too many // attributes. If this value is 0, then no attributes were dropped. DroppedAttributesCount uint32 `protobuf:"varint,4,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *InstrumentationScope) Reset() { *x = InstrumentationScope{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *InstrumentationScope) String() string { @@ -442,7 +449,7 @@ func (*InstrumentationScope) ProtoMessage() {} func (x *InstrumentationScope) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -489,11 +496,10 @@ func (x *InstrumentationScope) GetDroppedAttributesCount() uint32 { // Entity represents an object of interest associated with produced telemetry: e.g spans, metrics, profiles, or logs. // // Status: [Development] +// +// [Since v1.6.0] type EntityRef struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The Schema URL, if known. This is the identifier of the Schema that the entity data // is recorded in. To learn more about Schema URL see // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url @@ -518,15 +524,15 @@ type EntityRef struct { // These attribute keys are not part of entity's identity. // These keys MUST exist in the containing {message}.attributes. DescriptionKeys []string `protobuf:"bytes,4,rep,name=description_keys,json=descriptionKeys,proto3" json:"description_keys,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EntityRef) Reset() { *x = EntityRef{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EntityRef) String() string { @@ -537,7 +543,7 @@ func (*EntityRef) ProtoMessage() {} func (x *EntityRef) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_common_v1_common_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -582,101 +588,60 @@ func (x *EntityRef) GetDescriptionKeys() []string { var File_opentelemetry_proto_common_v1_common_proto protoreflect.FileDescriptor -var file_opentelemetry_proto_common_v1_common_proto_rawDesc = []byte{ - 0x0a, 0x2a, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1d, 0x6f, 0x70, - 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x22, 0x96, 0x03, 0x0a, 0x08, - 0x41, 0x6e, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, - 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, - 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, - 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x48, 0x00, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, - 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x4c, 0x0a, 0x0b, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x61, 0x72, 0x72, 0x61, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x50, 0x0a, 0x0c, 0x6b, 0x76, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, - 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4c, - 0x69, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x6b, 0x76, 0x6c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x13, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x42, 0x07, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x22, 0x4d, 0x0a, 0x0a, 0x41, 0x72, 0x72, 0x61, 0x79, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x41, 0x6e, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x73, 0x22, 0x4f, 0x0a, 0x0c, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4c, - 0x69, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x73, 0x22, 0x7e, 0x0a, 0x08, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x3d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, - 0x31, 0x2e, 0x41, 0x6e, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6b, 0x65, 0x79, 0x53, 0x74, 0x72, 0x69, - 0x6e, 0x64, 0x65, 0x78, 0x22, 0xc7, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x47, 0x0a, 0x0a, 0x61, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, - 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x16, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x41, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x82, - 0x01, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x66, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x55, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, - 0x17, 0x0a, 0x07, 0x69, 0x64, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x06, 0x69, 0x64, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x0f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, - 0x65, 0x79, 0x73, 0x42, 0x7b, 0x0a, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, - 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x6f, 0x74, 0x6c, 0x70, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, - 0xaa, 0x02, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, - 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_opentelemetry_proto_common_v1_common_proto_rawDesc = "" + + "\n" + + "*opentelemetry/proto/common/v1/common.proto\x12\x1dopentelemetry.proto.common.v1\"\x96\x03\n" + + "\bAnyValue\x12#\n" + + "\fstring_value\x18\x01 \x01(\tH\x00R\vstringValue\x12\x1f\n" + + "\n" + + "bool_value\x18\x02 \x01(\bH\x00R\tboolValue\x12\x1d\n" + + "\tint_value\x18\x03 \x01(\x03H\x00R\bintValue\x12#\n" + + "\fdouble_value\x18\x04 \x01(\x01H\x00R\vdoubleValue\x12L\n" + + "\varray_value\x18\x05 \x01(\v2).opentelemetry.proto.common.v1.ArrayValueH\x00R\n" + + "arrayValue\x12P\n" + + "\fkvlist_value\x18\x06 \x01(\v2+.opentelemetry.proto.common.v1.KeyValueListH\x00R\vkvlistValue\x12!\n" + + "\vbytes_value\x18\a \x01(\fH\x00R\n" + + "bytesValue\x124\n" + + "\x15string_value_strindex\x18\b \x01(\x05H\x00R\x13stringValueStrindexB\a\n" + + "\x05value\"M\n" + + "\n" + + "ArrayValue\x12?\n" + + "\x06values\x18\x01 \x03(\v2'.opentelemetry.proto.common.v1.AnyValueR\x06values\"O\n" + + "\fKeyValueList\x12?\n" + + "\x06values\x18\x01 \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\x06values\"~\n" + + "\bKeyValue\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12=\n" + + "\x05value\x18\x02 \x01(\v2'.opentelemetry.proto.common.v1.AnyValueR\x05value\x12!\n" + + "\fkey_strindex\x18\x03 \x01(\x05R\vkeyStrindex\"\xc7\x01\n" + + "\x14InstrumentationScope\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x12G\n" + + "\n" + + "attributes\x18\x03 \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x128\n" + + "\x18dropped_attributes_count\x18\x04 \x01(\rR\x16droppedAttributesCount\"\x82\x01\n" + + "\tEntityRef\x12\x1d\n" + + "\n" + + "schema_url\x18\x01 \x01(\tR\tschemaUrl\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x17\n" + + "\aid_keys\x18\x03 \x03(\tR\x06idKeys\x12)\n" + + "\x10description_keys\x18\x04 \x03(\tR\x0fdescriptionKeysB{\n" + + " io.opentelemetry.proto.common.v1B\vCommonProtoP\x01Z(go.opentelemetry.io/proto/otlp/common/v1\xaa\x02\x1dOpenTelemetry.Proto.Common.V1b\x06proto3" var ( file_opentelemetry_proto_common_v1_common_proto_rawDescOnce sync.Once - file_opentelemetry_proto_common_v1_common_proto_rawDescData = file_opentelemetry_proto_common_v1_common_proto_rawDesc + file_opentelemetry_proto_common_v1_common_proto_rawDescData []byte ) func file_opentelemetry_proto_common_v1_common_proto_rawDescGZIP() []byte { file_opentelemetry_proto_common_v1_common_proto_rawDescOnce.Do(func() { - file_opentelemetry_proto_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_opentelemetry_proto_common_v1_common_proto_rawDescData) + file_opentelemetry_proto_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_common_v1_common_proto_rawDesc), len(file_opentelemetry_proto_common_v1_common_proto_rawDesc))) }) return file_opentelemetry_proto_common_v1_common_proto_rawDescData } var file_opentelemetry_proto_common_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_opentelemetry_proto_common_v1_common_proto_goTypes = []interface{}{ +var file_opentelemetry_proto_common_v1_common_proto_goTypes = []any{ (*AnyValue)(nil), // 0: opentelemetry.proto.common.v1.AnyValue (*ArrayValue)(nil), // 1: opentelemetry.proto.common.v1.ArrayValue (*KeyValueList)(nil), // 2: opentelemetry.proto.common.v1.KeyValueList @@ -703,81 +668,7 @@ func file_opentelemetry_proto_common_v1_common_proto_init() { if File_opentelemetry_proto_common_v1_common_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_opentelemetry_proto_common_v1_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AnyValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_common_v1_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ArrayValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_common_v1_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*KeyValueList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_common_v1_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*KeyValue); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_common_v1_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InstrumentationScope); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_common_v1_common_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EntityRef); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_opentelemetry_proto_common_v1_common_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_opentelemetry_proto_common_v1_common_proto_msgTypes[0].OneofWrappers = []any{ (*AnyValue_StringValue)(nil), (*AnyValue_BoolValue)(nil), (*AnyValue_IntValue)(nil), @@ -791,7 +682,7 @@ func file_opentelemetry_proto_common_v1_common_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opentelemetry_proto_common_v1_common_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_common_v1_common_proto_rawDesc), len(file_opentelemetry_proto_common_v1_common_proto_rawDesc)), NumEnums: 0, NumMessages: 6, NumExtensions: 0, @@ -802,7 +693,6 @@ func file_opentelemetry_proto_common_v1_common_proto_init() { MessageInfos: file_opentelemetry_proto_common_v1_common_proto_msgTypes, }.Build() File_opentelemetry_proto_common_v1_common_proto = out.File - file_opentelemetry_proto_common_v1_common_proto_rawDesc = nil file_opentelemetry_proto_common_v1_common_proto_goTypes = nil file_opentelemetry_proto_common_v1_common_proto_depIdxs = nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/metrics/v1/metrics.pb.go b/vendor/go.opentelemetry.io/proto/otlp/metrics/v1/metrics.pb.go index e148ddd13469..55b7d1bb2e6b 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/metrics/v1/metrics.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/metrics/v1/metrics.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.6 +// protoc-gen-go v1.36.11 +// protoc v7.35.0 // source: opentelemetry/proto/metrics/v1/metrics.proto package v1 @@ -27,6 +27,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -56,18 +57,18 @@ const ( // it receives and reports the sum of these requests every second as a // DELTA metric: // - // 1. The system starts receiving at time=t_0. - // 2. A request is received, the system measures 1 request. - // 3. A request is received, the system measures 1 request. - // 4. A request is received, the system measures 1 request. - // 5. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0 to - // t_0+1 with a value of 3. - // 6. A request is received, the system measures 1 request. - // 7. A request is received, the system measures 1 request. - // 8. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0+1 to - // t_0+2 with a value of 2. + // 1. The system starts receiving at time=t_0. + // 2. A request is received, the system measures 1 request. + // 3. A request is received, the system measures 1 request. + // 4. A request is received, the system measures 1 request. + // 5. The 1 second collection cycle ends. A metric is exported for the + // number of requests received over the interval of time t_0 to + // t_0+1 with a value of 3. + // 6. A request is received, the system measures 1 request. + // 7. A request is received, the system measures 1 request. + // 8. The 1 second collection cycle ends. A metric is exported for the + // number of requests received over the interval of time t_0+1 to + // t_0+2 with a value of 2. AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA AggregationTemporality = 1 // CUMULATIVE is an AggregationTemporality for a metric aggregator which // reports changes since a fixed start time. This means that current values @@ -81,24 +82,24 @@ const ( // it receives and reports the sum of these requests every second as a // CUMULATIVE metric: // - // 1. The system starts receiving at time=t_0. - // 2. A request is received, the system measures 1 request. - // 3. A request is received, the system measures 1 request. - // 4. A request is received, the system measures 1 request. - // 5. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0 to - // t_0+1 with a value of 3. - // 6. A request is received, the system measures 1 request. - // 7. A request is received, the system measures 1 request. - // 8. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0 to - // t_0+2 with a value of 5. - // 9. The system experiences a fault and loses state. - // 10. The system recovers and resumes receiving at time=t_1. - // 11. A request is received, the system measures 1 request. - // 12. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_1 to - // t_0+1 with a value of 1. + // 1. The system starts receiving at time=t_0. + // 2. A request is received, the system measures 1 request. + // 3. A request is received, the system measures 1 request. + // 4. A request is received, the system measures 1 request. + // 5. The 1 second collection cycle ends. A metric is exported for the + // number of requests received over the interval of time t_0 to + // t_0+1 with a value of 3. + // 6. A request is received, the system measures 1 request. + // 7. A request is received, the system measures 1 request. + // 8. The 1 second collection cycle ends. A metric is exported for the + // number of requests received over the interval of time t_0 to + // t_0+2 with a value of 5. + // 9. The system experiences a fault and loses state. + // 10. The system recovers and resumes receiving at time=t_1. + // 11. A request is received, the system measures 1 request. + // 12. The 1 second collection cycle ends. A metric is exported for the + // number of requests received over the interval of time t_1 to + // t_0+1 with a value of 1. // // Note: Even though, when reporting changes since last report time, using // CUMULATIVE is valid, it is not recommended. This may cause problems for @@ -153,8 +154,7 @@ func (AggregationTemporality) EnumDescriptor() ([]byte, []int) { // enum is a bit-mask. To test the presence of a single flag in the flags of // a data point, for example, use an expression like: // -// (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK -// +// (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK type DataPointFlags int32 const ( @@ -212,21 +212,22 @@ func (DataPointFlags) EnumDescriptor() ([]byte, []int) { // // MetricsData // └─── ResourceMetrics -// ├── Resource -// ├── SchemaURL -// └── ScopeMetrics -// ├── Scope -// ├── SchemaURL -// └── Metric -// ├── Name -// ├── Description -// ├── Unit -// └── data -// ├── Gauge -// ├── Sum -// ├── Histogram -// ├── ExponentialHistogram -// └── Summary +// +// ├── Resource +// ├── SchemaURL +// └── ScopeMetrics +// ├── Scope +// ├── SchemaURL +// └── Metric +// ├── Name +// ├── Description +// ├── Unit +// └── data +// ├── Gauge +// ├── Sum +// ├── Histogram +// ├── ExponentialHistogram +// └── Summary // // The main difference between this message and collector protocol is that // in this message there will not be any "control" or "metadata" specific to @@ -235,25 +236,22 @@ func (DataPointFlags) EnumDescriptor() ([]byte, []int) { // When new fields are added into this message, the OTLP request MUST be updated // as well. type MetricsData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // An array of ResourceMetrics. // For data coming from a single resource this array will typically contain // one element. Intermediary nodes that receive data from multiple origins // typically batch the data before forwarding further and in that case this // array will contain multiple elements. ResourceMetrics []*ResourceMetrics `protobuf:"bytes,1,rep,name=resource_metrics,json=resourceMetrics,proto3" json:"resource_metrics,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *MetricsData) Reset() { *x = MetricsData{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MetricsData) String() string { @@ -264,7 +262,7 @@ func (*MetricsData) ProtoMessage() {} func (x *MetricsData) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -288,10 +286,7 @@ func (x *MetricsData) GetResourceMetrics() []*ResourceMetrics { // A collection of ScopeMetrics from a Resource. type ResourceMetrics struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource for the metrics in this message. // If this field is not set then no resource info is known. Resource *v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` @@ -303,16 +298,16 @@ type ResourceMetrics struct { // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url // This schema_url applies to the data in the "resource" field. It does not apply // to the data in the "scope_metrics" field which have their own schema_url field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ResourceMetrics) Reset() { *x = ResourceMetrics{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ResourceMetrics) String() string { @@ -323,7 +318,7 @@ func (*ResourceMetrics) ProtoMessage() {} func (x *ResourceMetrics) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -361,10 +356,7 @@ func (x *ResourceMetrics) GetSchemaUrl() string { // A collection of Metrics produced by an Scope. type ScopeMetrics struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The instrumentation scope information for the metrics in this message. // Semantically when InstrumentationScope isn't set, it is equivalent with // an empty instrumentation scope name (unknown). @@ -377,16 +369,16 @@ type ScopeMetrics struct { // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url // This schema_url applies to the data in the "scope" field and all metrics in the // "metrics" field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ScopeMetrics) Reset() { *x = ScopeMetrics{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ScopeMetrics) String() string { @@ -397,7 +389,7 @@ func (*ScopeMetrics) ProtoMessage() {} func (x *ScopeMetrics) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -436,65 +428,68 @@ func (x *ScopeMetrics) GetSchemaUrl() string { // Defines a Metric which has one or more timeseries. The following is a // brief summary of the Metric data model. For more details, see: // -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md +// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md // // The data model and relation between entities is shown in the // diagram below. Here, "DataPoint" is the term used to refer to any // one of the specific data point value types, and "points" is the term used // to refer to any one of the lists of points contained in the Metric. // -// - Metric is composed of a metadata and data. -// - Metadata part contains a name, description, unit. -// - Data is one of the possible types (Sum, Gauge, Histogram, Summary). -// - DataPoint contains timestamps, attributes, and one of the possible value type -// fields. +// - Metric is composed of a metadata and data. +// +// - Metadata part contains a name, description, unit. +// +// - Data is one of the possible types (Sum, Gauge, Histogram, Summary). +// +// - DataPoint contains timestamps, attributes, and one of the possible value type +// fields. // -// Metric -// +------------+ -// |name | -// |description | -// |unit | +------------------------------------+ -// |data |---> |Gauge, Sum, Histogram, Summary, ... | -// +------------+ +------------------------------------+ +// Metric +// +------------+ +// |name | +// |description | +// |unit | +------------------------------------+ +// |data |---> |Gauge, Sum, Histogram, Summary, ... | +// +------------+ +------------------------------------+ // -// Data [One of Gauge, Sum, Histogram, Summary, ...] -// +-----------+ -// |... | // Metadata about the Data. -// |points |--+ -// +-----------+ | -// | +---------------------------+ -// | |DataPoint 1 | -// v |+------+------+ +------+ | -// +-----+ ||label |label |...|label | | -// | 1 |-->||value1|value2|...|valueN| | -// +-----+ |+------+------+ +------+ | -// | . | |+-----+ | -// | . | ||value| | -// | . | |+-----+ | -// | . | +---------------------------+ -// | . | . -// | . | . -// | . | . -// | . | +---------------------------+ -// | . | |DataPoint M | -// +-----+ |+------+------+ +------+ | -// | M |-->||label |label |...|label | | -// +-----+ ||value1|value2|...|valueN| | -// |+------+------+ +------+ | -// |+-----+ | -// ||value| | -// |+-----+ | -// +---------------------------+ +// Data [One of Gauge, Sum, Histogram, Summary, ...] +// +-----------+ +// |... | // Metadata about the Data. +// |points |--+ +// +-----------+ | +// | +---------------------------+ +// | |DataPoint 1 | +// v |+------+------+ +------+ | +// +-----+ ||label |label |...|label | | +// | 1 |-->||value1|value2|...|valueN| | +// +-----+ |+------+------+ +------+ | +// | . | |+-----+ | +// | . | ||value| | +// | . | |+-----+ | +// | . | +---------------------------+ +// | . | . +// | . | . +// | . | . +// | . | +---------------------------+ +// | . | |DataPoint M | +// +-----+ |+------+------+ +------+ | +// | M |-->||label |label |...|label | | +// +-----+ ||value1|value2|...|valueN| | +// |+------+------+ +------+ | +// |+-----+ | +// ||value| | +// |+-----+ | +// +---------------------------+ // // Each distinct type of DataPoint represents the output of a specific // aggregation function, the result of applying the DataPoint's // associated function of to one or more measurements. // // All DataPoint types have three common fields: -// - Attributes includes key-value pairs associated with the data point -// - TimeUnixNano is required, set to the end time of the aggregation -// - StartTimeUnixNano is optional, but strongly encouraged for DataPoints -// having an AggregationTemporality field, as discussed below. +// - Attributes includes key-value pairs associated with the data point +// - TimeUnixNano is required, set to the end time of the aggregation +// - StartTimeUnixNano is optional, but strongly encouraged for DataPoints +// having an AggregationTemporality field, as discussed below. // // Both TimeUnixNano and StartTimeUnixNano values are expressed as // UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. @@ -518,10 +513,7 @@ func (x *ScopeMetrics) GetSchemaUrl() string { // when the start time is truly unknown, setting StartTimeUnixNano is // strongly encouraged. type Metric struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The name of the metric. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // A description of the metric, which can be used in documentation. @@ -530,10 +522,11 @@ type Metric struct { // described by https://ucum.org/ucum and https://units-of-measurement.org/ Unit string `protobuf:"bytes,3,opt,name=unit,proto3" json:"unit,omitempty"` // Data determines the aggregation type (if any) of the metric, what is the - // reported value type for the data points, as well as the relatationship to + // reported value type for the data points, as well as the relationship to // the time interval over which they are reported. // - // Types that are assignable to Data: + // Types that are valid to be assigned to Data: + // // *Metric_Gauge // *Metric_Sum // *Metric_Histogram @@ -548,16 +541,18 @@ type Metric struct { // Attribute keys MUST be unique (it is not allowed to have more than one // attribute with the same key). // The behavior of software that receives duplicated keys can be unpredictable. - Metadata []*v11.KeyValue `protobuf:"bytes,12,rep,name=metadata,proto3" json:"metadata,omitempty"` + // + // [Since v1.2.0] + Metadata []*v11.KeyValue `protobuf:"bytes,12,rep,name=metadata,proto3" json:"metadata,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Metric) Reset() { *x = Metric{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Metric) String() string { @@ -568,7 +563,7 @@ func (*Metric) ProtoMessage() {} func (x *Metric) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -604,44 +599,54 @@ func (x *Metric) GetUnit() string { return "" } -func (m *Metric) GetData() isMetric_Data { - if m != nil { - return m.Data +func (x *Metric) GetData() isMetric_Data { + if x != nil { + return x.Data } return nil } func (x *Metric) GetGauge() *Gauge { - if x, ok := x.GetData().(*Metric_Gauge); ok { - return x.Gauge + if x != nil { + if x, ok := x.Data.(*Metric_Gauge); ok { + return x.Gauge + } } return nil } func (x *Metric) GetSum() *Sum { - if x, ok := x.GetData().(*Metric_Sum); ok { - return x.Sum + if x != nil { + if x, ok := x.Data.(*Metric_Sum); ok { + return x.Sum + } } return nil } func (x *Metric) GetHistogram() *Histogram { - if x, ok := x.GetData().(*Metric_Histogram); ok { - return x.Histogram + if x != nil { + if x, ok := x.Data.(*Metric_Histogram); ok { + return x.Histogram + } } return nil } func (x *Metric) GetExponentialHistogram() *ExponentialHistogram { - if x, ok := x.GetData().(*Metric_ExponentialHistogram); ok { - return x.ExponentialHistogram + if x != nil { + if x, ok := x.Data.(*Metric_ExponentialHistogram); ok { + return x.ExponentialHistogram + } } return nil } func (x *Metric) GetSummary() *Summary { - if x, ok := x.GetData().(*Metric_Summary); ok { - return x.Summary + if x != nil { + if x, ok := x.Data.(*Metric_Summary); ok { + return x.Summary + } } return nil } @@ -697,22 +702,19 @@ func (*Metric_Summary) isMetric_Data() {} // AggregationTemporality is not included. Consequently, this also means // "StartTimeUnixNano" is ignored for all data points. type Gauge struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The time series data points. // Note: Multiple time series may be included (same timestamp, different attributes). - DataPoints []*NumberDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` + DataPoints []*NumberDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Gauge) Reset() { *x = Gauge{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Gauge) String() string { @@ -723,7 +725,7 @@ func (*Gauge) ProtoMessage() {} func (x *Gauge) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -748,10 +750,7 @@ func (x *Gauge) GetDataPoints() []*NumberDataPoint { // Sum represents the type of a scalar metric that is calculated as a sum of all // reported measurements over a time interval. type Sum struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The time series data points. // Note: Multiple time series may be included (same timestamp, different attributes). DataPoints []*NumberDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` @@ -759,16 +758,16 @@ type Sum struct { // since last report time, or cumulative changes since a fixed start time. AggregationTemporality AggregationTemporality `protobuf:"varint,2,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.metrics.v1.AggregationTemporality" json:"aggregation_temporality,omitempty"` // Represents whether the sum is monotonic. - IsMonotonic bool `protobuf:"varint,3,opt,name=is_monotonic,json=isMonotonic,proto3" json:"is_monotonic,omitempty"` + IsMonotonic bool `protobuf:"varint,3,opt,name=is_monotonic,json=isMonotonic,proto3" json:"is_monotonic,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Sum) Reset() { *x = Sum{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Sum) String() string { @@ -779,7 +778,7 @@ func (*Sum) ProtoMessage() {} func (x *Sum) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -818,25 +817,22 @@ func (x *Sum) GetIsMonotonic() bool { // Histogram represents the type of a metric that is calculated by aggregating // as a Histogram of all reported measurements over a time interval. type Histogram struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The time series data points. // Note: Multiple time series may be included (same timestamp, different attributes). DataPoints []*HistogramDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` // aggregation_temporality describes if the aggregator reports delta changes // since last report time, or cumulative changes since a fixed start time. AggregationTemporality AggregationTemporality `protobuf:"varint,2,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.metrics.v1.AggregationTemporality" json:"aggregation_temporality,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Histogram) Reset() { *x = Histogram{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Histogram) String() string { @@ -847,7 +843,7 @@ func (*Histogram) ProtoMessage() {} func (x *Histogram) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -879,25 +875,22 @@ func (x *Histogram) GetAggregationTemporality() AggregationTemporality { // ExponentialHistogram represents the type of a metric that is calculated by aggregating // as a ExponentialHistogram of all reported double measurements over a time interval. type ExponentialHistogram struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The time series data points. // Note: Multiple time series may be included (same timestamp, different attributes). DataPoints []*ExponentialHistogramDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` // aggregation_temporality describes if the aggregator reports delta changes // since last report time, or cumulative changes since a fixed start time. AggregationTemporality AggregationTemporality `protobuf:"varint,2,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.metrics.v1.AggregationTemporality" json:"aggregation_temporality,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExponentialHistogram) Reset() { *x = ExponentialHistogram{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExponentialHistogram) String() string { @@ -908,7 +901,7 @@ func (*ExponentialHistogram) ProtoMessage() {} func (x *ExponentialHistogram) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -947,22 +940,19 @@ func (x *ExponentialHistogram) GetAggregationTemporality() AggregationTemporalit // because the count and sum fields of a SummaryDataPoint are assumed to be // cumulative values. type Summary struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The time series data points. // Note: Multiple time series may be included (same timestamp, different attributes). - DataPoints []*SummaryDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` + DataPoints []*SummaryDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Summary) Reset() { *x = Summary{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Summary) String() string { @@ -973,7 +963,7 @@ func (*Summary) ProtoMessage() {} func (x *Summary) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -998,10 +988,7 @@ func (x *Summary) GetDataPoints() []*SummaryDataPoint { // NumberDataPoint is a single data point in a timeseries that describes the // time-varying scalar value of a metric. type NumberDataPoint struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The set of key/value pairs that uniquely identify the timeseries from // where this point belongs. The list may be empty (may contain 0 elements). // Attribute keys MUST be unique (it is not allowed to have more than one @@ -1022,7 +1009,8 @@ type NumberDataPoint struct { // The value itself. A point is considered invalid when one of the recognized // value fields is not present inside this oneof. // - // Types that are assignable to Value: + // Types that are valid to be assigned to Value: + // // *NumberDataPoint_AsDouble // *NumberDataPoint_AsInt Value isNumberDataPoint_Value `protobuf_oneof:"value"` @@ -1031,16 +1019,16 @@ type NumberDataPoint struct { Exemplars []*Exemplar `protobuf:"bytes,5,rep,name=exemplars,proto3" json:"exemplars,omitempty"` // Flags that apply to this specific data point. See DataPointFlags // for the available flags and their meaning. - Flags uint32 `protobuf:"varint,8,opt,name=flags,proto3" json:"flags,omitempty"` + Flags uint32 `protobuf:"varint,8,opt,name=flags,proto3" json:"flags,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *NumberDataPoint) Reset() { *x = NumberDataPoint{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *NumberDataPoint) String() string { @@ -1051,7 +1039,7 @@ func (*NumberDataPoint) ProtoMessage() {} func (x *NumberDataPoint) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1087,23 +1075,27 @@ func (x *NumberDataPoint) GetTimeUnixNano() uint64 { return 0 } -func (m *NumberDataPoint) GetValue() isNumberDataPoint_Value { - if m != nil { - return m.Value +func (x *NumberDataPoint) GetValue() isNumberDataPoint_Value { + if x != nil { + return x.Value } return nil } func (x *NumberDataPoint) GetAsDouble() float64 { - if x, ok := x.GetValue().(*NumberDataPoint_AsDouble); ok { - return x.AsDouble + if x != nil { + if x, ok := x.Value.(*NumberDataPoint_AsDouble); ok { + return x.AsDouble + } } return 0 } func (x *NumberDataPoint) GetAsInt() int64 { - if x, ok := x.GetValue().(*NumberDataPoint_AsInt); ok { - return x.AsInt + if x != nil { + if x, ok := x.Value.(*NumberDataPoint_AsInt); ok { + return x.AsInt + } } return 0 } @@ -1149,10 +1141,7 @@ func (*NumberDataPoint_AsInt) isNumberDataPoint_Value() {} // "explicit_bounds" and "bucket_counts" must be omitted and only "count" and // "sum" are known. type HistogramDataPoint struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The set of key/value pairs that uniquely identify the timeseries from // where this point belongs. The list may be empty (may contain 0 elements). // Attribute keys MUST be unique (it is not allowed to have more than one @@ -1219,16 +1208,16 @@ type HistogramDataPoint struct { // min is the minimum value over (start_time, end_time]. Min *float64 `protobuf:"fixed64,11,opt,name=min,proto3,oneof" json:"min,omitempty"` // max is the maximum value over (start_time, end_time]. - Max *float64 `protobuf:"fixed64,12,opt,name=max,proto3,oneof" json:"max,omitempty"` + Max *float64 `protobuf:"fixed64,12,opt,name=max,proto3,oneof" json:"max,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *HistogramDataPoint) Reset() { *x = HistogramDataPoint{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *HistogramDataPoint) String() string { @@ -1239,7 +1228,7 @@ func (*HistogramDataPoint) ProtoMessage() {} func (x *HistogramDataPoint) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1335,12 +1324,8 @@ func (x *HistogramDataPoint) GetMax() float64 { // time-varying values of a ExponentialHistogram of double values. A ExponentialHistogram contains // summary statistics for a population of values, it may optionally contain the // distribution of those values across a set of buckets. -// type ExponentialHistogramDataPoint struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The set of key/value pairs that uniquely identify the timeseries from // where this point belongs. The list may be empty (may contain 0 elements). // Attribute keys MUST be unique (it is not allowed to have more than one @@ -1374,7 +1359,7 @@ type ExponentialHistogramDataPoint struct { // scale describes the resolution of the histogram. Boundaries are // located at powers of the base, where: // - // base = (2^(2^-scale)) + // base = (2^(2^-scale)) // // The histogram bucket identified by `index`, a signed integer, // contains values that are greater than (base^index) and @@ -1417,15 +1402,15 @@ type ExponentialHistogramDataPoint struct { // expressed using the standard exponential formula as well as values that // have been rounded to zero. ZeroThreshold float64 `protobuf:"fixed64,14,opt,name=zero_threshold,json=zeroThreshold,proto3" json:"zero_threshold,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExponentialHistogramDataPoint) Reset() { *x = ExponentialHistogramDataPoint{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExponentialHistogramDataPoint) String() string { @@ -1436,7 +1421,7 @@ func (*ExponentialHistogramDataPoint) ProtoMessage() {} func (x *ExponentialHistogramDataPoint) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1553,10 +1538,7 @@ func (x *ExponentialHistogramDataPoint) GetZeroThreshold() float64 { // time-varying values of a Summary metric. The count and sum fields represent // cumulative values. type SummaryDataPoint struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The set of key/value pairs that uniquely identify the timeseries from // where this point belongs. The list may be empty (may contain 0 elements). // Attribute keys MUST be unique (it is not allowed to have more than one @@ -1590,16 +1572,16 @@ type SummaryDataPoint struct { QuantileValues []*SummaryDataPoint_ValueAtQuantile `protobuf:"bytes,6,rep,name=quantile_values,json=quantileValues,proto3" json:"quantile_values,omitempty"` // Flags that apply to this specific data point. See DataPointFlags // for the available flags and their meaning. - Flags uint32 `protobuf:"varint,8,opt,name=flags,proto3" json:"flags,omitempty"` + Flags uint32 `protobuf:"varint,8,opt,name=flags,proto3" json:"flags,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *SummaryDataPoint) Reset() { *x = SummaryDataPoint{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SummaryDataPoint) String() string { @@ -1610,7 +1592,7 @@ func (*SummaryDataPoint) ProtoMessage() {} func (x *SummaryDataPoint) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1679,10 +1661,7 @@ func (x *SummaryDataPoint) GetFlags() uint32 { // was recorded, for example the span and trace ID of the active span when the // exemplar was recorded. type Exemplar struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The set of key/value pairs that were filtered out by the aggregator, but // recorded alongside the original measurement. Only key/value pairs that were // filtered out by the aggregator should be included @@ -1696,7 +1675,8 @@ type Exemplar struct { // considered invalid when one of the recognized value fields is not present // inside this oneof. // - // Types that are assignable to Value: + // Types that are valid to be assigned to Value: + // // *Exemplar_AsDouble // *Exemplar_AsInt Value isExemplar_Value `protobuf_oneof:"value"` @@ -1707,16 +1687,16 @@ type Exemplar struct { // (Optional) Trace ID of the exemplar trace. // trace_id may be missing if the measurement is not recorded inside a trace // or if the trace is not sampled. - TraceId []byte `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId []byte `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Exemplar) Reset() { *x = Exemplar{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Exemplar) String() string { @@ -1727,7 +1707,7 @@ func (*Exemplar) ProtoMessage() {} func (x *Exemplar) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1756,23 +1736,27 @@ func (x *Exemplar) GetTimeUnixNano() uint64 { return 0 } -func (m *Exemplar) GetValue() isExemplar_Value { - if m != nil { - return m.Value +func (x *Exemplar) GetValue() isExemplar_Value { + if x != nil { + return x.Value } return nil } func (x *Exemplar) GetAsDouble() float64 { - if x, ok := x.GetValue().(*Exemplar_AsDouble); ok { - return x.AsDouble + if x != nil { + if x, ok := x.Value.(*Exemplar_AsDouble); ok { + return x.AsDouble + } } return 0 } func (x *Exemplar) GetAsInt() int64 { - if x, ok := x.GetValue().(*Exemplar_AsInt); ok { - return x.AsInt + if x != nil { + if x, ok := x.Value.(*Exemplar_AsInt); ok { + return x.AsInt + } } return 0 } @@ -1810,10 +1794,7 @@ func (*Exemplar_AsInt) isExemplar_Value() {} // Buckets are a set of bucket counts, encoded in a contiguous array // of counts. type ExponentialHistogramDataPoint_Buckets struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The bucket index of the first entry in the bucket_counts array. // // Note: This uses a varint encoding as a simple form of compression. @@ -1827,16 +1808,16 @@ type ExponentialHistogramDataPoint_Buckets struct { // fixed64. This field is expected to have many buckets, // especially zeros, so uint64 has been selected to ensure // varint encoding. - BucketCounts []uint64 `protobuf:"varint,2,rep,packed,name=bucket_counts,json=bucketCounts,proto3" json:"bucket_counts,omitempty"` + BucketCounts []uint64 `protobuf:"varint,2,rep,packed,name=bucket_counts,json=bucketCounts,proto3" json:"bucket_counts,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ExponentialHistogramDataPoint_Buckets) Reset() { *x = ExponentialHistogramDataPoint_Buckets{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ExponentialHistogramDataPoint_Buckets) String() string { @@ -1847,7 +1828,7 @@ func (*ExponentialHistogramDataPoint_Buckets) ProtoMessage() {} func (x *ExponentialHistogramDataPoint_Buckets) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1885,26 +1866,23 @@ func (x *ExponentialHistogramDataPoint_Buckets) GetBucketCounts() []uint64 { // See the following issue for more context: // https://github.com/open-telemetry/opentelemetry-proto/issues/125 type SummaryDataPoint_ValueAtQuantile struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The quantile of a distribution. Must be in the interval // [0.0, 1.0]. Quantile float64 `protobuf:"fixed64,1,opt,name=quantile,proto3" json:"quantile,omitempty"` // The value at the given quantile of a distribution. // // Quantile values must NOT be negative. - Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *SummaryDataPoint_ValueAtQuantile) Reset() { *x = SummaryDataPoint_ValueAtQuantile{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SummaryDataPoint_ValueAtQuantile) String() string { @@ -1915,7 +1893,7 @@ func (*SummaryDataPoint_ValueAtQuantile) ProtoMessage() {} func (x *SummaryDataPoint_ValueAtQuantile) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1946,321 +1924,151 @@ func (x *SummaryDataPoint_ValueAtQuantile) GetValue() float64 { var File_opentelemetry_proto_metrics_v1_metrics_proto protoreflect.FileDescriptor -var file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc = []byte{ - 0x0a, 0x2c, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x76, 0x31, - 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x2a, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x6f, 0x70, 0x65, 0x6e, - 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x69, 0x0a, 0x0b, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x44, 0x61, 0x74, 0x61, 0x12, 0x5a, 0x0a, 0x10, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x73, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0xd2, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x45, 0x0a, 0x08, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6f, 0x70, - 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x12, 0x51, 0x0a, 0x0d, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x52, 0x0c, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x75, 0x72, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x55, - 0x72, 0x6c, 0x4a, 0x06, 0x08, 0xe8, 0x07, 0x10, 0xe9, 0x07, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x53, - 0x63, 0x6f, 0x70, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x49, 0x0a, 0x05, 0x73, - 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x6f, 0x70, 0x65, - 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x72, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x52, - 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x40, 0x0a, 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, - 0x07, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x55, 0x72, 0x6c, 0x22, 0xa6, 0x04, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x6e, 0x69, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x6e, 0x69, 0x74, 0x12, 0x3d, 0x0a, 0x05, - 0x67, 0x61, 0x75, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6f, 0x70, - 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x61, 0x75, - 0x67, 0x65, 0x48, 0x00, 0x52, 0x05, 0x67, 0x61, 0x75, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x03, 0x73, - 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, - 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x6d, 0x48, 0x00, 0x52, - 0x03, 0x73, 0x75, 0x6d, 0x12, 0x49, 0x0a, 0x09, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, - 0x6d, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, - 0x61, 0x6d, 0x48, 0x00, 0x52, 0x09, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, - 0x6b, 0x0a, 0x15, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x68, - 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, - 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x45, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x48, 0x69, 0x73, 0x74, 0x6f, - 0x67, 0x72, 0x61, 0x6d, 0x48, 0x00, 0x52, 0x14, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, - 0x69, 0x61, 0x6c, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x43, 0x0a, 0x07, - 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x48, 0x00, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, - 0x79, 0x12, 0x43, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0c, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x4a, 0x04, - 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, - 0x22, 0x59, 0x0a, 0x05, 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x50, 0x0a, 0x0b, 0x64, 0x61, 0x74, - 0x61, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, - 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, - 0x0a, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0xeb, 0x01, 0x0a, 0x03, - 0x53, 0x75, 0x6d, 0x12, 0x50, 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, - 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x50, - 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x6f, 0x0a, 0x17, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, - 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x16, - 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6f, - 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x6d, 0x6f, 0x6e, - 0x6f, 0x74, 0x6f, 0x6e, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, - 0x4d, 0x6f, 0x6e, 0x6f, 0x74, 0x6f, 0x6e, 0x69, 0x63, 0x22, 0xd1, 0x01, 0x0a, 0x09, 0x48, 0x69, - 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x53, 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x5f, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x6f, - 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x69, - 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, - 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x6f, 0x0a, 0x17, - 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x65, 0x6d, 0x70, - 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, - 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, - 0x61, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x16, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0xe7, 0x01, - 0x0a, 0x14, 0x45, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x48, 0x69, 0x73, - 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x5e, 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, 0x2e, 0x6f, 0x70, - 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, - 0x6d, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, - 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x6f, 0x0a, 0x17, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, - 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x52, - 0x16, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, - 0x6f, 0x72, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x5c, 0x0a, 0x07, 0x53, 0x75, 0x6d, 0x6d, 0x61, - 0x72, 0x79, 0x12, 0x51, 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x50, - 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0xd6, 0x02, 0x0a, 0x0f, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x0a, 0x61, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, - 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x06, - 0x52, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, - 0x61, 0x6e, 0x6f, 0x12, 0x24, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, - 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, 0x74, 0x69, 0x6d, - 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x1d, 0x0a, 0x09, 0x61, 0x73, 0x5f, - 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x08, - 0x61, 0x73, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x12, 0x17, 0x0a, 0x06, 0x61, 0x73, 0x5f, 0x69, - 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x10, 0x48, 0x00, 0x52, 0x05, 0x61, 0x73, 0x49, 0x6e, - 0x74, 0x12, 0x46, 0x0a, 0x09, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, - 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x09, - 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, - 0x67, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x42, - 0x07, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0xd9, - 0x03, 0x0a, 0x12, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x44, 0x61, 0x74, 0x61, - 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, - 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x2f, - 0x0a, 0x14, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x75, 0x6e, 0x69, - 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x06, 0x52, 0x11, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, - 0x24, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, - 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, - 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x06, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x15, 0x0a, 0x03, 0x73, - 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x88, - 0x01, 0x01, 0x12, 0x23, 0x0a, 0x0d, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x06, 0x52, 0x0c, 0x62, 0x75, 0x63, 0x6b, 0x65, - 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x6c, 0x69, - 0x63, 0x69, 0x74, 0x5f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x01, - 0x52, 0x0e, 0x65, 0x78, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x42, 0x6f, 0x75, 0x6e, 0x64, 0x73, - 0x12, 0x46, 0x0a, 0x09, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x18, 0x08, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x09, 0x65, - 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, - 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x15, - 0x0a, 0x03, 0x6d, 0x69, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x01, 0x48, 0x01, 0x52, 0x03, 0x6d, - 0x69, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x15, 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x01, 0x48, 0x02, 0x52, 0x03, 0x6d, 0x61, 0x78, 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, 0x04, - 0x5f, 0x73, 0x75, 0x6d, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x6d, 0x69, 0x6e, 0x42, 0x06, 0x0a, 0x04, - 0x5f, 0x6d, 0x61, 0x78, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0xfa, 0x05, 0x0a, 0x1d, 0x45, - 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, - 0x72, 0x61, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x0a, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, - 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x06, 0x52, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, - 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x24, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x75, - 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, - 0x74, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x14, 0x0a, 0x05, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x06, 0x52, 0x05, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x15, 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x48, - 0x00, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x88, 0x01, 0x01, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x61, - 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x11, 0x52, 0x05, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x06, 0x52, 0x09, 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x61, - 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x45, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x48, 0x69, 0x73, - 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x2e, - 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, - 0x65, 0x12, 0x61, 0x0a, 0x08, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, - 0x48, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, - 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x52, 0x08, 0x6e, 0x65, 0x67, 0x61, - 0x74, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x46, 0x0a, 0x09, 0x65, 0x78, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x45, - 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x09, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x72, 0x73, 0x12, 0x15, 0x0a, 0x03, 0x6d, 0x69, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x01, 0x48, - 0x01, 0x52, 0x03, 0x6d, 0x69, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x15, 0x0a, 0x03, 0x6d, 0x61, 0x78, - 0x18, 0x0d, 0x20, 0x01, 0x28, 0x01, 0x48, 0x02, 0x52, 0x03, 0x6d, 0x61, 0x78, 0x88, 0x01, 0x01, - 0x12, 0x25, 0x0a, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, - 0x6c, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x7a, 0x65, 0x72, 0x6f, 0x54, 0x68, - 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x1a, 0x46, 0x0a, 0x07, 0x42, 0x75, 0x63, 0x6b, 0x65, - 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x11, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x62, 0x75, - 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x04, 0x52, 0x0c, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, - 0x06, 0x0a, 0x04, 0x5f, 0x73, 0x75, 0x6d, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x6d, 0x69, 0x6e, 0x42, - 0x06, 0x0a, 0x04, 0x5f, 0x6d, 0x61, 0x78, 0x22, 0xa6, 0x03, 0x0a, 0x10, 0x53, 0x75, 0x6d, 0x6d, - 0x61, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x0a, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, - 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x06, 0x52, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, - 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x24, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x75, - 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, - 0x74, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x14, 0x0a, 0x05, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x06, 0x52, 0x05, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, - 0x03, 0x73, 0x75, 0x6d, 0x12, 0x69, 0x0a, 0x0f, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x2e, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x41, 0x74, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x52, - 0x0e, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, - 0x66, 0x6c, 0x61, 0x67, 0x73, 0x1a, 0x43, 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x41, 0x74, - 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, - 0x74, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, - 0x74, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, - 0x22, 0x85, 0x02, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x12, 0x58, 0x0a, - 0x13, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, - 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x52, 0x12, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x65, 0x64, 0x41, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x5f, - 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x06, 0x52, - 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x1d, 0x0a, - 0x09, 0x61, 0x73, 0x5f, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, - 0x48, 0x00, 0x52, 0x08, 0x61, 0x73, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x12, 0x17, 0x0a, 0x06, - 0x61, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x10, 0x48, 0x00, 0x52, 0x05, - 0x61, 0x73, 0x49, 0x6e, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x70, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x19, - 0x0a, 0x08, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x07, 0x74, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x2a, 0x8c, 0x01, 0x0a, 0x16, 0x41, 0x67, 0x67, - 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, - 0x69, 0x74, 0x79, 0x12, 0x27, 0x0a, 0x23, 0x41, 0x47, 0x47, 0x52, 0x45, 0x47, 0x41, 0x54, 0x49, - 0x4f, 0x4e, 0x5f, 0x54, 0x45, 0x4d, 0x50, 0x4f, 0x52, 0x41, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x55, - 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, - 0x41, 0x47, 0x47, 0x52, 0x45, 0x47, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x45, 0x4d, 0x50, - 0x4f, 0x52, 0x41, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x44, 0x45, 0x4c, 0x54, 0x41, 0x10, 0x01, 0x12, - 0x26, 0x0a, 0x22, 0x41, 0x47, 0x47, 0x52, 0x45, 0x47, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, - 0x45, 0x4d, 0x50, 0x4f, 0x52, 0x41, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x43, 0x55, 0x4d, 0x55, 0x4c, - 0x41, 0x54, 0x49, 0x56, 0x45, 0x10, 0x02, 0x2a, 0x5e, 0x0a, 0x0e, 0x44, 0x61, 0x74, 0x61, 0x50, - 0x6f, 0x69, 0x6e, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x1f, 0x0a, 0x1b, 0x44, 0x41, 0x54, - 0x41, 0x5f, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x53, 0x5f, 0x44, 0x4f, - 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x55, 0x53, 0x45, 0x10, 0x00, 0x12, 0x2b, 0x0a, 0x27, 0x44, 0x41, - 0x54, 0x41, 0x5f, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x53, 0x5f, 0x4e, - 0x4f, 0x5f, 0x52, 0x45, 0x43, 0x4f, 0x52, 0x44, 0x45, 0x44, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, - 0x5f, 0x4d, 0x41, 0x53, 0x4b, 0x10, 0x01, 0x42, 0x7f, 0x0a, 0x21, 0x69, 0x6f, 0x2e, 0x6f, 0x70, - 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x6f, - 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x69, - 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x74, 0x6c, 0x70, 0x2f, 0x6d, 0x65, 0x74, - 0x72, 0x69, 0x63, 0x73, 0x2f, 0x76, 0x31, 0xaa, 0x02, 0x1e, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc = "" + + "\n" + + ",opentelemetry/proto/metrics/v1/metrics.proto\x12\x1eopentelemetry.proto.metrics.v1\x1a*opentelemetry/proto/common/v1/common.proto\x1a.opentelemetry/proto/resource/v1/resource.proto\"i\n" + + "\vMetricsData\x12Z\n" + + "\x10resource_metrics\x18\x01 \x03(\v2/.opentelemetry.proto.metrics.v1.ResourceMetricsR\x0fresourceMetrics\"\xd2\x01\n" + + "\x0fResourceMetrics\x12E\n" + + "\bresource\x18\x01 \x01(\v2).opentelemetry.proto.resource.v1.ResourceR\bresource\x12Q\n" + + "\rscope_metrics\x18\x02 \x03(\v2,.opentelemetry.proto.metrics.v1.ScopeMetricsR\fscopeMetrics\x12\x1d\n" + + "\n" + + "schema_url\x18\x03 \x01(\tR\tschemaUrlJ\x06\b\xe8\a\x10\xe9\a\"\xba\x01\n" + + "\fScopeMetrics\x12I\n" + + "\x05scope\x18\x01 \x01(\v23.opentelemetry.proto.common.v1.InstrumentationScopeR\x05scope\x12@\n" + + "\ametrics\x18\x02 \x03(\v2&.opentelemetry.proto.metrics.v1.MetricR\ametrics\x12\x1d\n" + + "\n" + + "schema_url\x18\x03 \x01(\tR\tschemaUrl\"\xa6\x04\n" + + "\x06Metric\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x02 \x01(\tR\vdescription\x12\x12\n" + + "\x04unit\x18\x03 \x01(\tR\x04unit\x12=\n" + + "\x05gauge\x18\x05 \x01(\v2%.opentelemetry.proto.metrics.v1.GaugeH\x00R\x05gauge\x127\n" + + "\x03sum\x18\a \x01(\v2#.opentelemetry.proto.metrics.v1.SumH\x00R\x03sum\x12I\n" + + "\thistogram\x18\t \x01(\v2).opentelemetry.proto.metrics.v1.HistogramH\x00R\thistogram\x12k\n" + + "\x15exponential_histogram\x18\n" + + " \x01(\v24.opentelemetry.proto.metrics.v1.ExponentialHistogramH\x00R\x14exponentialHistogram\x12C\n" + + "\asummary\x18\v \x01(\v2'.opentelemetry.proto.metrics.v1.SummaryH\x00R\asummary\x12C\n" + + "\bmetadata\x18\f \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\bmetadataB\x06\n" + + "\x04dataJ\x04\b\x04\x10\x05J\x04\b\x06\x10\aJ\x04\b\b\x10\t\"Y\n" + + "\x05Gauge\x12P\n" + + "\vdata_points\x18\x01 \x03(\v2/.opentelemetry.proto.metrics.v1.NumberDataPointR\n" + + "dataPoints\"\xeb\x01\n" + + "\x03Sum\x12P\n" + + "\vdata_points\x18\x01 \x03(\v2/.opentelemetry.proto.metrics.v1.NumberDataPointR\n" + + "dataPoints\x12o\n" + + "\x17aggregation_temporality\x18\x02 \x01(\x0e26.opentelemetry.proto.metrics.v1.AggregationTemporalityR\x16aggregationTemporality\x12!\n" + + "\fis_monotonic\x18\x03 \x01(\bR\visMonotonic\"\xd1\x01\n" + + "\tHistogram\x12S\n" + + "\vdata_points\x18\x01 \x03(\v22.opentelemetry.proto.metrics.v1.HistogramDataPointR\n" + + "dataPoints\x12o\n" + + "\x17aggregation_temporality\x18\x02 \x01(\x0e26.opentelemetry.proto.metrics.v1.AggregationTemporalityR\x16aggregationTemporality\"\xe7\x01\n" + + "\x14ExponentialHistogram\x12^\n" + + "\vdata_points\x18\x01 \x03(\v2=.opentelemetry.proto.metrics.v1.ExponentialHistogramDataPointR\n" + + "dataPoints\x12o\n" + + "\x17aggregation_temporality\x18\x02 \x01(\x0e26.opentelemetry.proto.metrics.v1.AggregationTemporalityR\x16aggregationTemporality\"\\\n" + + "\aSummary\x12Q\n" + + "\vdata_points\x18\x01 \x03(\v20.opentelemetry.proto.metrics.v1.SummaryDataPointR\n" + + "dataPoints\"\xd6\x02\n" + + "\x0fNumberDataPoint\x12G\n" + + "\n" + + "attributes\x18\a \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x12/\n" + + "\x14start_time_unix_nano\x18\x02 \x01(\x06R\x11startTimeUnixNano\x12$\n" + + "\x0etime_unix_nano\x18\x03 \x01(\x06R\ftimeUnixNano\x12\x1d\n" + + "\tas_double\x18\x04 \x01(\x01H\x00R\basDouble\x12\x17\n" + + "\x06as_int\x18\x06 \x01(\x10H\x00R\x05asInt\x12F\n" + + "\texemplars\x18\x05 \x03(\v2(.opentelemetry.proto.metrics.v1.ExemplarR\texemplars\x12\x14\n" + + "\x05flags\x18\b \x01(\rR\x05flagsB\a\n" + + "\x05valueJ\x04\b\x01\x10\x02\"\xd9\x03\n" + + "\x12HistogramDataPoint\x12G\n" + + "\n" + + "attributes\x18\t \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x12/\n" + + "\x14start_time_unix_nano\x18\x02 \x01(\x06R\x11startTimeUnixNano\x12$\n" + + "\x0etime_unix_nano\x18\x03 \x01(\x06R\ftimeUnixNano\x12\x14\n" + + "\x05count\x18\x04 \x01(\x06R\x05count\x12\x15\n" + + "\x03sum\x18\x05 \x01(\x01H\x00R\x03sum\x88\x01\x01\x12#\n" + + "\rbucket_counts\x18\x06 \x03(\x06R\fbucketCounts\x12'\n" + + "\x0fexplicit_bounds\x18\a \x03(\x01R\x0eexplicitBounds\x12F\n" + + "\texemplars\x18\b \x03(\v2(.opentelemetry.proto.metrics.v1.ExemplarR\texemplars\x12\x14\n" + + "\x05flags\x18\n" + + " \x01(\rR\x05flags\x12\x15\n" + + "\x03min\x18\v \x01(\x01H\x01R\x03min\x88\x01\x01\x12\x15\n" + + "\x03max\x18\f \x01(\x01H\x02R\x03max\x88\x01\x01B\x06\n" + + "\x04_sumB\x06\n" + + "\x04_minB\x06\n" + + "\x04_maxJ\x04\b\x01\x10\x02\"\xfa\x05\n" + + "\x1dExponentialHistogramDataPoint\x12G\n" + + "\n" + + "attributes\x18\x01 \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x12/\n" + + "\x14start_time_unix_nano\x18\x02 \x01(\x06R\x11startTimeUnixNano\x12$\n" + + "\x0etime_unix_nano\x18\x03 \x01(\x06R\ftimeUnixNano\x12\x14\n" + + "\x05count\x18\x04 \x01(\x06R\x05count\x12\x15\n" + + "\x03sum\x18\x05 \x01(\x01H\x00R\x03sum\x88\x01\x01\x12\x14\n" + + "\x05scale\x18\x06 \x01(\x11R\x05scale\x12\x1d\n" + + "\n" + + "zero_count\x18\a \x01(\x06R\tzeroCount\x12a\n" + + "\bpositive\x18\b \x01(\v2E.opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.BucketsR\bpositive\x12a\n" + + "\bnegative\x18\t \x01(\v2E.opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.BucketsR\bnegative\x12\x14\n" + + "\x05flags\x18\n" + + " \x01(\rR\x05flags\x12F\n" + + "\texemplars\x18\v \x03(\v2(.opentelemetry.proto.metrics.v1.ExemplarR\texemplars\x12\x15\n" + + "\x03min\x18\f \x01(\x01H\x01R\x03min\x88\x01\x01\x12\x15\n" + + "\x03max\x18\r \x01(\x01H\x02R\x03max\x88\x01\x01\x12%\n" + + "\x0ezero_threshold\x18\x0e \x01(\x01R\rzeroThreshold\x1aF\n" + + "\aBuckets\x12\x16\n" + + "\x06offset\x18\x01 \x01(\x11R\x06offset\x12#\n" + + "\rbucket_counts\x18\x02 \x03(\x04R\fbucketCountsB\x06\n" + + "\x04_sumB\x06\n" + + "\x04_minB\x06\n" + + "\x04_max\"\xa6\x03\n" + + "\x10SummaryDataPoint\x12G\n" + + "\n" + + "attributes\x18\a \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x12/\n" + + "\x14start_time_unix_nano\x18\x02 \x01(\x06R\x11startTimeUnixNano\x12$\n" + + "\x0etime_unix_nano\x18\x03 \x01(\x06R\ftimeUnixNano\x12\x14\n" + + "\x05count\x18\x04 \x01(\x06R\x05count\x12\x10\n" + + "\x03sum\x18\x05 \x01(\x01R\x03sum\x12i\n" + + "\x0fquantile_values\x18\x06 \x03(\v2@.opentelemetry.proto.metrics.v1.SummaryDataPoint.ValueAtQuantileR\x0equantileValues\x12\x14\n" + + "\x05flags\x18\b \x01(\rR\x05flags\x1aC\n" + + "\x0fValueAtQuantile\x12\x1a\n" + + "\bquantile\x18\x01 \x01(\x01R\bquantile\x12\x14\n" + + "\x05value\x18\x02 \x01(\x01R\x05valueJ\x04\b\x01\x10\x02\"\x85\x02\n" + + "\bExemplar\x12X\n" + + "\x13filtered_attributes\x18\a \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\x12filteredAttributes\x12$\n" + + "\x0etime_unix_nano\x18\x02 \x01(\x06R\ftimeUnixNano\x12\x1d\n" + + "\tas_double\x18\x03 \x01(\x01H\x00R\basDouble\x12\x17\n" + + "\x06as_int\x18\x06 \x01(\x10H\x00R\x05asInt\x12\x17\n" + + "\aspan_id\x18\x04 \x01(\fR\x06spanId\x12\x19\n" + + "\btrace_id\x18\x05 \x01(\fR\atraceIdB\a\n" + + "\x05valueJ\x04\b\x01\x10\x02*\x8c\x01\n" + + "\x16AggregationTemporality\x12'\n" + + "#AGGREGATION_TEMPORALITY_UNSPECIFIED\x10\x00\x12!\n" + + "\x1dAGGREGATION_TEMPORALITY_DELTA\x10\x01\x12&\n" + + "\"AGGREGATION_TEMPORALITY_CUMULATIVE\x10\x02*^\n" + + "\x0eDataPointFlags\x12\x1f\n" + + "\x1bDATA_POINT_FLAGS_DO_NOT_USE\x10\x00\x12+\n" + + "'DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK\x10\x01B\x7f\n" + + "!io.opentelemetry.proto.metrics.v1B\fMetricsProtoP\x01Z)go.opentelemetry.io/proto/otlp/metrics/v1\xaa\x02\x1eOpenTelemetry.Proto.Metrics.V1b\x06proto3" var ( file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescOnce sync.Once - file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescData = file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc + file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescData []byte ) func file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescGZIP() []byte { file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescOnce.Do(func() { - file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescData) + file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc), len(file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc))) }) return file_opentelemetry_proto_metrics_v1_metrics_proto_rawDescData } var file_opentelemetry_proto_metrics_v1_metrics_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 16) -var file_opentelemetry_proto_metrics_v1_metrics_proto_goTypes = []interface{}{ +var file_opentelemetry_proto_metrics_v1_metrics_proto_goTypes = []any{ (AggregationTemporality)(0), // 0: opentelemetry.proto.metrics.v1.AggregationTemporality (DataPointFlags)(0), // 1: opentelemetry.proto.metrics.v1.DataPointFlags (*MetricsData)(nil), // 2: opentelemetry.proto.metrics.v1.MetricsData @@ -2326,214 +2134,20 @@ func file_opentelemetry_proto_metrics_v1_metrics_proto_init() { if File_opentelemetry_proto_metrics_v1_metrics_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MetricsData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResourceMetrics); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ScopeMetrics); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Metric); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Gauge); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sum); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Histogram); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExponentialHistogram); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Summary); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NumberDataPoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HistogramDataPoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExponentialHistogramDataPoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SummaryDataPoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Exemplar); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ExponentialHistogramDataPoint_Buckets); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SummaryDataPoint_ValueAtQuantile); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[3].OneofWrappers = []interface{}{ + file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[3].OneofWrappers = []any{ (*Metric_Gauge)(nil), (*Metric_Sum)(nil), (*Metric_Histogram)(nil), (*Metric_ExponentialHistogram)(nil), (*Metric_Summary)(nil), } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[9].OneofWrappers = []interface{}{ + file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[9].OneofWrappers = []any{ (*NumberDataPoint_AsDouble)(nil), (*NumberDataPoint_AsInt)(nil), } - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[10].OneofWrappers = []interface{}{} - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[11].OneofWrappers = []interface{}{} - file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[13].OneofWrappers = []interface{}{ + file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[10].OneofWrappers = []any{} + file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[11].OneofWrappers = []any{} + file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes[13].OneofWrappers = []any{ (*Exemplar_AsDouble)(nil), (*Exemplar_AsInt)(nil), } @@ -2541,7 +2155,7 @@ func file_opentelemetry_proto_metrics_v1_metrics_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc), len(file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc)), NumEnums: 2, NumMessages: 16, NumExtensions: 0, @@ -2553,7 +2167,6 @@ func file_opentelemetry_proto_metrics_v1_metrics_proto_init() { MessageInfos: file_opentelemetry_proto_metrics_v1_metrics_proto_msgTypes, }.Build() File_opentelemetry_proto_metrics_v1_metrics_proto = out.File - file_opentelemetry_proto_metrics_v1_metrics_proto_rawDesc = nil file_opentelemetry_proto_metrics_v1_metrics_proto_goTypes = nil file_opentelemetry_proto_metrics_v1_metrics_proto_depIdxs = nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/resource/v1/resource.pb.go b/vendor/go.opentelemetry.io/proto/otlp/resource/v1/resource.pb.go index 301247ddfee4..de95b8f21cc3 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/resource/v1/resource.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/resource/v1/resource.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.6 +// protoc-gen-go v1.36.11 +// protoc v7.35.0 // source: opentelemetry/proto/resource/v1/resource.proto package v1 @@ -26,6 +26,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -37,10 +38,7 @@ const ( // Resource information. type Resource struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Set of attributes that describe the resource. // Attribute keys MUST be unique (it is not allowed to have more than one // attribute with the same key). @@ -54,16 +52,18 @@ type Resource struct { // Note: keys in the references MUST exist in attributes of this message. // // Status: [Development] - EntityRefs []*v1.EntityRef `protobuf:"bytes,3,rep,name=entity_refs,json=entityRefs,proto3" json:"entity_refs,omitempty"` + // + // [Since v1.6.0] + EntityRefs []*v1.EntityRef `protobuf:"bytes,3,rep,name=entity_refs,json=entityRefs,proto3" json:"entity_refs,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Resource) Reset() { *x = Resource{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_resource_v1_resource_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_resource_v1_resource_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Resource) String() string { @@ -74,7 +74,7 @@ func (*Resource) ProtoMessage() {} func (x *Resource) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_resource_v1_resource_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -112,54 +112,32 @@ func (x *Resource) GetEntityRefs() []*v1.EntityRef { var File_opentelemetry_proto_resource_v1_resource_proto protoreflect.FileDescriptor -var file_opentelemetry_proto_resource_v1_resource_proto_rawDesc = []byte{ - 0x0a, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x76, - 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x1f, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x76, - 0x31, 0x1a, 0x2a, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd8, 0x01, - 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x61, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, - 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, - 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x16, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x41, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x49, 0x0a, - 0x0b, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x66, 0x52, 0x0a, 0x65, 0x6e, - 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x66, 0x73, 0x42, 0x83, 0x01, 0x0a, 0x22, 0x69, 0x6f, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x42, - 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x2a, 0x67, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x74, 0x6c, 0x70, - 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x76, 0x31, 0xaa, 0x02, 0x1f, 0x4f, - 0x70, 0x65, 0x6e, 0x54, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_opentelemetry_proto_resource_v1_resource_proto_rawDesc = "" + + "\n" + + ".opentelemetry/proto/resource/v1/resource.proto\x12\x1fopentelemetry.proto.resource.v1\x1a*opentelemetry/proto/common/v1/common.proto\"\xd8\x01\n" + + "\bResource\x12G\n" + + "\n" + + "attributes\x18\x01 \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x128\n" + + "\x18dropped_attributes_count\x18\x02 \x01(\rR\x16droppedAttributesCount\x12I\n" + + "\ventity_refs\x18\x03 \x03(\v2(.opentelemetry.proto.common.v1.EntityRefR\n" + + "entityRefsB\x83\x01\n" + + "\"io.opentelemetry.proto.resource.v1B\rResourceProtoP\x01Z*go.opentelemetry.io/proto/otlp/resource/v1\xaa\x02\x1fOpenTelemetry.Proto.Resource.V1b\x06proto3" var ( file_opentelemetry_proto_resource_v1_resource_proto_rawDescOnce sync.Once - file_opentelemetry_proto_resource_v1_resource_proto_rawDescData = file_opentelemetry_proto_resource_v1_resource_proto_rawDesc + file_opentelemetry_proto_resource_v1_resource_proto_rawDescData []byte ) func file_opentelemetry_proto_resource_v1_resource_proto_rawDescGZIP() []byte { file_opentelemetry_proto_resource_v1_resource_proto_rawDescOnce.Do(func() { - file_opentelemetry_proto_resource_v1_resource_proto_rawDescData = protoimpl.X.CompressGZIP(file_opentelemetry_proto_resource_v1_resource_proto_rawDescData) + file_opentelemetry_proto_resource_v1_resource_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_resource_v1_resource_proto_rawDesc), len(file_opentelemetry_proto_resource_v1_resource_proto_rawDesc))) }) return file_opentelemetry_proto_resource_v1_resource_proto_rawDescData } var file_opentelemetry_proto_resource_v1_resource_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_opentelemetry_proto_resource_v1_resource_proto_goTypes = []interface{}{ +var file_opentelemetry_proto_resource_v1_resource_proto_goTypes = []any{ (*Resource)(nil), // 0: opentelemetry.proto.resource.v1.Resource (*v1.KeyValue)(nil), // 1: opentelemetry.proto.common.v1.KeyValue (*v1.EntityRef)(nil), // 2: opentelemetry.proto.common.v1.EntityRef @@ -179,25 +157,11 @@ func file_opentelemetry_proto_resource_v1_resource_proto_init() { if File_opentelemetry_proto_resource_v1_resource_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_opentelemetry_proto_resource_v1_resource_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Resource); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opentelemetry_proto_resource_v1_resource_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_resource_v1_resource_proto_rawDesc), len(file_opentelemetry_proto_resource_v1_resource_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -208,7 +172,6 @@ func file_opentelemetry_proto_resource_v1_resource_proto_init() { MessageInfos: file_opentelemetry_proto_resource_v1_resource_proto_msgTypes, }.Build() File_opentelemetry_proto_resource_v1_resource_proto = out.File - file_opentelemetry_proto_resource_v1_resource_proto_rawDesc = nil file_opentelemetry_proto_resource_v1_resource_proto_goTypes = nil file_opentelemetry_proto_resource_v1_resource_proto_depIdxs = nil } diff --git a/vendor/go.opentelemetry.io/proto/otlp/trace/v1/trace.pb.go b/vendor/go.opentelemetry.io/proto/otlp/trace/v1/trace.pb.go index d7bfca90299a..9a9daf44d008 100644 --- a/vendor/go.opentelemetry.io/proto/otlp/trace/v1/trace.pb.go +++ b/vendor/go.opentelemetry.io/proto/otlp/trace/v1/trace.pb.go @@ -14,8 +14,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.21.6 +// protoc-gen-go v1.36.11 +// protoc v7.35.0 // source: opentelemetry/proto/trace/v1/trace.proto package v1 @@ -27,6 +27,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -42,7 +43,7 @@ const ( // a bit-mask. To extract the bit-field, for example, use an // expression like: // -// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK) +// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK) // // See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. // @@ -50,6 +51,8 @@ const ( // OpenTelemetry protocol. Older Span producers do not set this // field, consequently consumers should not rely on the absence of a // particular flag bit to indicate the presence of a particular feature. +// +// [Since v1.1.0] type SpanFlags int32 const ( @@ -61,8 +64,11 @@ const ( // Bits 8 and 9 are used to indicate that the parent span or link span is remote. // Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known. // Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote. + // + // [Since v1.2.0] SpanFlags_SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK SpanFlags = 256 - SpanFlags_SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK SpanFlags = 512 + // [Since v1.2.0] + SpanFlags_SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK SpanFlags = 512 ) // Enum value maps for SpanFlags. @@ -248,25 +254,22 @@ func (Status_StatusCode) EnumDescriptor() ([]byte, []int) { // When new fields are added into this message, the OTLP request MUST be updated // as well. type TracesData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // An array of ResourceSpans. // For data coming from a single resource this array will typically contain // one element. Intermediary nodes that receive data from multiple origins // typically batch the data before forwarding further and in that case this // array will contain multiple elements. ResourceSpans []*ResourceSpans `protobuf:"bytes,1,rep,name=resource_spans,json=resourceSpans,proto3" json:"resource_spans,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *TracesData) Reset() { *x = TracesData{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TracesData) String() string { @@ -277,7 +280,7 @@ func (*TracesData) ProtoMessage() {} func (x *TracesData) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -301,10 +304,7 @@ func (x *TracesData) GetResourceSpans() []*ResourceSpans { // A collection of ScopeSpans from a Resource. type ResourceSpans struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource for the spans in this message. // If this field is not set then no resource info is known. Resource *v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` @@ -316,16 +316,16 @@ type ResourceSpans struct { // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url // This schema_url applies to the data in the "resource" field. It does not apply // to the data in the "scope_spans" field which have their own schema_url field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ResourceSpans) Reset() { *x = ResourceSpans{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ResourceSpans) String() string { @@ -336,7 +336,7 @@ func (*ResourceSpans) ProtoMessage() {} func (x *ResourceSpans) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -374,10 +374,7 @@ func (x *ResourceSpans) GetSchemaUrl() string { // A collection of Spans produced by an InstrumentationScope. type ScopeSpans struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The instrumentation scope information for the spans in this message. // Semantically when InstrumentationScope isn't set, it is equivalent with // an empty instrumentation scope name (unknown). @@ -390,16 +387,16 @@ type ScopeSpans struct { // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url // This schema_url applies to the data in the "scope" field and all spans and span // events in the "spans" field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ScopeSpans) Reset() { *x = ScopeSpans{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ScopeSpans) String() string { @@ -410,7 +407,7 @@ func (*ScopeSpans) ProtoMessage() {} func (x *ScopeSpans) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -450,10 +447,7 @@ func (x *ScopeSpans) GetSchemaUrl() string { // // The next available field id is 17. type Span struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // A unique identifier for a trace. All spans from the same trace share // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR // of length other than 16 bytes is considered invalid (empty string in OTLP/JSON @@ -496,6 +490,8 @@ type Span struct { // Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. // // [Optional]. + // + // [Since v1.1.0] Flags uint32 `protobuf:"fixed32,16,opt,name=flags,proto3" json:"flags,omitempty"` // A description of the span's operation. // @@ -528,12 +524,12 @@ type Span struct { // This field is semantically required and it is expected that end_time >= start_time. EndTimeUnixNano uint64 `protobuf:"fixed64,8,opt,name=end_time_unix_nano,json=endTimeUnixNano,proto3" json:"end_time_unix_nano,omitempty"` // A collection of key/value pairs. Note, global attributes - // like server name can be set using the resource API. Examples of attributes: + // like service name can be set using the resource API. Examples of attributes: // - // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" - // "/http/server_latency": 300 - // "example.com/myattribute": true - // "example.com/score": 10.239 + // "user_agent.original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" + // "http.response.status_code": 200 + // "com.example.myattribute": true + // "com.example.score": 10.239 // // Attribute keys MUST be unique (it is not allowed to have more than one // attribute with the same key). @@ -556,16 +552,16 @@ type Span struct { DroppedLinksCount uint32 `protobuf:"varint,14,opt,name=dropped_links_count,json=droppedLinksCount,proto3" json:"dropped_links_count,omitempty"` // An optional final status for this span. Semantically when Status isn't set, it means // span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). - Status *Status `protobuf:"bytes,15,opt,name=status,proto3" json:"status,omitempty"` + Status *Status `protobuf:"bytes,15,opt,name=status,proto3" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Span) Reset() { *x = Span{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Span) String() string { @@ -576,7 +572,7 @@ func (*Span) ProtoMessage() {} func (x *Span) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -706,23 +702,20 @@ func (x *Span) GetStatus() *Status { // The Status type defines a logical error model that is suitable for different // programming environments, including REST APIs and RPC APIs. type Status struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // A developer-facing human readable error message. Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // The status code. - Code Status_StatusCode `protobuf:"varint,3,opt,name=code,proto3,enum=opentelemetry.proto.trace.v1.Status_StatusCode" json:"code,omitempty"` + Code Status_StatusCode `protobuf:"varint,3,opt,name=code,proto3,enum=opentelemetry.proto.trace.v1.Status_StatusCode" json:"code,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Status) Reset() { *x = Status{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Status) String() string { @@ -733,7 +726,7 @@ func (*Status) ProtoMessage() {} func (x *Status) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -765,10 +758,7 @@ func (x *Status) GetCode() Status_StatusCode { // Event is a time-stamped annotation of the span, consisting of user-supplied // text description and key-value pairs. type Span_Event struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The time the event occurred. TimeUnixNano uint64 `protobuf:"fixed64,1,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` // The name of the event. @@ -782,15 +772,15 @@ type Span_Event struct { // The number of dropped attributes. If the value is 0, // then no attributes were dropped. DroppedAttributesCount uint32 `protobuf:"varint,4,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Span_Event) Reset() { *x = Span_Event{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Span_Event) String() string { @@ -801,7 +791,7 @@ func (*Span_Event) ProtoMessage() {} func (x *Span_Event) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -849,10 +839,7 @@ func (x *Span_Event) GetDroppedAttributesCount() uint32 { // where a single batch handler processes multiple requests from different // traces or when the handler receives a request from a different project. type Span_Link struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // A unique identifier of a trace that this linked span is part of. The ID is a // 16-byte array. TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` @@ -885,16 +872,18 @@ type Span_Link struct { // When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero. // // [Optional]. - Flags uint32 `protobuf:"fixed32,6,opt,name=flags,proto3" json:"flags,omitempty"` + // + // [Since v1.1.0] + Flags uint32 `protobuf:"fixed32,6,opt,name=flags,proto3" json:"flags,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Span_Link) Reset() { *x = Span_Link{} - if protoimpl.UnsafeEnabled { - mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Span_Link) String() string { @@ -905,7 +894,7 @@ func (*Span_Link) ProtoMessage() {} func (x *Span_Link) ProtoReflect() protoreflect.Message { mi := &file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -964,179 +953,101 @@ func (x *Span_Link) GetFlags() uint32 { var File_opentelemetry_proto_trace_v1_trace_proto protoreflect.FileDescriptor -var file_opentelemetry_proto_trace_v1_trace_proto_rawDesc = []byte{ - 0x0a, 0x28, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, - 0x72, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x6f, 0x70, 0x65, 0x6e, - 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x2a, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x60, 0x0a, 0x0a, 0x54, 0x72, 0x61, 0x63, 0x65, 0x73, 0x44, 0x61, - 0x74, 0x61, 0x12, 0x52, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, - 0x70, 0x61, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6f, 0x70, 0x65, - 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x22, 0xc8, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x12, 0x45, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6f, 0x70, 0x65, - 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, - 0x49, 0x0a, 0x0b, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, - 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x52, 0x0a, - 0x73, 0x63, 0x6f, 0x70, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x55, 0x72, 0x6c, 0x4a, 0x06, 0x08, 0xe8, 0x07, 0x10, 0xe9, - 0x07, 0x22, 0xb0, 0x01, 0x0a, 0x0a, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x73, - 0x12, 0x49, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x33, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, - 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x63, 0x6f, 0x70, 0x65, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x38, 0x0a, 0x05, 0x73, - 0x70, 0x61, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x70, 0x65, - 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x70, 0x61, 0x6e, 0x52, 0x05, - 0x73, 0x70, 0x61, 0x6e, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, - 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x55, 0x72, 0x6c, 0x22, 0xc8, 0x0a, 0x0a, 0x04, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x19, 0x0a, - 0x08, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x07, 0x74, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, 0x61, 0x6e, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x70, 0x61, 0x6e, 0x49, - 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x72, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x70, 0x61, - 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, - 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x07, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x2b, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x70, 0x61, 0x6e, 0x2e, 0x53, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, - 0x69, 0x6e, 0x64, 0x12, 0x2f, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x06, 0x52, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, - 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x2b, 0x0a, 0x12, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x06, - 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x4e, 0x61, 0x6e, - 0x6f, 0x12, 0x47, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, - 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, - 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x72, - 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, - 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x16, 0x64, 0x72, - 0x6f, 0x70, 0x70, 0x65, 0x64, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x0b, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, - 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x70, 0x61, 0x6e, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, - 0x64, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3d, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x6b, - 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x70, 0x61, 0x6e, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, - 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x64, 0x72, 0x6f, 0x70, 0x70, - 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x4c, 0x69, 0x6e, - 0x6b, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, - 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x1a, 0xc4, 0x01, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, - 0x24, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x5f, 0x6e, 0x61, 0x6e, - 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, - 0x78, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x61, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, 0x65, - 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x65, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x16, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x41, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0xf4, 0x01, 0x0a, - 0x04, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x74, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, - 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x06, 0x73, 0x70, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x72, 0x61, - 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x74, 0x72, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x61, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, - 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4b, - 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x16, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0x41, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x07, 0x52, 0x05, 0x66, 0x6c, - 0x61, 0x67, 0x73, 0x22, 0x99, 0x01, 0x0a, 0x08, 0x53, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, - 0x12, 0x19, 0x0a, 0x15, 0x53, 0x50, 0x41, 0x4e, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x53, - 0x50, 0x41, 0x4e, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, - 0x4c, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x50, 0x41, 0x4e, 0x5f, 0x4b, 0x49, 0x4e, 0x44, - 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x50, 0x41, - 0x4e, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, - 0x16, 0x0a, 0x12, 0x53, 0x50, 0x41, 0x4e, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x50, 0x52, 0x4f, - 0x44, 0x55, 0x43, 0x45, 0x52, 0x10, 0x04, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x50, 0x41, 0x4e, 0x5f, - 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x43, 0x4f, 0x4e, 0x53, 0x55, 0x4d, 0x45, 0x52, 0x10, 0x05, 0x22, - 0xbd, 0x01, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x12, 0x43, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, - 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x4e, 0x0a, 0x0a, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x55, - 0x53, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x45, 0x54, 0x10, 0x00, 0x12, 0x12, - 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x4f, 0x4b, - 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x43, 0x4f, 0x44, - 0x45, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x2a, - 0x9c, 0x01, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x6e, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x19, 0x0a, - 0x15, 0x53, 0x50, 0x41, 0x4e, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x53, 0x5f, 0x44, 0x4f, 0x5f, 0x4e, - 0x4f, 0x54, 0x5f, 0x55, 0x53, 0x45, 0x10, 0x00, 0x12, 0x20, 0x0a, 0x1b, 0x53, 0x50, 0x41, 0x4e, - 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x53, 0x5f, 0x54, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x46, 0x4c, 0x41, - 0x47, 0x53, 0x5f, 0x4d, 0x41, 0x53, 0x4b, 0x10, 0xff, 0x01, 0x12, 0x2a, 0x0a, 0x25, 0x53, 0x50, - 0x41, 0x4e, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x53, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x58, 0x54, - 0x5f, 0x48, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x54, 0x45, 0x5f, 0x4d, - 0x41, 0x53, 0x4b, 0x10, 0x80, 0x02, 0x12, 0x26, 0x0a, 0x21, 0x53, 0x50, 0x41, 0x4e, 0x5f, 0x46, - 0x4c, 0x41, 0x47, 0x53, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x58, 0x54, 0x5f, 0x49, 0x53, 0x5f, - 0x52, 0x45, 0x4d, 0x4f, 0x54, 0x45, 0x5f, 0x4d, 0x41, 0x53, 0x4b, 0x10, 0x80, 0x04, 0x42, 0x77, - 0x0a, 0x1f, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, - 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x76, - 0x31, 0x42, 0x0a, 0x54, 0x72, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x27, 0x67, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, - 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x74, 0x6c, 0x70, 0x2f, - 0x74, 0x72, 0x61, 0x63, 0x65, 0x2f, 0x76, 0x31, 0xaa, 0x02, 0x1c, 0x4f, 0x70, 0x65, 0x6e, 0x54, - 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, - 0x72, 0x61, 0x63, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_opentelemetry_proto_trace_v1_trace_proto_rawDesc = "" + + "\n" + + "(opentelemetry/proto/trace/v1/trace.proto\x12\x1copentelemetry.proto.trace.v1\x1a*opentelemetry/proto/common/v1/common.proto\x1a.opentelemetry/proto/resource/v1/resource.proto\"`\n" + + "\n" + + "TracesData\x12R\n" + + "\x0eresource_spans\x18\x01 \x03(\v2+.opentelemetry.proto.trace.v1.ResourceSpansR\rresourceSpans\"\xc8\x01\n" + + "\rResourceSpans\x12E\n" + + "\bresource\x18\x01 \x01(\v2).opentelemetry.proto.resource.v1.ResourceR\bresource\x12I\n" + + "\vscope_spans\x18\x02 \x03(\v2(.opentelemetry.proto.trace.v1.ScopeSpansR\n" + + "scopeSpans\x12\x1d\n" + + "\n" + + "schema_url\x18\x03 \x01(\tR\tschemaUrlJ\x06\b\xe8\a\x10\xe9\a\"\xb0\x01\n" + + "\n" + + "ScopeSpans\x12I\n" + + "\x05scope\x18\x01 \x01(\v23.opentelemetry.proto.common.v1.InstrumentationScopeR\x05scope\x128\n" + + "\x05spans\x18\x02 \x03(\v2\".opentelemetry.proto.trace.v1.SpanR\x05spans\x12\x1d\n" + + "\n" + + "schema_url\x18\x03 \x01(\tR\tschemaUrl\"\xc8\n" + + "\n" + + "\x04Span\x12\x19\n" + + "\btrace_id\x18\x01 \x01(\fR\atraceId\x12\x17\n" + + "\aspan_id\x18\x02 \x01(\fR\x06spanId\x12\x1f\n" + + "\vtrace_state\x18\x03 \x01(\tR\n" + + "traceState\x12$\n" + + "\x0eparent_span_id\x18\x04 \x01(\fR\fparentSpanId\x12\x14\n" + + "\x05flags\x18\x10 \x01(\aR\x05flags\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12?\n" + + "\x04kind\x18\x06 \x01(\x0e2+.opentelemetry.proto.trace.v1.Span.SpanKindR\x04kind\x12/\n" + + "\x14start_time_unix_nano\x18\a \x01(\x06R\x11startTimeUnixNano\x12+\n" + + "\x12end_time_unix_nano\x18\b \x01(\x06R\x0fendTimeUnixNano\x12G\n" + + "\n" + + "attributes\x18\t \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x128\n" + + "\x18dropped_attributes_count\x18\n" + + " \x01(\rR\x16droppedAttributesCount\x12@\n" + + "\x06events\x18\v \x03(\v2(.opentelemetry.proto.trace.v1.Span.EventR\x06events\x120\n" + + "\x14dropped_events_count\x18\f \x01(\rR\x12droppedEventsCount\x12=\n" + + "\x05links\x18\r \x03(\v2'.opentelemetry.proto.trace.v1.Span.LinkR\x05links\x12.\n" + + "\x13dropped_links_count\x18\x0e \x01(\rR\x11droppedLinksCount\x12<\n" + + "\x06status\x18\x0f \x01(\v2$.opentelemetry.proto.trace.v1.StatusR\x06status\x1a\xc4\x01\n" + + "\x05Event\x12$\n" + + "\x0etime_unix_nano\x18\x01 \x01(\x06R\ftimeUnixNano\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12G\n" + + "\n" + + "attributes\x18\x03 \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x128\n" + + "\x18dropped_attributes_count\x18\x04 \x01(\rR\x16droppedAttributesCount\x1a\xf4\x01\n" + + "\x04Link\x12\x19\n" + + "\btrace_id\x18\x01 \x01(\fR\atraceId\x12\x17\n" + + "\aspan_id\x18\x02 \x01(\fR\x06spanId\x12\x1f\n" + + "\vtrace_state\x18\x03 \x01(\tR\n" + + "traceState\x12G\n" + + "\n" + + "attributes\x18\x04 \x03(\v2'.opentelemetry.proto.common.v1.KeyValueR\n" + + "attributes\x128\n" + + "\x18dropped_attributes_count\x18\x05 \x01(\rR\x16droppedAttributesCount\x12\x14\n" + + "\x05flags\x18\x06 \x01(\aR\x05flags\"\x99\x01\n" + + "\bSpanKind\x12\x19\n" + + "\x15SPAN_KIND_UNSPECIFIED\x10\x00\x12\x16\n" + + "\x12SPAN_KIND_INTERNAL\x10\x01\x12\x14\n" + + "\x10SPAN_KIND_SERVER\x10\x02\x12\x14\n" + + "\x10SPAN_KIND_CLIENT\x10\x03\x12\x16\n" + + "\x12SPAN_KIND_PRODUCER\x10\x04\x12\x16\n" + + "\x12SPAN_KIND_CONSUMER\x10\x05\"\xbd\x01\n" + + "\x06Status\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\x12C\n" + + "\x04code\x18\x03 \x01(\x0e2/.opentelemetry.proto.trace.v1.Status.StatusCodeR\x04code\"N\n" + + "\n" + + "StatusCode\x12\x15\n" + + "\x11STATUS_CODE_UNSET\x10\x00\x12\x12\n" + + "\x0eSTATUS_CODE_OK\x10\x01\x12\x15\n" + + "\x11STATUS_CODE_ERROR\x10\x02J\x04\b\x01\x10\x02*\x9c\x01\n" + + "\tSpanFlags\x12\x19\n" + + "\x15SPAN_FLAGS_DO_NOT_USE\x10\x00\x12 \n" + + "\x1bSPAN_FLAGS_TRACE_FLAGS_MASK\x10\xff\x01\x12*\n" + + "%SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK\x10\x80\x02\x12&\n" + + "!SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK\x10\x80\x04Bw\n" + + "\x1fio.opentelemetry.proto.trace.v1B\n" + + "TraceProtoP\x01Z'go.opentelemetry.io/proto/otlp/trace/v1\xaa\x02\x1cOpenTelemetry.Proto.Trace.V1b\x06proto3" var ( file_opentelemetry_proto_trace_v1_trace_proto_rawDescOnce sync.Once - file_opentelemetry_proto_trace_v1_trace_proto_rawDescData = file_opentelemetry_proto_trace_v1_trace_proto_rawDesc + file_opentelemetry_proto_trace_v1_trace_proto_rawDescData []byte ) func file_opentelemetry_proto_trace_v1_trace_proto_rawDescGZIP() []byte { file_opentelemetry_proto_trace_v1_trace_proto_rawDescOnce.Do(func() { - file_opentelemetry_proto_trace_v1_trace_proto_rawDescData = protoimpl.X.CompressGZIP(file_opentelemetry_proto_trace_v1_trace_proto_rawDescData) + file_opentelemetry_proto_trace_v1_trace_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_trace_v1_trace_proto_rawDesc), len(file_opentelemetry_proto_trace_v1_trace_proto_rawDesc))) }) return file_opentelemetry_proto_trace_v1_trace_proto_rawDescData } var file_opentelemetry_proto_trace_v1_trace_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_opentelemetry_proto_trace_v1_trace_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_opentelemetry_proto_trace_v1_trace_proto_goTypes = []interface{}{ +var file_opentelemetry_proto_trace_v1_trace_proto_goTypes = []any{ (SpanFlags)(0), // 0: opentelemetry.proto.trace.v1.SpanFlags (Span_SpanKind)(0), // 1: opentelemetry.proto.trace.v1.Span.SpanKind (Status_StatusCode)(0), // 2: opentelemetry.proto.trace.v1.Status.StatusCode @@ -1177,97 +1088,11 @@ func file_opentelemetry_proto_trace_v1_trace_proto_init() { if File_opentelemetry_proto_trace_v1_trace_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TracesData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResourceSpans); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ScopeSpans); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Span); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Status); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Span_Event); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opentelemetry_proto_trace_v1_trace_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Span_Link); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opentelemetry_proto_trace_v1_trace_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_opentelemetry_proto_trace_v1_trace_proto_rawDesc), len(file_opentelemetry_proto_trace_v1_trace_proto_rawDesc)), NumEnums: 3, NumMessages: 7, NumExtensions: 0, @@ -1279,7 +1104,6 @@ func file_opentelemetry_proto_trace_v1_trace_proto_init() { MessageInfos: file_opentelemetry_proto_trace_v1_trace_proto_msgTypes, }.Build() File_opentelemetry_proto_trace_v1_trace_proto = out.File - file_opentelemetry_proto_trace_v1_trace_proto_rawDesc = nil file_opentelemetry_proto_trace_v1_trace_proto_goTypes = nil file_opentelemetry_proto_trace_v1_trace_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/grpc/CONTRIBUTING.md b/vendor/google.golang.org/grpc/CONTRIBUTING.md index 2079de7b0ed8..bd80b1f92c0a 100644 --- a/vendor/google.golang.org/grpc/CONTRIBUTING.md +++ b/vendor/google.golang.org/grpc/CONTRIBUTING.md @@ -23,6 +23,29 @@ wanted"](https://github.com/grpc/grpc-go/issues?q=sort%3Aupdated-desc%20is%3Aiss are especially nice for first-time contributors, as they should be well-defined problems that already have agreed-upon solutions. +## Generative AI Policy + +AI tools have the ability to produce more code than is possible for the gRPC +team to read, understand, review, and accept into the repository. For this +reason, we request that all contributions adhere to the following rules: + +1. **No AI-Generated Interactions:** All communication in the repo must be + authored by a human. _Exception: AIs may be used for directed writing + assistance or translation._ Absolutely no automated agents are allowed to + directly publish to GitHub. + +2. **Author Ownership and Accountability:** Code contributions are expected to + be fully owned and understood by the human contributor. If the code was + produced by generative AI, the author is expected to have reviewed and + understood it in its entirety before submitting it for review. This includes + all content: production code, tests, examples, tools, etc. + +In addition to the above requirements, any AI-assisted contributions must also +comply with the [Linux Foundation Generative AI +Policy](https://www.linuxfoundation.org/legal/generative-ai). This includes +confirming that all contributions are legally allowed to be contributed to the +gRPC project under the applicable license terms. + ## Code Style We follow [Google's published Go style diff --git a/vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go b/vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go index 12479f69851f..22dbc52287a8 100644 --- a/vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go +++ b/vendor/google.golang.org/grpc/balancer/endpointsharding/endpointsharding.go @@ -39,27 +39,14 @@ import ( var randIntN = rand.IntN -// ChildState is the balancer state of a child along with the endpoint which -// identifies the child balancer. +// ChildState is the state of a child balancer. type ChildState struct { - Endpoint resolver.Endpoint - State balancer.State - - // Balancer exposes only the ExitIdler interface of the child LB policy. - // Other methods of the child policy are called only by endpointsharding. - Balancer ExitIdler -} - -// ExitIdler provides access to only the ExitIdle method of the child balancer. -type ExitIdler interface { - // ExitIdle instructs the LB policy to reconnect to backends / exit the - // IDLE state, if appropriate and possible. Note that SubConns that enter - // the IDLE state will not reconnect until SubConn.Connect is called. - ExitIdle() + Endpoint resolver.Endpoint // Endpoint of the child balancer. + State balancer.State // State of the child balancer. + ExitIdle func() // Function to exit the child balancer from IDLE state. } -// Options are the options to configure the behaviour of the -// endpointsharding balancer. +// Options configure the behaviour of the endpointsharding balancer. type Options struct { // DisableAutoReconnect allows the balancer to keep child balancer in the // IDLE state until they are explicitly triggered to exit using the @@ -77,14 +64,13 @@ type ChildBuilderFunc func(cc balancer.ClientConn, opts balancer.BuildOptions) b // policies each owning a single endpoint. The endpointsharding balancer // forwards the LoadBalancingConfig in ClientConn state updates to its children. func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions, childBuilder ChildBuilderFunc, esOpts Options) balancer.Balancer { - es := &endpointSharding{ + return &endpointSharding{ cc: cc, bOpts: opts, esOpts: esOpts, childBuilder: childBuilder, + endpoints: resolver.NewEndpointMap[*endpointState](), } - es.children.Store(resolver.NewEndpointMap[*balancerWrapper]()) - return es } // endpointSharding is a balancer that wraps child balancers. It creates a child @@ -96,124 +82,129 @@ type endpointSharding struct { esOpts Options childBuilder ChildBuilderFunc - // childMu synchronizes calls to any single child. It must be held for all - // calls into a child. To avoid deadlocks, do not acquire childMu while - // holding mu. - childMu sync.Mutex - children atomic.Pointer[resolver.EndpointMap[*balancerWrapper]] - - // inhibitChildUpdates is set during UpdateClientConnState/ResolverError - // calls (calls to children will each produce an update, only want one - // update). - inhibitChildUpdates atomic.Bool - - // mu synchronizes access to the state stored in balancerWrappers in the - // children field. mu must not be held during calls into a child since - // synchronous calls back from the child may require taking mu, causing a - // deadlock. To avoid deadlocks, do not acquire childMu while holding mu. - mu sync.Mutex + // mu guards access to the below fields and guarantees mutual exclusion + // between top-down methods (like UpdateClientConnState, ResolverError etc, + // which are already serialized) and bottom-up methods (like UpdateState) + // that can be called concurrently. + // + // Lock ordering & deadlock prevention: + // Child callbacks (like UpdateState) acquire this mutex to push state updates + // to the parent. This establishes a strict lock ordering: + // [endpointState.childMu] -> [endpointSharding.mu] + // + // To prevent deadlocks, we must never invert this order. Therefore, we must + // never call any methods on a child balancer while holding this mutex. If we + // did, and that child balancer invoked UpdateState synchronously, it would + // attempt to re-acquire this mutex, causing a deadlock. + // + // Concurrency: + // Top-down operations need to iterate over all children. To ensure a + // single, clean aggregated update at the end of such operations, we inhibit + // intermediate updates from children. We grab this mutex briefly to set + // `inhibitChildUpdates = true` and immediately release it. This allows us + // to perform the potentially slow, top-down child updates without holding + // any parent locks. Once finished, we grab the mutex again to unset the + // flag and push the final aggregated state. An update from a child during + // this time will *only* update the child state, and will not access the + // endpoints map or push an aggregated state to the parent. + mu sync.Mutex + endpoints *resolver.EndpointMap[*endpointState] + inhibitChildUpdates bool } // rotateEndpoints returns a slice of all the input endpoints rotated a random // amount. func rotateEndpoints(es []resolver.Endpoint) []resolver.Endpoint { - les := len(es) - if les == 0 { + n := len(es) + if n == 0 { return es } - r := randIntN(les) + r := randIntN(n) + // Make a copy to avoid mutating data beyond the end of es. - ret := make([]resolver.Endpoint, les) + ret := make([]resolver.Endpoint, n) copy(ret, es[r:]) - copy(ret[les-r:], es[:r]) + copy(ret[n-r:], es[:r]) return ret } // UpdateClientConnState creates a child for new endpoints and deletes children // for endpoints that are no longer present. It also updates all the children, // and sends a single synchronous update of the childrens' aggregated state at -// the end of the UpdateClientConnState operation. If any endpoint has no -// addresses it will ignore that endpoint. Otherwise, returns first error found -// from a child, but fully processes the new update. +// the end of the UpdateClientConnState operation. +// +// Returns the first error found from a child, but fully processes the update. func (es *endpointSharding) UpdateClientConnState(state balancer.ClientConnState) error { - es.childMu.Lock() - defer es.childMu.Unlock() - - es.inhibitChildUpdates.Store(true) - defer func() { - es.inhibitChildUpdates.Store(false) - es.updateState() - }() - var ret error - - children := es.children.Load() - newChildren := resolver.NewEndpointMap[*balancerWrapper]() + es.inhibitUpdatesFromChildren() - // Update/Create new children. + // Update/create child balancers for each endpoint in the update. Note that we + // don't hold the mutex here, but this is fine because inhibitChildUpdates is + // true, and therefore UpdateState will not access es.endpoints. + var retErr error + newEndpoints := resolver.NewEndpointMap[*endpointState]() for _, endpoint := range rotateEndpoints(state.ResolverState.Endpoints) { - if _, ok := newChildren.Get(endpoint); ok { - // Endpoint child was already created, continue to avoid duplicate - // update. + if _, ok := newEndpoints.Get(endpoint); ok { + // Skip duplicate endpoints. continue } - childBalancer, ok := children.Get(endpoint) + epState, ok := es.endpoints.Get(endpoint) if ok { - // Endpoint attributes may have changed, update the stored endpoint. - es.mu.Lock() - childBalancer.childState.Endpoint = endpoint - es.mu.Unlock() + // Endpoint child already exists, update the stored endpoint. + epState.endpoint = endpoint } else { - childBalancer = &balancerWrapper{ - childState: ChildState{Endpoint: endpoint}, - ClientConn: es.cc, - es: es, + // Endpoint child does not exist, create a new one. + epState = &endpointState{ + ClientConn: es.cc, + parent: es, + endpoint: endpoint, + disableAutoReconnect: es.esOpts.DisableAutoReconnect, } - childBalancer.childState.Balancer = childBalancer - childBalancer.child = es.childBuilder(childBalancer, es.bOpts) + epState.childLB = es.childBuilder(epState, es.bOpts) } - newChildren.Set(endpoint, childBalancer) - if err := childBalancer.updateClientConnStateLocked(balancer.ClientConnState{ + // Update the endpoint state for the endpoint. + newEndpoints.Set(endpoint, epState) + + if err := epState.updateClientConnState(balancer.ClientConnState{ BalancerConfig: state.BalancerConfig, ResolverState: resolver.State{ Endpoints: []resolver.Endpoint{endpoint}, Attributes: state.ResolverState.Attributes, }, - }); err != nil && ret == nil { - // Return first error found, and always commit full processing of - // updating children. If desired to process more specific errors - // across all endpoints, caller should make these specific - // validations, this is a current limitation for simplicity sake. - ret = err + }); err != nil && retErr == nil { + // Keep the first error found from any child. + retErr = err } } + // Delete old children that are no longer present. - for e, child := range children.All() { - if _, ok := newChildren.Get(e); !ok { - child.closeLocked() + for e, child := range es.endpoints.All() { + if _, ok := newEndpoints.Get(e); !ok { + child.close() } } - es.children.Store(newChildren) - if newChildren.Len() == 0 { - return balancer.ErrBadResolverState + + if newEndpoints.Len() == 0 { + retErr = balancer.ErrBadResolverState } - return ret + + es.mu.Lock() + es.endpoints = newEndpoints + es.inhibitChildUpdates = false + es.updateStateLocked() + es.mu.Unlock() + + return retErr } // ResolverError forwards the resolver error to all of the endpointSharding's // children and sends a single synchronous update of the childStates at the end // of the ResolverError operation. func (es *endpointSharding) ResolverError(err error) { - es.childMu.Lock() - defer es.childMu.Unlock() - es.inhibitChildUpdates.Store(true) - defer func() { - es.inhibitChildUpdates.Store(false) - es.updateState() - }() - children := es.children.Load() - for _, child := range children.All() { - child.resolverErrorLocked(err) + es.inhibitUpdatesFromChildren() + for _, child := range es.endpoints.All() { + child.resolverError(err) } + es.allowUpdatesFromChildren() } func (es *endpointSharding) UpdateSubConnState(balancer.SubConn, balancer.SubConnState) { @@ -221,41 +212,49 @@ func (es *endpointSharding) UpdateSubConnState(balancer.SubConn, balancer.SubCon } func (es *endpointSharding) Close() { - es.childMu.Lock() - defer es.childMu.Unlock() - children := es.children.Load() - for _, child := range children.All() { - child.closeLocked() + es.inhibitUpdatesFromChildren() + for _, child := range es.endpoints.All() { + child.close() } } func (es *endpointSharding) ExitIdle() { - es.childMu.Lock() - defer es.childMu.Unlock() - for _, bw := range es.children.Load().All() { - if !bw.isClosed { - bw.child.ExitIdle() - } + es.inhibitUpdatesFromChildren() + for _, child := range es.endpoints.All() { + child.exitIdle() } + es.allowUpdatesFromChildren() } -// updateState updates this component's state. It sends the aggregated state, -// and a picker with round robin behavior with all the child states present if -// needed. -func (es *endpointSharding) updateState() { - if es.inhibitChildUpdates.Load() { - return - } - var readyPickers, connectingPickers, idlePickers, transientFailurePickers []balancer.Picker +func (es *endpointSharding) inhibitUpdatesFromChildren() { + es.mu.Lock() + es.inhibitChildUpdates = true + es.mu.Unlock() +} +func (es *endpointSharding) allowUpdatesFromChildren() { es.mu.Lock() - defer es.mu.Unlock() + es.inhibitChildUpdates = false + es.updateStateLocked() + es.mu.Unlock() +} - children := es.children.Load() - childStates := make([]ChildState, 0, children.Len()) +// updateStateLocked updates this component's state. It sends the aggregated +// state, and a picker with round robin behavior with all the child states +// present if needed. This method must only be called when inhibitChildUpdates +// is false. +// +// Caller must hold es.mu. +func (es *endpointSharding) updateStateLocked() { + var readyPickers, connectingPickers, idlePickers, transientFailurePickers []balancer.Picker - for _, child := range children.All() { - childState := child.childState + childStates := make([]ChildState, 0, es.endpoints.Len()) + for _, epState := range es.endpoints.All() { + childState := ChildState{ + Endpoint: epState.endpoint, + State: epState.state, + ExitIdle: func() { go epState.exitIdle() }, + } childStates = append(childStates, childState) childPicker := childState.State.Picker switch childState.State.ConnectivityState { @@ -292,14 +291,14 @@ func (es *endpointSharding) updateState() { aggState = connectivity.TransientFailure pickers = []balancer.Picker{base.NewErrPicker(errors.New("no children to pick from"))} } // No children (resolver error before valid update). - p := &pickerWithChildStates{ - pickers: pickers, - childStates: childStates, - next: uint32(randIntN(len(pickers))), - } + es.cc.UpdateState(balancer.State{ ConnectivityState: aggState, - Picker: p, + Picker: &pickerWithChildStates{ + pickers: pickers, + childStates: childStates, + next: uint32(randIntN(len(pickers))), + }, }) } @@ -328,61 +327,59 @@ func ChildStatesFromPicker(picker balancer.Picker) []ChildState { return p.childStates } -// balancerWrapper is a wrapper of a balancer. It ID's a child balancer by -// endpoint, and persists recent child balancer state. -type balancerWrapper struct { - // The following fields are initialized at build time and read-only after - // that and therefore do not need to be guarded by a mutex. - - // child contains the wrapped balancer. Access its methods only through - // methods on balancerWrapper to ensure proper synchronization - child balancer.Balancer - balancer.ClientConn // embed to intercept UpdateState, doesn't deal with SubConns +// endpointState is the internal state maintained for each endpoint. +type endpointState struct { + balancer.ClientConn // Embedded to intercept UpdateState - es *endpointSharding + parent *endpointSharding // Parent endpointsharding balancer. + endpoint resolver.Endpoint // Endpoint of the child balancer. + state balancer.State // State of the child balancer. + disableAutoReconnect bool // Whether to disable auto reconnect for this child. - // Access to the following fields is guarded by es.mu. - - childState ChildState - isClosed bool + childMu sync.Mutex // Guarantees mutual exclusion for Balancer API calls to the child balancer. + childLB balancer.Balancer // Child balancer. + closed bool // Tracks closure of the child balancer to ensure ExitIdle is not called after Close(). } -func (bw *balancerWrapper) UpdateState(state balancer.State) { - bw.es.mu.Lock() - bw.childState.State = state - bw.es.mu.Unlock() - if state.ConnectivityState == connectivity.Idle && !bw.es.esOpts.DisableAutoReconnect { - bw.ExitIdle() +func (es *endpointState) UpdateState(state balancer.State) { + es.parent.mu.Lock() + es.state = state + if !es.parent.inhibitChildUpdates { + es.parent.updateStateLocked() + } + es.parent.mu.Unlock() + + if state.ConnectivityState == connectivity.Idle && !es.disableAutoReconnect { + go es.exitIdle() } - bw.es.updateState() } -// ExitIdle pings an IDLE child balancer to exit idle in a new goroutine to -// avoid deadlocks due to synchronous balancer state updates. -func (bw *balancerWrapper) ExitIdle() { - go func() { - bw.es.childMu.Lock() - if !bw.isClosed { - bw.child.ExitIdle() - } - bw.es.childMu.Unlock() - }() +func (es *endpointState) updateClientConnState(state balancer.ClientConnState) error { + es.childMu.Lock() + err := es.childLB.UpdateClientConnState(state) + es.childMu.Unlock() + return err } -// updateClientConnStateLocked delivers the ClientConnState to the child -// balancer. Callers must hold the child mutex of the parent endpointsharding -// balancer. -func (bw *balancerWrapper) updateClientConnStateLocked(ccs balancer.ClientConnState) error { - return bw.child.UpdateClientConnState(ccs) +func (es *endpointState) resolverError(err error) { + es.childMu.Lock() + es.childLB.ResolverError(err) + es.childMu.Unlock() } -// closeLocked closes the child balancer. Callers must hold the child mutext of -// the parent endpointsharding balancer. -func (bw *balancerWrapper) closeLocked() { - bw.child.Close() - bw.isClosed = true +func (es *endpointState) close() { + es.childMu.Lock() + if !es.closed { + es.closed = true + es.childLB.Close() + } + es.childMu.Unlock() } -func (bw *balancerWrapper) resolverErrorLocked(err error) { - bw.child.ResolverError(err) +func (es *endpointState) exitIdle() { + es.childMu.Lock() + if !es.closed { + es.childLB.ExitIdle() + } + es.childMu.Unlock() } diff --git a/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go b/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go index d48bc304c2b9..ddd08f5373c3 100644 --- a/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go +++ b/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go @@ -36,7 +36,6 @@ import ( "google.golang.org/grpc/balancer/pickfirst/internal" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/experimental/balancer/weight" - expstats "google.golang.org/grpc/experimental/stats" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/envconfig" internalgrpclog "google.golang.org/grpc/internal/grpclog" @@ -56,30 +55,7 @@ const Name = "pick_first" // attributes to indicate whether the health listener usage is enabled. type enableHealthListenerKeyType struct{} -var ( - logger = grpclog.Component("pick-first-leaf-lb") - disconnectionsMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{ - Name: "grpc.lb.pick_first.disconnections", - Description: "EXPERIMENTAL. Number of times the selected subchannel becomes disconnected.", - Unit: "{disconnection}", - Labels: []string{"grpc.target"}, - Default: false, - }) - connectionAttemptsSucceededMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{ - Name: "grpc.lb.pick_first.connection_attempts_succeeded", - Description: "EXPERIMENTAL. Number of successful connection attempts.", - Unit: "{attempt}", - Labels: []string{"grpc.target"}, - Default: false, - }) - connectionAttemptsFailedMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{ - Name: "grpc.lb.pick_first.connection_attempts_failed", - Description: "EXPERIMENTAL. Number of failed connection attempts.", - Unit: "{attempt}", - Labels: []string{"grpc.target"}, - Default: false, - }) -) +var logger = grpclog.Component("pick-first-leaf-lb") const ( // TODO: change to pick-first when this becomes the default pick_first policy. @@ -101,11 +77,9 @@ const ( type pickfirstBuilder struct{} -func (pickfirstBuilder) Build(cc balancer.ClientConn, bo balancer.BuildOptions) balancer.Balancer { +func (pickfirstBuilder) Build(cc balancer.ClientConn, _ balancer.BuildOptions) balancer.Balancer { b := &pickfirstBalancer{ - cc: cc, - target: bo.Target.String(), - metricsRecorder: cc.MetricsRecorder(), + cc: cc, subConns: resolver.NewAddressMapV2[*scData](), state: connectivity.Connecting, @@ -185,10 +159,8 @@ func (b *pickfirstBalancer) newSCData(addr resolver.Address) (*scData, error) { type pickfirstBalancer struct { // The following fields are initialized at build time and read-only after // that and therefore do not need to be guarded by a mutex. - logger *internalgrpclog.PrefixLogger - cc balancer.ClientConn - target string - metricsRecorder expstats.MetricsRecorder // guaranteed to be non nil + logger *internalgrpclog.PrefixLogger + cc balancer.ClientConn // The mutex is used to ensure synchronization of updates triggered // from the idle picker and the already serialized resolver, @@ -633,14 +605,11 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub return } - // Record a connection attempt when exiting CONNECTING. if newState.ConnectivityState == connectivity.TransientFailure { sd.connectionFailedInFirstPass = true - connectionAttemptsFailedMetric.Record(b.metricsRecorder, 1, b.target) } if newState.ConnectivityState == connectivity.Ready { - connectionAttemptsSucceededMetric.Record(b.metricsRecorder, 1, b.target) b.shutdownRemainingLocked(sd) if !b.addressList.seekTo(sd.addr) { // This should not fail as we should have only one SubConn after @@ -689,15 +658,6 @@ func (b *pickfirstBalancer) updateSubConnState(sd *scData, newState balancer.Sub // the first address when the picker is used. b.shutdownRemainingLocked(sd) sd.effectiveState = newState.ConnectivityState - // READY SubConn interspliced in between CONNECTING and IDLE, need to - // account for that. - if oldState == connectivity.Connecting { - // A known issue (https://github.com/grpc/grpc-go/issues/7862) - // causes a race that prevents the READY state change notification. - // This works around it. - connectionAttemptsSucceededMetric.Record(b.metricsRecorder, 1, b.target) - } - disconnectionsMetric.Record(b.metricsRecorder, 1, b.target) b.addressList.reset() b.updateBalancerState(balancer.State{ ConnectivityState: connectivity.Idle, diff --git a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go index 296123e20d48..d22d1c3f10c3 100644 --- a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go +++ b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 +// protoc-gen-go v1.36.12 // protoc v5.27.1 // source: grpc/binlog/v1/binarylog.proto @@ -679,7 +679,7 @@ func (x *Message) GetData() []byte { // A list of metadata pairs, used in the payload of client header, // server header, and server trailer. // Implementations may omit some entries to honor the header limits -// of GRPC_BINARY_LOG_CONFIG. +// of GRPC_BINARY_LOG_FILTER. // // Header keys added by gRPC are omitted. To be more specific, // implementations will not log the following entries, and this is @@ -689,7 +689,9 @@ func (x *Message) GetData() []byte { // or keys like 'lb-token' // - transport specific entries, including but not limited to: // ':path', ':authority', 'content-encoding', 'user-agent', 'te', etc -// - entries added for call credentials +// - entries added for call credentials (on client side, excludes all +// such headers; on server side, excludes only the "authorization" +// header) // // Implementations must always log grpc-trace-bin if it is present. // Practically speaking it will only be visible on server side because diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index b27c7e84a3d4..7a25d251e7d3 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -1211,6 +1211,12 @@ func (cc *ClientConn) Close() error { cc.mu.Unlock() cc.resolverWrapper.close() + // Swap in a default ConfigSelector so the resolver-provided one (which may + // transitively retain resolver-owned state such as parsed service configs + // and cluster maps) is released once in-flight RPCs finish selecting on + // it. Done after the resolver has closed so no further UpdateState calls + // race with this swap. + cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{nil}) // The order of closing matters here since the balancer wrapper assumes the // picker is closed before it is closed. cc.pickerWrapper.close() diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go index dcb98cdbc1eb..35d4c830357a 100644 --- a/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go +++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 +// protoc-gen-go v1.36.12 // protoc v5.27.1 // source: grpc/health/v1/health.proto diff --git a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go index 9669328914ad..ca0e586dff04 100644 --- a/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go +++ b/vendor/google.golang.org/grpc/internal/binarylog/method_logger.go @@ -395,7 +395,7 @@ func (c *Cancel) toProto() *binlogpb.GrpcLogEntry { // omitted. func metadataKeyOmit(key string) bool { switch key { - case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te": + case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te", "authorization": return true case "grpc-trace-bin": // grpc-trace-bin is special because it's visible to users. return false diff --git a/vendor/google.golang.org/grpc/internal/buffer/unbounded.go b/vendor/google.golang.org/grpc/internal/buffer/unbounded.go index 467392b8d455..d1f4b634b918 100644 --- a/vendor/google.golang.org/grpc/internal/buffer/unbounded.go +++ b/vendor/google.golang.org/grpc/internal/buffer/unbounded.go @@ -27,32 +27,29 @@ import ( // extra goroutines. This is typically used for passing updates from one entity // to another within gRPC. // +// To avoid extra memory allocations and type assertions, using any on +// performance-critical code paths is discouraged. Use concrete types wherever +// possible when instantiating Unbounded. +// // All methods on this type are thread-safe and don't block on anything except // the underlying mutex used for synchronization. -// -// Unbounded supports values of any type to be stored in it by using a channel -// of `any`. This means that a call to Put() incurs an extra memory allocation, -// and also that users need a type assertion while reading. For performance -// critical code paths, using Unbounded is strongly discouraged and defining a -// new type specific implementation of this buffer is preferred. See -// internal/transport/transport.go for an example of this. -type Unbounded struct { - c chan any +type Unbounded[T any] struct { + c chan T closed bool closing bool mu sync.Mutex - backlog []any + backlog []T } // NewUnbounded returns a new instance of Unbounded. -func NewUnbounded() *Unbounded { - return &Unbounded{c: make(chan any, 1)} +func NewUnbounded[T any]() *Unbounded[T] { + return &Unbounded[T]{c: make(chan T, 1)} } var errBufferClosed = errors.New("Put called on closed buffer.Unbounded") // Put adds t to the unbounded buffer. -func (b *Unbounded) Put(t any) error { +func (b *Unbounded[T]) Put(t T) error { b.mu.Lock() defer b.mu.Unlock() if b.closing { @@ -72,13 +69,14 @@ func (b *Unbounded) Put(t any) error { // Load sends the earliest buffered data, if any, onto the read channel returned // by Get(). Users are expected to call this every time they successfully read a // value from the read channel. -func (b *Unbounded) Load() { +func (b *Unbounded[T]) Load() { b.mu.Lock() defer b.mu.Unlock() if len(b.backlog) > 0 { select { case b.c <- b.backlog[0]: - b.backlog[0] = nil + var zero T + b.backlog[0] = zero b.backlog = b.backlog[1:] default: } @@ -96,14 +94,14 @@ func (b *Unbounded) Load() { // // If the unbounded buffer is closed, the read channel returned by this method // is closed after all data is drained. -func (b *Unbounded) Get() <-chan any { +func (b *Unbounded[T]) Get() <-chan T { return b.c } // Close closes the unbounded buffer. No subsequent data may be Put(), and the // channel returned from Get() will be closed after all the data is read and // Load() is called for the final time. -func (b *Unbounded) Close() { +func (b *Unbounded[T]) Close() { b.mu.Lock() defer b.mu.Unlock() if b.closing { diff --git a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go index 33344812746c..2f4ae2fada4b 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go @@ -144,14 +144,21 @@ var ( // ControlBufferThrottleLimit is the maximum number of control frames that can // be queued in the control buffer before throttling is applied. The value - // must be between 1 and 10,000, and is set to 100 by default. + // must be between 1 and 100,000, and is set to 10,000 by default. // // This environment variable serves as an escape hatch to increase the // throttling limit if unforeseen issues arise, and it will be removed in a // future release. // - // TODO: Remove this env var once v1.83.0 is released. - ControlBufferThrottleLimit = uint64FromEnv("GRPC_GO_EXPERIMENTAL_CONTROL_BUFFER_THROTTLE_LIMIT", 100, 1, 10000) + // TODO: Remove this env var once v1.86.0 is released. + ControlBufferThrottleLimit = uint64FromEnv("GRPC_GO_EXPERIMENTAL_CONTROL_BUFFER_THROTTLE_LIMIT", 10000, 1, 100000) + + // ALTSMaxFrameSize is the maximum frame size for ALTS in bytes. + // This can be overridden by setting the environment variable + // "GRPC_GO_EXPERIMENTAL_ALTS_MAX_FRAME_SIZE" (min: 4096, max: 512*1024, capped at + // 512KiB to match altsWriteBufferMaxSize in + // credentials/alts/internal/conn/record.go). + ALTSMaxFrameSize = uint64FromEnv("GRPC_GO_EXPERIMENTAL_ALTS_MAX_FRAME_SIZE", 4096, 4096, 512*1024) // EnableReceiveBufferCompaction enables the compaction of data buffers // to reduce the number of buffers in the receive buffer. diff --git a/vendor/google.golang.org/grpc/internal/envconfig/xds.go b/vendor/google.golang.org/grpc/internal/envconfig/xds.go index e4b691913822..5ec39bd75698 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/xds.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/xds.go @@ -98,4 +98,9 @@ var ( // filter. For more details, see: // https://github.com/grpc/proposal/blob/master/A83-xds-gcp-authn-filter.md GCPAuthenticationFilterEnabled = boolFromEnv("GRPC_EXPERIMENTAL_XDS_GCP_AUTHENTICATION_FILTER", false) + + // XDSClientExtAuthzEnabled indicates whether the external authorization + // filter is enabled on the client side. For more details, see: + // https://github.com/grpc/proposal/blob/master/A92-xds-ext-authz.md + XDSClientExtAuthzEnabled = boolFromEnv("GRPC_EXPERIMENTAL_XDS_EXT_AUTHZ_ON_CLIENT", false) ) diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go b/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go index d4999fcca832..caa9dd68eae5 100644 --- a/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go +++ b/vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go @@ -41,7 +41,7 @@ type CallbackSerializer struct { // its resources. done chan struct{} - callbacks *buffer.Unbounded + callbacks *buffer.Unbounded[func(context.Context)] } // NewCallbackSerializer returns a new CallbackSerializer instance. The provided @@ -52,7 +52,7 @@ type CallbackSerializer struct { func NewCallbackSerializer(ctx context.Context) *CallbackSerializer { cs := &CallbackSerializer{ done: make(chan struct{}), - callbacks: buffer.NewUnbounded(), + callbacks: buffer.NewUnbounded[func(context.Context)](), } go cs.run(ctx) return cs @@ -113,7 +113,7 @@ func (cs *CallbackSerializer) run(ctx context.Context) { // Run all callbacks. for cb := range cs.callbacks.Get() { cs.callbacks.Load() - cb.(func(context.Context))(ctx) + cb(ctx) } } diff --git a/vendor/google.golang.org/grpc/internal/grpcsync/refcounted.go b/vendor/google.golang.org/grpc/internal/grpcsync/refcounted.go new file mode 100644 index 000000000000..bca9b83754dd --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/grpcsync/refcounted.go @@ -0,0 +1,109 @@ +/* + * + * Copyright 2026 gRPC authors. + * + * 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. + * + */ + +package grpcsync + +import ( + "sync/atomic" + + "google.golang.org/grpc/grpclog" +) + +var logger = grpclog.Component("grpcsync") + +// RefCounted is a reference counted wrapper of type T. It tracks the number of +// active references and runs a cleanup when the last reference is released. +type RefCounted[T any] struct { + val T + refCount atomic.Int32 + onZero func() +} + +// NewRefCounted creates a new RefCounted instance wrapping the given value with +// initial refcount of one. +// +// The value should typically be a pointer, interface, or handle rather than a +// plain value type (such as a struct or primitive value). +// +// The provided onZero callback must not be nil, and is executed exactly once +// when the reference count drops to zero. Panics if onZero is nil. +// +// WARNING: onZero runs synchronously inside Decrement; it must not acquire +// locks held by Decrement callers. +func NewRefCounted[T any](val T, onZero func()) *RefCounted[T] { + if onZero == nil { + panic("grpcsync: onZero callback cannot be nil") + } + rc := &RefCounted[T]{ + val: val, + onZero: onZero, + } + rc.refCount.Store(1) + return rc +} + +// Value returns the encapsulated resource. +func (rc *RefCounted[T]) Value() T { + return rc.val +} + +// TryIncrement attempts to increment the reference count, returning true if +// successful. It returns false if the count has already reached 0, indicating +// the resource has been cleaned up and cannot be resurrected. +// +// WARNING: Avoid calling TryIncrement on hot paths when an active reference is +// already guaranteed by the caller; use Increment instead to bypass the +// CompareAndSwap loop overhead. TryIncrement should be reserved for speculative +// lookups (such as fetching from a cache or map) where the resource might be +// dead. +func (rc *RefCounted[T]) TryIncrement() bool { + // Utilize a CompareAndSwap loop to prevent race conditions where a concurrent + // decrement could drop the count to zero between the read and the increment + // operation, which would otherwise inadvertently resurrect a closed resource. + for { + count := rc.refCount.Load() + if count <= 0 { + return false // Already dead or dying + } + if rc.refCount.CompareAndSwap(count, count+1) { + return true + } + } +} + +// Increment increments the reference count. +// +// WARNING: Call Increment only when there is a guarantee that an active +// reference is already present, ensuring the resource is not dead. If there is +// a possibility that the resource is dead or its reference count might have +// reached zero, call TryIncrement instead. +func (rc *RefCounted[T]) Increment() { + if rc.refCount.Add(1) <= 1 { + logger.Errorf("Resource already closed or dead") + } +} + +// Decrement decrements the reference count. If it drops to zero, the onZero +// callback is executed synchronously before this method returns. +func (rc *RefCounted[T]) Decrement() { + if v := rc.refCount.Add(-1); v < 0 { + logger.Errorf("Refcount cannot be negative") + } else if v == 0 { + rc.onZero() + } +} diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go index 4b3d563f8d76..2b7fa6b08b20 100644 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -245,6 +245,10 @@ var ( AsyncReporterCleanupDelegate = func(cleanup func()) func() { return cleanup } + + // XDSFilterWrapperOption returns a ServerOption that sets the internal + // stream wrapper used for server-side xDS HTTP filters. + XDSFilterWrapperOption any // func(func(grpc.ServerStream) (grpc.ServerStream, error)) grpc.ServerOption ) // HealthChecker defines the signature of the client-side LB channel health diff --git a/vendor/google.golang.org/grpc/internal/resolver/config_selector.go b/vendor/google.golang.org/grpc/internal/resolver/config_selector.go index 238950bbbf99..ead6dda4e99f 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/config_selector.go +++ b/vendor/google.golang.org/grpc/internal/resolver/config_selector.go @@ -42,6 +42,10 @@ type RPCInfo struct { // efficiency reasons. SelectConfig should not be blocking. Context context.Context Method string // i.e. "/Service/Method" + // Authority is the target authority (host) name of the RPC. This is required + // for HTTP filters (such as external processing) to populate request + // attributes. + Authority string } // RPCConfig describes the configuration to use for each RPC. @@ -54,17 +58,6 @@ type RPCConfig struct { Interceptor any } -// ServerInterceptor is an interceptor for incoming RPC's on gRPC server side. -type ServerInterceptor interface { - // AllowRPC checks if an incoming RPC is allowed to proceed based on - // information about connection RPC was received on, and HTTP Headers. This - // information will be piped into context. - AllowRPC(ctx context.Context) error // TODO: Make this a real interceptor for filters such as rate limiting. - // Close closes the interceptor. Once called, no new calls to NewStream are - // accepted. Ongoing calls to NewStream are allowed to complete. - Close() -} - type csKeyType string const csKey = csKeyType("grpc.internal.resolver.configSelector") diff --git a/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go b/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go index 070680edbac1..4718576edb79 100644 --- a/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go +++ b/vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go @@ -47,10 +47,9 @@ const ( var bdpPing = &ping{data: [8]byte{2, 4, 16, 16, 9, 14, 7, 7}} type bdpEstimator struct { + mu sync.Mutex // sentAt is the time when the ping was sent. sentAt time.Time - - mu sync.Mutex // bdp is the current bdp estimate. bdp uint32 // sample is the number of bytes received in one measurement cycle. @@ -75,7 +74,9 @@ func (b *bdpEstimator) timesnap(d [8]byte) { if bdpPing.data != d { return } + b.mu.Lock() b.sentAt = time.Now() + b.mu.Unlock() } // add adds bytes to the current sample for calculating bdp. diff --git a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go index b9bae02498ea..e33ac3a5fcda 100644 --- a/vendor/google.golang.org/grpc/internal/transport/controlbuf.go +++ b/vendor/google.golang.org/grpc/internal/transport/controlbuf.go @@ -26,6 +26,7 @@ import ( "runtime" "sync" "sync/atomic" + "time" "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" @@ -97,22 +98,35 @@ func (il *itemList) isEmpty() bool { return il.head == nil } -// maxQueuedControlBufferItems is the maximum number of frames (other than -// HEADERS and DATA) that we will buffer before preventing new reads from -// occurring on the transport. These are control frames sent in response to -// client requests, or frames that result in work being scheduled, such as -// RST_STREAM due to bad headers or settings acks. -var maxQueuedControlBufferItems = int(envconfig.ControlBufferThrottleLimit) +// maxQueuedTransportResponseFrames is the maximum number of "transport +// response" frames that we will buffer before preventing new reads from +// occurring on the transport. See cbItem.isTransportResponseFrame for the +// items that count towards this limit. +var maxQueuedTransportResponseFrames = int(envconfig.ControlBufferThrottleLimit) type cbItem interface { - isThrottled() bool + // isTransportResponseFrame reports whether the item counts against the + // maxQueuedTransportResponseFrames limit, when queued in the + // controlBuffer of a transport on the given side. + // + // Items that the peer can make the transport queue in unbounded + // numbers, for example by sending PING or SETTINGS frames, must be + // counted, so that the transport stops reading from a peer that sends + // such frames without reading what the transport writes. Items whose + // number grows with the local application's load (for example, one + // per stream it creates) must not be counted. Otherwise, under high + // concurrency, both peers could stop reading at the same time and + // deadlock (see https://github.com/grpc/grpc-go/issues/9330). + isTransportResponseFrame(s side) bool } -// throttledItem represents every item in the controlBuffer to which the overall -// throttling limit applies, other than outgoing HEADERS and DATA frames. -type throttledItem struct{} +// nonTransportResponseFrame represents items in the controlBuffer that are not +// queued in response to peer control/reset frames (for example, +// locally-initiated or flow-controlled items). These items are not counted +// against the maxQueuedTransportResponseFrames limit. +type nonTransportResponseFrame struct{} -func (throttledItem) isThrottled() bool { return true } +func (nonTransportResponseFrame) isTransportResponseFrame(side) bool { return false } // The following defines various control items which could flow through // the control buffer of transport. They represent different aspects of @@ -120,12 +134,13 @@ func (throttledItem) isThrottled() bool { return true } // registerStream is used to register an incoming stream with loopy writer. type registerStream struct { - throttledItem + nonTransportResponseFrame streamID uint32 wq *writeQuota } type clientHeaders struct { + nonTransportResponseFrame streamID uint32 hf []hpack.HeaderField initStream func(uint32) error @@ -134,9 +149,8 @@ type clientHeaders struct { onOrphaned func(error) } -func (*clientHeaders) isThrottled() bool { return false } - type serverHeaders struct { + nonTransportResponseFrame streamID uint32 hf []hpack.HeaderField endStream bool @@ -144,24 +158,37 @@ type serverHeaders struct { cleanup *cleanupStream } -func (h *serverHeaders) isThrottled() bool { return false } - type cleanupStream struct { - throttledItem streamID uint32 rst bool rstCode http2.ErrCode onWrite func() } +// isTransportResponseFrame returns true on the server since cleanupStream +// either results in a RST_STREAM frame being sent on the wire or in +// non-trivial work being performed when under a Rapid Reset attack. +// +// It returns false on the client, where a cleanupStream is queued at most once +// per stream, and the number of streams is controlled by the client and not by +// the server. Counting them on the client makes the client stop reading under +// high concurrency, which deadlocks with a server that has also stopped +// reading (see https://github.com/grpc/grpc-go/issues/9330). +func (*cleanupStream) isTransportResponseFrame(s side) bool { return s == serverSide } + type earlyAbortStream struct { - throttledItem streamID uint32 rst bool hf []hpack.HeaderField // Pre-built header fields } +// isTransportResponseFrame returns true on the server since earlyAbortStream +// results in a HEADERS frame being sent on the wire, and possibly a RST_STREAM +// frame. It is never queued on the client. +func (*earlyAbortStream) isTransportResponseFrame(s side) bool { return s == serverSide } + type dataFrame struct { + nonTransportResponseFrame streamID uint32 endStream bool h []byte @@ -172,36 +199,40 @@ type dataFrame struct { onEachWrite func() } -func (*dataFrame) isThrottled() bool { return false } - type incomingWindowUpdate struct { - throttledItem streamID uint32 increment uint32 } +// isTransportResponseFrame returns true to protect against a WINDOW_UPDATE +// flood attack from the peer. +func (*incomingWindowUpdate) isTransportResponseFrame(side) bool { return true } + type outgoingWindowUpdate struct { - throttledItem + nonTransportResponseFrame streamID uint32 increment uint32 } type incomingSettings struct { - throttledItem ss []http2.Setting } +// isTransportResponseFrame returns true since incomingSettings results in a +// SETTINGS ACK frame being sent on the wire. +func (*incomingSettings) isTransportResponseFrame(side) bool { return true } + type outgoingSettings struct { - throttledItem + nonTransportResponseFrame ss []http2.Setting } type incomingGoAway struct { - throttledItem + nonTransportResponseFrame } type goAway struct { - throttledItem + nonTransportResponseFrame code http2.ErrCode debugData []byte headsUp bool @@ -209,22 +240,43 @@ type goAway struct { } type ping struct { - throttledItem ack bool data [8]byte } +// isTransportResponseFrame returns true for all pings, and not only for ping +// acks sent in response to pings from the peer. This is because a BDP ping is +// queued in response to a DATA frame (of any size) from the peer, whenever +// there is no BDP ping outstanding. And since the BDP ping's payload is fixed, +// the peer can make it look like the BDP ping was acked at any time, by +// sending a ping ack with that payload. A peer alternating between empty DATA +// frames and such ping acks would otherwise be able to queue an unbounded +// number of BDP pings. Pings initiated locally (keepalive and BDP) are rare +// enough to not cause throttling of well-behaved peers. +func (*ping) isTransportResponseFrame(side) bool { return true } + type outFlowControlSizeRequest struct { - throttledItem + nonTransportResponseFrame resp chan uint32 } +// outStreamRequestForTesting is used by tests to retrieve a pointer to an outStream +// safely inside the loopyWriter goroutine without racing on loopyWriter.estdStreams. +// By holding the *outStream pointer while streams and transports close down, tests +// can inspect settled accounting values (such as bytesOutStanding) after loopyWriter +// has run to completion without any data races. +type outStreamRequestForTesting struct { + nonTransportResponseFrame + streamID uint32 + resp chan *outStream +} + // closeConnection is an instruction to tell the loopy writer to flush the // framer and exit, which will cause the transport's connection to be closed // (by the client or server). The transport itself will close after the reader // encounters the EOF caused by the connection closure. type closeConnection struct { - throttledItem + nonTransportResponseFrame } type outStreamState int @@ -305,8 +357,9 @@ func (l *outStreamList) dequeue() *outStream { // shouldn't be confused with an HTTP2 frame, although some of the control // frames like dataFrame and headerFrame do go out on wire as HTTP2 frames. type controlBuffer struct { - wakeupCh chan struct{} // Unblocks readers waiting for something to read. + wakeupCh chan struct{} // Unblocks readers waiting for new items. done <-chan struct{} // Closed when the transport is done. + side side // Side of the transport owning this buffer. // Mutex guards all the fields below, except trfChan which can be read // atomically without holding mu. @@ -315,26 +368,30 @@ type controlBuffer struct { closed bool // True when the controlbuf is finished. list *itemList // List of queued control frames. - // transportResponseFrames counts the number of queued items that represent - // the response of an action initiated by the peer. trfChan is created - // when transportResponseFrames >= maxQueuedTransportResponseFrames and is - // closed and nilled when transportResponseFrames drops below the - // threshold. Both fields are protected by mu. + // transportResponseFrames counts the number of queued items that + // represent the response of an action initiated by the peer (as + // determined by cbItem.isTransportResponseFrame for this side). + // trfChan is created when transportResponseFrames >= + // maxQueuedTransportResponseFrames and is closed and nilled when + // transportResponseFrames drops below the threshold. Both fields are + // protected by mu. transportResponseFrames int trfChan atomic.Pointer[chan struct{}] } -func newControlBuffer(done <-chan struct{}) *controlBuffer { +func newControlBuffer(done <-chan struct{}, s side) *controlBuffer { return &controlBuffer{ wakeupCh: make(chan struct{}, 1), list: &itemList{}, done: done, + side: s, } } -// throttle blocks if there are too many frames in the control buf that -// represent the response of an action initiated by the peer, like -// incomingSettings cleanupStreams etc. +// throttle blocks if there are too many items in the control buffer that count +// towards the maxQueuedTransportResponseFrames limit (see +// cbItem.isTransportResponseFrame), until their number drops below the limit, +// the control buffer is finished, or the transport is done. func (c *controlBuffer) throttle() { if ch := c.trfChan.Load(); ch != nil { select { @@ -344,6 +401,25 @@ func (c *controlBuffer) throttle() { } } +// throttleWithTimeout is like throttle, but it stops waiting and returns an +// error if the control buffer is still throttled after the given duration. +func (c *controlBuffer) throttleWithTimeout(timeout time.Duration) error { + ch := c.trfChan.Load() + if ch == nil { + return nil + } + timer := time.NewTimer(timeout) + defer timer.Stop() + select { + case <-(*ch): + return nil + case <-c.done: + return nil + case <-timer.C: + return fmt.Errorf("still throttled after %v, with at least %d queued frames", timeout, maxQueuedTransportResponseFrames) + } +} + // put adds an item to the controlbuf. func (c *controlBuffer) put(it cbItem) error { _, err := c.executeAndPut(nil, it) @@ -379,9 +455,9 @@ func (c *controlBuffer) executeAndPut(f func() bool, it cbItem) (bool, error) { c.consumerWaiting = false } c.list.enqueue(it) - if it.isThrottled() { + if it.isTransportResponseFrame(c.side) { c.transportResponseFrames++ - if c.transportResponseFrames == maxQueuedControlBufferItems { + if c.transportResponseFrames == maxQueuedTransportResponseFrames { // We are adding the frame that puts us over the threshold; create // a throttling channel. ch := make(chan struct{}) @@ -436,8 +512,8 @@ func (c *controlBuffer) getOnceLocked() (any, error) { return nil, nil } h := c.list.dequeue().(cbItem) - if h.isThrottled() { - if c.transportResponseFrames == maxQueuedControlBufferItems { + if h.isTransportResponseFrame(c.side) { + if c.transportResponseFrames == maxQueuedTransportResponseFrames { // We are removing the frame that put us over the // threshold; close and clear the throttling channel. ch := c.trfChan.Swap(nil) @@ -473,9 +549,10 @@ func (c *controlBuffer) finish() { } } - // In case throttle() is currently in flight, it needs to be unblocked. - // Otherwise, the transport may not close, since the transport is closed by - // the reader encountering the connection error. + // In case throttle() or throttleWithTimeout() is currently in flight, + // it needs to be unblocked. Otherwise, the transport may not close, + // since the transport is closed by the reader encountering the + // connection error. ch := c.trfChan.Swap(nil) if ch != nil { close(*ch) @@ -799,6 +876,10 @@ func (l *loopyWriter) outFlowControlSizeRequestHandler(o *outFlowControlSizeRequ o.resp <- l.sendQuota } +func (l *loopyWriter) outStreamRequestHandler(o *outStreamRequestForTesting) { + o.resp <- l.estdStreams[o.streamID] +} + func (l *loopyWriter) cleanupStreamHandler(c *cleanupStream) error { c.onWrite() if str, ok := l.estdStreams[c.streamID]; ok { @@ -896,6 +977,8 @@ func (l *loopyWriter) handle(i any) error { return l.goAwayHandler(i) case *outFlowControlSizeRequest: l.outFlowControlSizeRequestHandler(i) + case *outStreamRequestForTesting: + l.outStreamRequestHandler(i) case closeConnection: // Just return a non-I/O error and run() will flush and close the // connection. diff --git a/vendor/google.golang.org/grpc/internal/transport/handler_server.go b/vendor/google.golang.org/grpc/internal/transport/handler_server.go index 9cd8d28d33eb..a701522b4950 100644 --- a/vendor/google.golang.org/grpc/internal/transport/handler_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/handler_server.go @@ -268,7 +268,7 @@ func (ht *serverHandlerTransport) writeStatus(s *ServerStream, st *status.Status for _, v := range vv { // http2 ResponseWriter mechanism to send undeclared Trailers after // the headers have possibly been written. - h.Add(http2.TrailerPrefix+k, encodeMetadataHeader(k, v)) + h.Add(http.TrailerPrefix+k, encodeMetadataHeader(k, v)) } } } @@ -494,7 +494,8 @@ func mapRecvMsgError(err error) error { if err == io.EOF || err == io.ErrUnexpectedEOF { return err } - if se, ok := err.(http2.StreamError); ok { + var se http2.StreamError + if errors.As(err, &se) { if code, ok := http2ErrConvTab[se.Code]; ok { return status.Error(code, se.Error()) } diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index 10d19774159b..a198bafbd3ff 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -65,6 +65,13 @@ var clientConnectionCounter uint64 var goAwayLoopyWriterTimeout = 5 * time.Second +// clientThrottleTimeout is the maximum amount of time for which the client +// stops reading from the connection because too many frames queued in +// response to the server (see maxQueuedTransportResponseFrames) are waiting +// to be written. After that, the client closes the connection instead of +// waiting forever, since the server is most likely not reading. +var clientThrottleTimeout = 10 * time.Second + var metadataFromOutgoingContextRaw = internal.FromOutgoingContextRaw.(func(context.Context) (metadata.MD, [][]string, bool)) // http2Client implements the ClientTransport interface with HTTP2. @@ -107,6 +114,12 @@ type http2Client struct { kp keepalive.ClientParameters keepaliveEnabled bool + // throttleTimeout is the maximum amount of time for which reads can + // stay throttled before the connection is closed. It is copied from + // clientThrottleTimeout on creation, so that tests can override the + // latter without racing with the readers of other transports. + throttleTimeout time.Duration + statsHandler stats.Handler initialWindowSize int32 @@ -359,6 +372,7 @@ func NewHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts streamQuota: defaultMaxStreamsClient, streamsQuotaAvailable: make(chan struct{}, 1), keepaliveEnabled: keepaliveEnabled, + throttleTimeout: clientThrottleTimeout, bufferPool: opts.BufferPool, onClose: onClose, } @@ -386,7 +400,7 @@ func NewHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts } else if md := imetadata.Get(addr); md != nil { t.md = md } - t.controlBuf = newControlBuffer(t.ctxDone) + t.controlBuf = newControlBuffer(t.ctxDone, clientSide) if opts.InitialWindowSize >= defaultWindowSize { t.initialWindowSize = opts.InitialWindowSize } @@ -554,8 +568,6 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) if err != nil { return nil, err } - // TODO(mmukhi): Benchmark if the performance gets better if count the metadata and other header fields - // first and create a slice of that exact size. // Make the slice of certain predictable size to reduce allocations made by append. hfLen := 7 // :method, :scheme, :path, :authority, content-type, user-agent, te hfLen += len(authData) + len(callAuthData) @@ -575,6 +587,21 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) if _, ok := ctx.Deadline(); ok { hfLen++ } + // Count the metadata header fields as well so the slice is not reallocated + // while they are appended below. Reserved headers are dropped when writing, + // so this may slightly over-count, which is preferable to growing the slice. + md, added, mdOK := metadataFromOutgoingContextRaw(ctx) + if mdOK { + for _, vv := range md { + hfLen += len(vv) + } + for _, vv := range added { + hfLen += len(vv) / 2 + } + } + for _, vv := range t.md { + hfLen += len(vv) + } headerFields := make([]hpack.HeaderField, 0, hfLen) headerFields = append(headerFields, hpack.HeaderField{Name: ":method", Value: "POST"}) headerFields = append(headerFields, hpack.HeaderField{Name: ":scheme", Value: t.scheme}) @@ -619,7 +646,7 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) } - if md, added, ok := metadataFromOutgoingContextRaw(ctx); ok { + if mdOK { var k string for k, vv := range md { // HTTP doesn't allow you to set pseudoheaders after non pseudoheaders were set. @@ -648,6 +675,9 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) if isReservedHeader(k) { continue } + if err := imetadata.ValidatePair(k, vv...); err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } for _, v := range vv { headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) } @@ -691,6 +721,9 @@ func (t *http2Client) getTrAuthData(ctx context.Context, audience string) (map[s for k, v := range data { // Capital header names are illegal in HTTP/2. k = strings.ToLower(k) + if err := imetadata.ValidatePair(k, v); err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } authData[k] = v } } @@ -724,6 +757,9 @@ func (t *http2Client) getCallAuthData(ctx context.Context, audience string, call for k, v := range data { // Capital header names are illegal in HTTP/2 k = strings.ToLower(k) + if err := imetadata.ValidatePair(k, v); err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } callAuthData[k] = v } } @@ -930,6 +966,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr, handler s LocalAddr: t.localAddr, Compression: callHdr.SendCompress, Header: header, + Authority: callHdr.Host, }) } if transportDrainRequired { @@ -1226,23 +1263,26 @@ func (t *http2Client) handleData(f *parsedDataFrame) { t.closeStream(s, io.EOF, true, http2.ErrCodeFlowControl, status.New(codes.Internal, err.Error()), nil, false) return } + } - if s.nonGRPCStatus != nil { - // The frame should be handled as a non-gRPC response body - st := s.handleNonGRPCData(f) - if st != nil { - t.closeStream(s, st.Err(), true, http2.ErrCodeProtocol, st, nil, true) - return - } - if w := s.fc.onRead(size); w > 0 { - t.controlBuf.put(&outgoingWindowUpdate{ - streamID: s.id, - increment: w, - }) - } + if s.nonGRPCStatus != nil { + // The frame should be handled as a non-gRPC response body. A non-nil + // status also covers END_STREAM, so no separate handling is needed below. + st := s.handleNonGRPCData(f) + if st != nil { + t.closeStream(s, st.Err(), true, http2.ErrCodeProtocol, st, nil, true) return } + if w := s.fc.onRead(size); w > 0 { + t.controlBuf.put(&outgoingWindowUpdate{ + streamID: s.id, + increment: w, + }) + } + return + } + if size > 0 { dataLen := f.data.Len() if f.Header().Flags.Has(http2.FlagDataPadded) { if w := s.fc.onRead(size - uint32(dataLen)); w > 0 { @@ -1701,9 +1741,19 @@ func (t *http2Client) reader(errCh chan<- error) { atomic.StoreInt64(&t.lastRead, time.Now().UnixNano()) } - // loop to keep reading incoming messages on this transport. + // Loop to keep reading incoming messages on this transport. for { - t.controlBuf.throttle() + // Stop reading while too many items that the server can make + // the client queue (see cbItem.isTransportResponseFrame) are + // waiting to be written, to bound the memory that a server + // can make the client use by flooding it without reading. If + // reads stay throttled for t.throttleTimeout, close the + // connection instead of waiting forever. + if err := t.controlBuf.throttleWithTimeout(t.throttleTimeout); err != nil { + t.logger.Warningf("Closing connection since the server is not reading: %v", err) + errClose = connectionErrorf(true, err, "closing connection since the server is not reading: %v", err) + return + } frame, err := t.framer.readFrame() if t.keepaliveEnabled { atomic.StoreInt64(&t.lastRead, time.Now().UnixNano()) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go index 82e13e64aa67..5c3fc76589f2 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_server.go @@ -297,7 +297,7 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, ) t.logger = prefixLoggerForServerTransport(t) - t.controlBuf = newControlBuffer(t.done) + t.controlBuf = newControlBuffer(t.done, serverSide) if !config.StaticWindowSize { t.bdpEst = &bdpEstimator{ bdp: initialWindowSize, @@ -380,6 +380,11 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade defer t.maxStreamMu.Unlock() streamID := frame.Header().StreamID + if streamID%2 != 1 || streamID <= t.maxStreamID { + // illegal gRPC stream id. + return fmt.Errorf("received an illegal stream id: %v. headers frame: %+v", streamID, frame) + } + t.maxStreamID = streamID // frame.Truncated is set to true when framer detects that the current header // list size hits MaxHeaderListSize limit. @@ -393,12 +398,6 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade return nil } - if streamID%2 != 1 || streamID <= t.maxStreamID { - // illegal gRPC stream id. - return fmt.Errorf("received an illegal stream id: %v. headers frame: %+v", streamID, frame) - } - t.maxStreamID = streamID - s := &ServerStream{ Stream: Stream{ id: streamID, @@ -531,6 +530,7 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade if frame.StreamEnded() { // s is just created by the caller. No lock needed. s.state = streamReadDone + s.write(recvMsg{err: io.EOF}) } if timeoutSet { s.ctx, s.cancel = context.WithTimeout(ctx, timeout) @@ -1013,7 +1013,17 @@ func (t *http2Server) streamContextErr(s *ServerStream) error { return ErrConnClosing default: } - return ContextErr(s.ctx.Err()) + err := s.ctx.Err() + if err == nil { + // In closeStream and finishStream, the stream state is transitioned to + // streamDone before s.cancel() is invoked so that concurrent operations + // immediately observe the terminal state. A concurrent caller (such as + // write or writeHeader) can see streamDone and invoke streamContextErr + // before s.cancel() runs or propagates to s.ctx. Default to + // context.Canceled rather than passing nil to ContextErr. + err = context.Canceled + } + return ContextErr(err) } // WriteHeader sends the header metadata md back to the client. @@ -1335,10 +1345,6 @@ func (t *http2Server) deleteStream(s *ServerStream, eosReceived bool) { // finishStream closes the stream and puts the trailing headerFrame into controlbuf. func (t *http2Server) finishStream(s *ServerStream, rst bool, rstCode http2.ErrCode, hdr *serverHeaders, eosReceived bool) { - // In case stream sending and receiving are invoked in separate - // goroutines (e.g., bi-directional streaming), cancel needs to be - // called to interrupt the potential blocking on other goroutines. - s.cancel() oldState := s.swapState(streamDone) if oldState == streamDone { @@ -1346,6 +1352,11 @@ func (t *http2Server) finishStream(s *ServerStream, rst bool, rstCode http2.ErrC return } + // In case stream sending and receiving are invoked in separate + // goroutines (e.g., bi-directional streaming), cancel needs to be + // called to interrupt the potential blocking on other goroutines. + s.cancel() + hdr.cleanup = &cleanupStream{ streamID: s.id, rst: rst, @@ -1359,15 +1370,16 @@ func (t *http2Server) finishStream(s *ServerStream, rst bool, rstCode http2.ErrC // closeStream clears the footprint of a stream when the stream is not needed any more. func (t *http2Server) closeStream(s *ServerStream, rst bool, rstCode http2.ErrCode, eosReceived bool) { + // We can't return early even if the stream's state is "done" as the state + // might have been set by the `finishStream` method. Deleting the stream via + // `finishStream` can get blocked on flow control. + s.swapState(streamDone) + // In case stream sending and receiving are invoked in separate // goroutines (e.g., bi-directional streaming), cancel needs to be // called to interrupt the potential blocking on other goroutines. s.cancel() - // We can't return early even if the stream's state is "done" as the state - // might have been set by the `finishStream` method. Deleting the stream via - // `finishStream` can get blocked on flow control. - s.swapState(streamDone) t.deleteStream(s, eosReceived) t.controlBuf.put(&cleanupStream{ diff --git a/vendor/google.golang.org/grpc/internal/transport/http_util.go b/vendor/google.golang.org/grpc/internal/transport/http_util.go index c34975ffefda..faa42f8cad5c 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http_util.go +++ b/vendor/google.golang.org/grpc/internal/transport/http_util.go @@ -300,24 +300,29 @@ func decodeGrpcMessageUnchecked(msg string) string { type bufWriter struct { pool *imem.SimpleBufferPool - buf []byte + bufHandle *[]byte offset int batchSize int conn io.Writer err error } +// unsharedBufWriter keeps the unshared slice header in the writer allocation. +type unsharedBufWriter struct { + bufWriter + buf []byte +} + func newBufWriter(conn io.Writer, batchSize int, pool *imem.SimpleBufferPool) *bufWriter { - w := &bufWriter{ - batchSize: batchSize, - conn: conn, - pool: pool, - } - // this indicates that we should use non shared buf - if pool == nil { - w.buf = make([]byte, batchSize) + if pool == nil && batchSize > 0 { + w := &unsharedBufWriter{ + bufWriter: bufWriter{batchSize: batchSize, conn: conn}, + buf: make([]byte, batchSize), + } + w.bufHandle = &w.buf + return &w.bufWriter } - return w + return &bufWriter{batchSize: batchSize, conn: conn, pool: pool} } func (w *bufWriter) Write(b []byte) (int, error) { @@ -328,13 +333,13 @@ func (w *bufWriter) Write(b []byte) (int, error) { n, err := w.conn.Write(b) return n, toIOError(err) } - if w.buf == nil { - b := w.pool.Get(w.batchSize) - w.buf = *b + if w.bufHandle == nil { + w.bufHandle = w.pool.Get(w.batchSize) } + buf := *w.bufHandle written := 0 for len(b) > 0 { - copied := copy(w.buf[w.offset:], b) + copied := copy(buf[w.offset:], b) b = b[copied:] written += copied w.offset += copied @@ -350,15 +355,17 @@ func (w *bufWriter) Write(b []byte) (int, error) { func (w *bufWriter) Flush() error { err := w.flushKeepBuffer() - // Only release the buffer if we are in a "shared" mode - if w.buf != nil && w.pool != nil { - b := w.buf - w.pool.Put(&b) - w.buf = nil - } + w.releaseBuffer() return err } +func (w *bufWriter) releaseBuffer() { + if w.pool != nil && w.bufHandle != nil { + w.pool.Put(w.bufHandle) + w.bufHandle = nil + } +} + func (w *bufWriter) flushKeepBuffer() error { if w.err != nil { return w.err @@ -366,9 +373,13 @@ func (w *bufWriter) flushKeepBuffer() error { if w.offset == 0 { return nil } - _, w.err = w.conn.Write(w.buf[:w.offset]) + buf := *w.bufHandle + _, w.err = w.conn.Write(buf[:w.offset]) w.err = toIOError(w.err) w.offset = 0 + if w.err != nil { + w.releaseBuffer() + } return w.err } diff --git a/vendor/google.golang.org/grpc/internal/transport/transport.go b/vendor/google.golang.org/grpc/internal/transport/transport.go index 5fc901e5cf14..f627adf6807f 100644 --- a/vendor/google.golang.org/grpc/internal/transport/transport.go +++ b/vendor/google.golang.org/grpc/internal/transport/transport.go @@ -89,10 +89,10 @@ type recvMsg struct { // recvBuffer is an unbounded channel of recvMsg structs. // -// Note: recvBuffer differs from buffer.Unbounded only in the fact that it -// holds a channel of recvMsg structs instead of objects implementing "item" -// interface. recvBuffer is written to much more often and using strict recvMsg -// structs helps avoid allocation in "recvBuffer.put" +// Note: recvBuffer differs from buffer.Unbounded in that it provides in-place +// value initialization (via init) to avoid struct pointer allocations on +// streams, and automatically frees pooled mem.Buffer payloads when stream +// errors occur. type recvBuffer struct { c chan recvMsg mu sync.Mutex @@ -121,7 +121,9 @@ func (b *recvBuffer) put(r recvMsg) { if b.err != nil { // drop the buffer on the floor. Since b.err is not nil, any subsequent reads // will always return an error, making this buffer inaccessible. - r.buffer.Free() + if r.buffer != nil { + r.buffer.Free() + } // An error had occurred earlier, don't accept more // data or errors. return @@ -466,15 +468,18 @@ func (s *Stream) ReadMessageHeader(header []byte) (err error) { return er } s.readRequester.requestRead(len(header)) + bytesRead := 0 for len(header) != 0 { n, err := s.trReader.ReadMessageHeader(header) + bytesRead += n header = header[n:] if len(header) == 0 { err = nil } if err != nil { - if n > 0 && err == io.EOF { + if bytesRead > 0 && err == io.EOF { err = io.ErrUnexpectedEOF + s.trReader.er = err } return err } @@ -505,19 +510,22 @@ func (s *Stream) read(n int) (data mem.BufferSlice, err error) { allocCap := min(ceil(n, http2MaxFrameLen), 128) data = make(mem.BufferSlice, 0, allocCap) s.readRequester.requestRead(n) + bytesRead := 0 for n != 0 { buf, err := s.trReader.Read(n) var bufLen int if buf != nil { bufLen = buf.Len() } + bytesRead += bufLen n -= bufLen if n == 0 { err = nil } if err != nil { - if bufLen > 0 && err == io.EOF { + if bytesRead > 0 && err == io.EOF { err = io.ErrUnexpectedEOF + s.trReader.er = err } data.Free() return nil, err diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go index d2e15253bbfb..a3090ff3d6e1 100644 --- a/vendor/google.golang.org/grpc/metadata/metadata.go +++ b/vendor/google.golang.org/grpc/metadata/metadata.go @@ -24,6 +24,7 @@ package metadata // import "google.golang.org/grpc/metadata" import ( "context" "fmt" + "sort" "strings" "google.golang.org/grpc/internal" @@ -90,6 +91,76 @@ func Pairs(kv ...string) MD { return md } +// loggableMetadataKeys is the set of metadata keys whose values are known not +// to carry credentials or other sensitive data, and are therefore safe to print +// verbatim in String. Values for any key not in this set are redacted. Keys are +// in metadata's canonical lowercase form. +// +// The list is intentionally restricted to standardized gRPC and HTTP/2 protocol +// headers. Everything else, including all application-defined keys, is +// censored. +// Note that this list might change as we add/remove support for +// metadata types. +var loggableMetadataKeys = map[string]bool{ + "content-type": true, + "te": true, + "user-agent": true, + "grpc-encoding": true, + "grpc-accept-encoding": true, + "grpc-timeout": true, + "grpc-status": true, + "grpc-message-type": true, + "grpc-previous-rpc-attempts": true, + "grpc-retry-pushback-ms": true, +} + +// String implements fmt.Stringer to allow metadata to be printed when stored in +// a context. +// +// To avoid accidentally leaking credentials or other sensitive data (for +// example via log(md), or by logging a value that happens to contain metadata), +// String reports only keys on an allowlist of standardized, non-sensitive +// protocol headers (see loggableMetadataKeys). Every other key is omitted +// entirely, along with its values, because a key name may itself be sensitive; +// only the number of omitted keys is reported, as "". This is a +// best-effort guard against accidents, not a security boundary: a caller that +// genuinely wants the full contents can still print map[string][]string(md) +// directly. +// +// Note that this only affects verbs that use the Stringer, such as %v and %s. +// The %#v verb prints the underlying map with all values and is not redacted. +// Users should not rely on the output of this method to be stable +// # Experimental +// +// Notice: This API is EXPERIMENTAL and may be changed or removed in a later +// release. +func (md MD) String() string { + keys := make([]string, 0, len(md)) + for k := range md { + if loggableMetadataKeys[strings.ToLower(k)] { + keys = append(keys, k) + } + } + sort.Strings(keys) + + var sb strings.Builder + sb.WriteString("map[") + for i, k := range keys { + if i > 0 { + sb.WriteByte(' ') + } + fmt.Fprintf(&sb, "%s:%v", k, md[k]) + } + if redacted := len(md) - len(keys); redacted > 0 { + if len(keys) > 0 { + sb.WriteByte(' ') + } + fmt.Fprintf(&sb, "<%d redacted>", redacted) + } + sb.WriteByte(']') + return sb.String() +} + // Len returns the number of items in md. func (md MD) Len() int { return len(md) @@ -289,6 +360,66 @@ func FromOutgoingContext(ctx context.Context) (MD, bool) { return out, ok } +// ValueFromOutgoingContext returns the metadata value corresponding to the +// metadata key from the outgoing metadata if it exists. Keys are matched in a +// case-insensitive manner. +// +// Unlike FromOutgoingContext, this does not copy the entire outgoing metadata. +func ValueFromOutgoingContext(ctx context.Context, key string) []string { + raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD) + if !ok { + return nil + } + + key = strings.ToLower(key) + // Unlike ValueFromIncomingContext, this can't return as soon as raw.md is + // checked: raw.added still needs to be walked and accumulated regardless. + // The else below prevents that from overwriting an exact match with an + // unrelated case-insensitive one. + var matchedMD []string + if v, ok := raw.md[key]; ok { + matchedMD = v + } else { + for k, v := range raw.md { + // Case insensitive comparison: MD is a map, and there's no + // guarantee that the MD attached to the context is created using + // our helper functions. + if strings.EqualFold(k, key) { + matchedMD = v + break + } + } + } + + // Defer allocating vals until raw.added actually has a match, so a match + // found only in raw.md doesn't pay for both a copyOf and a growing + // append. + var vals []string + for _, added := range raw.added { + if len(added)%2 == 1 { + panic(fmt.Sprintf("metadata: ValueFromOutgoingContext got an odd number of input pairs for metadata: %d", len(added))) + } + + // Case insensitive, like FromOutgoingContext: added isn't guaranteed + // lowercase, though AppendToOutgoingContext already lowercases it in + // practice, so try the cheap exact match first. + for i := 0; i < len(added); i += 2 { + if added[i] == key || strings.EqualFold(added[i], key) { + if vals == nil { + vals = make([]string, 0, len(matchedMD)+1) + vals = append(vals, matchedMD...) + } + vals = append(vals, added[i+1]) + } + } + } + + if vals == nil && matchedMD != nil { + return copyOf(matchedMD) + } + return vals +} + type rawMD struct { md MD added [][]string diff --git a/vendor/google.golang.org/grpc/resolver_wrapper.go b/vendor/google.golang.org/grpc/resolver_wrapper.go index 6e613764372b..f8b0fd38fd59 100644 --- a/vendor/google.golang.org/grpc/resolver_wrapper.go +++ b/vendor/google.golang.org/grpc/resolver_wrapper.go @@ -188,7 +188,7 @@ func (ccr *ccResolverWrapper) ParseServiceConfig(scJSON string) *serviceconfig.P // addChannelzTraceEvent adds a channelz trace event containing the new // state received from resolver implementations. func (ccr *ccResolverWrapper) addChannelzTraceEvent(s resolver.State) { - if !logger.V(0) && !channelz.IsOn() { + if !logger.V(2) && !channelz.IsOn() { return } var updates []string diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go index 52f4ea513df1..6f1bb2eae43e 100644 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -179,7 +179,6 @@ type callInfo struct { contentSubtype string codec baseCodec maxRetryRPCBufferSize int - onFinish []func(err error) authority string acceptedResponseCompressors []string } @@ -394,8 +393,7 @@ type OnFinishCallOption struct { OnFinish func(error) } -func (o OnFinishCallOption) before(c *callInfo) error { - c.onFinish = append(c.onFinish, o.OnFinish) +func (o OnFinishCallOption) before(*callInfo) error { return nil } diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go index cf0a2067190c..5c165972969e 100644 --- a/vendor/google.golang.org/grpc/server.go +++ b/vendor/google.golang.org/grpc/server.go @@ -89,6 +89,7 @@ func init() { internal.MetricsRecorderForServer = func(srv *Server) estats.MetricsRecorder { return istats.NewMetricsRecorderList(srv.opts.statsHandlers) } + internal.XDSFilterWrapperOption = xdsFilterWrapperOption } var statusOK = status.New(codes.OK, "") @@ -117,10 +118,8 @@ type ServiceDesc struct { // serviceInfo wraps information about a service. It is very similar to // ServiceDesc and is constructed from it for internal purposes. type serviceInfo struct { - // Contains the implementation for the methods in this service. - serviceImpl any - methods map[string]*MethodDesc - streams map[string]*StreamDesc + serviceImpl any // Implementation for the methods in this service. + streams map[string]*StreamDesc // Streaming descriptors and wrapped unary descriptors for this service. mdata any } @@ -183,6 +182,7 @@ type serverOptions struct { bufferPool mem.BufferPool waitForHandlers bool staticWindowSize bool + streamWrapper func(ServerStream) (ServerStream, error) } var defaultServerOptions = serverOptions{ @@ -663,6 +663,14 @@ func bufferPool(bufferPool mem.BufferPool) ServerOption { }) } +// xdsFilterWrapperOption returns a ServerOption that sets the server-level +// stream wrapper (used internally by xDS server filters). +func xdsFilterWrapperOption(w func(ServerStream) (ServerStream, error)) ServerOption { + return newFuncServerOption(func(o *serverOptions) { + o.streamWrapper = w + }) +} + // serverWorkerResetThreshold defines how often the stack must be reset. Every // N requests, by spawning a new goroutine in its place, a worker can reset its // stack so that large stacks don't live in memory forever. 2^16 should allow @@ -790,18 +798,22 @@ func (s *Server) register(sd *ServiceDesc, ss any) { } info := &serviceInfo{ serviceImpl: ss, - methods: make(map[string]*MethodDesc), streams: make(map[string]*StreamDesc), mdata: sd.Metadata, } - for i := range sd.Methods { - d := &sd.Methods[i] - info.methods[d.MethodName] = d - } for i := range sd.Streams { d := &sd.Streams[i] info.streams[d.StreamName] = d } + for i := range sd.Methods { + d := &sd.Methods[i] + info.streams[d.MethodName] = &StreamDesc{ + StreamName: d.MethodName, + Handler: s.wrapUnaryHandler(d), + ServerStreams: false, + ClientStreams: false, + } + } s.services[sd.ServiceName] = info } @@ -827,20 +839,26 @@ type ServiceInfo struct { func (s *Server) GetServiceInfo() map[string]ServiceInfo { ret := make(map[string]ServiceInfo) for n, srv := range s.services { - methods := make([]MethodInfo, 0, len(srv.methods)+len(srv.streams)) - for m := range srv.methods { - methods = append(methods, MethodInfo{ - Name: m, - IsClientStream: false, - IsServerStream: false, - }) + methods := make([]MethodInfo, 0, len(srv.streams)) + // Iterate over unary methods first to maintain backward compatibility of order. + for m, d := range srv.streams { + if !d.ClientStreams && !d.ServerStreams { + methods = append(methods, MethodInfo{ + Name: m, + IsClientStream: false, + IsServerStream: false, + }) + } } + // Iterate over streaming methods. for m, d := range srv.streams { - methods = append(methods, MethodInfo{ - Name: m, - IsClientStream: d.ClientStreams, - IsServerStream: d.ServerStreams, - }) + if d.ClientStreams || d.ServerStreams { + methods = append(methods, MethodInfo{ + Name: m, + IsClientStream: d.ClientStreams, + IsServerStream: d.ServerStreams, + }) + } } ret[n] = ServiceInfo{ @@ -1185,42 +1203,6 @@ func (s *Server) incrCallsFailed() { s.channelz.ServerMetrics.CallsFailed.Add(1) } -func (s *Server) sendResponse(ctx context.Context, stream *transport.ServerStream, msg any, cp Compressor, opts *transport.WriteOptions, comp encoding.Compressor) error { - data, err := encode(s.getCodec(stream.ContentSubtype()), msg) - if err != nil { - channelz.Error(logger, s.channelz, "grpc: server failed to encode response: ", err) - return err - } - - compData, pf, err := compress(data, cp, comp, s.opts.bufferPool) - if err != nil { - data.Free() - channelz.Error(logger, s.channelz, "grpc: server failed to compress response: ", err) - return err - } - - hdr, payload := msgHeader(data, compData, pf) - - defer func() { - compData.Free() - data.Free() - // payload does not need to be freed here, it is either data or compData, both of - // which are already freed. - }() - - dataLen := data.Len() - payloadLen := payload.Len() - // TODO(dfawley): should we be checking len(data) instead? - if payloadLen > s.opts.maxSendMessageSize { - return status.Errorf(codes.ResourceExhausted, "grpc: trying to send message larger than max (%d vs. %d)", payloadLen, s.opts.maxSendMessageSize) - } - err = stream.Write(hdr, payload, opts) - if err == nil && s.statsHandler != nil { - s.statsHandler.HandleRPC(ctx, outPayload(false, msg, dataLen, payloadLen, time.Now())) - } - return err -} - // chainUnaryServerInterceptors chains all unary server interceptors into one. func chainUnaryServerInterceptors(s *Server) { // Prepend opts.unaryInt to the chaining interceptors if it exists, since unaryInt will @@ -1257,300 +1239,6 @@ func getChainUnaryHandler(interceptors []UnaryServerInterceptor, curr int, info } } -func (s *Server) processUnaryRPC(ctx context.Context, stream *transport.ServerStream, info *serviceInfo, md *MethodDesc, trInfo *traceInfo) (err error) { - sh := s.statsHandler - if sh != nil || trInfo != nil || channelz.IsOn() { - if channelz.IsOn() { - s.incrCallsStarted() - } - var statsBegin *stats.Begin - if sh != nil { - statsBegin = &stats.Begin{ - BeginTime: time.Now(), - IsClientStream: false, - IsServerStream: false, - } - sh.HandleRPC(ctx, statsBegin) - } - if trInfo != nil { - trInfo.tr.LazyLog(&trInfo.firstLine, false) - } - // The deferred error handling for tracing, stats handler and channelz are - // combined into one function to reduce stack usage -- a defer takes ~56-64 - // bytes on the stack, so overflowing the stack will require a stack - // re-allocation, which is expensive. - // - // To maintain behavior similar to separate deferred statements, statements - // should be executed in the reverse order. That is, tracing first, stats - // handler second, and channelz last. Note that panics *within* defers will - // lead to different behavior, but that's an acceptable compromise; that - // would be undefined behavior territory anyway. - defer func() { - if trInfo != nil { - if err != nil && err != io.EOF { - trInfo.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true) - trInfo.tr.SetError() - } - trInfo.tr.Finish() - } - - if sh != nil { - end := &stats.End{ - BeginTime: statsBegin.BeginTime, - EndTime: time.Now(), - } - if err != nil && err != io.EOF { - end.Error = toRPCErr(err) - } - sh.HandleRPC(ctx, end) - } - - if channelz.IsOn() { - if err != nil && err != io.EOF { - s.incrCallsFailed() - } else { - s.incrCallsSucceeded() - } - } - }() - } - var binlogs []binarylog.MethodLogger - if ml := binarylog.GetMethodLogger(stream.Method()); ml != nil { - binlogs = append(binlogs, ml) - } - if s.opts.binaryLogger != nil { - if ml := s.opts.binaryLogger.GetMethodLogger(stream.Method()); ml != nil { - binlogs = append(binlogs, ml) - } - } - if len(binlogs) != 0 { - md, _ := metadata.FromIncomingContext(ctx) - logEntry := &binarylog.ClientHeader{ - Header: md, - MethodName: stream.Method(), - PeerAddr: nil, - } - if deadline, ok := ctx.Deadline(); ok { - logEntry.Timeout = time.Until(deadline) - if logEntry.Timeout < 0 { - logEntry.Timeout = 0 - } - } - if a := md[":authority"]; len(a) > 0 { - logEntry.Authority = a[0] - } - if peer, ok := peer.FromContext(ctx); ok { - logEntry.PeerAddr = peer.Addr - } - for _, binlog := range binlogs { - binlog.Log(ctx, logEntry) - } - } - - // comp and cp are used for compression. decomp and dc are used for - // decompression. If comp and decomp are both set, they are the same; - // however they are kept separate to ensure that at most one of the - // compressor/decompressor variable pairs are set for use later. - var comp, decomp encoding.Compressor - var cp Compressor - var dc Decompressor - var sendCompressorName string - - // If dc is set and matches the stream's compression, use it. Otherwise, try - // to find a matching registered compressor for decomp. - if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc { - dc = s.opts.dc - } else if rc != "" && rc != encoding.Identity { - decomp = encoding.GetCompressor(rc) - if decomp == nil { - st := status.Newf(codes.Unimplemented, "grpc: Decompressor is not installed for grpc-encoding %q", rc) - stream.WriteStatus(st) - return st.Err() - } - } - - // If cp is set, use it. Otherwise, attempt to compress the response using - // the incoming message compression method. - // - // NOTE: this needs to be ahead of all handling, https://github.com/grpc/grpc-go/issues/686. - if s.opts.cp != nil { - cp = s.opts.cp - sendCompressorName = cp.Type() - } else if rc := stream.RecvCompress(); rc != "" && rc != encoding.Identity { - // Legacy compressor not specified; attempt to respond with same encoding. - comp = encoding.GetCompressor(rc) - if comp != nil { - sendCompressorName = comp.Name() - } - } - - if sendCompressorName != "" { - if err := stream.SetSendCompress(sendCompressorName); err != nil { - return status.Errorf(codes.Internal, "grpc: failed to set send compressor: %v", err) - } - } - - var payInfo *payloadInfo - if sh != nil || len(binlogs) != 0 { - payInfo = &payloadInfo{} - defer payInfo.free() - } - - d, err := recvAndDecompress(&parser{r: stream, bufferPool: s.opts.bufferPool}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp, true) - if err != nil { - if e := stream.WriteStatus(status.Convert(err)); e != nil { - channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e) - } - return err - } - freed := false - dataFree := func() { - if !freed { - d.Free() - freed = true - } - } - defer dataFree() - df := func(v any) error { - defer dataFree() - if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil { - return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err) - } - - if sh != nil { - sh.HandleRPC(ctx, &stats.InPayload{ - RecvTime: time.Now(), - Payload: v, - Length: d.Len(), - WireLength: payInfo.compressedLength + headerLen, - CompressedLength: payInfo.compressedLength, - }) - } - if len(binlogs) != 0 { - cm := &binarylog.ClientMessage{ - Message: d.Materialize(), - } - for _, binlog := range binlogs { - binlog.Log(ctx, cm) - } - } - if trInfo != nil { - trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true) - } - return nil - } - ctx = NewContextWithServerTransportStream(ctx, stream) - reply, appErr := md.Handler(info.serviceImpl, ctx, df, s.opts.unaryInt) - if appErr != nil { - appStatus, ok := status.FromError(appErr) - if !ok { - // Convert non-status application error to a status error with code - // Unknown, but handle context errors specifically. - appStatus = status.FromContextError(appErr) - appErr = appStatus.Err() - } - if trInfo != nil { - trInfo.tr.LazyLog(stringer(appStatus.Message()), true) - trInfo.tr.SetError() - } - if e := stream.WriteStatus(appStatus); e != nil { - channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e) - } - if len(binlogs) != 0 { - if h, _ := stream.Header(); h.Len() > 0 { - // Only log serverHeader if there was header. Otherwise it can - // be trailer only. - sh := &binarylog.ServerHeader{ - Header: h, - } - for _, binlog := range binlogs { - binlog.Log(ctx, sh) - } - } - st := &binarylog.ServerTrailer{ - Trailer: stream.Trailer(), - Err: appErr, - } - for _, binlog := range binlogs { - binlog.Log(ctx, st) - } - } - return appErr - } - if trInfo != nil { - trInfo.tr.LazyLog(stringer("OK"), false) - } - opts := &transport.WriteOptions{Last: true} - - // Server handler could have set new compressor by calling SetSendCompressor. - // In case it is set, we need to use it for compressing outbound message. - if stream.SendCompress() != sendCompressorName { - comp = encoding.GetCompressor(stream.SendCompress()) - } - if err := s.sendResponse(ctx, stream, reply, cp, opts, comp); err != nil { - if err == io.EOF { - // The entire stream is done (for unary RPC only). - return err - } - if sts, ok := status.FromError(err); ok { - if e := stream.WriteStatus(sts); e != nil { - channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e) - } - } else { - switch st := err.(type) { - case transport.ConnectionError: - // Nothing to do here. - default: - panic(fmt.Sprintf("grpc: Unexpected error (%T) from sendResponse: %v", st, st)) - } - } - if len(binlogs) != 0 { - h, _ := stream.Header() - sh := &binarylog.ServerHeader{ - Header: h, - } - st := &binarylog.ServerTrailer{ - Trailer: stream.Trailer(), - Err: appErr, - } - for _, binlog := range binlogs { - binlog.Log(ctx, sh) - binlog.Log(ctx, st) - } - } - return err - } - if len(binlogs) != 0 { - h, _ := stream.Header() - sh := &binarylog.ServerHeader{ - Header: h, - } - sm := &binarylog.ServerMessage{ - Message: reply, - } - for _, binlog := range binlogs { - binlog.Log(ctx, sh) - binlog.Log(ctx, sm) - } - } - if trInfo != nil { - trInfo.tr.LazyLog(&payload{sent: true, msg: reply}, true) - } - // TODO: Should we be logging if writing status failed here, like above? - // Should the logging be in WriteStatus? Should we ignore the WriteStatus - // error or allow the stats handler to see it? - if len(binlogs) != 0 { - st := &binarylog.ServerTrailer{ - Trailer: stream.Trailer(), - Err: appErr, - } - for _, binlog := range binlogs { - binlog.Log(ctx, st) - } - } - return stream.WriteStatus(statusOK) -} - // chainStreamServerInterceptors chains all stream server interceptors into one. func chainStreamServerInterceptors(s *Server) { // Prepend opts.streamInt to the chaining interceptors if it exists, since streamInt will @@ -1587,7 +1275,21 @@ func getChainStreamHandler(interceptors []StreamServerInterceptor, curr int, inf } } -func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.ServerStream, info *serviceInfo, sd *StreamDesc, trInfo *traceInfo) (err error) { +// wrapUnaryHandler converts a standard Unary Method Descriptor into a +// StreamHandler, allowing Unary RPCs to be processed via the same unified +// pipeline as Streaming RPCs. +func (s *Server) wrapUnaryHandler(md *MethodDesc) StreamHandler { + return func(srv any, stream ServerStream) error { + df := func(v any) error { return stream.RecvMsg(v) } + reply, err := md.Handler(srv, stream.Context(), df, s.opts.unaryInt) + if err != nil { + return err + } + return stream.SendMsg(reply) + } +} + +func (s *Server) processRPC(ctx context.Context, stream *transport.ServerStream, info *serviceInfo, sd *StreamDesc, trInfo *traceInfo) (err error) { if channelz.IsOn() { s.incrCallsStarted() } @@ -1615,7 +1317,16 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv } if sh != nil || trInfo != nil || channelz.IsOn() { - // See comment in processUnaryRPC on defers. + // The deferred error handling for tracing, stats handler and channelz are + // combined into one function to reduce stack usage -- a defer takes ~56-64 + // bytes on the stack, so overflowing the stack will require a stack + // re-allocation, which is expensive. + // + // To maintain behavior similar to separate deferred statements, statements + // should be executed in the reverse order. That is, tracing first, stats + // handler second, and channelz last. Note that panics *within* defers will + // lead to different behavior, but that's an acceptable compromise; that + // would be undefined behavior territory anyway. defer func() { if trInfo != nil { ss.mu.Lock() @@ -1717,23 +1428,34 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv ss.ctx = newContextWithRPCInfo(ss.ctx, false, ss.codec, ss.compressorV0, ss.compressorV1) - if trInfo != nil { - trInfo.tr.LazyLog(&trInfo.firstLine, false) - } + // Execute the xDS HTTP filter interceptors. var appErr error - var server any - if info != nil { - server = info.serviceImpl + var wrappedStream ServerStream = ss + if s.opts.streamWrapper != nil { + wrappedStream, appErr = s.opts.streamWrapper(ss) } - if s.opts.streamInt == nil { - appErr = sd.Handler(server, ss) - } else { - info := &StreamServerInfo{ - FullMethod: stream.Method(), - IsClientStream: sd.ClientStreams, - IsServerStream: sd.ServerStreams, + + if appErr == nil { + if trInfo != nil { + trInfo.tr.LazyLog(&trInfo.firstLine, false) + } + var server any + if info != nil { + server = info.serviceImpl + } + if s.opts.streamInt == nil || (!sd.ClientStreams && !sd.ServerStreams) { + // If there is no stream interceptor, or if this is a unary RPC, call + // the handler directly. The wrapped unary handler will call the unary + // interceptor if it exists. + appErr = sd.Handler(server, wrappedStream) + } else { + info := &StreamServerInfo{ + FullMethod: stream.Method(), + IsClientStream: sd.ClientStreams, + IsServerStream: sd.ServerStreams, + } + appErr = s.opts.streamInt(server, wrappedStream, info, sd.Handler) } - appErr = s.opts.streamInt(server, ss, info, sd.Handler) } if appErr != nil { appStatus, ok := status.FromError(appErr) @@ -1750,6 +1472,17 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv ss.mu.Unlock() } if len(ss.binlogs) != 0 { + if !ss.serverHeaderBinlogged { + if h, _ := ss.s.Header(); h.Len() > 0 { + sh := &binarylog.ServerHeader{ + Header: h, + } + ss.serverHeaderBinlogged = true + for _, binlog := range ss.binlogs { + binlog.Log(ctx, sh) + } + } + } st := &binarylog.ServerTrailer{ Trailer: ss.s.Trailer(), Err: appErr, @@ -1758,8 +1491,9 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv binlog.Log(ctx, st) } } - ss.s.WriteStatus(appStatus) - // TODO: Should we log an error from WriteStatus here and below? + if err := ss.s.WriteStatus(appStatus); err != nil { + channelz.Warningf(logger, s.channelz, "grpc: Server.processRPC failed to write status: %v", err) + } return appErr } if trInfo != nil { @@ -1776,7 +1510,10 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv binlog.Log(ctx, st) } } - return ss.s.WriteStatus(statusOK) + if err := ss.s.WriteStatus(statusOK); err != nil { + channelz.Warningf(logger, s.channelz, "grpc: Server.processRPC failed to write status: %v", err) + } + return err } func (s *Server) handleMalformedMethodName(stream *transport.ServerStream, ti *traceInfo) { @@ -1854,18 +1591,14 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Ser srv, knownService := s.services[service] if knownService { - if md, ok := srv.methods[method]; ok { - s.processUnaryRPC(ctx, stream, srv, md, ti) - return - } if sd, ok := srv.streams[method]; ok { - s.processStreamingRPC(ctx, stream, srv, sd, ti) + s.processRPC(ctx, stream, srv, sd, ti) return } } // Unknown service, or known server unknown method. if unknownDesc := s.opts.unknownStreamDesc; unknownDesc != nil { - s.processStreamingRPC(ctx, stream, nil, unknownDesc, ti) + s.processRPC(ctx, stream, nil, unknownDesc, ti) return } var errDesc string @@ -1986,7 +1719,13 @@ func (s *Server) stop(graceful bool) { } if graceful || s.opts.waitForHandlers { + // Release the lock while waiting for handlers to finish. Holding it + // here would deadlock a concurrent Stop() (the recommended way to abort + // a GracefulStop that is taking too long), because Stop() must acquire + // s.mu before it can force the server to shut down. + s.mu.Unlock() s.handlersWG.Wait() + s.mu.Lock() } if s.events != nil { @@ -2069,9 +1808,6 @@ func (s *Server) isRegisteredMethod(serviceMethod string) bool { method := serviceMethod[pos+1:] srv, knownService := s.services[service] if knownService { - if _, ok := srv.methods[method]; ok { - return true - } if _, ok := srv.streams[method]; ok { return true } diff --git a/vendor/google.golang.org/grpc/stats/stats.go b/vendor/google.golang.org/grpc/stats/stats.go index 10bf998aa5be..c6996724c95c 100644 --- a/vendor/google.golang.org/grpc/stats/stats.go +++ b/vendor/google.golang.org/grpc/stats/stats.go @@ -190,6 +190,9 @@ type OutHeader struct { Compression string // Header contains the header metadata sent. Header metadata.MD + // Authority is the :authority pseudo-header sent for the RPC. + // It is valid only if Client is true. + Authority string // The following fields are valid only if Client is true. // FullMethod is the full RPC method string, i.e., /package.service/method. diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go index 51aff85dfba0..9fd628b8dcfb 100644 --- a/vendor/google.golang.org/grpc/stream.go +++ b/vendor/google.golang.org/grpc/stream.go @@ -28,6 +28,7 @@ import ( "strconv" "strings" "sync" + "sync/atomic" "time" "google.golang.org/grpc/balancer" @@ -148,6 +149,81 @@ type ClientStream interface { RecvMsg(m any) error } +// clientStreamWrapper wraps a ClientStream and handles SendMsg, CloseSend, and +// RecvMsg parities based on the nature of stream. +type clientStreamWrapper struct { + ClientStream + desc *StreamDesc + closeSendCalled atomic.Bool +} + +// CloseSend closes the send direction of the stream. The implementation ensures +// that CloseSend is only called once on the underlying ClientStream, even if +// CloseSend is called multiple times on the wrapper. +func (w *clientStreamWrapper) CloseSend() error { + if w.closeSendCalled.Swap(true) { + return nil + } + return w.ClientStream.CloseSend() +} + +// SendMsg sends message m across the stream. For RPCs where client can call +// SendMsg only once, i.e. only server-streaming RPCs, it converts io.EOF to nil +// and immediately calls CloseSend to trigger any interceptor hooks. +func (w *clientStreamWrapper) SendMsg(m any) error { + err := w.ClientStream.SendMsg(m) + // If the RPC is a client-streaming RPC, the client can send multiple + // messages. In this case, the client should handle any type of + // error,including io.EOF and call CloseSend once it is done sending messages. + if w.desc.ClientStreams { + return err + } + + if err == io.EOF { + // For non-client-streaming RPCs, we return nil instead of EOF on error + // because the generated code requires it. finish is not called; RecvMsg() + // will call it with the stream's status independently. + return nil + } + if err != nil { + return err + } + // In some scenarios (e.g., xDS), the same interceptors process both unary and + // streaming RPCs, relying on CloseSend to signal that no more messages are on + // the way. Although protobuf-generated stubs already invoke CloseSend for + // server-streaming RPCs, it is explicitly called here to ensure downstream + // interceptors are also notified when callers interact with the ClientStream + // API directly. + if err := w.CloseSend(); err != nil && err != io.EOF { + return err + } + return nil + +} + +// RecvMsg receives message m from the stream. For non-server-streaming RPCs +// (unary and client-streaming), it calls the underlying RecvMsg a second time +// after receiving the first message to get the trailers. +func (w *clientStreamWrapper) RecvMsg(m any) error { + err := w.ClientStream.RecvMsg(m) + if err != nil { + return err + } + if w.desc.ServerStreams { + return nil + } + // Call RecvMsg again for non-server streaming RPCs to get the trailers and + // ensure RPC has completed successfully. + err = w.ClientStream.RecvMsg(m) + if err == io.EOF { + return nil + } + if err == nil { + return status.Error(codes.Internal, "cardinality violation: expected for non server-streaming RPCs, but received another message") + } + return err +} + // NewStream creates a new Stream for the client side. This is typically // called by generated code. ctx is used for the lifetime of the stream. // @@ -253,14 +329,11 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth mc := &emptyMethodConfig var onCommit func() - newStream := func(ctx context.Context, filterOpts ...CallOption) (ClientStream, error) { - if filterOpts != nil { - opts = combine(opts, filterOpts) - } + newStream := func(ctx context.Context, opts ...CallOption) (ClientStream, error) { return newClientStreamWithParams(ctx, desc, cc, method, mc, onCommit, nameResolutionDelayed, opts...) } - rpcInfo := iresolver.RPCInfo{Context: ctx, Method: method} + rpcInfo := iresolver.RPCInfo{Context: ctx, Method: method, Authority: cc.authority} rpcConfig, err := cc.safeConfigSelector.SelectConfig(rpcInfo) if err != nil { if st, ok := status.FromError(err); ok { @@ -278,13 +351,23 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth ctx = rpcConfig.Context } mc = &rpcConfig.MethodConfig - onCommit = rpcConfig.OnCommitted + + if rpcConfig.OnCommitted != nil { + onCommit = rpcConfig.OnCommitted + // Register an OnFinish CallOption with the OnCommitted callback to + // ensure it is invoked on stream termination, even if the stream + // fails early before committing. Implementations of OnCommitted are + // expected to be idempotent (e.g., guarded by sync.Once), since both + // onCommit and OnFinish may run for a single RPC. + opts = append(opts, OnFinish(func(error) { rpcConfig.OnCommitted() })) + } + if rpcConfig.Interceptor != nil { rpcInfo.Context = nil ns := newStream if interceptor, ok := rpcConfig.Interceptor.(clientInterceptor); ok { - newStream = func(ctx context.Context, filterOpts ...CallOption) (ClientStream, error) { - cs, err := interceptor.NewStream(ctx, rpcInfo, ns, filterOpts...) + newStream = func(ctx context.Context, opts ...CallOption) (ClientStream, error) { + cs, err := interceptor.NewStream(ctx, rpcInfo, ns, opts...) if err != nil { return nil, toRPCErr(err) } @@ -296,7 +379,11 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth } } - return newStream(ctx) + cs, err := newStream(ctx, opts...) + if err != nil { + return nil, err + } + return &clientStreamWrapper{ClientStream: cs, desc: desc}, nil } func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, mc *serviceconfig.MethodConfig, onCommit func(), nameResolutionDelayed bool, opts ...CallOption) (_ ClientStream, err error) { @@ -536,13 +623,21 @@ func (a *csAttempt) getTransport() error { func (a *csAttempt) newStream() error { cs := a.cs - cs.callHdr.PreviousAttempts = cs.numRetries + // The header is copied because the fields set below, notably the authority + // override taken from the pick result, describe the endpoint picked for + // this attempt only. Mutating the clientStream's header would carry them + // into a later attempt. + callHdr := *cs.callHdr + callHdr.PreviousAttempts = cs.numRetries // Merge metadata stored in PickResult, if any, with existing call metadata. // It is safe to overwrite the csAttempt's context here, since all state // maintained in it are local to the attempt. When the attempt has to be // retried, a new instance of csAttempt will be created. if a.pickResult.Metadata != nil { + if err := imetadata.Validate(a.pickResult.Metadata); err != nil { + return status.Error(codes.Internal, err.Error()) + } // We currently do not have a function it the metadata package which // merges given metadata with existing metadata in a context. Existing // function `AppendToOutgoingContext()` takes a variadic argument of key @@ -560,11 +655,11 @@ func (a *csAttempt) newStream() error { // apply it, as specified in gRFC A81. if cs.callInfo.authority == "" { if authMD := a.pickResult.Metadata.Get(":authority"); len(authMD) > 0 { - cs.callHdr.Authority = authMD[0] + callHdr.Authority = authMD[0] } } } - s, err := a.transport.NewStream(a.ctx, cs.callHdr, a.statsHandler) + s, err := a.transport.NewStream(a.ctx, &callHdr, a.statsHandler) if err != nil { nse, ok := err.(*transport.NewStreamError) if !ok { @@ -599,10 +694,6 @@ type clientStream struct { cancel context.CancelFunc // cancels all attempts - sentLast bool // sent an end stream - - receivedFirstMsg bool // set after the first message is received - methodConfig *MethodConfig ctx context.Context // the application's context, wrapped by stats/tracing @@ -610,19 +701,10 @@ type clientStream struct { retryThrottler *retryThrottler // The throttler active when the RPC began. binlogs []binarylog.MethodLogger - // serverHeaderBinlogged is a boolean for whether server header has been - // logged. Server header will be logged when the first time one of those - // happens: stream.Header(), stream.Recv(). - // - // It's only read and used by Recv() and Header(), so it doesn't need to be - // synchronized. - serverHeaderBinlogged bool mu sync.Mutex - firstAttempt bool // if true, transparent retry is valid - numRetries int // exclusive of transparent retry attempt(s) - numRetriesSincePushback int // retries since pushback; to reset backoff - finished bool // TODO: replace with atomic cmpxchg or sync.Once? + numRetries int // exclusive of transparent retry attempt(s) + numRetriesSincePushback int // retries since pushback; to reset backoff // attempt is the active client stream attempt. // The only place where it is written is the newAttemptLocked method and this method never writes nil. // So, attempt can be nil only inside newClientStream function when clientStream is first created. @@ -632,13 +714,33 @@ type clientStream struct { // place where we need to check if the attempt is nil. attempt *csAttempt // TODO(hedging): hedging will have multiple attempts simultaneously. - committed bool // active attempt committed for retry? onCommit func() replayBuffer []replayOp // operations to replay on retry replayBufferSize int // current size of replayBuffer + + // Bool fields are grouped at the tail to eliminate the alignment padding + // that would otherwise follow each bool when the next field is pointer- or + // int-sized. See https://github.com/grpc/grpc-go/issues/9280 for benchmarks. + // Add new bool fields here, not inline above. + + // Not guarded by mu. + sentLast bool // sent an end stream + receivedFirstMsg bool // set after the first message is received + // serverHeaderBinlogged is a boolean for whether server header has been + // logged. Server header will be logged when the first time one of those + // happens: stream.Header(), stream.Recv(). + // + // It's only read and used by Recv() and Header(), so it doesn't need to be + // synchronized. + serverHeaderBinlogged bool // nameResolutionDelay indicates if there was a delay in the name resolution. // This field is only valid on client side, it's always false on server side. nameResolutionDelay bool + + // Guarded by mu. + firstAttempt bool // if true, transparent retry is valid + finished bool // TODO: replace with atomic cmpxchg or sync.Once? + committed bool // active attempt committed for retry? } type replayOp struct { @@ -656,10 +758,8 @@ type csAttempt struct { parser parser pickResult balancer.PickResult - finished bool - decompressorV0 Decompressor - decompressorV1 encoding.Compressor - decompressorSet bool + decompressorV0 Decompressor + decompressorV1 encoding.Compressor mu sync.Mutex // guards trInfo.tr // trInfo may be nil (if EnableTracing is false). @@ -670,10 +770,18 @@ type csAttempt struct { statsHandler stats.Handler beginTime time.Time - // set for newStream errors that may be transparently retried - allowTransparentRetry bool - // set for pick errors that are returned as a status - drop bool + // Bool fields are grouped at the tail to eliminate the alignment padding + // that would otherwise follow each bool when the next field is pointer- or + // int-sized. See https://github.com/grpc/grpc-go/issues/9347 for benchmarks. + // Add new bool fields here, not inline above. + + // Not guarded by mu. + decompressorSet bool + allowTransparentRetry bool // set for newStream errors that may be transparently retried + drop bool // set for pick errors that are returned as a status + + // Guarded by mu. + finished bool } func (cs *clientStream) commitAttemptLocked() { @@ -1044,8 +1152,8 @@ func (cs *clientStream) RecvMsg(m any) error { binlog.Log(cs.ctx, sm) } } - if err != nil || !cs.desc.ServerStreams { - // err != nil or non-server-streaming indicates end of stream. + if err != nil { + // err != nil indicates end of stream. cs.finish(err) } return err @@ -1093,7 +1201,8 @@ func (cs *clientStream) finish(err error) { } cs.finished = true cs.commitAttemptLocked() - if cs.attempt != nil { + attemptCreated := cs.attempt != nil + if attemptCreated { cs.attempt.finish(err) // after functions all rely upon having a stream. if cs.attempt.transportStream != nil { @@ -1131,7 +1240,13 @@ func (cs *clientStream) finish(err error) { if err == nil { cs.retryThrottler.successfulRPC() } - endOfClientStream(cs.cc, err, cs.opts...) + // If no attempt was ever created, stream creation has failed, and the + // cleanup is left to newClientStream, whose deferred cleanup invokes + // endOfClientStream if the call fails. Invoking it here as well would + // run the cleanup twice for the same call. + if attemptCreated { + endOfClientStream(cs.cc, err, cs.opts...) + } cs.cancel() } @@ -1145,12 +1260,6 @@ func (a *csAttempt) sendMsg(m any, hdr []byte, payld mem.BufferSlice, dataLength a.mu.Unlock() } if err := a.transportStream.Write(hdr, payld, &transport.WriteOptions{Last: !cs.desc.ClientStreams}); err != nil { - if !cs.desc.ClientStreams { - // For non-client-streaming RPCs, we return nil instead of EOF on error - // because the generated code requires it. finish is not called; RecvMsg() - // will call it with the stream's status independently. - return nil - } return io.EOF } if a.statsHandler != nil { @@ -1218,18 +1327,7 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) { Length: payInfo.uncompressedBytes.Len(), }) } - if cs.desc.ServerStreams { - // Subsequent messages should be received by subsequent RecvMsg calls. - return nil - } - // Special handling for non-server-stream rpcs. - // This recv expects EOF or errors, so we don't collect inPayload. - if err := recv(&a.parser, cs.codec, a.transportStream, a.decompressorV0, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decompressorV1, false); err == io.EOF { - return a.transportStream.Status().Err() // non-server streaming Recv returns nil on success - } else if err != nil { - return toRPCErr(err) - } - return status.Error(codes.Internal, "cardinality violation: expected for non server-streaming RPCs, but received another message") + return nil } func (a *csAttempt) finish(err error) { @@ -1399,7 +1497,7 @@ func newNonRetryClientStream(ctx context.Context, desc *StreamDesc, method strin } }() } - return as, nil + return &clientStreamWrapper{ClientStream: as, desc: desc}, nil } type addrConnStream struct { @@ -1411,20 +1509,28 @@ type addrConnStream struct { callInfo *callInfo transport transport.ClientTransport ctx context.Context - sentLast bool - receivedFirstMsg bool desc *StreamDesc codec baseCodec sendCompressorV0 Compressor sendCompressorV1 encoding.Compressor - decompressorSet bool decompressorV0 Decompressor decompressorV1 encoding.Compressor - parser parser // mu guards finished and is held for the entire finish method. - mu sync.Mutex - finished bool + mu sync.Mutex + parser parser + + // Bool fields are grouped at the tail to eliminate the alignment padding + // that would otherwise follow each bool when the next field is pointer- or + // int-sized. See https://github.com/grpc/grpc-go/issues/9348 for benchmarks. + // Add new bool fields here, not inline above. + + // Not guarded by mu. + sentLast bool + receivedFirstMsg bool + decompressorSet bool + + finished bool // guarded by mu } func (as *addrConnStream) Header() (metadata.MD, error) { @@ -1497,12 +1603,6 @@ func (as *addrConnStream) SendMsg(m any) (err error) { } if err := as.transportStream.Write(hdr, payload, &transport.WriteOptions{Last: !as.desc.ClientStreams}); err != nil { - if !as.desc.ClientStreams { - // For non-client-streaming RPCs, we return nil instead of EOF on error - // because the generated code requires it. finish is not called; RecvMsg() - // will call it with the stream's status independently. - return nil - } return io.EOF } @@ -1511,8 +1611,8 @@ func (as *addrConnStream) SendMsg(m any) (err error) { func (as *addrConnStream) RecvMsg(m any) (err error) { defer func() { - if err != nil || !as.desc.ServerStreams { - // err != nil or non-server-streaming indicates end of stream. + if err != nil { + // err != nil indicates end of stream. as.finish(err) } }() @@ -1551,20 +1651,7 @@ func (as *addrConnStream) RecvMsg(m any) (err error) { return toRPCErr(err) } as.receivedFirstMsg = true - - if as.desc.ServerStreams { - // Subsequent messages should be received by subsequent RecvMsg calls. - return nil - } - - // Special handling for non-server-stream rpcs. - // This recv expects EOF or errors, so we don't collect inPayload. - if err := recv(&as.parser, as.codec, as.transportStream, as.decompressorV0, m, *as.callInfo.maxReceiveMessageSize, nil, as.decompressorV1, false); err == io.EOF { - return as.transportStream.Status().Err() // non-server streaming Recv returns nil on success - } else if err != nil { - return toRPCErr(err) - } - return status.Error(codes.Internal, "cardinality violation: expected for non server-streaming RPCs, but received another message") + return nil } func (as *addrConnStream) finish(err error) { @@ -1658,15 +1745,23 @@ type serverStream struct { sendCompressorName string - recvFirstMsg bool // set after the first message is received - maxReceiveMessageSize int maxSendMessageSize int - trInfo *traceInfo + + // mu guards trInfo.tr after the service handler runs. + mu sync.Mutex + trInfo *traceInfo statsHandler stats.Handler binlogs []binarylog.MethodLogger + + // Bool fields are grouped at the tail to eliminate the alignment padding + // that would otherwise follow each bool when the next field is pointer- or + // int-sized. See https://github.com/grpc/grpc-go/issues/9349 for benchmarks. + // Add new bool fields here, not inline above. + + recvFirstMsg bool // set after the first message is received // serverHeaderBinlogged indicates whether server header has been logged. It // will happen when one of the following two happens: stream.SendHeader(), // stream.Send(). @@ -1674,8 +1769,6 @@ type serverStream struct { // It's only checked in send and sendHeader, doesn't need to be // synchronized. serverHeaderBinlogged bool - - mu sync.Mutex // protects trInfo.tr after the service handler runs. } func (ss *serverStream) Context() context.Context { diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 835dc07fdc50..d41341bcfe1b 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.83.2" +const Version = "1.85.0" diff --git a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go new file mode 100644 index 000000000000..1d7ee3b47660 --- /dev/null +++ b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go @@ -0,0 +1,142 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: google/protobuf/empty.proto + +package emptypb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +// A generic empty message that you can re-use to avoid defining duplicated +// empty messages in your APIs. A typical example is to use it as the request +// or the response type of an API method. For instance: +// +// service Foo { +// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); +// } +type Empty struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Empty) Reset() { + *x = Empty{} + mi := &file_google_protobuf_empty_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_google_protobuf_empty_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_google_protobuf_empty_proto_rawDescGZIP(), []int{0} +} + +var File_google_protobuf_empty_proto protoreflect.FileDescriptor + +const file_google_protobuf_empty_proto_rawDesc = "" + + "\n" + + "\x1bgoogle/protobuf/empty.proto\x12\x0fgoogle.protobuf\"\a\n" + + "\x05EmptyB}\n" + + "\x13com.google.protobufB\n" + + "EmptyProtoP\x01Z.google.golang.org/protobuf/types/known/emptypb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3" + +var ( + file_google_protobuf_empty_proto_rawDescOnce sync.Once + file_google_protobuf_empty_proto_rawDescData []byte +) + +func file_google_protobuf_empty_proto_rawDescGZIP() []byte { + file_google_protobuf_empty_proto_rawDescOnce.Do(func() { + file_google_protobuf_empty_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_google_protobuf_empty_proto_rawDesc), len(file_google_protobuf_empty_proto_rawDesc))) + }) + return file_google_protobuf_empty_proto_rawDescData +} + +var file_google_protobuf_empty_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_google_protobuf_empty_proto_goTypes = []any{ + (*Empty)(nil), // 0: google.protobuf.Empty +} +var file_google_protobuf_empty_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_google_protobuf_empty_proto_init() } +func file_google_protobuf_empty_proto_init() { + if File_google_protobuf_empty_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_google_protobuf_empty_proto_rawDesc), len(file_google_protobuf_empty_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_google_protobuf_empty_proto_goTypes, + DependencyIndexes: file_google_protobuf_empty_proto_depIdxs, + MessageInfos: file_google_protobuf_empty_proto_msgTypes, + }.Build() + File_google_protobuf_empty_proto = out.File + file_google_protobuf_empty_proto_goTypes = nil + file_google_protobuf_empty_proto_depIdxs = nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d4bf6d11e52b..eb99f62688d5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -137,8 +137,8 @@ github.com/google/uuid # github.com/gorilla/mux v1.8.1 ## explicit; go 1.20 github.com/gorilla/mux -# github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 -## explicit; go 1.25.0 +# github.com/grpc-ecosystem/grpc-gateway/v2 v2.31.0 +## explicit; go 1.26.0 github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities @@ -161,6 +161,12 @@ github.com/mattn/go-runewidth # github.com/moby/docker-image-spec v1.3.1 ## explicit; go 1.18 github.com/moby/docker-image-spec/specs-go/v1 +# github.com/moby/extensions v0.0.0-20261120190433-fb779cf107cd +## explicit; go 1.26.0 +github.com/moby/extensions +github.com/moby/extensions/client +github.com/moby/extensions/clientpoint +github.com/moby/extensions/serverpoint # github.com/moby/go-archive v0.3.3 ## explicit; go 1.25 github.com/moby/go-archive @@ -202,6 +208,10 @@ github.com/moby/moby/client/pkg/security github.com/moby/moby/client/pkg/streamformatter github.com/moby/moby/client/pkg/stringid github.com/moby/moby/client/pkg/versions +# github.com/moby/moby/extpoints v0.0.0-20261204092146-b33fe34839ba +## explicit; go 1.26.0 +github.com/moby/moby/extpoints/jobs/api/v0 +github.com/moby/moby/extpoints/jobs/api/v0/protogen # github.com/moby/patternmatcher v0.6.1 ## explicit; go 1.19 github.com/moby/patternmatcher @@ -386,8 +396,8 @@ go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded go.opentelemetry.io/otel/trace/internal/telemetry go.opentelemetry.io/otel/trace/noop -# go.opentelemetry.io/proto/otlp v1.11.0 -## explicit; go 1.25.0 +# go.opentelemetry.io/proto/otlp v1.11.1 +## explicit; go 1.26.0 go.opentelemetry.io/proto/otlp/collector/metrics/v1 go.opentelemetry.io/proto/otlp/collector/trace/v1 go.opentelemetry.io/proto/otlp/common/v1 @@ -450,12 +460,12 @@ golang.org/x/time/rate # google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc ## explicit; go 1.26.0 google.golang.org/genproto/googleapis/api/httpbody -# google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc +# google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 ## explicit; go 1.26.0 google.golang.org/genproto/googleapis/rpc/errdetails google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.83.2 -## explicit; go 1.25.0 +# google.golang.org/grpc v1.85.0 +## explicit; go 1.26.0 google.golang.org/grpc google.golang.org/grpc/attributes google.golang.org/grpc/backoff @@ -561,6 +571,7 @@ google.golang.org/protobuf/types/descriptorpb google.golang.org/protobuf/types/gofeaturespb google.golang.org/protobuf/types/known/anypb google.golang.org/protobuf/types/known/durationpb +google.golang.org/protobuf/types/known/emptypb google.golang.org/protobuf/types/known/fieldmaskpb google.golang.org/protobuf/types/known/structpb google.golang.org/protobuf/types/known/timestamppb From 8c7017f2af7b7c1d0cc34dbf8ac126daf56a9a5d Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Tue, 10 Nov 2026 10:20:52 +0100 Subject: [PATCH 2/5] cli/command/job: add `docker job inspect` and `runs` commands - `inspect [--run RUN] JOB` prints a job or one of its runs as JSON. - `runs [--limit N] [--before CURSOR] JOB` lists a job's runs, most recent first, with paging; a stale cursor is reported on stderr. Signed-off-by: Guillaume Lours --- cli/command/job/client.go | 3 + cli/command/job/client_test.go | 14 +- cli/command/job/cmd.go | 10 + cli/command/job/inspect.go | 96 +++++++ cli/command/job/inspect_test.go | 284 ++++++++++++++++++++ cli/command/job/runs.go | 130 +++++++++ cli/command/job/runs_test.go | 462 ++++++++++++++++++++++++++++++++ 7 files changed, 996 insertions(+), 3 deletions(-) create mode 100644 cli/command/job/inspect.go create mode 100644 cli/command/job/inspect_test.go create mode 100644 cli/command/job/runs.go create mode 100644 cli/command/job/runs_test.go diff --git a/cli/command/job/client.go b/cli/command/job/client.go index 945ef471bdf3..0254fb917a42 100644 --- a/cli/command/job/client.go +++ b/cli/command/job/client.go @@ -31,6 +31,9 @@ type jobsClient interface { // ListRuns returns a job's runs, most recent first. Used as the // fallback when the latest run's container is gone. ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) + + // InspectRun returns a single run. + InspectRun(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) } // newJobsClient dials the daemon's jobs extension point and returns a diff --git a/cli/command/job/client_test.go b/cli/command/job/client_test.go index 80a7b4cf23b3..55fc65a33e2e 100644 --- a/cli/command/job/client_test.go +++ b/cli/command/job/client_test.go @@ -23,9 +23,10 @@ var _ jobsClient = jobsv0.Jobs(nil) // one Func field per method, a nil field falling back to a harmless // zero-value response. type fakeClient struct { - listFunc func(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) - inspectFunc func(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) - listRunsFunc func(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) + listFunc func(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) + inspectFunc func(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) + listRunsFunc func(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) + inspectRunFunc func(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) } func (c *fakeClient) List(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) { @@ -49,6 +50,13 @@ func (c *fakeClient) ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) return &jobsv0.ListRunsReply{}, nil } +func (c *fakeClient) InspectRun(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + if c.inspectRunFunc != nil { + return c.inspectRunFunc(ctx, req) + } + return &jobsv0.InspectRunReply{}, nil +} + var _ jobsClient = (*fakeClient)(nil) func TestWrapJobsError(t *testing.T) { diff --git a/cli/command/job/cmd.go b/cli/command/job/cmd.go index 81ccc431751c..c97464264d5b 100644 --- a/cli/command/job/cmd.go +++ b/cli/command/job/cmd.go @@ -34,6 +34,8 @@ func newJobCommand(dockerCli command.Cli) *cobra.Command { cmd.AddCommand( newListCommand(dockerCli, jobs), newLogsCommand(dockerCli, jobs), + newRunsCommand(dockerCli, jobs), + newInspectCommand(dockerCli, jobs), ) return cmd } @@ -104,3 +106,11 @@ func (c *lazyJobsClient) ListRuns(ctx context.Context, req *jobsv0.ListRunsReque } return client.ListRuns(ctx, req) } + +func (c *lazyJobsClient) InspectRun(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.InspectRun(ctx, req) +} diff --git a/cli/command/job/inspect.go b/cli/command/job/inspect.go new file mode 100644 index 000000000000..6342d61c25ba --- /dev/null +++ b/cli/command/job/inspect.go @@ -0,0 +1,96 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.26 + +package job + +import ( + "context" + "encoding/json" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// inspectOptions holds the parsed flags/args of `docker job inspect`. +type inspectOptions struct { + job string + run string +} + +// newInspectCommand wires the `docker job inspect [--run RUN] JOB` cobra +// command. client is injected explicitly, following the same pattern as +// newListCommand/newLogsCommand/newRunCommand (see list.go/logs.go/run.go). +func newInspectCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts inspectOptions + + cmd := &cobra.Command{ + Use: "inspect [OPTIONS] JOB", + Short: "Display detailed information on a job", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + opts.job = args[0] + return runInspect(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&opts.run, "run", "", "Inspect a specific run instead of the job") + return cmd +} + +// jobView is a jobsv0.Job as printed by `docker job inspect`: the container +// spec is a JSON document carried as bytes, so it is shown as that document +// rather than as the base64 string a []byte marshals to. The embedded +// structs' ContainerSpec and Spec fields are shadowed by the ones declared +// here. +type jobView struct { + jobsv0.Job + Spec *specView +} + +type specView struct { + jobsv0.JobSpec + ContainerSpec json.RawMessage +} + +func newJobView(j *jobsv0.Job) *jobView { + if j == nil { + return nil + } + v := &jobView{Job: *j} + if j.Spec != nil { + v.Spec = &specView{JobSpec: *j.Spec, ContainerSpec: j.Spec.ContainerSpec} + } + return v +} + +// runInspect prints the jobsv0.Job (or jobsv0.Run, with opts.run set) as +// indented JSON on dockerCli.Out() -- a single object, not wrapped in an +// array, unlike the generic cli/command/inspect package. +func runInspect(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *inspectOptions) error { + var v any + if opts.run != "" { + reply, err := client.InspectRun(ctx, &jobsv0.InspectRunRequest{JobRef: opts.job, RunRef: opts.run}) + if err != nil { + return wrapJobsError(err) + } + v = reply.Run + } else { + reply, err := client.Inspect(ctx, &jobsv0.InspectRequest{JobRef: opts.job}) + if err != nil { + return wrapJobsError(err) + } + v = newJobView(reply.Job) + } + + out, err := json.MarshalIndent(v, "", " ") + if err != nil { + return err + } + _, err = dockerCli.Out().Write(append(out, '\n')) + return err +} diff --git a/cli/command/job/inspect_test.go b/cli/command/job/inspect_test.go new file mode 100644 index 000000000000..578b9dd974ef --- /dev/null +++ b/cli/command/job/inspect_test.go @@ -0,0 +1,284 @@ +package job + +import ( + "context" + "encoding/json" + "errors" + "io" + "strings" + "testing" + + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// Output format: `docker job inspect` dumps the raw jobsv0.Job (or +// jobsv0.Run, with --run) as indented JSON on dockerCli.Out(), 2-space +// indent, one object -- not wrapped in an array, unlike the generic +// cli/command/inspect package (which serves multi-reference --format/ +// template inspection across several docker CLI resources and is not a good +// fit for this single-object, template-less case). Tests assert on decoded +// JSON fields rather than the exact byte layout, to stay robust to +// formatting-only changes. + +func TestNewInspectCommandWithoutRunCallsInspectOnly(t *testing.T) { + var gotReq *jobsv0.InspectRequest + client := &fakeClient{ + inspectFunc: func(_ context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + gotReq = req + return &jobsv0.InspectReply{Job: &jobsv0.Job{ID: "job-1", Name: "backup"}}, nil + }, + inspectRunFunc: func(context.Context, *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + t.Fatal("client.InspectRun must not be called without --run") + return nil, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Inspect was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + + var got jobsv0.Job + assert.NilError(t, json.Unmarshal(cli.OutBuffer().Bytes(), &got)) + assert.Check(t, is.Equal(got.ID, "job-1")) + assert.Check(t, is.Equal(got.Name, "backup")) +} + +func TestNewInspectCommandWithRunCallsInspectRunOnly(t *testing.T) { + var gotReq *jobsv0.InspectRunRequest + client := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + t.Fatal("client.Inspect must not be called with --run") + return nil, nil + }, + inspectRunFunc: func(_ context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + gotReq = req + return &jobsv0.InspectRunReply{Run: &jobsv0.Run{ID: "run-1", JobID: "job-1"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + cmd.SetArgs([]string{"--run", "latest", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.InspectRun was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunRef, "latest")) + + var got jobsv0.Run + assert.NilError(t, json.Unmarshal(cli.OutBuffer().Bytes(), &got)) + assert.Check(t, is.Equal(got.ID, "run-1")) + assert.Check(t, is.Equal(got.JobID, "job-1")) +} + +func TestNewInspectCommandWithArbitraryRunRefForwarded(t *testing.T) { + var gotReq *jobsv0.InspectRunRequest + client := &fakeClient{ + inspectRunFunc: func(_ context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + gotReq = req + return &jobsv0.InspectRunReply{Run: &jobsv0.Run{ID: "run-42"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + cmd.SetArgs([]string{"--run", "run-42", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(gotReq.RunRef, "run-42")) +} + +func TestNewInspectCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewInspectCommandUnimplementedOnInspectIsActionable(t *testing.T) { + client := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewInspectCommandUnimplementedOnInspectRunIsActionable(t *testing.T) { + client := &fakeClient{ + inspectRunFunc: func(context.Context, *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + cmd.SetArgs([]string{"--run", "latest", "backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewInspectCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + testCases := []struct { + doc string + run string + errText string + }{ + {doc: "job not found, without --run", errText: `job "backup" not found`}, + {doc: "run not found, with --run", run: "latest", errText: `run "latest" not found for job "backup"`}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + client := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return nil, errors.New(tc.errText) + }, + inspectRunFunc: func(context.Context, *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + return nil, errors.New(tc.errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newInspectCommand(cli, client) + args := []string{"backup"} + if tc.run != "" { + args = append([]string{"--run", tc.run}, args...) + } + cmd.SetArgs(args) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, tc.errText) + }) + } +} + +// TestRunInspectDirect exercises runInspect directly (bypassing cobra arg +// parsing), following the pattern set by run_test.go/logs_test.go of testing +// the RunE body as a plain function in addition to going through the cobra +// command. +func TestRunInspectDirect(t *testing.T) { + client := &fakeClient{ + inspectFunc: func(_ context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ID: "job-1", Name: req.JobRef}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runInspect(context.Background(), cli, client, &inspectOptions{job: "backup"}) + + assert.NilError(t, err) + var got jobsv0.Job + assert.NilError(t, json.Unmarshal(cli.OutBuffer().Bytes(), &got)) + assert.Check(t, is.Equal(got.Name, "backup")) +} + +func TestRunInspectDirectWithRun(t *testing.T) { + client := &fakeClient{ + inspectRunFunc: func(_ context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { + return &jobsv0.InspectRunReply{Run: &jobsv0.Run{ID: "run-1", JobID: req.JobRef}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runInspect(context.Background(), cli, client, &inspectOptions{job: "backup", run: "latest"}) + + assert.NilError(t, err) + var got jobsv0.Run + assert.NilError(t, json.Unmarshal(cli.OutBuffer().Bytes(), &got)) + assert.Check(t, is.Equal(got.ID, "run-1")) + assert.Check(t, is.Equal(got.JobID, "backup")) +} + +// The container spec is a JSON document carried as bytes: it must be printed +// as that document, not as the base64 string a []byte marshals to. +func TestRunInspectPrintsContainerSpecAsJSON(t *testing.T) { + client := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + ID: "job-1", + Name: "backup", + Spec: &jobsv0.JobSpec{ + ContainerSpec: []byte(`{"Image":"busybox","Cmd":["echo","hi"]}`), + TimeoutSeconds: 30, + }, + }}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runInspect(context.Background(), cli, client, &inspectOptions{job: "backup"}) + + assert.NilError(t, err) + var got struct { + Name string + Spec struct { + ContainerSpec map[string]any + TimeoutSeconds int64 + } + } + assert.NilError(t, json.Unmarshal(cli.OutBuffer().Bytes(), &got), "output: %s", cli.OutBuffer()) + assert.Check(t, is.Equal(got.Name, "backup")) + assert.Check(t, is.Equal(got.Spec.ContainerSpec["Image"], "busybox")) + assert.Check(t, is.Equal(got.Spec.TimeoutSeconds, int64(30)), "the other spec fields must be kept") +} + +func TestRunInspectJobWithoutSpec(t *testing.T) { + client := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ID: "job-1", Name: "backup"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runInspect(context.Background(), cli, client, &inspectOptions{job: "backup"}) + + assert.NilError(t, err) + assert.Check(t, strings.Contains(cli.OutBuffer().String(), `"Spec": null`), "output: %s", cli.OutBuffer()) +} + +// A reply without a job used to be printed as null. Building the view of the +// job must not turn that into a panic. +func TestRunInspectReplyWithoutJob(t *testing.T) { + client := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runInspect(context.Background(), cli, client, &inspectOptions{job: "backup"}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "null\n")) +} diff --git a/cli/command/job/runs.go b/cli/command/job/runs.go new file mode 100644 index 000000000000..1c95d213ddcc --- /dev/null +++ b/cli/command/job/runs.go @@ -0,0 +1,130 @@ +package job + +import ( + "context" + "fmt" + "strconv" + "time" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + "github.com/docker/cli/cli/command/formatter" + "github.com/docker/cli/cli/command/formatter/tabwriter" + units "github.com/docker/go-units" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// runRow is one formatted row of `docker job runs`, matching the columns +// ITERATION STATE EXIT TRIGGER STARTED FINISHED CONTAINER. +type runRow struct { + Iteration string + State string + Exit string + Trigger string + Started string + Finished string + Container string +} + +// newRunRow formats r into a runRow. now is the reference time used to +// humanize STARTED/FINISHED with github.com/docker/go-units HumanDuration; +// production code passes time.Now(), tests inject a fixed value to stay +// deterministic. +func newRunRow(r jobsv0.Run, now time.Time) runRow { + row := runRow{ + Iteration: strconv.FormatUint(r.Iteration, 10), + State: r.State, + Exit: "-", + Trigger: "-", + Started: "-", + Finished: "-", + Container: "-", + } + + if r.ExitCode != nil { + row.Exit = strconv.FormatInt(r.ExitCode.Value, 10) + } + if r.Trigger != nil { + row.Trigger = r.Trigger.Kind + } + if r.StartedAtNano != 0 { + row.Started = units.HumanDuration(now.Sub(time.Unix(0, r.StartedAtNano))) + " ago" + } + if r.FinishedAtNano != 0 { + row.Finished = units.HumanDuration(now.Sub(time.Unix(0, r.FinishedAtNano))) + " ago" + } + if r.ContainerID != "" { + row.Container = formatter.TruncateID(r.ContainerID) + } + + return row +} + +// runsOptions holds the parsed flags/args of `docker job runs`. +type runsOptions struct { + job string + limit int32 + before string +} + +// newRunsCommand wires the `docker job runs [OPTIONS] JOB` cobra command. +// client is injected explicitly, following the same pattern as +// newListCommand (see list.go). +func newRunsCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts runsOptions + + cmd := &cobra.Command{ + Use: "runs [OPTIONS] JOB", + Short: "List a job's runs", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + opts.job = args[0] + return runRuns(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.Int32Var(&opts.limit, "limit", 0, "Maximum number of runs to list (0 for the daemon default)") + flags.StringVar(&opts.before, "before", "", "List runs older than this cursor (from a previous page's NextCursor)") + return cmd +} + +// runRuns calls client.ListRuns and renders the returned page as a +// tabwriter table to dockerCli.Out(), in the order the daemon returned +// them (most-recent-first, per ListRuns's godoc) without re-sorting. A stale +// requested cursor is warned about on dockerCli.Err(); a non-empty +// NextCursor prints a paging hint on dockerCli.Out() after the table. +func runRuns(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *runsOptions) error { + reply, err := client.ListRuns(ctx, &jobsv0.ListRunsRequest{ + JobRef: opts.job, + Limit: opts.limit, + Before: opts.before, + }) + if err != nil { + return wrapJobsError(err) + } + + if reply.CursorStale { + _, _ = fmt.Fprintln(dockerCli.Err(), "Warning: the requested cursor is stale; showing the most recent runs instead") + } + + now := time.Now() + w := tabwriter.NewWriter(dockerCli.Out(), 0, 4, 2, ' ', 0) + _, _ = fmt.Fprintln(w, "ITERATION\tSTATE\tEXIT\tTRIGGER\tSTARTED\tFINISHED\tCONTAINER") + for _, r := range reply.Runs { + row := newRunRow(r, now) + _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", + row.Iteration, row.State, row.Exit, row.Trigger, row.Started, row.Finished, row.Container) + } + if err := w.Flush(); err != nil { + return err + } + + if reply.NextCursor != "" { + _, _ = fmt.Fprintf(dockerCli.Out(), "\nFor the next page, run: docker job runs --before %s %s\n", reply.NextCursor, opts.job) + } + return nil +} diff --git a/cli/command/job/runs_test.go b/cli/command/job/runs_test.go new file mode 100644 index 000000000000..9b1559ec7178 --- /dev/null +++ b/cli/command/job/runs_test.go @@ -0,0 +1,462 @@ +package job + +import ( + "context" + "errors" + "io" + "strconv" + "strings" + "testing" + "time" + + "github.com/docker/cli/cli/command/formatter" + "github.com/docker/cli/internal/test" + units "github.com/docker/go-units" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// runsHeaderColumns is the exact header line expected on `docker job runs`: ITERATION STATE EXIT TRIGGER STARTED +// FINISHED CONTAINER. +var runsHeaderColumns = []string{"ITERATION", "STATE", "EXIT", "TRIGGER", "STARTED", "FINISHED", "CONTAINER"} + +func TestNewRunRow(t *testing.T) { + now := time.Date(2024, 3, 10, 15, 0, 0, 0, time.UTC) + + testCases := []struct { + doc string + run jobsv0.Run + expected runRow + }{ + { + doc: "pending run: never started, never finished, no container, no exit code", + run: jobsv0.Run{ + Iteration: 1, + State: jobsv0.RunStatePending, + }, + expected: runRow{ + Iteration: "1", + State: "pending", + Exit: "-", + Trigger: "-", + Started: "-", + Finished: "-", + Container: "-", + }, + }, + { + doc: "running run: started, not finished, ExitCode nil, manual trigger", + run: jobsv0.Run{ + Iteration: 2, + State: jobsv0.RunStateRunning, + ContainerID: "abcdef0123456789abcdef", + StartedAtNano: now.Add(-30 * time.Second).UnixNano(), + Trigger: &jobsv0.TriggerEvidence{Kind: jobsv0.TriggerKindManual}, + }, + expected: runRow{ + Iteration: "2", + State: "running", + Exit: "-", + Trigger: "manual", + Started: "30 seconds ago", + Finished: "-", + Container: "abcdef012345", + }, + }, + { + doc: "succeeded run with exit code zero: EXIT must be 0, NOT - (no-exit-code vs exit-code-zero trap)", + run: jobsv0.Run{ + Iteration: 3, + State: jobsv0.RunStateSucceeded, + ContainerID: "1234567890ab1234567890ab", + StartedAtNano: now.Add(-5 * time.Minute).UnixNano(), + FinishedAtNano: now.Add(-2 * time.Minute).UnixNano(), + ExitCode: &jobsv0.ExitCode{Value: 0}, + Trigger: &jobsv0.TriggerEvidence{Kind: jobsv0.TriggerKindSchedule}, + }, + expected: runRow{ + Iteration: "3", + State: "succeeded", + Exit: "0", + Trigger: "schedule", + Started: "5 minutes ago", + Finished: "2 minutes ago", + Container: "1234567890ab", + }, + }, + { + doc: "failed run with a nonzero exit code", + run: jobsv0.Run{ + Iteration: 4, + State: jobsv0.RunStateFailed, + ContainerID: "deadbeefdeadbeefdeadbeef", + StartedAtNano: now.Add(-1 * time.Hour).UnixNano(), + FinishedAtNano: now.Add(-59 * time.Minute).UnixNano(), + ExitCode: &jobsv0.ExitCode{Value: 137}, + Trigger: &jobsv0.TriggerEvidence{Kind: jobsv0.TriggerKindManual}, + }, + expected: runRow{ + Iteration: "4", + State: "failed", + Exit: "137", + Trigger: "manual", + Started: "About an hour ago", + Finished: "59 minutes ago", + Container: "deadbeefdead", + }, + }, + { + doc: "run whose container was never created: failed straight from pending, no exit code, no container", + run: jobsv0.Run{ + Iteration: 5, + State: jobsv0.RunStateFailed, + FinishedAtNano: now.Add(-10 * time.Second).UnixNano(), + Error: "container create failed", + }, + expected: runRow{ + Iteration: "5", + State: "failed", + Exit: "-", + Trigger: "-", + Started: "-", + Finished: "10 seconds ago", + Container: "-", + }, + }, + { + doc: "nil Trigger is handled defensively even though it is not expected in practice", + run: jobsv0.Run{ + Iteration: 6, + State: jobsv0.RunStateCancelled, + Trigger: nil, + }, + expected: runRow{ + Iteration: "6", + State: "cancelled", + Exit: "-", + Trigger: "-", + Started: "-", + Finished: "-", + Container: "-", + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + row := newRunRow(tc.run, now) + assert.Check(t, is.DeepEqual(row, tc.expected)) + }) + } +} + +// TestNewRunRowUsesHumanDuration guards against hardcoding a human-readable +// string that only happens to match go-units' current implementation: it +// recomputes the expected string through units.HumanDuration itself, so the +// test tracks the library rather than a magic string. +func TestNewRunRowUsesHumanDuration(t *testing.T) { + now := time.Date(2024, 3, 10, 15, 0, 0, 0, time.UTC) + startedAgo := 42 * time.Second + finishedAgo := 7 * time.Second + + r := jobsv0.Run{ + Iteration: 1, + State: jobsv0.RunStateSucceeded, + StartedAtNano: now.Add(-startedAgo).UnixNano(), + FinishedAtNano: now.Add(-finishedAgo).UnixNano(), + ExitCode: &jobsv0.ExitCode{Value: 0}, + } + + row := newRunRow(r, now) + + assert.Check(t, is.Equal(row.Started, units.HumanDuration(startedAgo)+" ago")) + assert.Check(t, is.Equal(row.Finished, units.HumanDuration(finishedAgo)+" ago")) +} + +// TestNewRunRowContainerTruncation confirms CONTAINER reuses the repo's +// existing ID-truncation convention (formatter.TruncateID, wrapping +// github.com/moby/moby/client/pkg/stringid.TruncateID -- the same helper used +// by `docker ps` and friends) rather than a hand-rolled slice. +func TestNewRunRowContainerTruncation(t *testing.T) { + now := time.Date(2024, 3, 10, 15, 0, 0, 0, time.UTC) + containerID := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd" + + row := newRunRow(jobsv0.Run{ContainerID: containerID}, now) + + assert.Check(t, is.Equal(row.Container, formatter.TruncateID(containerID))) +} + +func TestNewRunsCommandForwardsRequest(t *testing.T) { + var gotReq *jobsv0.ListRunsRequest + client := &fakeClient{ + listRunsFunc: func(_ context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + gotReq = req + return &jobsv0.ListRunsReply{}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"--limit", "5", "--before", "cursor-123", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.ListRuns was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.Limit, int32(5))) + assert.Check(t, is.Equal(gotReq.Before, "cursor-123")) +} + +func TestNewRunsCommandDefaultsLimitZeroAndBeforeEmpty(t *testing.T) { + var gotReq *jobsv0.ListRunsRequest + client := &fakeClient{ + listRunsFunc: func(_ context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + gotReq = req + return &jobsv0.ListRunsReply{}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.ListRuns was not called") + assert.Check(t, is.Equal(gotReq.Limit, int32(0))) + assert.Check(t, is.Equal(gotReq.Before, "")) +} + +func TestNewRunsCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewRunsCommandHeader(t *testing.T) { + cli := test.NewFakeCli(nil) + client := &fakeClient{} + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + for _, col := range runsHeaderColumns { + assert.Check(t, strings.Contains(out, col), "expected header column %q in output:\n%s", col, out) + } +} + +func TestNewRunsCommandRendersRunsInReceivedOrder(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {Iteration: 9, State: jobsv0.RunStateSucceeded, ExitCode: &jobsv0.ExitCode{Value: 0}}, + {Iteration: 3, State: jobsv0.RunStateFailed, ExitCode: &jobsv0.ExitCode{Value: 1}}, + {Iteration: 7, State: jobsv0.RunStateSucceeded, ExitCode: &jobsv0.ExitCode{Value: 0}}, + }}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + i9 := strings.Index(out, "9") + i3 := strings.Index(out, "3") + i7 := strings.Index(out, "7") + assert.Check(t, i9 >= 0 && i3 >= 0 && i7 >= 0, "all three iterations must appear in output:\n%s", out) + // The daemon already returns most-recent-first; the CLI must NOT re-sort. + assert.Check(t, i9 < i3, "expected iteration 9 before 3 (no CLI re-sorting):\n%s", out) + assert.Check(t, i3 < i7, "expected iteration 3 before 7 (no CLI re-sorting):\n%s", out) +} + +func TestNewRunsCommandExitCodeZeroIsNotDash(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {Iteration: 1, State: jobsv0.RunStateSucceeded, ExitCode: &jobsv0.ExitCode{Value: 0}}, + }}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + assert.Check(t, hasTableCell(out, "0"), "expected a table cell with the exit code 0, not '-':\n%s", out) +} + +func TestNewRunsCommandCursorStaleWarnsOnStderrBeforeTable(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{ + Runs: []jobsv0.Run{{Iteration: 1, State: jobsv0.RunStateSucceeded}}, + CursorStale: true, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"--before", "evicted-cursor", "backup"}) + assert.NilError(t, cmd.Execute()) + + errOut := cli.ErrBuffer().String() + assert.Check(t, errOut != "", "expected a stale-cursor warning on stderr, got none") + assert.Check(t, strings.Contains(strings.ToLower(errOut), "stale"), "expected the warning to mention the stale cursor:\n%s", errOut) + + // The command must still succeed and render the table on stdout. + out := cli.OutBuffer().String() + assert.Check(t, is.Contains(out, "ITERATION")) +} + +func TestNewRunsCommandNoWarningWhenCursorNotStale(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{ + Runs: []jobsv0.Run{{Iteration: 1, State: jobsv0.RunStateSucceeded}}, + CursorStale: false, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.ErrBuffer().String(), "")) +} + +func TestNewRunsCommandNextCursorPrintsPagingHint(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{ + Runs: []jobsv0.Run{{Iteration: 1, State: jobsv0.RunStateSucceeded}}, + NextCursor: "next-page-cursor", + }, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + assert.Check(t, strings.Contains(out, "--before"), "expected a paging hint mentioning --before:\n%s", out) + assert.Check(t, strings.Contains(out, "next-page-cursor"), "expected the paging hint to interpolate the actual cursor value:\n%s", out) +} + +func TestNewRunsCommandNoNextCursorNoPagingHint(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{ + Runs: []jobsv0.Run{{Iteration: 1, State: jobsv0.RunStateSucceeded}}, + NextCursor: "", + }, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + out := cli.OutBuffer().String() + assert.Check(t, !strings.Contains(out, "--before"), "did not expect a paging hint when NextCursor is empty:\n%s", out) +} + +func TestNewRunsCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewRunsCommandOtherErrorsPassThrough(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return nil, errors.New("job not found") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "job not found") +} + +// TestRunRunsDirect exercises runRuns directly (bypassing cobra arg +// parsing), following the pattern set by list.go/logs.go/run.go of testing +// the RunE body as a plain function in addition to going through the cobra +// command. +func TestRunRunsDirect(t *testing.T) { + var gotReq *jobsv0.ListRunsRequest + client := &fakeClient{ + listRunsFunc: func(_ context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + gotReq = req + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{ + {Iteration: 1, State: jobsv0.RunStateSucceeded, ExitCode: &jobsv0.ExitCode{Value: 0}}, + }}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runRuns(context.Background(), cli, client, &runsOptions{job: "backup", limit: 5, before: "cursor-1"}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.Limit, int32(5))) + assert.Check(t, is.Equal(gotReq.Before, "cursor-1")) + assert.Check(t, is.Contains(cli.OutBuffer().String(), "ITERATION")) + assert.Check(t, is.Contains(cli.OutBuffer().String(), strconv.FormatUint(1, 10))) +} + +// --limit is an int32 on the wire: a value that does not fit must be refused +// instead of silently wrapping around (4294967296 would become 0, i.e. the +// daemon default). +func TestNewRunsCommandRejectsLimitOutOfInt32Range(t *testing.T) { + client := &fakeClient{ + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + t.Fatal("client.ListRuns must not be called with an out-of-range --limit") + return nil, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunsCommand(cli, client) + cmd.SetArgs([]string{"--limit", "4294967296", "backup"}) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + + assert.ErrorContains(t, cmd.Execute(), "--limit") +} From 1ea0e434caa7780046c057d12cd627b6c4579010 Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Tue, 10 Nov 2026 10:21:15 +0100 Subject: [PATCH 3/5] cli/command/job: add `docker job run`, `cancel`, `pause`, `unpause`, `rm` and `prune` commands - `run [--reschedule] JOB` triggers a run and prints its ID. - `cancel JOB` stops the in-flight run; cancelling an idle job is a no-op. - `pause JOB` and `unpause JOB` suppress and re-arm a schedule trigger. - `rm [--runs keep|remove|remove-finished] JOB` removes a job; run history is kept unless asked otherwise, and the ID of a removed job stays usable to read or purge it. - `prune [--label LABEL]` removes idle manual jobs. Signed-off-by: Guillaume Lours --- cli/command/job/cancel.go | 48 ++++++++ cli/command/job/cancel_test.go | 159 +++++++++++++++++++++++++ cli/command/job/client.go | 21 ++++ cli/command/job/client_test.go | 48 ++++++++ cli/command/job/cmd.go | 54 +++++++++ cli/command/job/pause.go | 41 +++++++ cli/command/job/pause_test.go | 140 ++++++++++++++++++++++ cli/command/job/prune.go | 76 ++++++++++++ cli/command/job/prune_test.go | 204 ++++++++++++++++++++++++++++++++ cli/command/job/rm.go | 55 +++++++++ cli/command/job/rm_test.go | 197 ++++++++++++++++++++++++++++++ cli/command/job/run.go | 53 +++++++++ cli/command/job/run_test.go | 153 ++++++++++++++++++++++++ cli/command/job/unpause.go | 41 +++++++ cli/command/job/unpause_test.go | 140 ++++++++++++++++++++++ 15 files changed, 1430 insertions(+) create mode 100644 cli/command/job/cancel.go create mode 100644 cli/command/job/cancel_test.go create mode 100644 cli/command/job/pause.go create mode 100644 cli/command/job/pause_test.go create mode 100644 cli/command/job/prune.go create mode 100644 cli/command/job/prune_test.go create mode 100644 cli/command/job/rm.go create mode 100644 cli/command/job/rm_test.go create mode 100644 cli/command/job/run.go create mode 100644 cli/command/job/run_test.go create mode 100644 cli/command/job/unpause.go create mode 100644 cli/command/job/unpause_test.go diff --git a/cli/command/job/cancel.go b/cli/command/job/cancel.go new file mode 100644 index 000000000000..d2a1b4a4943f --- /dev/null +++ b/cli/command/job/cancel.go @@ -0,0 +1,48 @@ +package job + +import ( + "context" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// newCancelCommand wires the `docker job cancel JOB` cobra command. client is +// injected explicitly, following the same pattern as newRunCommand (see +// run.go). +func newCancelCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + cmd := &cobra.Command{ + Use: "cancel JOB", + Short: "Cancel a job's in-flight run", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return runCancel(cmd.Context(), dockerCli, client, args[0]) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + return cmd +} + +// runCancel cancels jobRef's in-flight run via client.Cancel. If a run was +// cancelled, its ID is printed on dockerCli.Out(), the same convention as +// runRun (see run.go). If no run was in flight, a message is printed instead +// and nil is returned: cancelling an idle job is a valid, idempotent +// request, not a failure. +func runCancel(ctx context.Context, dockerCli command.Cli, client jobsClient, jobRef string) error { + reply, err := client.Cancel(ctx, &jobsv0.CancelRequest{JobRef: jobRef}) + if err != nil { + return wrapJobsError(err) + } + + if reply.RunID == "" { + _, _ = fmt.Fprintf(dockerCli.Out(), "no run in flight for job %q\n", jobRef) + return nil + } + + _, _ = fmt.Fprintln(dockerCli.Out(), reply.RunID) + return nil +} diff --git a/cli/command/job/cancel_test.go b/cli/command/job/cancel_test.go new file mode 100644 index 000000000000..c2ffee4a40ba --- /dev/null +++ b/cli/command/job/cancel_test.go @@ -0,0 +1,159 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// Output convention choice: on a successful cancellation (reply.RunID set), +// runCancel prints the cancelled run's ID on dockerCli.Out(), mirroring +// runRun's "print the created/affected resource's ID" convention (see +// run.go). When no run was in flight (reply.RunID == ""), printing an empty +// line would be confusing in a demo -- the user asked for a cancel and +// nothing happened, silently or with a blank line, which looks like a bug. +// Instead runCancel prints a clear, non-error message to dockerCli.Out() +// (`no run in flight for job ""`) and returns a nil error: asking to +// cancel an idle job is a valid, idempotent request, not a failure -- the +// same spirit as jobsv0.Jobs.Pause/Resume being documented idempotent. + +func TestNewCancelCommandForwardsJobRef(t *testing.T) { + var gotReq *jobsv0.CancelRequest + client := &fakeClient{ + cancelFunc: func(_ context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + gotReq = req + return &jobsv0.CancelReply{RunID: "run-1"}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newCancelCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Cancel was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) +} + +func TestNewCancelCommandPrintsCancelledRunID(t *testing.T) { + client := &fakeClient{ + cancelFunc: func(context.Context, *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + return &jobsv0.CancelReply{RunID: "run-42"}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newCancelCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "run-42\n")) +} + +func TestNewCancelCommandNoRunInFlightPrintsMessageWithoutError(t *testing.T) { + client := &fakeClient{ + cancelFunc: func(context.Context, *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + return &jobsv0.CancelReply{RunID: ""}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newCancelCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "no run in flight for job \"backup\"\n")) +} + +func TestNewCancelCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newCancelCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewCancelCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + cancelFunc: func(context.Context, *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newCancelCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewCancelCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + cancelFunc: func(context.Context, *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + return nil, errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newCancelCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, errText) +} + +// TestRunCancelDirect exercises runCancel directly (bypassing cobra arg +// parsing), following the pattern set by run_test.go/inspect_test.go of +// testing the RunE body as a plain function in addition to going through the +// cobra command. +func TestRunCancelDirect(t *testing.T) { + var gotReq *jobsv0.CancelRequest + client := &fakeClient{ + cancelFunc: func(_ context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + gotReq = req + return &jobsv0.CancelReply{RunID: "run-7"}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runCancel(context.Background(), cli, client, "backup") + + assert.NilError(t, err) + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "run-7\n")) +} + +func TestRunCancelDirectNoRunInFlight(t *testing.T) { + client := &fakeClient{ + cancelFunc: func(context.Context, *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + return &jobsv0.CancelReply{RunID: ""}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runCancel(context.Background(), cli, client, "backup") + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "no run in flight for job \"backup\"\n")) +} diff --git a/cli/command/job/client.go b/cli/command/job/client.go index 0254fb917a42..77459b93840d 100644 --- a/cli/command/job/client.go +++ b/cli/command/job/client.go @@ -32,8 +32,29 @@ type jobsClient interface { // fallback when the latest run's container is gone. ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) + // Run executes an existing job, returning the created run. + Run(ctx context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) + // InspectRun returns a single run. InspectRun(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) + + // Cancel stops the job's in-flight run. + Cancel(ctx context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) + + // Prune removes idle manual jobs. + Prune(ctx context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) + + // Remove deletes a job. It returns only an error: jobsv0.Jobs.Remove has + // no reply message. + Remove(ctx context.Context, req *jobsv0.RemoveRequest) error + + // Pause suppresses a job's schedule trigger. Like Remove, it returns + // only an error: jobsv0.Jobs.Pause has no reply message. + Pause(ctx context.Context, req *jobsv0.PauseRequest) error + + // Resume re-arms a paused job's schedule trigger. Like Remove, it + // returns only an error: jobsv0.Jobs.Resume has no reply message. + Resume(ctx context.Context, req *jobsv0.ResumeRequest) error } // newJobsClient dials the daemon's jobs extension point and returns a diff --git a/cli/command/job/client_test.go b/cli/command/job/client_test.go index 55fc65a33e2e..1cbf581ec805 100644 --- a/cli/command/job/client_test.go +++ b/cli/command/job/client_test.go @@ -26,7 +26,13 @@ type fakeClient struct { listFunc func(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) inspectFunc func(ctx context.Context, req *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) listRunsFunc func(ctx context.Context, req *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) + runFunc func(ctx context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) inspectRunFunc func(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) + cancelFunc func(ctx context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) + pruneFunc func(ctx context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) + removeFunc func(ctx context.Context, req *jobsv0.RemoveRequest) error + pauseFunc func(ctx context.Context, req *jobsv0.PauseRequest) error + resumeFunc func(ctx context.Context, req *jobsv0.ResumeRequest) error } func (c *fakeClient) List(ctx context.Context, req *jobsv0.ListRequest) (*jobsv0.ListReply, error) { @@ -50,6 +56,13 @@ func (c *fakeClient) ListRuns(ctx context.Context, req *jobsv0.ListRunsRequest) return &jobsv0.ListRunsReply{}, nil } +func (c *fakeClient) Run(ctx context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + if c.runFunc != nil { + return c.runFunc(ctx, req) + } + return &jobsv0.RunReply{}, nil +} + func (c *fakeClient) InspectRun(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { if c.inspectRunFunc != nil { return c.inspectRunFunc(ctx, req) @@ -57,6 +70,41 @@ func (c *fakeClient) InspectRun(ctx context.Context, req *jobsv0.InspectRunReque return &jobsv0.InspectRunReply{}, nil } +func (c *fakeClient) Cancel(ctx context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + if c.cancelFunc != nil { + return c.cancelFunc(ctx, req) + } + return &jobsv0.CancelReply{}, nil +} + +func (c *fakeClient) Prune(ctx context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + if c.pruneFunc != nil { + return c.pruneFunc(ctx, req) + } + return &jobsv0.PruneReply{}, nil +} + +func (c *fakeClient) Remove(ctx context.Context, req *jobsv0.RemoveRequest) error { + if c.removeFunc != nil { + return c.removeFunc(ctx, req) + } + return nil +} + +func (c *fakeClient) Pause(ctx context.Context, req *jobsv0.PauseRequest) error { + if c.pauseFunc != nil { + return c.pauseFunc(ctx, req) + } + return nil +} + +func (c *fakeClient) Resume(ctx context.Context, req *jobsv0.ResumeRequest) error { + if c.resumeFunc != nil { + return c.resumeFunc(ctx, req) + } + return nil +} + var _ jobsClient = (*fakeClient)(nil) func TestWrapJobsError(t *testing.T) { diff --git a/cli/command/job/cmd.go b/cli/command/job/cmd.go index c97464264d5b..c5aa86e654ca 100644 --- a/cli/command/job/cmd.go +++ b/cli/command/job/cmd.go @@ -34,8 +34,14 @@ func newJobCommand(dockerCli command.Cli) *cobra.Command { cmd.AddCommand( newListCommand(dockerCli, jobs), newLogsCommand(dockerCli, jobs), + newRunCommand(dockerCli, jobs), newRunsCommand(dockerCli, jobs), newInspectCommand(dockerCli, jobs), + newCancelCommand(dockerCli, jobs), + newPruneCommand(dockerCli, jobs), + newRmCommand(dockerCli, jobs), + newPauseCommand(dockerCli, jobs), + newUnpauseCommand(dockerCli, jobs), ) return cmd } @@ -107,6 +113,14 @@ func (c *lazyJobsClient) ListRuns(ctx context.Context, req *jobsv0.ListRunsReque return client.ListRuns(ctx, req) } +func (c *lazyJobsClient) Run(ctx context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.Run(ctx, req) +} + func (c *lazyJobsClient) InspectRun(ctx context.Context, req *jobsv0.InspectRunRequest) (*jobsv0.InspectRunReply, error) { client, err := c.resolve() if err != nil { @@ -114,3 +128,43 @@ func (c *lazyJobsClient) InspectRun(ctx context.Context, req *jobsv0.InspectRunR } return client.InspectRun(ctx, req) } + +func (c *lazyJobsClient) Cancel(ctx context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.Cancel(ctx, req) +} + +func (c *lazyJobsClient) Prune(ctx context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.Prune(ctx, req) +} + +func (c *lazyJobsClient) Remove(ctx context.Context, req *jobsv0.RemoveRequest) error { + client, err := c.resolve() + if err != nil { + return err + } + return client.Remove(ctx, req) +} + +func (c *lazyJobsClient) Pause(ctx context.Context, req *jobsv0.PauseRequest) error { + client, err := c.resolve() + if err != nil { + return err + } + return client.Pause(ctx, req) +} + +func (c *lazyJobsClient) Resume(ctx context.Context, req *jobsv0.ResumeRequest) error { + client, err := c.resolve() + if err != nil { + return err + } + return client.Resume(ctx, req) +} diff --git a/cli/command/job/pause.go b/cli/command/job/pause.go new file mode 100644 index 000000000000..1393038a53b9 --- /dev/null +++ b/cli/command/job/pause.go @@ -0,0 +1,41 @@ +package job + +import ( + "context" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// newPauseCommand wires the `docker job pause JOB` cobra command. client is +// injected explicitly, following the same pattern as newRunCommand (see +// run.go). +func newPauseCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + cmd := &cobra.Command{ + Use: "pause JOB", + Short: "Suppress a job's schedule trigger", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return runPause(cmd.Context(), dockerCli, client, args[0]) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + return cmd +} + +// runPause pauses jobRef via client.Pause. client.Pause has no reply +// message, so on success jobRef is printed on dockerCli.Out(), mirroring +// runRm (see rm.go) and `docker volume rm`/`docker network rm`. +func runPause(ctx context.Context, dockerCli command.Cli, client jobsClient, jobRef string) error { + err := client.Pause(ctx, &jobsv0.PauseRequest{JobRef: jobRef}) + if err != nil { + return wrapJobsError(err) + } + + _, _ = fmt.Fprintln(dockerCli.Out(), jobRef) + return nil +} diff --git a/cli/command/job/pause_test.go b/cli/command/job/pause_test.go new file mode 100644 index 000000000000..a62002c72ab7 --- /dev/null +++ b/cli/command/job/pause_test.go @@ -0,0 +1,140 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// Output convention choice: client.Pause has no reply message (like +// client.Remove), so on success runPause prints jobRef (the job name/ID +// passed as the single positional argument) on dockerCli.Out(), mirroring +// runRm (see rm.go) and `docker volume rm`/`docker network rm`. + +func TestNewPauseCommandForwardsJobRef(t *testing.T) { + var gotReq *jobsv0.PauseRequest + client := &fakeClient{ + pauseFunc: func(_ context.Context, req *jobsv0.PauseRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Pause was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) +} + +func TestNewPauseCommandPrintsJobOnSuccess(t *testing.T) { + client := &fakeClient{ + pauseFunc: func(context.Context, *jobsv0.PauseRequest) error { + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "backup\n")) +} + +func TestNewPauseCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newPauseCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewPauseCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + pauseFunc: func(context.Context, *jobsv0.PauseRequest) error { + return status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewPauseCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + pauseFunc: func(context.Context, *jobsv0.PauseRequest) error { + return errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, errText) +} + +// TestRunPauseDirect exercises runPause directly (bypassing cobra arg +// parsing), following the pattern set by cancel_test.go/rm_test.go of +// testing the RunE body as a plain function in addition to going through the +// cobra command. +func TestRunPauseDirect(t *testing.T) { + var gotReq *jobsv0.PauseRequest + client := &fakeClient{ + pauseFunc: func(_ context.Context, req *jobsv0.PauseRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + err := runPause(context.Background(), cli, client, "backup") + + assert.NilError(t, err) + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "backup\n")) +} + +func TestRunPauseDirectOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + pauseFunc: func(context.Context, *jobsv0.PauseRequest) error { + return errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + err := runPause(context.Background(), cli, client, "backup") + + assert.ErrorContains(t, err, errText) + // Nothing should be printed on failure. + assert.Check(t, is.Equal(cli.OutBuffer().String(), "")) +} diff --git a/cli/command/job/prune.go b/cli/command/job/prune.go new file mode 100644 index 000000000000..e4be25d31014 --- /dev/null +++ b/cli/command/job/prune.go @@ -0,0 +1,76 @@ +package job + +import ( + "context" + "errors" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + "github.com/docker/cli/internal/prompt" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// pruneOptions holds the parsed flags of `docker job prune`. +type pruneOptions struct { + labels []string + force bool +} + +// newPruneCommand wires the `docker job prune [--label ...]` cobra command. +// client is injected explicitly, following the same pattern as +// newRunCommand (see run.go). +func newPruneCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts pruneOptions + + cmd := &cobra.Command{ + Use: "prune [OPTIONS]", + Short: "Remove idle manual jobs", + Args: cli.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return runPrune(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.BoolVarP(&opts.force, "force", "f", false, "Do not prompt for confirmation") + flags.StringArrayVar(&opts.labels, "label", nil, "Only remove jobs matching a label (\"key\" or \"key=value\")") + return cmd +} + +const pruneWarning = `WARNING! This will remove all idle manual jobs. +Are you sure you want to continue?` + +// runPrune removes idle manual jobs matching opts.labels via client.Prune, +// printing each removed job's ID on its own line on dockerCli.Out() -- +// mirroring `docker container prune`/`docker volume prune`, including the +// confirmation prompt that opts.force skips. Nothing removed prints nothing +// and returns a nil error, keeping the command scriptable. +func runPrune(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *pruneOptions) error { + if !opts.force { + r, err := prompt.Confirm(ctx, dockerCli.In(), dockerCli.Out(), pruneWarning) + if err != nil { + return err + } + if !r { + return cancelledErr{errors.New("job prune has been cancelled")} + } + } + + reply, err := client.Prune(ctx, &jobsv0.PruneRequest{Labels: opts.labels}) + if err != nil { + return wrapJobsError(err) + } + + for _, id := range reply.RemovedJobIDs { + _, _ = fmt.Fprintln(dockerCli.Out(), id) + } + return nil +} + +type cancelledErr struct{ error } + +func (cancelledErr) Cancelled() {} diff --git a/cli/command/job/prune_test.go b/cli/command/job/prune_test.go new file mode 100644 index 000000000000..40e82deb7c0a --- /dev/null +++ b/cli/command/job/prune_test.go @@ -0,0 +1,204 @@ +package job + +import ( + "context" + "io" + "strings" + "testing" + + "github.com/containerd/errdefs" + "github.com/docker/cli/cli/streams" + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// Flag convention: --label is repeatable (pflag StringArrayVar, not +// StringSliceVar) so a label value containing a comma is not silently split +// -- consistent with jobsv0.PruneRequest.Labels/ListRequest.Labels both being +// "key" or "key=value" filter entries, matched conjunctively (see jobs.go). +// +// Output convention choice: each removed job ID is printed on its own line +// on dockerCli.Out(), mirroring `docker container prune`/`docker volume +// prune` printing one identifier per line for what was removed. When nothing +// was pruned, runPrune prints nothing and returns a nil error -- unlike +// `docker system prune`'s reclaimed-space summary, there is no secondary +// metric worth reporting here (Prune only ever reports removed job IDs), so +// an empty, silent success keeps the command composable/scriptable (e.g. +// `docker job prune --label foo` in a script can just check the exit code). + +func TestNewPruneCommandWithoutLabelSendsEmptyRequest(t *testing.T) { + var gotReq *jobsv0.PruneRequest + client := &fakeClient{ + pruneFunc: func(_ context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + gotReq = req + return &jobsv0.PruneReply{}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"--force"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Prune was not called") + assert.Check(t, is.Len(gotReq.Labels, 0)) +} + +func TestNewPruneCommandForwardsRepeatedLabelFlag(t *testing.T) { + var gotReq *jobsv0.PruneRequest + client := &fakeClient{ + pruneFunc: func(_ context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + gotReq = req + return &jobsv0.PruneReply{}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"--force", "--label", "foo", "--label", "bar=baz"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Prune was not called") + assert.Check(t, is.DeepEqual(gotReq.Labels, []string{"foo", "bar=baz"})) +} + +func TestNewPruneCommandPrintsRemovedJobIDs(t *testing.T) { + client := &fakeClient{ + pruneFunc: func(context.Context, *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + return &jobsv0.PruneReply{RemovedJobIDs: []string{"job-1", "job-2"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"--force"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "job-1\njob-2\n")) +} + +func TestNewPruneCommandPrintsNothingWhenNoJobsRemoved(t *testing.T) { + client := &fakeClient{ + pruneFunc: func(context.Context, *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + return &jobsv0.PruneReply{}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"--force"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "")) +} + +func TestNewPruneCommandRejectsPositionalArgs(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "accepts no arguments") +} + +func TestNewPruneCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + pruneFunc: func(context.Context, *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"--force"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +// TestRunPruneDirect exercises runPrune directly (bypassing cobra arg +// parsing), following the pattern set by run_test.go/inspect_test.go of +// testing the RunE body as a plain function in addition to going through the +// cobra command. +func TestRunPruneDirect(t *testing.T) { + var gotReq *jobsv0.PruneRequest + client := &fakeClient{ + pruneFunc: func(_ context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + gotReq = req + return &jobsv0.PruneReply{RemovedJobIDs: []string{"job-9"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runPrune(context.Background(), cli, client, &pruneOptions{labels: []string{"foo"}, force: true}) + + assert.NilError(t, err) + assert.Check(t, is.DeepEqual(gotReq.Labels, []string{"foo"})) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "job-9\n")) +} + +func TestNewPruneCommandAsksForConfirmation(t *testing.T) { + testCases := []struct { + doc string + input string + wantPruned bool + }{ + {doc: "confirmed", input: "y\n", wantPruned: true}, + {doc: "declined", input: "n\n", wantPruned: false}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + var pruned bool + client := &fakeClient{ + pruneFunc: func(context.Context, *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) { + pruned = true + return &jobsv0.PruneReply{RemovedJobIDs: []string{"job-1"}}, nil + }, + } + cli := test.NewFakeCli(nil) + cli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(tc.input)))) + + cmd := newPruneCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.Check(t, is.Contains(cli.OutBuffer().String(), "WARNING! This will remove all idle manual jobs.")) + assert.Check(t, is.Equal(pruned, tc.wantPruned)) + if tc.wantPruned { + assert.NilError(t, err) + assert.Check(t, is.Contains(cli.OutBuffer().String(), "job-1\n")) + } else { + assert.Check(t, errdefs.IsCanceled(err), "got %v", err) + } + }) + } +} + +func TestNewPruneCommandForceSkipsConfirmation(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + // No input is provided: a prompt would be declined. + + cmd := newPruneCommand(cli, client) + cmd.SetArgs([]string{"-f"}) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + + assert.NilError(t, cmd.Execute()) + assert.Check(t, !strings.Contains(cli.OutBuffer().String(), "WARNING!"), "output: %q", cli.OutBuffer()) +} diff --git a/cli/command/job/rm.go b/cli/command/job/rm.go new file mode 100644 index 000000000000..a0db703c38a9 --- /dev/null +++ b/cli/command/job/rm.go @@ -0,0 +1,55 @@ +package job + +import ( + "context" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// rmOptions holds the parsed flags of `docker job rm`. +type rmOptions struct { + job string + runs string +} + +// newRmCommand wires the `docker job rm [--runs ...] JOB` cobra command. +// client is injected explicitly, following the same pattern as +// newRunCommand (see run.go). +func newRmCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts rmOptions + + cmd := &cobra.Command{ + Use: "rm JOB", + Aliases: []string{"remove"}, + Short: "Remove a job", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + opts.job = args[0] + return runRm(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&opts.runs, "runs", "", `Run history retention: "keep", "remove", or "remove-finished" (default "keep")`) + return cmd +} + +// runRm removes opts.job via client.Remove. client.Remove has no reply +// message, so on success opts.job (the identifier passed by the caller) is +// printed on dockerCli.Out(), mirroring `docker volume rm`/`docker network +// rm`. +func runRm(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *rmOptions) error { + err := client.Remove(ctx, &jobsv0.RemoveRequest{JobRef: opts.job, RunsRemoval: opts.runs}) + if err != nil { + return wrapJobsError(err) + } + + _, _ = fmt.Fprintln(dockerCli.Out(), opts.job) + return nil +} diff --git a/cli/command/job/rm_test.go b/cli/command/job/rm_test.go new file mode 100644 index 000000000000..f227ca9b0f4e --- /dev/null +++ b/cli/command/job/rm_test.go @@ -0,0 +1,197 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// --runs is forwarded to jobsv0.RemoveRequest.RunsRemoval as a raw string, +// with no client-side mapping/enum: an unset flag sends an empty string, +// which the daemon defaults to "keep" (see jobsv0.RunsKeep and +// jobsv0.RemoveRequest.RunsRemoval in jobs.go). Validation of the value is +// left entirely to the daemon. +// +// Output convention choice: on success runRm prints opts.job (the job +// name/ID passed as the single positional argument) on dockerCli.Out(), +// mirroring `docker volume rm`/`docker network rm` (see +// cli/command/volume/remove.go and cli/command/network/remove.go), which +// both print the resource identifier as given by the caller via +// fmt.Fprintln(dockerCli.Out(), name) on a successful removal. + +func TestNewRmCommandForwardsJobRefWithoutRunsFlag(t *testing.T) { + var gotReq *jobsv0.RemoveRequest + client := &fakeClient{ + removeFunc: func(_ context.Context, req *jobsv0.RemoveRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Remove was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunsRemoval, "")) +} + +func TestNewRmCommandForwardsRunsFlag(t *testing.T) { + var gotReq *jobsv0.RemoveRequest + client := &fakeClient{ + removeFunc: func(_ context.Context, req *jobsv0.RemoveRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs([]string{"--runs", "remove", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Remove was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunsRemoval, "remove")) +} + +func TestNewRmCommandForwardsRunsFlagRawValue(t *testing.T) { + // The CLI performs no validation/mapping of --runs: an arbitrary string + // is forwarded as-is, leaving the daemon to reject invalid values. + var gotReq *jobsv0.RemoveRequest + client := &fakeClient{ + removeFunc: func(_ context.Context, req *jobsv0.RemoveRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs([]string{"--runs", "bogus-value", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Remove was not called") + assert.Check(t, is.Equal(gotReq.RunsRemoval, "bogus-value")) +} + +func TestNewRmCommandPrintsJobOnSuccess(t *testing.T) { + client := &fakeClient{ + removeFunc: func(context.Context, *jobsv0.RemoveRequest) error { + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "backup\n")) +} + +func TestNewRmCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewRmCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + removeFunc: func(context.Context, *jobsv0.RemoveRequest) error { + return status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewRmCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + removeFunc: func(context.Context, *jobsv0.RemoveRequest) error { + return errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRmCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, errText) +} + +// TestRunRmDirect exercises runRm directly (bypassing cobra arg parsing), +// following the pattern set by cancel_test.go/prune_test.go of testing the +// RunE body as a plain function in addition to going through the cobra +// command. +func TestRunRmDirect(t *testing.T) { + var gotReq *jobsv0.RemoveRequest + client := &fakeClient{ + removeFunc: func(_ context.Context, req *jobsv0.RemoveRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + err := runRm(context.Background(), cli, client, &rmOptions{job: "backup", runs: jobsv0.RunsRemoveFinished}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunsRemoval, jobsv0.RunsRemoveFinished)) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "backup\n")) +} + +func TestRunRmDirectOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + removeFunc: func(context.Context, *jobsv0.RemoveRequest) error { + return errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + err := runRm(context.Background(), cli, client, &rmOptions{job: "backup"}) + + assert.ErrorContains(t, err, errText) + // Nothing should be printed on failure. + assert.Check(t, is.Equal(cli.OutBuffer().String(), "")) +} + +// `docker container rm`, `volume rm` and `network rm` are all reachable as +// `remove`: keep the same spelling. +func TestNewRmCommandHasRemoveAlias(t *testing.T) { + cmd := newRmCommand(test.NewFakeCli(nil), &fakeClient{}) + + assert.Check(t, is.Contains(cmd.Aliases, "remove")) +} diff --git a/cli/command/job/run.go b/cli/command/job/run.go new file mode 100644 index 000000000000..c4e6720d14e8 --- /dev/null +++ b/cli/command/job/run.go @@ -0,0 +1,53 @@ +package job + +import ( + "context" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// runOptions holds the parsed flags/args of `docker job run`. +type runOptions struct { + job string + reschedule bool +} + +// newRunCommand wires the `docker job run [--reschedule] JOB` cobra command. +// client is injected explicitly, following the same pattern as +// newListCommand/newLogsCommand (see list.go/logs.go). +func newRunCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts runOptions + + cmd := &cobra.Command{ + Use: "run [OPTIONS] JOB", + Short: "Run a job", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + opts.job = args[0] + return runRun(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.BoolVar(&opts.reschedule, "reschedule", false, "Reschedule the job's next occurrence from this run") + return cmd +} + +// runRun triggers a run of opts.job via client.Run, printing the created +// run's ID on success -- the same convention as `docker container commit` +// (see cli/command/container/commit.go). +func runRun(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *runOptions) error { + reply, err := client.Run(ctx, &jobsv0.RunRequest{JobRef: opts.job, Reschedule: opts.reschedule}) + if err != nil { + return wrapJobsError(err) + } + + _, _ = fmt.Fprintln(dockerCli.Out(), reply.Run.ID) + return nil +} diff --git a/cli/command/job/run_test.go b/cli/command/job/run_test.go new file mode 100644 index 000000000000..57cf26984eb0 --- /dev/null +++ b/cli/command/job/run_test.go @@ -0,0 +1,153 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +func TestNewRunCommandForwardsJobRefAndDefaultsRescheduleFalse(t *testing.T) { + var gotReq *jobsv0.RunRequest + client := &fakeClient{ + runFunc: func(_ context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + gotReq = req + return &jobsv0.RunReply{Run: &jobsv0.Run{ID: "run-1"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Run was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.Reschedule, false)) +} + +func TestNewRunCommandRescheduleFlagForwarded(t *testing.T) { + var gotReq *jobsv0.RunRequest + client := &fakeClient{ + runFunc: func(_ context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + gotReq = req + return &jobsv0.RunReply{Run: &jobsv0.Run{ID: "run-1"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunCommand(cli, client) + cmd.SetArgs([]string{"--reschedule", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Run was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.Reschedule, true)) +} + +func TestNewRunCommandPrintsCreatedRunID(t *testing.T) { + client := &fakeClient{ + runFunc: func(context.Context, *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + return &jobsv0.RunReply{Run: &jobsv0.Run{ID: "run-42"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + // Convention: print only the created resource's ID, one line, nothing + // else -- same as `docker container commit` (see + // cli/command/container/commit.go) and `docker run`'s container ID. + assert.Check(t, is.Equal(cli.OutBuffer().String(), "run-42\n")) +} + +func TestNewRunCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newRunCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewRunCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + runFunc: func(context.Context, *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewRunCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + testCases := []struct { + doc string + errText string + }{ + {doc: "job not found", errText: `job "backup" not found`}, + {doc: "reschedule rejected for a job without a schedule trigger", errText: "reschedule is not supported for jobs without a schedule trigger"}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + client := &fakeClient{ + runFunc: func(context.Context, *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + return nil, errors.New(tc.errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newRunCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, tc.errText) + }) + } +} + +// TestRunRunDirect exercises runRun directly (bypassing cobra arg parsing), +// following the pattern set by list.go/logs.go of testing the RunE body as a +// plain function in addition to going through the cobra command. +func TestRunRunDirect(t *testing.T) { + var gotReq *jobsv0.RunRequest + client := &fakeClient{ + runFunc: func(_ context.Context, req *jobsv0.RunRequest) (*jobsv0.RunReply, error) { + gotReq = req + return &jobsv0.RunReply{Run: &jobsv0.Run{ID: "run-7"}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runRun(context.Background(), cli, client, &runOptions{job: "backup", reschedule: true}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.Reschedule, true)) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "run-7\n")) +} diff --git a/cli/command/job/unpause.go b/cli/command/job/unpause.go new file mode 100644 index 000000000000..30f49075291e --- /dev/null +++ b/cli/command/job/unpause.go @@ -0,0 +1,41 @@ +package job + +import ( + "context" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// newUnpauseCommand wires the `docker job unpause JOB` cobra command. client is +// injected explicitly, following the same pattern as newRunCommand (see +// run.go). +func newUnpauseCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + cmd := &cobra.Command{ + Use: "unpause JOB", + Short: "Re-arm a paused job's schedule trigger", + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return runUnpause(cmd.Context(), dockerCli, client, args[0]) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + return cmd +} + +// runUnpause unpauses jobRef via client.Resume. client.Resume has no reply +// message, so on success jobRef is printed on dockerCli.Out(), mirroring +// runRm (see rm.go) and `docker volume rm`/`docker network rm`. +func runUnpause(ctx context.Context, dockerCli command.Cli, client jobsClient, jobRef string) error { + err := client.Resume(ctx, &jobsv0.ResumeRequest{JobRef: jobRef}) + if err != nil { + return wrapJobsError(err) + } + + _, _ = fmt.Fprintln(dockerCli.Out(), jobRef) + return nil +} diff --git a/cli/command/job/unpause_test.go b/cli/command/job/unpause_test.go new file mode 100644 index 000000000000..a6371ecdfd82 --- /dev/null +++ b/cli/command/job/unpause_test.go @@ -0,0 +1,140 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// Output convention choice: client.Resume has no reply message (like +// client.Remove), so on success runUnpause prints jobRef (the job name/ID +// passed as the single positional argument) on dockerCli.Out(), mirroring +// runRm (see rm.go) and `docker volume rm`/`docker network rm`. + +func TestNewUnpauseCommandForwardsJobRef(t *testing.T) { + var gotReq *jobsv0.ResumeRequest + client := &fakeClient{ + resumeFunc: func(_ context.Context, req *jobsv0.ResumeRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newUnpauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Resume was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) +} + +func TestNewUnpauseCommandPrintsJobOnSuccess(t *testing.T) { + client := &fakeClient{ + resumeFunc: func(context.Context, *jobsv0.ResumeRequest) error { + return nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newUnpauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "backup\n")) +} + +func TestNewUnpauseCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newUnpauseCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewUnpauseCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + resumeFunc: func(context.Context, *jobsv0.ResumeRequest) error { + return status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newUnpauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + // The raw gRPC status dump must not leak to the user. + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewUnpauseCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + resumeFunc: func(context.Context, *jobsv0.ResumeRequest) error { + return errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newUnpauseCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, errText) +} + +// TestRunUnpauseDirect exercises runUnpause directly (bypassing cobra arg +// parsing), following the pattern set by cancel_test.go/rm_test.go of +// testing the RunE body as a plain function in addition to going through the +// cobra command. +func TestRunUnpauseDirect(t *testing.T) { + var gotReq *jobsv0.ResumeRequest + client := &fakeClient{ + resumeFunc: func(_ context.Context, req *jobsv0.ResumeRequest) error { + gotReq = req + return nil + }, + } + cli := test.NewFakeCli(nil) + + err := runUnpause(context.Background(), cli, client, "backup") + + assert.NilError(t, err) + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "backup\n")) +} + +func TestRunUnpauseDirectOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + resumeFunc: func(context.Context, *jobsv0.ResumeRequest) error { + return errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + err := runUnpause(context.Background(), cli, client, "backup") + + assert.ErrorContains(t, err, errText) + // Nothing should be printed on failure. + assert.Check(t, is.Equal(cli.OutBuffer().String(), "")) +} From f0c310ef586daccb2939d5931904643cd9279689 Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Tue, 10 Nov 2026 10:22:03 +0100 Subject: [PATCH 4/5] cli/command/job: add `docker job wait` command `wait [--run RUN] [--condition terminal|running] JOB` blocks until a run reaches the condition and exits with the run's exit code, so it can be used in scripts. Without --run the latest run is awaited, which for a schedule job that has not run yet means blocking until its next fire. A run stopped by a timeout fails with status 124, and one stopped by `docker job cancel` with status 130, whatever exit code its container reacted with, and its state is printed on stderr. These are the statuses `docker compose run` exits with for the same run (timeout(1) and the SIGINT convention), so that a script can tell them from a job that failed with `exit 1`. With `--condition running` the run ID is printed once the run is up. `logs` uses Wait for the window between the creation of a run and the start of its container: when the latest run is pending, it waits for the run to leave pending instead of showing an older run, or failing for a job that never ran before. The note it prints when it shows another run than the latest one now gives the state and the age of both runs, and says when the latest run succeeded and its container was removed (the normal case of a job that removes its container on success), so that the output of an older failed run is not taken for the state of the job. Signed-off-by: Guillaume Lours --- cli/command/job/client.go | 4 + cli/command/job/client_test.go | 8 + cli/command/job/cmd.go | 9 + cli/command/job/logs.go | 47 ++++- cli/command/job/logs_test.go | 129 ++++++++++++++ cli/command/job/wait.go | 107 +++++++++++ cli/command/job/wait_test.go | 316 +++++++++++++++++++++++++++++++++ 7 files changed, 619 insertions(+), 1 deletion(-) create mode 100644 cli/command/job/wait.go create mode 100644 cli/command/job/wait_test.go diff --git a/cli/command/job/client.go b/cli/command/job/client.go index 77459b93840d..84706603f248 100644 --- a/cli/command/job/client.go +++ b/cli/command/job/client.go @@ -48,6 +48,10 @@ type jobsClient interface { // no reply message. Remove(ctx context.Context, req *jobsv0.RemoveRequest) error + // Wait blocks until a run reaches the requested condition and returns + // that run. + Wait(ctx context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) + // Pause suppresses a job's schedule trigger. Like Remove, it returns // only an error: jobsv0.Jobs.Pause has no reply message. Pause(ctx context.Context, req *jobsv0.PauseRequest) error diff --git a/cli/command/job/client_test.go b/cli/command/job/client_test.go index 1cbf581ec805..f1db1d41a633 100644 --- a/cli/command/job/client_test.go +++ b/cli/command/job/client_test.go @@ -31,6 +31,7 @@ type fakeClient struct { cancelFunc func(ctx context.Context, req *jobsv0.CancelRequest) (*jobsv0.CancelReply, error) pruneFunc func(ctx context.Context, req *jobsv0.PruneRequest) (*jobsv0.PruneReply, error) removeFunc func(ctx context.Context, req *jobsv0.RemoveRequest) error + waitFunc func(ctx context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) pauseFunc func(ctx context.Context, req *jobsv0.PauseRequest) error resumeFunc func(ctx context.Context, req *jobsv0.ResumeRequest) error } @@ -91,6 +92,13 @@ func (c *fakeClient) Remove(ctx context.Context, req *jobsv0.RemoveRequest) erro return nil } +func (c *fakeClient) Wait(ctx context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + if c.waitFunc != nil { + return c.waitFunc(ctx, req) + } + return &jobsv0.WaitReply{}, nil +} + func (c *fakeClient) Pause(ctx context.Context, req *jobsv0.PauseRequest) error { if c.pauseFunc != nil { return c.pauseFunc(ctx, req) diff --git a/cli/command/job/cmd.go b/cli/command/job/cmd.go index c5aa86e654ca..640fc5691e44 100644 --- a/cli/command/job/cmd.go +++ b/cli/command/job/cmd.go @@ -40,6 +40,7 @@ func newJobCommand(dockerCli command.Cli) *cobra.Command { newCancelCommand(dockerCli, jobs), newPruneCommand(dockerCli, jobs), newRmCommand(dockerCli, jobs), + newWaitCommand(dockerCli, jobs), newPauseCommand(dockerCli, jobs), newUnpauseCommand(dockerCli, jobs), ) @@ -153,6 +154,14 @@ func (c *lazyJobsClient) Remove(ctx context.Context, req *jobsv0.RemoveRequest) return client.Remove(ctx, req) } +func (c *lazyJobsClient) Wait(ctx context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + client, err := c.resolve() + if err != nil { + return nil, err + } + return client.Wait(ctx, req) +} + func (c *lazyJobsClient) Pause(ctx context.Context, req *jobsv0.PauseRequest) error { client, err := c.resolve() if err != nil { diff --git a/cli/command/job/logs.go b/cli/command/job/logs.go index 9eab4cbbeb5e..704c9ee46713 100644 --- a/cli/command/job/logs.go +++ b/cli/command/job/logs.go @@ -10,6 +10,7 @@ import ( "github.com/containerd/errdefs" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" + "github.com/docker/go-units" "github.com/moby/moby/api/pkg/stdcopy" dockerclient "github.com/moby/moby/client" jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" @@ -72,6 +73,23 @@ func runLogs(ctx context.Context, dockerCli command.Cli, client jobsClient, opts return wrapJobsError(err) } + // A run is visible before its container is created: right after + // `docker job run`, the latest run is pending. Wait for it to leave + // pending, like `docker compose run` does, rather than falling back to an + // older run, or failing for a job that never ran before. The run is + // waited for by ID, as another run may become the latest in the meantime. + if job.LatestRun != nil && job.LatestRun.State == jobsv0.RunStatePending { + reply, err := client.Wait(ctx, &jobsv0.WaitRequest{ + JobRef: opts.job, + RunRef: job.LatestRun.ID, + Condition: jobsv0.WaitConditionRunning, + }) + if err != nil { + return wrapJobsError(err) + } + job.LatestRun = reply.Run + } + run, err := resolveLogsRun(job, func() (*jobsv0.ListRunsReply, error) { return client.ListRuns(ctx, &jobsv0.ListRunsRequest{JobRef: opts.job}) }) @@ -79,7 +97,7 @@ func runLogs(ctx context.Context, dockerCli command.Cli, client jobsClient, opts return wrapJobsError(err) } if run.ID != job.LatestRun.ID { - _, _ = fmt.Fprintf(dockerCli.Err(), "Note: the container of the latest run %s is not available; showing the logs of run %s\n", job.LatestRun.ID, run.ID) + _, _ = fmt.Fprint(dockerCli.Err(), fallbackNote(job.LatestRun, run, time.Now())) } // Only a schedule job can produce a next run on its own. @@ -102,6 +120,33 @@ func runLogs(ctx context.Context, dockerCli command.Cli, client jobsClient, opts } } +// fallbackNote tells why the logs shown are those of run shown rather than of +// the latest run, with the state and the age of both. A latest run that +// succeeded and lost its container is the normal case of a job registered +// with RemoveOnSuccess: the note says so first, as the output of an older +// failed run, shown without it, reads like the job is failing. +func fallbackNote(latest, shown *jobsv0.Run, now time.Time) string { + if latest.State == jobsv0.RunStateSucceeded && latest.ContainerGone { + return fmt.Sprintf("Note: the latest run %s %s and its container was removed, so its output is gone.\nShowing the logs of run %s (%s):\n", + latest.ID, runStateAge(latest, now, " "), shown.ID, runStateAge(shown, now, ", ")) + } + return fmt.Sprintf("Note: the container of the latest run %s (%s) is not available; showing the logs of run %s (%s)\n", + latest.ID, runStateAge(latest, now, ", "), shown.ID, runStateAge(shown, now, ", ")) +} + +// runStateAge describes run as its state, followed by sep and how long ago it +// ended (or, when it has not, was created), when the daemon recorded the time. +func runStateAge(run *jobsv0.Run, now time.Time, sep string) string { + at := run.FinishedAtNano + if at == 0 { + at = run.CreatedAtNano + } + if at == 0 { + return run.State + } + return run.State + sep + units.HumanDuration(now.Sub(time.Unix(0, at))) + " ago" +} + // streamRunLogs attaches to containerID's logs and demultiplexes them onto // dockerCli.Out()/dockerCli.Err(), following the pattern of // cli/command/container/logs.go's runLogs. It returns nil once the log diff --git a/cli/command/job/logs_test.go b/cli/command/job/logs_test.go index 5ca04dd1d1cb..0c6414512729 100644 --- a/cli/command/job/logs_test.go +++ b/cli/command/job/logs_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/docker/cli/internal/test" + "github.com/docker/go-units" "github.com/moby/moby/api/types/container" dockerclient "github.com/moby/moby/client" jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" @@ -314,3 +315,131 @@ func TestNewLogsCommandNotesFallbackToOlderRun(t *testing.T) { }) } } + +// A run is visible before its container is created. Right after `docker job +// run`, the latest run is pending: logs waits for it to leave pending, like +// `docker compose run` does, instead of falling back to an older run or +// failing for a job that never ran before. +func TestNewLogsCommandWaitsForPendingLatestRun(t *testing.T) { + var gotWait *jobsv0.WaitRequest + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-1", State: jobsv0.RunStatePending}, + }}, nil + }, + waitFunc: func(_ context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + gotWait = req + return &jobsv0.WaitReply{Run: &jobsv0.Run{ID: "run-1", State: jobsv0.RunStateRunning, ContainerID: "abc123"}}, nil + }, + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + t.Fatal("ListRuns must not be called when the pending run gets a container") + return nil, nil + }, + } + var gotContainerID string + docker := &fakeDockerAPIClient{ + inspectFunc: func(containerID string) (dockerclient.ContainerInspectResult, error) { + gotContainerID = containerID + return ttyInspectResult(), nil + }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done"), nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Assert(t, gotWait != nil, "client.Wait was not called") + assert.Check(t, is.Equal(gotWait.JobRef, "backup")) + assert.Check(t, is.Equal(gotWait.RunRef, "run-1"), "must wait for the pending run itself, not for whatever is the latest by then") + assert.Check(t, is.Equal(gotWait.Condition, jobsv0.WaitConditionRunning)) + assert.Check(t, is.Equal(gotContainerID, "abc123")) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done")) + assert.Check(t, is.Equal(cli.ErrBuffer().String(), "")) +} + +// A pending run whose container creation fails goes straight to failed, with +// no container: logs then falls back to the history, like for any other run +// without a container. +func TestNewLogsCommandPendingRunThatFailsToStartFallsBack(t *testing.T) { + failed := jobsv0.Run{ID: "run-2", State: jobsv0.RunStateFailed, Error: "no such image"} + jobs := &fakeClient{ + inspectFunc: func(context.Context, *jobsv0.InspectRequest) (*jobsv0.InspectReply, error) { + return &jobsv0.InspectReply{Job: &jobsv0.Job{ + Name: "backup", + LatestRun: &jobsv0.Run{ID: "run-2", State: jobsv0.RunStatePending}, + }}, nil + }, + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{Run: &failed}, nil + }, + listRunsFunc: func(context.Context, *jobsv0.ListRunsRequest) (*jobsv0.ListRunsReply, error) { + return &jobsv0.ListRunsReply{Runs: []jobsv0.Run{failed, {ID: "run-1", State: jobsv0.RunStateSucceeded, ContainerID: "abc123"}}}, nil + }, + } + docker := &fakeDockerAPIClient{ + inspectFunc: func(string) (dockerclient.ContainerInspectResult, error) { return ttyInspectResult(), nil }, + logFunc: func(string, dockerclient.ContainerLogsOptions) (dockerclient.ContainerLogsResult, error) { + return mockJobContainerLogsResult("[backup] done"), nil + }, + } + cli := test.NewFakeCli(docker) + + cmd := newLogsCommand(cli, jobs) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "[backup] done")) + assert.Check(t, is.Contains(cli.ErrBuffer().String(), "run-2 (failed")) + assert.Check(t, is.Contains(cli.ErrBuffer().String(), "run-1 (succeeded")) +} + +// The note on stderr tells why the logs are not the latest run's, with the +// state and the age of both runs. When the latest run succeeded and its +// container was removed (a job registered with RemoveOnSuccess), it says so +// first: showing the output of an older failed run without it reads like the +// job is failing. +func TestFallbackNote(t *testing.T) { + now := time.Unix(1_700_000_000, 0) + ago := func(d time.Duration) int64 { return now.Add(-d).UnixNano() } + human := units.HumanDuration + + testCases := []struct { + doc string + latest jobsv0.Run + shown jobsv0.Run + want string + }{ + { + doc: "latest run succeeded and its container was removed", + latest: jobsv0.Run{ID: "run-3", State: jobsv0.RunStateSucceeded, ContainerGone: true, CreatedAtNano: ago(2*time.Hour + time.Minute), FinishedAtNano: ago(2 * time.Hour)}, + shown: jobsv0.Run{ID: "run-2", State: jobsv0.RunStateFailed, ContainerID: "abc123", FinishedAtNano: ago(3 * time.Hour)}, + want: "Note: the latest run run-3 succeeded " + human(2*time.Hour) + " ago and its container was removed, so its output is gone.\n" + + "Showing the logs of run run-2 (failed, " + human(3*time.Hour) + " ago):\n", + }, + { + doc: "latest run failed and its container is not available", + latest: jobsv0.Run{ID: "run-3", State: jobsv0.RunStateFailed, CreatedAtNano: ago(5 * time.Minute)}, + shown: jobsv0.Run{ID: "run-2", State: jobsv0.RunStateSucceeded, ContainerID: "abc123", FinishedAtNano: ago(time.Hour)}, + want: "Note: the container of the latest run run-3 (failed, " + human(5*time.Minute) + " ago) is not available; " + + "showing the logs of run run-2 (succeeded, " + human(time.Hour) + " ago)\n", + }, + { + doc: "runs without timestamps", + latest: jobsv0.Run{ID: "run-3", State: jobsv0.RunStateCancelled}, + shown: jobsv0.Run{ID: "run-2", State: jobsv0.RunStateFailed, ContainerID: "abc123"}, + want: "Note: the container of the latest run run-3 (cancelled) is not available; showing the logs of run run-2 (failed)\n", + }, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + assert.Check(t, is.Equal(fallbackNote(&tc.latest, &tc.shown, now), tc.want)) + }) + } +} diff --git a/cli/command/job/wait.go b/cli/command/job/wait.go new file mode 100644 index 000000000000..812f60f82e0c --- /dev/null +++ b/cli/command/job/wait.go @@ -0,0 +1,107 @@ +package job + +import ( + "context" + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "github.com/spf13/cobra" +) + +// Exit statuses of a run stopped by the daemon, the same as `docker compose +// run` gives for the same run: 124 follows timeout(1), 130 the SIGINT +// convention. A script can then tell them apart from a job that failed with +// `exit 1`, without parsing stderr. +const ( + exitStatusTimedOut = 124 + exitStatusCancelled = 130 +) + +// waitOptions holds the parsed flags/args of `docker job wait`. +type waitOptions struct { + job string + run string + condition string +} + +// newWaitCommand wires the `docker job wait [OPTIONS] JOB` cobra command. +// client is injected explicitly, following the same pattern as +// newCancelCommand (see cancel.go). An empty --run or --condition defers to +// the daemon's defaults ("latest"/"terminal"). +func newWaitCommand(dockerCli command.Cli, client jobsClient) *cobra.Command { + var opts waitOptions + + cmd := &cobra.Command{ + Use: "wait [OPTIONS] JOB", + Short: "Block until a job's run reaches a terminal state", + Long: `Block until a run of a job reaches a terminal state, then exit with the run's exit code. + +The job must exist: names of removed jobs do not resolve. Without --run, the +latest run is awaited; for a schedule job that has not run yet, that means +blocking until its next scheduled fire. + +A run stopped by a timeout makes the command fail with status 124, and one +stopped by "docker job cancel" with status 130, whatever the exit code of its +container. A run whose container never started fails with status 1. + +With --condition running, the ID of the run is printed once it is running. A +run that already finished is reported as usual, by its exit code, so scripts +capturing the output must check which one they got.`, + Args: cli.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + opts.job = args[0] + return runWait(cmd.Context(), dockerCli, client, &opts) + }, + ValidArgsFunction: cobra.NoFileCompletions, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&opts.run, "run", "", `Run to wait for: a run ID, or "latest" (default "latest")`) + flags.StringVar(&opts.condition, "condition", "", `Condition to wait for: "terminal" or "running", i.e. the run left pending (default "terminal")`) + return cmd +} + +// runWait blocks until opts.job's run reaches opts.condition via client.Wait. +// A finished run's exit code is printed on dockerCli.Out() and mirrored into +// the process exit status via cli.StatusError, like cli/command/container/ +// attach.go's getExitStatus (a zero exit code returns nil). A running run (the +// "running" condition) has no exit code yet: its ID is printed instead, like +// `docker job run`. A run stopped by a timeout or a cancellation fails with +// status 124 or 130, and one whose container never started with status 1, +// with the reason on dockerCli.Err(): an exit code, when any, is the +// container's reaction to being stopped, not the job's outcome. +func runWait(ctx context.Context, dockerCli command.Cli, client jobsClient, opts *waitOptions) error { + reply, err := client.Wait(ctx, &jobsv0.WaitRequest{JobRef: opts.job, RunRef: opts.run, Condition: opts.condition}) + if err != nil { + return wrapJobsError(err) + } + + run := reply.Run + switch { + case run.State == jobsv0.RunStateRunning: + _, _ = fmt.Fprintln(dockerCli.Out(), run.ID) + return nil + case run.State == jobsv0.RunStateTimedOut: + _, _ = fmt.Fprintf(dockerCli.Err(), "run %s\n", run.State) + return cli.StatusError{StatusCode: exitStatusTimedOut} + case run.State == jobsv0.RunStateCancelled: + _, _ = fmt.Fprintf(dockerCli.Err(), "run %s\n", run.State) + return cli.StatusError{StatusCode: exitStatusCancelled} + case run.ExitCode == nil: + reason := run.Error + if reason == "" { + reason = run.State + } + _, _ = fmt.Fprintf(dockerCli.Err(), "run never started a container: %s\n", reason) + return cli.StatusError{StatusCode: 1} + } + + _, _ = fmt.Fprintln(dockerCli.Out(), run.ExitCode.Value) + if run.ExitCode.Value == 0 { + return nil + } + return cli.StatusError{StatusCode: int(run.ExitCode.Value)} +} diff --git a/cli/command/job/wait_test.go b/cli/command/job/wait_test.go new file mode 100644 index 000000000000..460a8bae06fe --- /dev/null +++ b/cli/command/job/wait_test.go @@ -0,0 +1,316 @@ +package job + +import ( + "context" + "errors" + "io" + "strings" + "testing" + + clipkg "github.com/docker/cli/cli" + "github.com/docker/cli/internal/test" + jobsv0 "github.com/moby/moby/extpoints/jobs/api/v0" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" +) + +// Unlike `docker container wait` (cli/command/container/wait.go), which only +// ever prints the exit code on stdout and never affects the CLI process's +// own exit status, `docker job wait` is meant to be scriptable +// (`docker job wait X && do-something`): the process must exit with the +// run's own exit code. That is done by returning cli.StatusError{StatusCode: +// N} from runWait, mirroring cli/command/container/attach.go's +// getExitStatus. As in that precedent, a zero exit code returns a nil error +// (not cli.StatusError{StatusCode: 0}), since StatusCode 0 combined with a +// non-nil error does not extract correctly (see the FIXME in +// cmd/docker/docker.go). + +func TestNewWaitCommandForwardsJobRef(t *testing.T) { + var gotReq *jobsv0.WaitRequest + client := &fakeClient{ + waitFunc: func(_ context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + gotReq = req + return &jobsv0.WaitReply{ + Run: &jobsv0.Run{ + State: jobsv0.RunStateSucceeded, + ExitCode: &jobsv0.ExitCode{Value: 0}, + }, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newWaitCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Wait was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunRef, "")) + assert.Check(t, is.Equal(gotReq.Condition, "")) +} + +func TestNewWaitCommandRequiresExactlyOneArg(t *testing.T) { + client := &fakeClient{} + cli := test.NewFakeCli(nil) + + cmd := newWaitCommand(cli, client) + cmd.SetArgs(nil) + cmd.SetOut(io.Discard) + cmd.SetErr(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, "requires 1 argument") +} + +func TestNewWaitCommandUnimplementedIsActionable(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return nil, status.Error(codes.Unimplemented, "unknown service jobsv0.Jobs") + }, + } + cli := test.NewFakeCli(nil) + + cmd := newWaitCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, `--extension-enable org.mobyproject.jobs.v0`) + assert.Check(t, !strings.Contains(err.Error(), "rpc error"), "error message leaks the raw gRPC status: %v", err) + assert.Check(t, !strings.Contains(err.Error(), "Unimplemented"), "error message leaks the raw gRPC code: %v", err) +} + +func TestNewWaitCommandOtherErrorsPassThroughUnwrapped(t *testing.T) { + errText := `job "backup" not found` + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return nil, errors.New(errText) + }, + } + cli := test.NewFakeCli(nil) + + cmd := newWaitCommand(cli, client) + cmd.SetArgs([]string{"backup"}) + cmd.SetOut(io.Discard) + err := cmd.Execute() + + assert.ErrorContains(t, err, errText) +} + +// TestRunWaitDirect* exercise runWait directly (bypassing cobra arg +// parsing), following the pattern set by cancel_test.go/run_test.go of +// testing the RunE body as a plain function in addition to going through the +// cobra command. + +func TestRunWaitDirectForwardsJobRefOnly(t *testing.T) { + var gotReq *jobsv0.WaitRequest + client := &fakeClient{ + waitFunc: func(_ context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + gotReq = req + return &jobsv0.WaitReply{ + Run: &jobsv0.Run{ + State: jobsv0.RunStateSucceeded, + ExitCode: &jobsv0.ExitCode{Value: 0}, + }, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup"}) + + assert.NilError(t, err) + assert.Check(t, gotReq != nil, "client.Wait was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunRef, "")) + assert.Check(t, is.Equal(gotReq.Condition, "")) +} + +func TestRunWaitExitCodeZeroPrintsZeroAndReturnsNil(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{ + Run: &jobsv0.Run{ + State: jobsv0.RunStateSucceeded, + ExitCode: &jobsv0.ExitCode{Value: 0}, + }, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup"}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "0\n")) + + var statusErr clipkg.StatusError + assert.Check(t, !errors.As(err, &statusErr), "runWait must not return cli.StatusError on a zero exit code") +} + +func TestRunWaitNonZeroExitCodePrintsCodeAndReturnsStatusError(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{ + Run: &jobsv0.Run{ + State: jobsv0.RunStateFailed, + ExitCode: &jobsv0.ExitCode{Value: 3}, + }, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup"}) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "3\n")) + + var statusErr clipkg.StatusError + assert.Check(t, errors.As(err, &statusErr), "expected a cli.StatusError, got %v", err) + assert.Check(t, is.Equal(statusErr.StatusCode, 3)) +} + +func TestRunWaitNoExitCodePrintsNoNumberAndReturnsGenericStatusError(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{ + Run: &jobsv0.Run{ + State: jobsv0.RunStateFailed, + Error: "failed to pull image", + }, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup"}) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), ""), "no exit code to print when the run never started a container") + assert.Check(t, strings.Contains(cli.ErrBuffer().String(), "failed to pull image"), "error message should surface Run.Error: %v", cli.ErrBuffer().String()) + + var statusErr clipkg.StatusError + assert.Check(t, errors.As(err, &statusErr), "expected a cli.StatusError, got %v", err) + assert.Check(t, is.Equal(statusErr.StatusCode, 1)) +} + +// TestRunWaitNoExitCodeAndNoErrorFallsBackToState covers a run that never +// started a container but also has no Run.Error -- e.g. cancelled while +// still pending (RunStateCancelled's godoc, unlike RunStatePending's, makes +// no promise that Error is set). The message must still be informative +// instead of ending in a bare, unexplained colon. +func TestRunWaitNoExitCodeAndNoErrorFallsBackToState(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{ + Run: &jobsv0.Run{ + State: jobsv0.RunStateCancelled, + Error: "", + }, + }, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup"}) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), ""), "no exit code to print when the run never started a container") + assert.Check(t, strings.Contains(cli.ErrBuffer().String(), jobsv0.RunStateCancelled), "error message should fall back to Run.State when Run.Error is empty: %v", cli.ErrBuffer().String()) + + var statusErr clipkg.StatusError + assert.Check(t, errors.As(err, &statusErr), "expected a cli.StatusError, got %v", err) + assert.Check(t, is.Equal(statusErr.StatusCode, 130)) +} + +func TestNewWaitCommandForwardsRunAndCondition(t *testing.T) { + var gotReq *jobsv0.WaitRequest + client := &fakeClient{ + waitFunc: func(_ context.Context, req *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + gotReq = req + return &jobsv0.WaitReply{Run: &jobsv0.Run{ID: "run-7", State: jobsv0.RunStateRunning}}, nil + }, + } + cli := test.NewFakeCli(nil) + + cmd := newWaitCommand(cli, client) + cmd.SetArgs([]string{"--run", "run-7", "--condition", "running", "backup"}) + assert.NilError(t, cmd.Execute()) + + assert.Check(t, gotReq != nil, "client.Wait was not called") + assert.Check(t, is.Equal(gotReq.JobRef, "backup")) + assert.Check(t, is.Equal(gotReq.RunRef, "run-7")) + assert.Check(t, is.Equal(gotReq.Condition, "running")) +} + +// With --condition running, a run that is up satisfies the wait: there is no +// exit code yet, so the run ID is printed (like `docker job run`) and the +// command succeeds. +func TestRunWaitConditionRunningPrintsRunID(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{Run: &jobsv0.Run{ID: "run-7", State: jobsv0.RunStateRunning}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup", condition: jobsv0.WaitConditionRunning}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "run-7\n")) +} + +// A run stopped by the daemon (timeout) or by Cancel carries the exit code of +// the container's last gasp -- 137, or even 0 when it handles SIGTERM. That +// must not be mistaken for the job's own success or failure: the process +// exits with 124 (timed out) or 130 (cancelled), like `docker compose run` +// does for the same run, following timeout(1) and the SIGINT convention. +func TestRunWaitTimedOutAndCancelledRunsFail(t *testing.T) { + testCases := []struct { + doc string + state string + exit int64 + status int + }{ + {doc: "timed out, killed", state: jobsv0.RunStateTimedOut, exit: 137, status: 124}, + {doc: "timed out, clean exit on SIGTERM", state: jobsv0.RunStateTimedOut, exit: 0, status: 124}, + {doc: "cancelled, clean exit on SIGTERM", state: jobsv0.RunStateCancelled, exit: 0, status: 130}, + } + + for _, tc := range testCases { + t.Run(tc.doc, func(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{Run: &jobsv0.Run{State: tc.state, ExitCode: &jobsv0.ExitCode{Value: tc.exit}}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup"}) + + assert.Check(t, is.Equal(cli.OutBuffer().String(), "")) + assert.Check(t, strings.Contains(cli.ErrBuffer().String(), tc.state), "stderr should name the state: %q", cli.ErrBuffer().String()) + var statusErr clipkg.StatusError + assert.Check(t, errors.As(err, &statusErr), "expected a cli.StatusError, got %v", err) + assert.Check(t, is.Equal(statusErr.StatusCode, tc.status)) + }) + } +} + +// With --condition running, a run that already finished still satisfies the +// wait (it jumped past the condition): it is reported like without the flag, +// with its exit code rather than its ID. +func TestRunWaitConditionRunningOnFinishedRunPrintsExitCode(t *testing.T) { + client := &fakeClient{ + waitFunc: func(context.Context, *jobsv0.WaitRequest) (*jobsv0.WaitReply, error) { + return &jobsv0.WaitReply{Run: &jobsv0.Run{ID: "run-7", State: jobsv0.RunStateSucceeded, ExitCode: &jobsv0.ExitCode{Value: 0}}}, nil + }, + } + cli := test.NewFakeCli(nil) + + err := runWait(context.Background(), cli, client, &waitOptions{job: "backup", condition: jobsv0.WaitConditionRunning}) + + assert.NilError(t, err) + assert.Check(t, is.Equal(cli.OutBuffer().String(), "0\n")) +} From c2fd0be530c1c1cfa26ae7b54aef9f64788d1190 Mon Sep 17 00:00:00 2001 From: Guillaume Lours Date: Tue, 10 Nov 2026 10:54:35 +0100 Subject: [PATCH 5/5] docs: generate markdown for the `docker job` commands Add the reference page of each `docker job` command and list the group in docker.md. Generated with `make mddocs`. Signed-off-by: Guillaume Lours --- docs/reference/commandline/docker.md | 1 + docs/reference/commandline/job.md | 28 +++++++++++++++++++++++ docs/reference/commandline/job_cancel.md | 8 +++++++ docs/reference/commandline/job_inspect.md | 14 ++++++++++++ docs/reference/commandline/job_logs.md | 14 ++++++++++++ docs/reference/commandline/job_ls.md | 12 ++++++++++ docs/reference/commandline/job_pause.md | 8 +++++++ docs/reference/commandline/job_prune.md | 15 ++++++++++++ docs/reference/commandline/job_rm.md | 18 +++++++++++++++ docs/reference/commandline/job_run.md | 14 ++++++++++++ docs/reference/commandline/job_runs.md | 15 ++++++++++++ docs/reference/commandline/job_unpause.md | 8 +++++++ docs/reference/commandline/job_wait.md | 27 ++++++++++++++++++++++ 13 files changed, 182 insertions(+) create mode 100644 docs/reference/commandline/job.md create mode 100644 docs/reference/commandline/job_cancel.md create mode 100644 docs/reference/commandline/job_inspect.md create mode 100644 docs/reference/commandline/job_logs.md create mode 100644 docs/reference/commandline/job_ls.md create mode 100644 docs/reference/commandline/job_pause.md create mode 100644 docs/reference/commandline/job_prune.md create mode 100644 docs/reference/commandline/job_rm.md create mode 100644 docs/reference/commandline/job_run.md create mode 100644 docs/reference/commandline/job_runs.md create mode 100644 docs/reference/commandline/job_unpause.md create mode 100644 docs/reference/commandline/job_wait.md diff --git a/docs/reference/commandline/docker.md b/docs/reference/commandline/docker.md index 73ef948beae2..81d44974028e 100644 --- a/docs/reference/commandline/docker.md +++ b/docs/reference/commandline/docker.md @@ -28,6 +28,7 @@ The base command for the Docker CLI. | [`import`](import.md) | Import the contents from a tarball to create a filesystem image | | [`info`](info.md) | Display system-wide information | | [`inspect`](inspect.md) | Return low-level information on Docker objects | +| [`job`](job.md) | Manage jobs | | [`kill`](kill.md) | Kill one or more running containers | | [`load`](load.md) | Load an image from a tar archive or STDIN | | [`login`](login.md) | Authenticate to a registry | diff --git a/docs/reference/commandline/job.md b/docs/reference/commandline/job.md new file mode 100644 index 000000000000..8f2c21191813 --- /dev/null +++ b/docs/reference/commandline/job.md @@ -0,0 +1,28 @@ +# docker job + + +Manage jobs, one-shot or scheduled containers run by the daemon. + +This requires the daemon's jobs extension, which is disabled by default: start +dockerd with --extension-enable org.mobyproject.jobs.v0. + +### Subcommands + +| Name | Description | +|:----------------------------|:-------------------------------------------------| +| [`cancel`](job_cancel.md) | Cancel a job's in-flight run | +| [`inspect`](job_inspect.md) | Display detailed information on a job | +| [`logs`](job_logs.md) | Fetch the logs of a job's most recent run | +| [`ls`](job_ls.md) | List jobs | +| [`pause`](job_pause.md) | Suppress a job's schedule trigger | +| [`prune`](job_prune.md) | Remove idle manual jobs | +| [`rm`](job_rm.md) | Remove a job | +| [`run`](job_run.md) | Run a job | +| [`runs`](job_runs.md) | List a job's runs | +| [`unpause`](job_unpause.md) | Re-arm a paused job's schedule trigger | +| [`wait`](job_wait.md) | Block until a job's run reaches a terminal state | + + + + + diff --git a/docs/reference/commandline/job_cancel.md b/docs/reference/commandline/job_cancel.md new file mode 100644 index 000000000000..a1336c6beaa3 --- /dev/null +++ b/docs/reference/commandline/job_cancel.md @@ -0,0 +1,8 @@ +# docker job cancel + + +Cancel a job's in-flight run + + + + diff --git a/docs/reference/commandline/job_inspect.md b/docs/reference/commandline/job_inspect.md new file mode 100644 index 000000000000..ba46c80de851 --- /dev/null +++ b/docs/reference/commandline/job_inspect.md @@ -0,0 +1,14 @@ +# docker job inspect + + +Display detailed information on a job + +### Options + +| Name | Type | Default | Description | +|:--------|:---------|:--------|:------------------------------------------| +| `--run` | `string` | | Inspect a specific run instead of the job | + + + + diff --git a/docs/reference/commandline/job_logs.md b/docs/reference/commandline/job_logs.md new file mode 100644 index 000000000000..c11bb0dbda2d --- /dev/null +++ b/docs/reference/commandline/job_logs.md @@ -0,0 +1,14 @@ +# docker job logs + + +Fetch the logs of a job's most recent run + +### Options + +| Name | Type | Default | Description | +|:-----------------|:-------|:--------|:------------------| +| `-f`, `--follow` | `bool` | | Follow log output | + + + + diff --git a/docs/reference/commandline/job_ls.md b/docs/reference/commandline/job_ls.md new file mode 100644 index 000000000000..2b143f8f7e0e --- /dev/null +++ b/docs/reference/commandline/job_ls.md @@ -0,0 +1,12 @@ +# docker job ls + + +List jobs + +### Aliases + +`docker job ls`, `docker job list` + + + + diff --git a/docs/reference/commandline/job_pause.md b/docs/reference/commandline/job_pause.md new file mode 100644 index 000000000000..ede9911c9861 --- /dev/null +++ b/docs/reference/commandline/job_pause.md @@ -0,0 +1,8 @@ +# docker job pause + + +Suppress a job's schedule trigger + + + + diff --git a/docs/reference/commandline/job_prune.md b/docs/reference/commandline/job_prune.md new file mode 100644 index 000000000000..6f924a4c580c --- /dev/null +++ b/docs/reference/commandline/job_prune.md @@ -0,0 +1,15 @@ +# docker job prune + + +Remove idle manual jobs + +### Options + +| Name | Type | Default | Description | +|:----------------|:--------------|:--------|:---------------------------------------------------------| +| `-f`, `--force` | `bool` | | Do not prompt for confirmation | +| `--label` | `stringArray` | | Only remove jobs matching a label (`key` or `key=value`) | + + + + diff --git a/docs/reference/commandline/job_rm.md b/docs/reference/commandline/job_rm.md new file mode 100644 index 000000000000..832cc3e96a6e --- /dev/null +++ b/docs/reference/commandline/job_rm.md @@ -0,0 +1,18 @@ +# docker job rm + + +Remove a job + +### Aliases + +`docker job rm`, `docker job remove` + +### Options + +| Name | Type | Default | Description | +|:---------|:---------|:--------|:-------------------------------------------------------------------------------| +| `--runs` | `string` | | Run history retention: `keep`, `remove`, or `remove-finished` (default `keep`) | + + + + diff --git a/docs/reference/commandline/job_run.md b/docs/reference/commandline/job_run.md new file mode 100644 index 000000000000..65ecadf9abf0 --- /dev/null +++ b/docs/reference/commandline/job_run.md @@ -0,0 +1,14 @@ +# docker job run + + +Run a job + +### Options + +| Name | Type | Default | Description | +|:---------------|:-------|:--------|:---------------------------------------------------| +| `--reschedule` | `bool` | | Reschedule the job's next occurrence from this run | + + + + diff --git a/docs/reference/commandline/job_runs.md b/docs/reference/commandline/job_runs.md new file mode 100644 index 000000000000..a4e78c47a783 --- /dev/null +++ b/docs/reference/commandline/job_runs.md @@ -0,0 +1,15 @@ +# docker job runs + + +List a job's runs + +### Options + +| Name | Type | Default | Description | +|:-----------|:---------|:--------|:---------------------------------------------------------------------| +| `--before` | `string` | | List runs older than this cursor (from a previous page's NextCursor) | +| `--limit` | `int32` | `0` | Maximum number of runs to list (0 for the daemon default) | + + + + diff --git a/docs/reference/commandline/job_unpause.md b/docs/reference/commandline/job_unpause.md new file mode 100644 index 000000000000..14fcc3f38028 --- /dev/null +++ b/docs/reference/commandline/job_unpause.md @@ -0,0 +1,8 @@ +# docker job unpause + + +Re-arm a paused job's schedule trigger + + + + diff --git a/docs/reference/commandline/job_wait.md b/docs/reference/commandline/job_wait.md new file mode 100644 index 000000000000..266b13b04a88 --- /dev/null +++ b/docs/reference/commandline/job_wait.md @@ -0,0 +1,27 @@ +# docker job wait + + +Block until a run of a job reaches a terminal state, then exit with the run's exit code. + +The job must exist: names of removed jobs do not resolve. Without --run, the +latest run is awaited; for a schedule job that has not run yet, that means +blocking until its next scheduled fire. + +A run stopped by a timeout makes the command fail with status 124, and one +stopped by "docker job cancel" with status 130, whatever the exit code of its +container. A run whose container never started fails with status 1. + +With --condition running, the ID of the run is printed once it is running. A +run that already finished is reported as usual, by its exit code, so scripts +capturing the output must check which one they got. + +### Options + +| Name | Type | Default | Description | +|:--------------|:---------|:--------|:-----------------------------------------------------------------------------------------------| +| `--condition` | `string` | | Condition to wait for: `terminal` or `running`, i.e. the run left pending (default `terminal`) | +| `--run` | `string` | | Run to wait for: a run ID, or `latest` (default `latest`) | + + + +