Skip to content

Commit 860a3df

Browse files
smiralaurazard
andcommitted
feat: implement new image service APIs
These new APIs only support one2one proxying, so they don't have any hacks, and look as regular gRPC APIs. Old APIs are deprecated, but still supported. Implement client-side multiplexing in `talosctl`, provide fallback to old APIs for legacy Talos versions. New APIs include removing an image, importing an image. Extracted from siderolabs#12392 Co-authored-by: Laura Brehm <laurabrehm@hey.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 2165280 commit 860a3df

File tree

37 files changed

+4960
-250
lines changed

37 files changed

+4960
-250
lines changed

api/common/common.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ enum ContainerdNamespace {
9595
NS_CRI = 2;
9696
}
9797

98+
message ContainerdInstance {
99+
// Containerd instance to use.
100+
common.ContainerDriver driver = 1;
101+
// Containerd namespace to use.
102+
common.ContainerdNamespace namespace = 2;
103+
}
104+
98105
message URL {
99106
string full_path = 1;
100107
}

api/machine/image.proto

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
syntax = "proto3";
2+
3+
package machine;
4+
5+
option go_package = "github.com/siderolabs/talos/pkg/machinery/api/machine";
6+
option java_package = "dev.talos.api.machine";
7+
8+
import "common/common.proto";
9+
import "google/protobuf/duration.proto";
10+
import "google/protobuf/timestamp.proto";
11+
import "google/protobuf/empty.proto";
12+
13+
// The machine service definition.
14+
service ImageService {
15+
// List images in the containerd.
16+
rpc List(ImageServiceListRequest) returns (stream ImageServiceListResponse);
17+
// Pull an image into the containerd.
18+
rpc Pull(ImageServicePullRequest) returns (stream ImageServicePullResponse);
19+
// Import an image from a stream (tarball).
20+
rpc Import(stream ImageServiceImportRequest) returns (ImageServiceImportResponse);
21+
// Remove an image from the containerd.
22+
rpc Remove (ImageServiceRemoveRequest) returns (google.protobuf.Empty);
23+
}
24+
25+
message ImageServiceListRequest {
26+
common.ContainerdInstance containerd = 1;
27+
}
28+
29+
message ImageServiceListResponse {
30+
string name = 1;
31+
string digest = 2;
32+
int64 size = 3;
33+
google.protobuf.Timestamp created_at = 4;
34+
}
35+
36+
message ImageServicePullRequest {
37+
common.ContainerdInstance containerd = 1;
38+
// Image reference to pull.
39+
string image_ref = 3;
40+
}
41+
42+
message ImageServicePullResponse {
43+
oneof response {
44+
// Name of the pulled image (when done).
45+
string name = 1;
46+
// Progress of the image pull (intermediate updates).
47+
ImageServicePullProgress pull_progress = 2;
48+
}
49+
}
50+
51+
52+
message ImageServiceImportRequest {
53+
oneof request {
54+
// Containerd instance to use.
55+
common.ContainerdInstance containerd = 1;
56+
// Chunk of the image tarball.
57+
common.Data image_chunk = 2;
58+
}
59+
}
60+
61+
message ImageServiceImportResponse {
62+
// Name of the imported image.
63+
string name = 1;
64+
}
65+
66+
message ImageServicePullLayerProgress {
67+
enum Status {
68+
// Keep this in sync with ImagePullLayerProgress.Status.
69+
DOWNLOADING = 0;
70+
DOWNLOAD_COMPLETE = 1;
71+
EXTRACTING = 2;
72+
EXTRACT_COMPLETE = 3;
73+
ALREADY_EXISTS = 4;
74+
}
75+
Status status = 1;
76+
google.protobuf.Duration elapsed = 2;
77+
int64 offset = 3;
78+
int64 total = 4;
79+
}
80+
81+
message ImageServicePullProgress{
82+
string layer_id = 1;
83+
ImageServicePullLayerProgress progress = 2;
84+
}
85+
86+
message ImageServiceRemoveRequest {
87+
common.ContainerdInstance containerd = 1;
88+
// Image reference to remove.
89+
string image_ref = 2;
90+
}

api/machine/machine.proto

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,19 @@ service MachineService {
100100
// MetaDelete deletes a META key.
101101
rpc MetaDelete(MetaDeleteRequest) returns (MetaDeleteResponse);
102102
// ImageList lists images in the CRI.
103-
rpc ImageList(ImageListRequest) returns (stream ImageListResponse);
103+
//
104+
// Use ImageService List RPC instead.
105+
rpc ImageList(ImageListRequest) returns (stream ImageListResponse) {
106+
option (common.remove_deprecated_method) = "v1.18";
107+
option deprecated = true;
108+
}
104109
// ImagePull pulls an image into the CRI.
105-
rpc ImagePull(ImagePullRequest) returns (ImagePullResponse);
110+
//
111+
// Use ImageService Pull RPC instead.
112+
rpc ImagePull(ImagePullRequest) returns (ImagePullResponse) {
113+
option (common.remove_deprecated_method) = "v1.18";
114+
option deprecated = true;
115+
}
106116
}
107117

108118
// rpc applyConfiguration

0 commit comments

Comments
 (0)