/
service.proto
540 lines (438 loc) · 21.9 KB
/
service.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
// Copyright 2024 The PipeCD 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.
syntax = "proto3";
package grpc.service.pipedservice;
option go_package = "github.com/pipe-cd/pipecd/pkg/app/server/service/pipedservice";
import "validate/validate.proto";
import "pkg/model/command.proto";
import "pkg/model/common.proto";
import "pkg/model/application.proto";
import "pkg/model/application_live_state.proto";
import "pkg/model/deployment.proto";
import "pkg/model/logblock.proto";
import "pkg/model/piped.proto";
import "pkg/model/event.proto";
import "pkg/model/analysis_result.proto";
// PipedService contains all RPC definitions for piped.
// All of these RPCs are only called by piped and authenticated by using PIPED_TOKEN.
service PipedService {
// ReportStat is periodically sent to report its realtime status/stats to control-plane.
// The received stats will be pushed to the metrics collector.
rpc ReportStat(ReportStatRequest) returns (ReportStatResponse) {}
// ReportPipedMeta is sent while starting up to report its metadata
// such as configured cloud providers.
rpc ReportPipedMeta(ReportPipedMetaRequest) returns (ReportPipedMetaResponse) {}
// ListApplications returns a list of registered applications
// that should be managed by the requested piped.
// Disabled applications should not be included in the response.
// Piped uses this RPC to fetch and sync the application configuration into its local database.
rpc ListApplications(ListApplicationsRequest) returns (ListApplicationsResponse) {}
// ReportApplicationSyncState is used to update the sync status of an application.
rpc ReportApplicationSyncState(ReportApplicationSyncStateRequest) returns (ReportApplicationSyncStateResponse) {}
// ReportApplicationDeployingStatus is used to report whether the specified application is deploying or not.
rpc ReportApplicationDeployingStatus(ReportApplicationDeployingStatusRequest) returns (ReportApplicationDeployingStatusResponse) {}
// ReportApplicationMostRecentDeployment is used to update the basic information about
// the most recent deployment of a specific application.
rpc ReportApplicationMostRecentDeployment(ReportApplicationMostRecentDeploymentRequest) returns (ReportApplicationMostRecentDeploymentResponse) {}
// GetApplicationMostRecentDeployment returns the most recent deployment of the given application.
rpc GetApplicationMostRecentDeployment(GetApplicationMostRecentDeploymentRequest) returns (GetApplicationMostRecentDeploymentResponse) {}
// GetDeployment returns the deployment for given deployment ID.
rpc GetDeployment(GetDeploymentRequest) returns (GetDeploymentResponse) {}
// ListNotCompletedDeployments returns a list of not completed deployments
// which are managed by this piped.
// DeploymentController component uses this RPC to spawns/syncs its local deployment executors.
rpc ListNotCompletedDeployments(ListNotCompletedDeploymentsRequest) returns (ListNotCompletedDeploymentsResponse) {}
// CreateDeployment creates/triggers a new deployment for an application
// that is managed by this piped.
// This will be used by DeploymentTrigger component.
rpc CreateDeployment(CreateDeploymentRequest) returns (CreateDeploymentResponse) {}
// ReportDeploymentPlanned is used to update the status
// of a specific deployment to PLANNED.
rpc ReportDeploymentPlanned(ReportDeploymentPlannedRequest) returns (ReportDeploymentPlannedResponse) {}
// ReportDeploymentStatusChanged is used to update the status
// of a specific deployment to RUNNING or ROLLING_BACK.
rpc ReportDeploymentStatusChanged(ReportDeploymentStatusChangedRequest) returns (ReportDeploymentStatusChangedResponse) {}
// ReportDeploymentCompleted is used to update the status
// of a specific deployment to SUCCESS | FAILURE | CANCELLED.
rpc ReportDeploymentCompleted(ReportDeploymentCompletedRequest) returns (ReportDeploymentCompletedResponse) {}
// SaveDeploymentMetadata is used to persist the metadata of a specific deployment.
// Different value for the same key will overwrite the previous value for that key.
rpc SaveDeploymentMetadata(SaveDeploymentMetadataRequest) returns (SaveDeploymentMetadataResponse) {}
// SaveStageMetadata is used to persist the metadata
// of a specific stage of a deployment.
// Different value for the same key will overwrite the previous value for that key.
rpc SaveStageMetadata(SaveStageMetadataRequest) returns (SaveStageMetadataResponse) {}
// ReportStageLogs is used to save the log of a pipeline stage.
rpc ReportStageLogs(ReportStageLogsRequest) returns (ReportStageLogsResponse) {}
// ReportStageLogsFromLastCheckpoint is used to save the full logs from the most recently saved point.
rpc ReportStageLogsFromLastCheckpoint(ReportStageLogsFromLastCheckpointRequest) returns (ReportStageLogsFromLastCheckpointResponse) {}
// ReportStageStatusChanged is used to update the status
// of a specific stage of a deployment.
rpc ReportStageStatusChanged(ReportStageStatusChangedRequest) returns (ReportStageStatusChangedResponse) {}
// ListUnhandledCommands is periodically called to obtain the commands
// that should be handled.
// Whenever an user makes an interaction from WebUI (cancel/approve/sync)
// a new command with a unique identifier will be generated an saved into the datastore.
// Piped uses this RPC to list all still-not-handled commands to handle them,
// then report back the result to server.
// On other side, the web will periodically check the command status and feedback the result to user.
// In the future, we may need a solution to remove all old-handled commands from datastore for space.
rpc ListUnhandledCommands(ListUnhandledCommandsRequest) returns (ListUnhandledCommandsResponse) {}
// ReportCommandHandled is called to mark a specific command as handled.
// The request payload will contain the handle status as well as any additional result data.
// The handle result should be updated to both datastore and cache (for reading from web).
rpc ReportCommandHandled(ReportCommandHandledRequest) returns (ReportCommandHandledResponse) {}
// ReportApplicationLiveState is periodically sent to correct full state of an application.
// For kubernetes application, this contains a full tree of its kubernetes resources.
// The tree data should be written into filestore immediately and then the state in cache should be refreshsed too.
rpc ReportApplicationLiveState(ReportApplicationLiveStateRequest) returns (ReportApplicationLiveStateResponse) {}
// ReportApplicationLiveStateEvents is sent to submit one or multiple events
// about the changes of application live state.
// Control plane uses the received events to update the state of application-resource-tree.
// We want to start by a simple solution at this initial stage of development,
// so the API server just handles as below:
// - loads the releated application-resource-tree from the cache
// - checks and builds new state for the application-resource-tree
// - updates new state into cache (cache data is for reading while handling web requests)
// In the future, we may want to redesign the behavior of this RPC by using pubsub/queue pattern.
// After receiving the events, all of them will be published into a queue immediately,
// and then another Handler service will pick them inorder to apply to build new state.
// By that way we can control the traffic to the datastore in a better way.
rpc ReportApplicationLiveStateEvents(ReportApplicationLiveStateEventsRequest) returns (ReportApplicationLiveStateEventsResponse) {}
// GetLatestEvent returns the latest event that meets the given conditions.
rpc GetLatestEvent(GetLatestEventRequest) returns (GetLatestEventResponse) {}
// ListEvents returns a list of Events inside the given range.
rpc ListEvents(ListEventsRequest) returns (ListEventsResponse) {}
// ReportEventHandled marks the given all events as handled.
// Deprecated. This is only for the old Piped agents.
rpc ReportEventsHandled(ReportEventsHandledRequest) returns (ReportEventsHandledResponse) {}
// ReportEventStatuses reports a status list of events.
rpc ReportEventStatuses(ReportEventStatusesRequest) returns (ReportEventStatusesResponse) {}
// GetLatestAnalysisResult returns the most successful analysis result.
rpc GetLatestAnalysisResult(GetLatestAnalysisResultRequest) returns (GetLatestAnalysisResultResponse) {}
// GetLatestAnalysisResult updates the most successful analysis result.
rpc PutLatestAnalysisResult(PutLatestAnalysisResultRequest) returns (PutLatestAnalysisResultResponse) {}
// GetDesiredVersion returns the desired version of the given Piped.
rpc GetDesiredVersion(GetDesiredVersionRequest) returns (GetDesiredVersionResponse) {}
// UpdateApplicationConfigurations updates application configurations.
rpc UpdateApplicationConfigurations(UpdateApplicationConfigurationsRequest) returns (UpdateApplicationConfigurationsResponse) {}
// ReportLatestUnusedApplicationConfigurations puts the latest configurations of applications that isn't registered yet.
rpc ReportUnregisteredApplicationConfigurations(ReportUnregisteredApplicationConfigurationsRequest) returns (ReportUnregisteredApplicationConfigurationsResponse) {}
// CreateDeploymentChain creates a new deployment chain object and all required commands to
// trigger deployment for applications in the chain.
rpc CreateDeploymentChain(CreateDeploymentChainRequest) returns (CreateDeploymentChainResponse) {}
// DeploymentPlannable checks the completion and status of the previous block in the deployment chain,
// only when all the nodes of the previous block are completed with a success status,
// the nodes of the next block will be treated as processable.
// In case the previous block of this deployment is finished with FAILURE | CANCELLED status,
// `cancel` flag will be returned to aware piped to stop this deployment.
rpc InChainDeploymentPlannable(InChainDeploymentPlannableRequest) returns (InChainDeploymentPlannableResponse) {}
}
enum ListOrder {
NONE = 0;
ASC = 1;
DESC = 2;
}
message ReportStatRequest {
// Metrics byte sequence in OpenMetrics format.
bytes piped_stats = 1;
}
message ReportStatResponse {
int64 report_interval = 1;
}
message ReportPipedMetaRequest {
string version = 1;
repeated model.Piped.CloudProvider cloud_providers = 2;
repeated model.Piped.PlatformProvider platform_providers = 6;
repeated model.ApplicationGitRepository repositories = 3;
model.Piped.SecretEncryption secret_encryption = 4;
string config = 5;
}
message ReportPipedMetaResponse {
string name = 1 [(validate.rules).string.min_len = 1];
string web_base_url = 2;
}
message ListApplicationsRequest {
}
message ListApplicationsResponse {
repeated model.Application applications = 1;
}
message ReportApplicationSyncStateRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
model.ApplicationSyncState state = 2 [(validate.rules).message.required = true];
}
message ReportApplicationSyncStateResponse {
}
message ReportApplicationDeployingStatusRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
bool deploying = 2;
}
message ReportApplicationDeployingStatusResponse {
}
message ReportApplicationMostRecentDeploymentRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
model.DeploymentStatus status = 2 [(validate.rules).enum.defined_only = true];
model.ApplicationDeploymentReference deployment = 3 [(validate.rules).message.required = true];
}
message ReportApplicationMostRecentDeploymentResponse {
}
message GetApplicationMostRecentDeploymentRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
model.DeploymentStatus status = 2 [(validate.rules).enum.defined_only = true];
}
message GetApplicationMostRecentDeploymentResponse {
model.ApplicationDeploymentReference deployment = 1 [(validate.rules).message.required = true];
}
message GetDeploymentRequest {
string id = 1 [(validate.rules).string.min_len = 1];
}
message GetDeploymentResponse {
model.Deployment deployment = 1 [(validate.rules).message.required = true];
}
message ListNotCompletedDeploymentsRequest {
}
message ListNotCompletedDeploymentsResponse {
repeated model.Deployment deployments = 1;
string cursor = 2;
}
message CreateDeploymentRequest {
model.Deployment deployment = 1 [(validate.rules).message.required = true];
}
message CreateDeploymentResponse {
}
message ReportDeploymentPlannedRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
// Simple description about what this deployment does.
// Empty means nothing has changed compared to when the deployment was created.
string summary = 2;
// The human-readable description why the deployment is at current status.
string status_reason = 3;
// Hash value of the most recently successfully deployed commit.
string running_commit_hash = 4;
// The config file name used by the last successful deployment.
string running_config_filename = 9;
// The application version this deployment is trying to deploy.
string version = 5;
repeated model.ArtifactVersion versions = 10;
// The planned stages.
// Empty means nothing has changed compared to when the deployment was created.
repeated model.PipelineStage stages = 6;
// DeploymentChainId represents the deployment chain id which the deployment
// belongs to. Empty means this deployment does not belong to any chain.
string deployment_chain_id = 7;
// DeploymentChainBlockIndex represents the block in deployment chain which
// the deployment assigned to.
uint32 deployment_chain_block_index = 8;
}
message ReportDeploymentPlannedResponse {
}
message ReportDeploymentStatusChangedRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
// We only accept RUNNING or ROLLING_BACK.
model.DeploymentStatus status = 2 [(validate.rules).enum = {in: [2,3]}];
// The human-readable description why the deployment is at current status.
string status_reason = 3;
// DeploymentChainId represents the deployment chain id which the deployment
// belongs to. Empty means this deployment does not belong to any chain.
string deployment_chain_id = 4;
// DeploymentChainBlockIndex represents the block in deployment chain which
// the deployment assigned to.
uint32 deployment_chain_block_index = 5;
}
message ReportDeploymentStatusChangedResponse {
}
message ReportDeploymentCompletedRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
// The status of deployment.
model.DeploymentStatus status = 2 [(validate.rules).enum.defined_only = true];
// The human-readable description why the deployment is at current status.
string status_reason = 3;
// The completed statuses of all stages.
map<string,model.StageStatus> stage_statuses = 4;
// DeploymentChainId represents the deployment chain id which the deployment
// belongs to. Empty means this deployment does not belong to any chain.
string deployment_chain_id = 5;
// DeploymentChainBlockIndex represents the block in deployment chain which
// the deployment assigned to.
uint32 deployment_chain_block_index = 6;
// The completion time of deployment.
int64 completed_at = 13 [(validate.rules).int64.gt = 0];
}
message ReportDeploymentCompletedResponse {
}
message SaveDeploymentMetadataRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
map<string,string> metadata = 2;
}
message SaveDeploymentMetadataResponse {
}
message SaveStageMetadataRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
string stage_id = 2 [(validate.rules).string.min_len = 1];
map<string,string> metadata = 3;
}
message SaveStageMetadataResponse {
}
message ReportStageLogsRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
string stage_id = 2 [(validate.rules).string.min_len = 1];
int32 retried_count = 3;
repeated model.LogBlock blocks = 4;
}
message ReportStageLogsResponse {
}
message ReportStageLogsFromLastCheckpointRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
string stage_id = 2 [(validate.rules).string.min_len = 1];
int32 retried_count = 3;
repeated model.LogBlock blocks = 4;
bool completed = 5;
}
message ReportStageLogsFromLastCheckpointResponse {
}
message ReportStageStatusChangedRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
string stage_id = 2 [(validate.rules).string.min_len = 1];
model.StageStatus status = 3 [(validate.rules).enum.defined_only = true];
// The human-readable description why the stage is at current status.
string status_reason = 4;
repeated string requires = 5;
bool visible = 6;
int32 retried_count = 7;
int64 completed_at = 13 [(validate.rules).int64.gt = 0];
}
message ReportStageStatusChangedResponse {
}
message ListUnhandledCommandsRequest {
}
message ListUnhandledCommandsResponse {
repeated model.Command commands = 1;
}
message ReportCommandHandledRequest {
string command_id = 1 [(validate.rules).string.min_len = 1];
model.CommandStatus status = 2 [(validate.rules).enum.defined_only = true];
map<string,string> metadata = 3;
int64 handled_at = 4 [(validate.rules).int64.gt = 0];
// Additional output data to be stored in filestore.
bytes output = 5;
}
message ReportCommandHandledResponse {
}
message ReportApplicationLiveStateRequest {
model.ApplicationLiveStateSnapshot snapshot = 1 [(validate.rules).message.required = true];
}
message ReportApplicationLiveStateResponse {
}
message ReportApplicationLiveStateEventsRequest {
repeated model.KubernetesResourceStateEvent kubernetes_events = 1;
}
message ReportApplicationLiveStateEventsResponse {
repeated string failed_ids = 1;
}
message GetLatestEventRequest {
string name = 1 [(validate.rules).string.min_len = 1];
map<string,string> labels = 2;
}
message GetLatestEventResponse {
model.Event event = 1 [(validate.rules).message.required = true];
}
message ListEventsRequest {
enum Status {
ALL = 0;
NOT_HANDLED = 1;
SUCCESS = 2;
FAILURE = 3;
OUTDATED = 4;
}
int64 from = 1;
int64 to = 2;
ListOrder order = 3 [(validate.rules).enum.defined_only = true];
Status status = 4 [(validate.rules).enum.defined_only = true];
}
message ListEventsResponse {
repeated model.Event events = 1;
}
message ReportEventsHandledRequest {
repeated string event_ids = 1 [(validate.rules).repeated.min_items = 1];
}
message ReportEventsHandledResponse {
}
message ReportEventStatusesRequest {
message Event {
string id = 1 [(validate.rules).string.min_len = 1];
model.EventStatus status = 2 [(validate.rules).enum.defined_only = true];
string status_description = 3 [(validate.rules).string.min_len = 1];
}
repeated Event events = 1;
}
message ReportEventStatusesResponse {
}
message GetLatestAnalysisResultRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
}
message GetLatestAnalysisResultResponse {
model.AnalysisResult analysis_result = 1 [(validate.rules).message.required = true];
}
message PutLatestAnalysisResultRequest {
string application_id = 1 [(validate.rules).string.min_len = 1];
model.AnalysisResult analysis_result = 2 [(validate.rules).message.required = true];
}
message PutLatestAnalysisResultResponse {
}
message GetDesiredVersionRequest {
}
message GetDesiredVersionResponse {
string version = 1;
}
message UpdateApplicationConfigurationsRequest {
// The application configurations that should be updated.
repeated model.ApplicationInfo applications = 1;
}
message UpdateApplicationConfigurationsResponse {
}
message ReportUnregisteredApplicationConfigurationsRequest {
// All the latest application configurations that isn't registered yet.
// Note that ALL configs are always be contained every time.
repeated model.ApplicationInfo applications = 1;
}
message ReportUnregisteredApplicationConfigurationsResponse {
}
message CreateDeploymentChainRequest {
// Note: The matcher use AND operator to merge all conditions used to determine
// which apps should be trigger as node in chain.
message ApplicationMatcher {
string name = 1;
// The kind is one of: KUBERNETES, TERRAFORM, CLOUDRUN, LAMBDA, ECS.
// This kind will be cast to model.ApplicationKind and we use string to use
// empty string as default value in case this matcher field is not set.
string kind = 2;
map<string,string> labels = 3;
}
model.Deployment first_deployment = 1 [(validate.rules).message.required = true];
repeated ApplicationMatcher matchers = 2;
}
message CreateDeploymentChainResponse {
}
message InChainDeploymentPlannableRequest {
string deployment_id = 1 [(validate.rules).string.min_len = 1];
string deployment_chain_id = 2 [(validate.rules).string.min_len = 1];
uint32 deployment_chain_block_index = 3;
}
message InChainDeploymentPlannableResponse {
// plannable used to determine whether piped should start planning the given development.
bool plannable = 1;
// cancel used to determine whether piped should cancel the given development.
bool cancel = 2;
string cancel_reason = 3;
}