Skip to content

Commit

Permalink
[apiserver] Mark required fields in .proto
Browse files Browse the repository at this point in the history
  • Loading branch information
z103cb committed Sep 26, 2023
1 parent 1ed0b7f commit 05beda4
Show file tree
Hide file tree
Showing 16 changed files with 1,701 additions and 1,335 deletions.
2 changes: 1 addition & 1 deletion apiserver/pkg/server/cluster_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ClusterServer struct {
// Creates a new Cluster.
func (s *ClusterServer) CreateCluster(ctx context.Context, request *api.CreateClusterRequest) (*api.Cluster, error) {
if err := ValidateCreateClusterRequest(request); err != nil {
return nil, util.Wrap(err, "Validate cluster request failed.")
return nil, util.Wrap(err, "Validate create cluster request failed.")
}

// use the namespace in the request to override the namespace in the cluster definition
Expand Down
70 changes: 36 additions & 34 deletions proto/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ option go_package = "github.com/ray-project/kuberay/proto/go_client";
package proto;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
Expand Down Expand Up @@ -63,22 +64,22 @@ service ClusterService {
}

message CreateClusterRequest {
// The cluster to be created.
Cluster cluster = 1;
// The namespace of the cluster to be created.
string namespace = 2;
// Required. The cluster to be created.
Cluster cluster = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the cluster to be created.
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
}

message GetClusterRequest {
// The name of the cluster to be retrieved.
string name = 1;
// The namespace of the cluster to be retrieved.
string namespace = 2;
// Required. The name of the cluster to be retrieved.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the cluster to be retrieved.
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
}

message ListClustersRequest {
// The namespace of the clusters to be retrieved.
string namespace = 1;
// Required. The namespace of the clusters to be retrieved.
string namespace = 1 [(google.api.field_behavior) = REQUIRED];

// A page token to request the next page of results. The token is acquried
// from the nextPageToken field of the response from the previous
Expand Down Expand Up @@ -116,21 +117,21 @@ message ListAllClustersResponse {
}

message DeleteClusterRequest {
// The name of the cluster to be deleted.
string name = 1;
// The namespace of the cluster to be deleted.
string namespace = 2;
// Required. The name of the cluster to be deleted.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the cluster to be deleted.
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
}

message Cluster {
// Required input field. Unique cluster name provided by user.
string name = 1;
string name = 1 [(google.api.field_behavior) = REQUIRED];

// Required input field. Cluster's namespace provided by user
string namespace = 2;
string namespace = 2 [(google.api.field_behavior) = REQUIRED];

// Required field. This field indicates the user who owns the cluster.
string user = 3;
string user = 3 [(google.api.field_behavior) = REQUIRED];

// Optional input field. Ray cluster version
string version = 4;
Expand All @@ -145,7 +146,8 @@ message Cluster {
Environment environment = 5;

// Required field. This field indicates ray cluster configuration
ClusterSpec cluster_spec = 6;
ClusterSpec cluster_spec = 6 [(google.api.field_behavior) = REQUIRED];

// Optional. Annotations, for example, "kubernetes.io/ingress.class" to define Ingress class
map<string, string> annotations = 7;

Expand All @@ -169,10 +171,10 @@ message Cluster {
}

message ClusterSpec {
// The head group configuration
HeadGroupSpec head_group_spec = 1;
// The worker group configurations
repeated WorkerGroupSpec worker_group_spec = 2;
// Required. The head group configuration
HeadGroupSpec head_group_spec = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The worker group configurations
repeated WorkerGroupSpec worker_group_spec = 2 [(google.api.field_behavior) = REQUIRED];
}

message Volume {
Expand Down Expand Up @@ -213,8 +215,8 @@ message Volume {
}

message HeadGroupSpec {
// Optional. The computeTemplate of head node group
string compute_template = 1;
// Required. The computeTemplate of head node group
string compute_template = 1 [(google.api.field_behavior) = REQUIRED];
// Optional field. This field will be used to retrieve right ray container
string image = 2;
// Optional. The service type (ClusterIP, NodePort, Load balancer) of the head node
Expand All @@ -241,19 +243,19 @@ message HeadGroupSpec {

message WorkerGroupSpec {
// Required. Group name of the current worker group
string group_name = 1;
// Optional. The computeTemplate of head node group
string compute_template = 2;
string group_name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The computeTemplate of head node group
string compute_template = 2 [(google.api.field_behavior) = REQUIRED];
// Optional field. This field will be used to retrieve right ray container
string image = 3;
// Required. Desired replicas of the worker group
int32 replicas = 4;
// Optional. Min replicas of the worker group
int32 replicas = 4 [(google.api.field_behavior) = REQUIRED];
// Optional. Min replicas of the worker group, can't be greater than max_replicas.
int32 min_replicas = 5;
// Optional. Max replicas of the worker group
int32 max_replicas = 6;
// Optional. The ray start parames of worker node group
map<string, string> ray_start_params = 7;
// Required. Max replicas of the worker group (>0)
int32 max_replicas = 6 [(google.api.field_behavior) = REQUIRED];
// Required. The ray start parameterss of worker node group
map<string, string> ray_start_params = 7 ;
// Optional. The volumes mount to worker pods
repeated Volume volumes = 8;
// Optional. ServiceAccount used by worker pod
Expand Down Expand Up @@ -296,4 +298,4 @@ message ClusterEvent {

// Output. The number of times this event has occurred.
int32 count = 9;
}
}
53 changes: 27 additions & 26 deletions proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ option go_package = "github.com/ray-project/kuberay/proto/go_client";
package proto;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

Expand Down Expand Up @@ -62,21 +63,21 @@ service ComputeTemplateService {

message CreateComputeTemplateRequest {
// The compute template to be created.
ComputeTemplate compute_template = 1;
// The namespace of the compute template to be created
string namespace = 2;
ComputeTemplate compute_template = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the compute template to be created
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
}

message GetComputeTemplateRequest {
// The name of the ComputeTemplate to be retrieved.
string name = 1;
// The namespace of the compute template to be retrieved.
string namespace = 2;
// Required. The name of the ComputeTemplate to be retrieved.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the compute template to be retrieved.
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
}

message ListComputeTemplatesRequest {
// The namespace of the compute templates to be retrieved.
string namespace = 1;
// Required. The namespace of the compute templates to be retrieved.
string namespace = 1 [(google.api.field_behavior) = REQUIRED];
// TODO: support paganation later
}

Expand All @@ -93,10 +94,10 @@ message ListAllComputeTemplatesResponse {
}

message DeleteComputeTemplateRequest {
// The name of the compute template to be deleted.
string name = 1;
// The namespace of the compute template to be deleted.
string namespace = 2;
// Required. The name of the compute template to be deleted.
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the compute template to be deleted.
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
}

// Toleration for the compute template
Expand All @@ -113,14 +114,14 @@ message PodToleration{

// ComputeTemplate can be reused by any compute units like worker group, workspace, image build job, etc
message ComputeTemplate {
// The name of the compute template
string name = 1;
// The namespace of the compute template
string namespace = 2;
// Number of cpus
uint32 cpu = 3;
// Number of memory
uint32 memory = 4;
// Required. The name of the compute template
string name = 1 [(google.api.field_behavior) = REQUIRED];
// Required. The namespace of the compute template
string namespace = 2 [(google.api.field_behavior) = REQUIRED];
// Required. Number of cpus
uint32 cpu = 3 [(google.api.field_behavior) = REQUIRED];
// Required. Number of memory
uint32 memory = 4 [(google.api.field_behavior) = REQUIRED];
// Number of gpus
uint32 gpu = 5;
// The detail gpu accelerator type
Expand All @@ -129,31 +130,31 @@ message ComputeTemplate {
repeated PodToleration tolerations = 7;
}


// This service is not implemented.
service ImageTemplateService {
// Creates a new ImageTemplate.
// Not implemented. Creates a new ImageTemplate.
rpc CreateImageTemplate(CreateImageTemplateRequest) returns (ImageTemplate) {
option (google.api.http) = {
post: "/apis/v1alpha2/image_templates"
body: "image_template"
};
}

// Finds a specific ImageTemplate by ID.
// Not implemented. Finds a specific ImageTemplate by ID.
rpc GetImageTemplate(GetImageTemplateRequest) returns (ImageTemplate) {
option (google.api.http) = {
get: "/apis/v1alpha2/namespaces/{namespace}/image_templates/{name}"
};
}

// Finds all ImageTemplates. Supports pagination, and sorting on certain fields.
// Not Implemented. Finds all ImageTemplates. Supports pagination, and sorting on certain fields.
rpc ListImageTemplates(ListImageTemplatesRequest) returns (ListImageTemplatesResponse) {
option (google.api.http) = {
get: "/apis/v1alpha2/namespaces/{namespace}/image_templates"
};
}

// Deletes an ImageTemplate.
// Not implemented. Deletes an ImageTemplate.
rpc DeleteImageTemplate(DeleteImageTemplateRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/apis/v1alpha2/namespaces/{namespace}/image_templates/{name}"
Expand Down
Loading

0 comments on commit 05beda4

Please sign in to comment.