Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 1 | // 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 | |
| 17 | syntax = "proto3"; |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 18 | package metropolis.proto.api; |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 19 | option go_package = "git.monogon.dev/source/nexantic.git/metropolis/proto/api"; |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 20 | |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 21 | import "metropolis/proto/api/enrolment.proto"; |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 22 | |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 23 | // NodeDebugService exposes debug and testing endpoints that allow introspection into a running Metropolis node. |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 24 | // It is not authenticated and will be disabled in production. It is currently consumed by metropolis/cli/dbg and |
| 25 | // by tests. |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 26 | service NodeDebugService { |
| 27 | // GetDebugKubeconfig issues kubeconfigs with arbitrary identities and groups for debugging |
| 28 | rpc GetDebugKubeconfig(GetDebugKubeconfigRequest) returns (GetDebugKubeconfigResponse); |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 29 | |
| 30 | // GetLogs Returns historical and/or streaming logs for a given DN with given filters from the system global |
| 31 | // LogTree. |
| 32 | // |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 33 | // For more information about this API, see //metropolis/node/core/logtree. But, in summary: |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 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 |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 36 | // process) or leveled (emitted by Metropolis code with a source line, timestamp, and severity). |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 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 |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 40 | // a running Metropolis node, or request all logs (at DN ""). |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 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 Bazanski | 57b4375 | 2020-07-13 19:17:48 +0200 | [diff] [blame] | 45 | // 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 Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | |
| 51 | message GetDebugKubeconfigRequest { |
| 52 | string id = 1; // Kubernetes identity (user) |
| 53 | repeated string groups = 2; // Kubernetes groups |
| 54 | } |
| 55 | |
| 56 | message GetDebugKubeconfigResponse { |
| 57 | string debug_kubeconfig = 1; |
| 58 | } |
| 59 | |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 60 | // Severity level corresponding to //metropolis/node/core/logtree.Severity. |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 61 | enum LeveledLogSeverity { |
| 62 | INVALID = 0; |
| 63 | INFO = 1; |
| 64 | WARNING = 2; |
| 65 | ERROR = 3; |
| 66 | FATAL = 4; |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 67 | } |
| 68 | |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 69 | // 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. |
| 76 | message 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 | |
| 99 | message 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 | |
| 127 | message 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 | |
| 137 | message LogEntry { |
| 138 | message Leveled { |
Serge Bazanski | 12971d6 | 2020-11-17 12:12:58 +0100 | [diff] [blame] | 139 | repeated string lines = 1; |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 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 Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 154 | } |
Serge Bazanski | 57b4375 | 2020-07-13 19:17:48 +0200 | [diff] [blame] | 155 | |
| 156 | message GetGoldenTicketRequest { |
| 157 | // IP address at which the new node will run. |
| 158 | string external_ip = 1; |
| 159 | } |
| 160 | |
| 161 | message GetGoldenTicketResponse { |
| 162 | // Ticket to use in the new node's EnrolmentConfig. |
| 163 | GoldenTicket ticket = 1; |
| 164 | } |