Skip to content

Commit

Permalink
feat: Edit Enclave (#1478)
Browse files Browse the repository at this point in the history
## Description:
With this change the user can click to edit a running enclave, change
the configuration of the enclave (package), click Run and the enclave
will update idempotently (using idempotent runs).

## Is this change user facing?
YES

## References (if applicable):

---------

Co-authored-by: Laurent Luce <[email protected]>
  • Loading branch information
adschwartz and laurentluce authored Oct 5, 2023
1 parent 503cb8d commit d11736a
Show file tree
Hide file tree
Showing 39 changed files with 1,057 additions and 647 deletions.

Large diffs are not rendered by default.

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ service KurtosisEnclaveManagerServer {
rpc CreateEnclave(engine_api.CreateEnclaveArgs) returns (engine_api.CreateEnclaveResponse) {};
rpc InspectFilesArtifactContents(InspectFilesArtifactContentsRequest) returns (api_container_api.InspectFilesArtifactContentsResponse) {}
rpc DestroyEnclave(engine_api.DestroyEnclaveArgs) returns (google.protobuf.Empty) {};
rpc GetStarlarkRun(GetStarlarkRunRequest) returns (api_container_api.GetStarlarkRunResponse) {};
}

message HealthCheckRequest {
Expand Down Expand Up @@ -55,3 +56,8 @@ message InspectFilesArtifactContentsRequest {
int32 apic_port = 2;
api_container_api.FilesArtifactNameAndUuid file_names_and_uuid = 3;
}

message GetStarlarkRunRequest{
string apic_ip_address = 1;
int32 apic_port = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* eslint-disable */
// @ts-nocheck

import { GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, HealthCheckRequest, HealthCheckResponse, InspectFilesArtifactContentsRequest, RunStarlarkPackageRequest } from "./kurtosis_enclave_manager_api_pb.js";
import { GetListFilesArtifactNamesAndUuidsRequest, GetServicesRequest, GetStarlarkRunRequest, HealthCheckRequest, HealthCheckResponse, InspectFilesArtifactContentsRequest, RunStarlarkPackageRequest } from "./kurtosis_enclave_manager_api_pb.js";
import { Empty, MethodKind } from "@bufbuild/protobuf";
import { CreateEnclaveArgs, CreateEnclaveResponse, DestroyEnclaveArgs, GetEnclavesResponse, GetServiceLogsArgs, GetServiceLogsResponse } from "./engine_service_pb.js";
import { GetServicesResponse, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, StarlarkRunResponseLine } from "./api_container_service_pb.js";
import { GetServicesResponse, GetStarlarkRunResponse, InspectFilesArtifactContentsResponse, ListFilesArtifactNamesAndUuidsResponse, StarlarkRunResponseLine } from "./api_container_service_pb.js";

/**
* @generated from service kurtosis_enclave_manager.KurtosisEnclaveManagerServer
Expand Down Expand Up @@ -95,6 +95,15 @@ export const KurtosisEnclaveManagerServer = {
O: Empty,
kind: MethodKind.Unary,
},
/**
* @generated from rpc kurtosis_enclave_manager.KurtosisEnclaveManagerServer.GetStarlarkRun
*/
getStarlarkRun: {
name: "GetStarlarkRun",
I: GetStarlarkRunRequest,
O: GetStarlarkRunResponse,
kind: MethodKind.Unary,
},
}
} as const;

Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,46 @@ export class InspectFilesArtifactContentsRequest extends Message<InspectFilesArt
}
}

/**
* @generated from message kurtosis_enclave_manager.GetStarlarkRunRequest
*/
export class GetStarlarkRunRequest extends Message<GetStarlarkRunRequest> {
/**
* @generated from field: string apic_ip_address = 1;
*/
apicIpAddress = "";

/**
* @generated from field: int32 apic_port = 2;
*/
apicPort = 0;

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

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "kurtosis_enclave_manager.GetStarlarkRunRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "apic_ip_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "apic_port", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
]);

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

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

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

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

53 changes: 45 additions & 8 deletions enclave-manager/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import (
)

const (
listenPort = 8081
grpcServerStopGracePeriod = 5 * time.Second
engineHostUrl = "http://localhost:9710"
kurtosisCloudApiHost = "https://cloud.kurtosis.com"
kurtosisCloudApiPort = 8080
KurtosisEnclaveManagerApiEnforceAuthKeyEnvVarArg = "KURTOSIS_ENCLAVE_MANAGER_API_ENFORCE_AUTH"
listenPort = 8081
grpcServerStopGracePeriod = 5 * time.Second
engineHostUrl = "http://localhost:9710"
kurtosisCloudApiHost = "https://cloud.kurtosis.com"
kurtosisCloudApiPort = 8080
)

type Authentication struct {
Expand Down Expand Up @@ -312,6 +311,44 @@ func (c *WebServer) InspectFilesArtifactContents(ctx context.Context, req *conne
return resp, nil
}

func (c *WebServer) GetStarlarkRun(
ctx context.Context,
req *connect.Request[kurtosis_enclave_manager_api_bindings.GetStarlarkRunRequest],
) (*connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse], error) {
auth, err := c.ValidateRequestAuthorization(ctx, c.enforceAuth, req.Header())
if err != nil {
return nil, stacktrace.Propagate(err, "Authentication attempt failed")
}
if !auth {
return nil, stacktrace.Propagate(err, "User not authorized")
}
apiContainerServiceClient, err := c.createAPICClient(req.Msg.ApicIpAddress, req.Msg.ApicPort)
if err != nil {
return nil, stacktrace.Propagate(err, "Failed to create the APIC client")
}

request := &connect.Request[emptypb.Empty]{
Msg: &emptypb.Empty{},
}
result, err := (*apiContainerServiceClient).GetStarlarkRun(ctx, request)
if err != nil {
return nil, err
}
resp := &connect.Response[kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse]{
Msg: &kurtosis_core_rpc_api_bindings.GetStarlarkRunResponse{
PackageId: result.Msg.PackageId,
SerializedScript: result.Msg.SerializedScript,
SerializedParams: result.Msg.SerializedParams,
Parallelism: result.Msg.Parallelism,
RelativePathToMainFile: result.Msg.RelativePathToMainFile,
MainFunctionName: result.Msg.MainFunctionName,
ExperimentalFeatures: result.Msg.ExperimentalFeatures,
RestartPolicy: result.Msg.RestartPolicy,
},
}
return resp, nil
}

func (c *WebServer) createAPICClient(
ip string,
port int32,
Expand All @@ -332,13 +369,13 @@ func (c *WebServer) createKurtosisCloudBackendClient(
host string,
port int,
) (*kurtosis_backend_server_rpc_api_bindingsconnect.KurtosisCloudBackendServerClient, error) {
url, err := url.Parse(fmt.Sprintf("%s:%d", host, port))
parsedUrl, err := url.Parse(fmt.Sprintf("%s:%d", host, port))
if err != nil {
return nil, stacktrace.Propagate(err, "Failed to parse the connection url for Kurtosis Cloud Backend")
}
client := kurtosis_backend_server_rpc_api_bindingsconnect.NewKurtosisCloudBackendServerClient(
http.DefaultClient,
url.String(),
parsedUrl.String(),
connect.WithGRPCWeb(),
)
return &client, nil
Expand Down
2 changes: 1 addition & 1 deletion engine/frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion engine/frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Home from './component/Home';
import { ChakraProvider } from '@chakra-ui/react'

const App = () => {
console.log("Enclave Manager version: 2023-10-04-01")
console.log("Enclave Manager version: 2023-10-05-01")
return (
<ChakraProvider>
<div className="h-screen w-screen bg-[#171923]">
Expand Down
Loading

0 comments on commit d11736a

Please sign in to comment.