Skip to content

Commit

Permalink
Merge pull request #950 from traPtitech/feat/runtime_image_size
Browse files Browse the repository at this point in the history
Runtimeアプリのimage sizeを見られるようにする
  • Loading branch information
pirosiki197 authored Aug 23, 2024
2 parents 965f607 + 38d2109 commit 0bbe3f9
Show file tree
Hide file tree
Showing 46 changed files with 3,854 additions and 1,599 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ init-protoc:
init-protoc-tools:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest
npm i -g @connectrpc/protoc-gen-connect-es @bufbuild/protoc-gen-es
npm i -g @connectrpc/protoc-gen-connect-es @bufbuild/protoc-gen-es@1

.PHONY: init
init: init-k3d init-kustomize init-protoc init-protoc-tools ## Install / update required tools
Expand Down
9 changes: 8 additions & 1 deletion api/proto/neoshowcase/protobuf/controller.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
syntax = "proto3";
package neoshowcase.protobuf;
option go_package = "github.com/traPtitech/neoshowcase/pkg/infrastructure/grpc/pb";

import "google/protobuf/empty.proto";
import "neoshowcase/protobuf/gateway.proto";

option go_package = "github.com/traPtitech/neoshowcase/pkg/infrastructure/grpc/pb";

message ImageConfig {
message RegistryConfig {
string scheme = 1;
Expand Down Expand Up @@ -37,6 +38,11 @@ message SaveBuildLogRequest {
bytes log = 2;
}

message SaveRuntimeImageRequest {
string build_id = 1;
int64 size = 2;
}

message RepositoryPrivate {
Repository repo = 1;
string username = 2;
Expand Down Expand Up @@ -143,6 +149,7 @@ service ControllerBuilderService {
rpc StreamBuildLog(stream BuildLogPortion) returns (google.protobuf.Empty);
rpc SaveArtifact(SaveArtifactRequest) returns (google.protobuf.Empty);
rpc SaveBuildLog(SaveBuildLogRequest) returns (google.protobuf.Empty);
rpc SaveRuntimeImage(SaveRuntimeImageRequest) returns (google.protobuf.Empty);
rpc ConnectBuilder(stream BuilderResponse) returns (stream BuilderRequest);
}

Expand Down
59 changes: 34 additions & 25 deletions api/proto/neoshowcase/protobuf/gateway.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
syntax = "proto3";
package neoshowcase.protobuf;
option go_package = "github.com/traPtitech/neoshowcase/pkg/infrastructure/grpc/pb";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "neoshowcase/protobuf/null.proto";

option go_package = "github.com/traPtitech/neoshowcase/pkg/infrastructure/grpc/pb";

// ---- Basic structs ----

// -- System
Expand Down Expand Up @@ -238,6 +239,13 @@ message ArtifactContent {
bytes content = 2;
}

message RuntimeImage {
string id = 1;
string build_id = 2;
int64 size = 3;
google.protobuf.Timestamp created_at = 4;
}

message AvailableMetrics {
repeated string metrics_names = 1;
}
Expand Down Expand Up @@ -280,6 +288,7 @@ message Build {
neoshowcase.protobuf.NullTimestamp finished_at = 8;
bool retriable = 9;
repeated Artifact artifacts = 10;
optional RuntimeImage runtime_image = 11;
}

message BuildLog {
Expand Down Expand Up @@ -500,7 +509,7 @@ service APIService {
// GetSystemInfo システム固有情報を取得します
rpc GetSystemInfo(google.protobuf.Empty) returns (SystemInfo) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GenerateKeyPair リポジトリ登録で使用する鍵ペアを一時的に生成します
rpc GenerateKeyPair(google.protobuf.Empty) returns (GenerateKeyPairResponse);

Expand All @@ -509,17 +518,17 @@ service APIService {
// GetMe 自身の情報を取得します プロキシ認証のため常に成功します
rpc GetMe(google.protobuf.Empty) returns (User) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetUsers 全てのユーザーの情報を取得します
rpc GetUsers(google.protobuf.Empty) returns (GetUsersResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// CreateUserKey アプリコンテナSSH用の公開鍵を登録します
rpc CreateUserKey(CreateUserKeyRequest) returns (UserKey);
// GetUserKeys 登録した公開鍵一覧を取得します
rpc GetUserKeys(google.protobuf.Empty) returns (GetUserKeysResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// DeleteUserKey 登録した公開鍵を削除します
rpc DeleteUserKey(DeleteUserKeyRequest) returns (google.protobuf.Empty);

Expand All @@ -528,21 +537,21 @@ service APIService {
// CreateRepository リポジトリを登録します
rpc CreateRepository(CreateRepositoryRequest) returns (Repository);
// GetRepositories リポジトリ一覧を取得します
rpc GetRepositories(GetRepositoriesRequest) returns (GetRepositoriesResponse) {
rpc GetRepositories(GetRepositoriesRequest) returns (GetRepositoriesResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetRepositoryCommits コミットのメタ情報を取得します
rpc GetRepositoryCommits(GetRepositoryCommitsRequest) returns (GetRepositoryCommitsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}
// GetRepository リポジトリを取得します
rpc GetRepository(RepositoryIdRequest) returns (Repository) {
rpc GetRepository(RepositoryIdRequest) returns (Repository) {
option idempotency_level = NO_SIDE_EFFECTS;
}
// GetRepositoryRefs リポジトリの現在の有効なref一覧を取得します
rpc GetRepositoryRefs(RepositoryIdRequest) returns (GetRepositoryRefsResponse) {
rpc GetRepositoryRefs(RepositoryIdRequest) returns (GetRepositoryRefsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// UpdateRepository リポジトリ情報を更新します
rpc UpdateRepository(UpdateRepositoryRequest) returns (google.protobuf.Empty);
// RefreshRepository 自動更新間隔を待たず、手動でリモートリポジトリの最新情報に追従させます
Expand All @@ -555,13 +564,13 @@ service APIService {
// CreateApplication アプリを作成します
rpc CreateApplication(CreateApplicationRequest) returns (Application);
// GetApplications アプリ一覧を取得します
rpc GetApplications(GetApplicationsRequest) returns (GetApplicationsResponse) {
rpc GetApplications(GetApplicationsRequest) returns (GetApplicationsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetApplication アプリを取得します
rpc GetApplication(ApplicationIdRequest) returns (Application) {
rpc GetApplication(ApplicationIdRequest) returns (Application) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// UpdateApplication アプリ情報を更新します
rpc UpdateApplication(UpdateApplicationRequest) returns (google.protobuf.Empty);
// DeleteApplication アプリを削除します 先にアプリのシャットダウンが必要です
Expand All @@ -570,17 +579,17 @@ service APIService {
// Application info

// GetAvailableMetrics 取得可能メトリクス一覧を取得します
rpc GetAvailableMetrics(google.protobuf.Empty) returns (AvailableMetrics) {
rpc GetAvailableMetrics(google.protobuf.Empty) returns (AvailableMetrics) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetApplicationMetrics アプリのメトリクスを取得します
rpc GetApplicationMetrics(GetApplicationMetricsRequest) returns (ApplicationMetrics) {
rpc GetApplicationMetrics(GetApplicationMetricsRequest) returns (ApplicationMetrics) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetOutput アプリの出力を取得します
rpc GetOutput(GetOutputRequest) returns (ApplicationOutputs) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetOutputStream アプリの出力をストリーム形式で取得します
rpc GetOutputStream(GetOutputStreamRequest) returns (stream ApplicationOutput);

Expand All @@ -589,7 +598,7 @@ service APIService {
// GetEnvVars アプリの環境変数を取得します
rpc GetEnvVars(ApplicationIdRequest) returns (ApplicationEnvVars) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// SetEnvVar アプリの環境変数をセットします システムによって設定された環境変数は上書きできません
rpc SetEnvVar(SetApplicationEnvVarRequest) returns (google.protobuf.Empty);
// DeleteEnvVar アプリの環境変数を削除します システムによって設定された環境変数は削除できません
Expand All @@ -604,27 +613,27 @@ service APIService {
// GetAllBuilds すべてのアプリケーションのビルドキューを取得します
rpc GetAllBuilds(GetAllBuildsRequest) returns (GetBuildsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetBuilds アプリのビルド一覧を取得します
rpc GetBuilds(ApplicationIdRequest) returns (GetBuildsResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetBuild アプリのビルド情報を取得します
rpc GetBuild(BuildIdRequest) returns (Build) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// RetryCommitBuild アプリの該当コミットのビルドをやり直します
rpc RetryCommitBuild(RetryCommitBuildRequest) returns (google.protobuf.Empty);
// CancelBuild 該当ビルドが進行中の場合キャンセルします
rpc CancelBuild(BuildIdRequest) returns (google.protobuf.Empty);
// GetBuildLog 終了したビルドのログを取得します
rpc GetBuildLog(BuildIdRequest) returns (BuildLog) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
// GetBuildLogStream ビルド中のログをストリーム形式で取得します
rpc GetBuildLogStream(BuildIdRequest) returns (stream BuildLog);
// GetBuildArtifact 静的サイトアプリの場合ビルド成果物(静的ファイルのtar)を取得します
rpc GetBuildArtifact(ArtifactIdRequest) returns (ArtifactContent) {
option idempotency_level = NO_SIDE_EFFECTS;
};
}
}
4 changes: 3 additions & 1 deletion cmd/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"context"
"fmt"
"github.com/traPtitech/neoshowcase/pkg/usecase/systeminfo"
"net/http"
"os"
"strings"
"time"

"github.com/traPtitech/neoshowcase/pkg/usecase/systeminfo"

"connectrpc.com/connect"
certmanagerv1 "github.com/cert-manager/cert-manager/pkg/client/clientset/versioned"
"github.com/friendsofgo/errors"
Expand Down Expand Up @@ -85,6 +86,7 @@ var providers = wire.NewSet(
repository.New,
repository.NewApplicationRepository,
repository.NewArtifactRepository,
repository.NewRuntimeImageRepository,
repository.NewBuildRepository,
repository.NewEnvironmentRepository,
repository.NewGitRepositoryRepository,
Expand Down
6 changes: 4 additions & 2 deletions cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ services:
labels:
- "traefik.enable=true"
- "traefik.http.routers.adminer.rule=Host(`adminer.local.trapti.tech`)"
- "traefik.http.services.adminer.loadbalancer.server.port=80"
- "traefik.http.services.adminer.loadbalancer.server.port=8080"
networks:
- default

Expand Down
61 changes: 61 additions & 0 deletions dashboard/src/api/neoshowcase/protobuf/gateway_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,61 @@ export class ArtifactContent extends Message<ArtifactContent> {
}
}

/**
* @generated from message neoshowcase.protobuf.RuntimeImage
*/
export class RuntimeImage extends Message<RuntimeImage> {
/**
* @generated from field: string id = 1;
*/
id = "";

/**
* @generated from field: string build_id = 2;
*/
buildId = "";

/**
* @generated from field: int64 size = 3;
*/
size = protoInt64.zero;

/**
* @generated from field: google.protobuf.Timestamp created_at = 4;
*/
createdAt?: Timestamp;

constructor(data?: PartialMessage<RuntimeImage>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "neoshowcase.protobuf.RuntimeImage";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "build_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "size", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
{ no: 4, name: "created_at", kind: "message", T: Timestamp },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RuntimeImage {
return new RuntimeImage().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RuntimeImage {
return new RuntimeImage().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RuntimeImage {
return new RuntimeImage().fromJsonString(jsonString, options);
}

static equals(a: RuntimeImage | PlainMessage<RuntimeImage> | undefined, b: RuntimeImage | PlainMessage<RuntimeImage> | undefined): boolean {
return proto3.util.equals(RuntimeImage, a, b);
}
}

/**
* @generated from message neoshowcase.protobuf.AvailableMetrics
*/
Expand Down Expand Up @@ -1882,6 +1937,11 @@ export class Build extends Message<Build> {
*/
artifacts: Artifact[] = [];

/**
* @generated from field: optional neoshowcase.protobuf.RuntimeImage runtime_image = 11;
*/
runtimeImage?: RuntimeImage;

constructor(data?: PartialMessage<Build>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -1900,6 +1960,7 @@ export class Build extends Message<Build> {
{ no: 8, name: "finished_at", kind: "message", T: NullTimestamp },
{ no: 9, name: "retriable", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 10, name: "artifacts", kind: "message", T: Artifact, repeated: true },
{ no: 11, name: "runtime_image", kind: "message", T: RuntimeImage, opt: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Build {
Expand Down
7 changes: 7 additions & 0 deletions docs/dbschema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| [repository_auth](repository_auth.md) | 5 | Gitリポジトリ認証情報テーブル | BASE TABLE |
| [repository_commits](repository_commits.md) | 9 | コミットメタ情報テーブル | BASE TABLE |
| [repository_owners](repository_owners.md) | 2 | リポジトリ所有者テーブル | BASE TABLE |
| [runtime_images](runtime_images.md) | 3 | ランタイムイメージテーブル | BASE TABLE |
| [users](users.md) | 3 | ユーザーテーブル | BASE TABLE |
| [user_keys](user_keys.md) | 5 | ユーザーSSHキーテーブル | BASE TABLE |
| [websites](websites.md) | 9 | Webサイトテーブル | BASE TABLE |
Expand All @@ -35,6 +36,7 @@ erDiagram
"repository_auth" |o--|| "repositories" : "FOREIGN KEY (repository_id) REFERENCES repositories (id)"
"repository_owners" }o--|| "repositories" : "FOREIGN KEY (repository_id) REFERENCES repositories (id)"
"repository_owners" }o--|| "users" : "FOREIGN KEY (user_id) REFERENCES users (id)"
"runtime_images" |o--|| "builds" : "FOREIGN KEY (build_id) REFERENCES builds (id)"
"user_keys" }o--|| "users" : "FOREIGN KEY (user_id) REFERENCES users (id)"
"websites" }o--|| "applications" : "FOREIGN KEY (application_id) REFERENCES applications (id)"
Expand Down Expand Up @@ -129,6 +131,11 @@ erDiagram
char_22_ user_id PK
char_22_ repository_id PK
}
"runtime_images" {
char_22_ build_id PK
bigint_20_ size
datetime_6_ created_at
}
"users" {
char_22_ id PK
varchar_255_ name
Expand Down
Loading

0 comments on commit 0bbe3f9

Please sign in to comment.