blob: b0bbb57875add915af16bedf8eefe75838281062 [file] [log] [blame]
Serge Bazanskiefdb6e92020-07-13 17:19:27 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17syntax = "proto3";
18package smalltown.core.proto.api;
19option go_package = "git.monogon.dev/source/nexantic.git/core/proto/api";
20
21import "core/proto/api/enrolment.proto";
22
23// NodeDebugService exposes debug and testing endpoints that allow introspection into a running Smalltown instance.
24// It is not authenticated and will be disabled in production. It is currently consumed by core/cmd/dbg and
25// by tests. For exact documentation of the available parameters please look at core/internal/node/debug.go.
26service NodeDebugService {
27 // GetDebugKubeconfig issues kubeconfigs with arbitrary identities and groups for debugging
28 rpc GetDebugKubeconfig(GetDebugKubeconfigRequest) returns (GetDebugKubeconfigResponse);
Serge Bazanskib0272182020-11-02 18:39:44 +010029
30 // GetLogs Returns historical and/or streaming logs for a given DN with given filters from the system global
31 // LogTree.
32 //
33 // For more information about this API, see //core/pkg/logtree. But, in summary:
34 // - All logging is performed to a DN (distinguished name), which is a dot-delimited string like foo.bar.baz.
35 // - Log entries can be either raw (coming from unstructured logging from an external service, like a running
36 // process) or leveled (emitted by Smalltown code with a source line, timestamp, and severity).
37 // - The DNs form a tree of logging nodes - and when requesting logs, a given subtree of DNs can be requested,
38 // instead of just a given DN.
39 // - All supervised processes live at `root.<supervisor DN>`. For more example paths, see the console logs of
40 // a running Smalltown instance, or request all logs (at DN "").
41 //
42 // TODO(q3k): move method and its related messages to the non-debug node endpoint once we have one.
43 rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse);
44
Serge Bazanski57b43752020-07-13 19:17:48 +020045 // GetGoldenTicket requests a 'golden ticket' which can be used to enroll any node into the cluster.
46 // This bypasses integrity checks.
47 rpc GetGoldenTicket(GetGoldenTicketRequest) returns (GetGoldenTicketResponse);
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020048}
49
50
51message GetDebugKubeconfigRequest {
52 string id = 1; // Kubernetes identity (user)
53 repeated string groups = 2; // Kubernetes groups
54}
55
56message GetDebugKubeconfigResponse {
57 string debug_kubeconfig = 1;
58}
59
Serge Bazanskib0272182020-11-02 18:39:44 +010060// Severity level corresponding to //core/pkg/logtree.Severity.
61enum LeveledLogSeverity {
62 INVALID = 0;
63 INFO = 1;
64 WARNING = 2;
65 ERROR = 3;
66 FATAL = 4;
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020067}
68
Serge Bazanskib0272182020-11-02 18:39:44 +010069// Filter set when requesting logs for a given DN. This message is equivalent to the following GADT enum:
70// data LogFilter = WithChildren
71// | OnlyRaw
72// | OnlyLeveled
73// | LeveledWithMinimumSeverity(Severity)
74//
75// Multiple LogFilters can be chained/combined when requesting logs, as long as they do not conflict.
76message LogFilter {
77 // Entries will be returned not only for the given DN, but all child DNs as well. For instance, if the
78 // requested DN is foo, entries logged to foo, foo.bar and foo.bar.baz will all be returned.
79 message WithChildren {
80 }
81 // Only raw logging entries will be returned. Conflicts with OnlyLeveled filters.
82 message OnlyRaw {
83 }
84 // Only leveled logging entries will be returned. Conflicts with OnlyRaw filters.
85 message OnlyLeveled {
86 }
87 // If leveled logs are returned, all entries at severity lower than `minimum` will be discarded.
88 message LeveledWithMinimumSeverity {
89 LeveledLogSeverity minimum = 1;
90 }
91 oneof filter {
92 WithChildren with_children = 1;
93 OnlyRaw only_raw = 3;
94 OnlyLeveled only_leveled = 4;
95 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
96 }
97}
98
99message GetLogsRequest {
100 // DN from which to request logs. All supervised runnables live at `root.`, the init code lives at `init.`.
101 string dn = 1;
102 // Filters to apply to returned data.
103 repeated LogFilter filters = 2;
104
105 enum BacklogMode {
106 BACKLOG_INVALID = 0;
107 // No historic data will be returned.
108 BACKLOG_DISABLE = 1;
109 // All available historic data will be returned.
110 BACKLOG_ALL = 2;
111 // At most backlog_count entries will be returned, if available.
112 BACKLOG_COUNT = 3;
113 }
114 BacklogMode backlog_mode = 3;
115 int64 backlog_count = 4;
116
117 enum StreamMode {
118 STREAM_INVALID = 0;
119 // No streaming entries, gRPC stream will be closed as soon as all backlog data is served.
120 STREAM_DISABLE = 1;
121 // Entries will be streamed as early as available right after all backlog data is served.
122 STREAM_UNBUFFERED = 2;
123 }
124 StreamMode stream_mode = 5;
125}
126
127message GetLogsResponse {
128 // Entries from the requested historical entries (via WithBackLog). They will all be served before the first
129 // stream_entries are served (if any).
130 repeated LogEntry backlog_entries = 1;
131 // Entries streamed as they arrive. Currently no server-side buffering is enabled, instead every line is served
132 // as early as it arrives. However, this might change in the future, so this behaviour cannot be depended
133 // upon.
134 repeated LogEntry stream_entries = 2;
135}
136
137message LogEntry {
138 message Leveled {
139 string message = 1;
140 int64 timestamp = 2;
141 LeveledLogSeverity severity = 3;
142 string location = 4;
143 }
144 message Raw {
145 string data = 1;
146 int64 original_length = 2;
147 }
148
149 string dn = 1;
150 oneof kind {
151 Leveled leveled = 2;
152 Raw raw = 3;
153 }
Serge Bazanskiefdb6e92020-07-13 17:19:27 +0200154}
Serge Bazanski57b43752020-07-13 19:17:48 +0200155
156message GetGoldenTicketRequest {
157 // IP address at which the new node will run.
158 string external_ip = 1;
159}
160
161message GetGoldenTicketResponse {
162 // Ticket to use in the new node's EnrolmentConfig.
163 GoldenTicket ticket = 1;
164}