Skip to content

Commit

Permalink
Merge branch 'main' into lporoli/em-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Nov 21, 2023
2 parents 2f7a810 + 43ff1c5 commit b3a0ea6
Show file tree
Hide file tree
Showing 42 changed files with 452 additions and 162 deletions.
26 changes: 17 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ executors:
machine:
# This custom CircleCi Ubuntu image has a pre-installed Docker, so we are not using the CircleCI remote Docker when we
# initiate this machine. More here: https://discuss.circleci.com/t/linux-machine-executor-images-2022-january-q1-update/42831
image: ubuntu-2004:2023.07.1
image: ubuntu-2004:2023.10.1

parameters:
go-version:
Expand Down Expand Up @@ -513,7 +513,7 @@ jobs:
- when:
condition:
and:
- equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
- equal: [ "kubernetes", << parameters.cli-cluster-backend >> ]
<<: *steps_prepare_testing_k8s_k3s

- when:
Expand Down Expand Up @@ -790,13 +790,18 @@ jobs:
# Execute port print
- run: "${KURTOSIS_BINPATH} port print test-datastore datastore-0 grpc"

# Execute docker compose import
- run: "${KURTOSIS_BINPATH} import --enclave test-import --env << pipeline.parameters.dockerimport-cli-dotenv-relative-path >> << pipeline.parameters.dockerimport-cli-dockerfile-relative-path >>"

# Stop test-datastore enclave
- run: "${KURTOSIS_BINPATH} enclave stop test-datastore"

# Ensure we can still inspect stopped enclaves
- run: "${KURTOSIS_BINPATH} enclave stop test-enclave"
- run: "${KURTOSIS_BINPATH} enclave stop test-datastore"
- run: "${KURTOSIS_BINPATH} enclave inspect test-enclave" # Ensure we can still inspect stopped enclaves
- run: "${KURTOSIS_BINPATH} enclave inspect test-enclave"

# Clean all before compose import to free resources
- run: "${KURTOSIS_BINPATH} clean -a"

# Execute docker compose import
- run: "${KURTOSIS_BINPATH} import --enclave test-import --env << pipeline.parameters.dockerimport-cli-dotenv-relative-path >> << pipeline.parameters.dockerimport-cli-dockerfile-relative-path >>"

# Execute engine functions
- run: "${KURTOSIS_BINPATH} engine stop"
Expand Down Expand Up @@ -824,7 +829,7 @@ jobs:
docker container restart $(echo $apic_container_id)
${KURTOSIS_BINPATH} service rm test-apic-restart service-test
# Test APIC idempotent runs restart
# Test APIC idempotent runs restart
- when:
condition:
equal: [ "docker", << parameters.cli-cluster-backend >> ]
Expand Down Expand Up @@ -1162,7 +1167,10 @@ workflows:
"pattern": "https://twitter.com/.*"
},
{
"pattern": "http://localhost:3000"
"pattern": "http://localhost:.*"
},
{
"pattern": "http://localhost/.*"
}
]
}
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [0.85.34](https://github.com/kurtosis-tech/kurtosis/compare/0.85.33...0.85.34) (2023-11-21)


### Bug Fixes

* display the relevant number in the error message ([#1835](https://github.com/kurtosis-tech/kurtosis/issues/1835)) ([a8c24bc](https://github.com/kurtosis-tech/kurtosis/commit/a8c24bcbeff813217e10a222001ce05c325de03c))

## [0.85.33](https://github.com/kurtosis-tech/kurtosis/compare/0.85.32...0.85.33) (2023-11-20)


### Features

* search in service logs ([#1830](https://github.com/kurtosis-tech/kurtosis/issues/1830)) ([7fce5b5](https://github.com/kurtosis-tech/kurtosis/commit/7fce5b59d1060f99f8c2cbd54d7bb8483150310e)), closes [#1791](https://github.com/kurtosis-tech/kurtosis/issues/1791)

## [0.85.32](https://github.com/kurtosis-tech/kurtosis/compare/0.85.31...0.85.32) (2023-11-20)


### Features

* emui auth via cookie ([#1783](https://github.com/kurtosis-tech/kurtosis/issues/1783)) ([d5d79d8](https://github.com/kurtosis-tech/kurtosis/commit/d5d79d8c4a67d175d9dc0d842e9edbb6068b8c6c))

## [0.85.31](https://github.com/kurtosis-tech/kurtosis/compare/0.85.30...0.85.31) (2023-11-17)


Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Business Source License 1.1
Parameters

Licensor: Kurtosis Technologies, Inc.
Licensed Work: Kurtosis 0.85.31
Licensed Work: Kurtosis 0.85.34
The Licensed Work is (c) 2023 Kurtosis Technologies, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work for an Environment Orchestration Service.
Expand All @@ -12,7 +12,7 @@ you may not use the Licensed Work for an Environment Orchestration Service.
allows third parties (other than your employees and
contractors) to create distributed system environments.

Change Date: 2027-11-17
Change Date: 2027-11-21

Change License: AGPLv3 (GNU Affero General Public License Version 3)

Expand Down
2 changes: 1 addition & 1 deletion api/golang/kurtosis_version/kurtosis_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const (
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
// This is necessary so that Kurt Core consumers will know if they're compatible with the currently-running
// API container
KurtosisVersion = "0.85.31"
KurtosisVersion = "0.85.34"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
)
2 changes: 1 addition & 1 deletion api/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kurtosis-sdk"
version = "0.85.31"
version = "0.85.34"
license = "BUSL-1.1"
description = "Rust SDK for Kurtosis"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion api/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kurtosis-sdk",
"//": "NOTE: DO NOT UPDATE THIS VERSION MANUALLY - IT WILL BE UPDATED DURING THE RELEASE PROCESS!",
"version": "0.85.31",
"version": "0.85.34",
"main": "./build/index",
"description": "This repo contains a Typescript client for communicating with the Kurtosis Engine server, which is responsible for creating, managing and destroying Kurtosis Enclaves.",
"types": "./build/index",
Expand Down
2 changes: 1 addition & 1 deletion api/typescript/src/kurtosis_version/kurtosis_version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
// This is necessary so that Kurt Core consumers (e.g. modules) will know if they're compatible with the currently-running
// API container
export const KURTOSIS_VERSION: string = "0.85.31"
export const KURTOSIS_VERSION: string = "0.85.34"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
2 changes: 1 addition & 1 deletion cli/cli/commands/service/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const (

portMappingSeparatorForLogs = ", "

defaultPortWaitTimeoutStr = "15s"
defaultPortWaitTimeoutStr = "30s"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (backend *KubernetesKurtosisBackend) getMatchingApiContainerKubernetesResou
"but found '%v'",
namespaceName,
enclaveIdStr,
len(services),
len(servicesForEnclaveId),
)
}
service := servicesForEnclaveId[0]
Expand Down
5 changes: 5 additions & 0 deletions enclave-manager/web/.env.cloudDevelopment
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REACT_APP_KURTOSIS_DEFAULT_HOST=localhost
REACT_APP_KURTOSIS_DEFAULT_EM_API_PORT=8081

REACT_APP_KURTOSIS_CLOUD_UI_URL=http://localhost:3000
REACT_APP_KURTOSIS_PACKAGE_INDEXER_URL=https://cloud.kurtosis.com:9770
6 changes: 5 additions & 1 deletion enclave-manager/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Removes the build output if present.
### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
Open [http://localhost:4000](http://localhost:4000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.
Expand All @@ -42,6 +42,10 @@ Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn start:prod`

Serve your local build on port 4000.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
Expand Down
2 changes: 2 additions & 0 deletions enclave-manager/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"framer-motion": "^10.16.4",
"has-ansi": "^5.0.1",
"html-react-parser": "^4.2.2",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"luxon": "^3.4.3",
"react": "^18.2.0",
Expand All @@ -31,6 +32,7 @@
"true-myth": "^7.1.0"
},
"devDependencies": {
"@types/js-cookie": "^3.0.6",
"@types/luxon": "^3.3.3",
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
Expand Down
Binary file not shown.
4 changes: 3 additions & 1 deletion enclave-manager/web/src/client/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { isDefined } from "../utils";
export const KURTOSIS_CLOUD_PROTOCOL = "https";
export const KURTOSIS_CLOUD_HOST = "cloud.kurtosis.com";
export const KURTOSIS_CLOUD_CONNECT_PAGE = "connect";
export const KURTOSIS_CLOUD_EM_PAGE = "enclave-manager";

// Cloud
export const KURTOSIS_CLOUD_UI_URL =
process.env.REACT_APP_KURTOSIS_CLOUD_UI_URL || `${KURTOSIS_CLOUD_PROTOCOL}://${KURTOSIS_CLOUD_HOST}`;
export const KURTOSIS_CLOUD_CONNECT_URL = `${KURTOSIS_CLOUD_PROTOCOL}://${KURTOSIS_CLOUD_HOST}/${KURTOSIS_CLOUD_CONNECT_PAGE}`;
export const KURTOSIS_CLOUD_CONNECT_URL = `${KURTOSIS_CLOUD_UI_URL}/${KURTOSIS_CLOUD_CONNECT_PAGE}`;
export const KURTOSIS_CLOUD_EM_URL = `${KURTOSIS_CLOUD_UI_URL}/${KURTOSIS_CLOUD_EM_PAGE}`;
export const KURTOSIS_PACKAGE_INDEXER_URL =
process.env.REACT_APP_KURTOSIS_PACKAGE_INDEXER_URL || `${KURTOSIS_CLOUD_PROTOCOL}://${KURTOSIS_CLOUD_HOST}:9770`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createPromiseClient } from "@connectrpc/connect";
import { createConnectTransport } from "@connectrpc/connect-web";
import { KurtosisEnclaveManagerServer } from "enclave-manager-sdk/build/kurtosis_enclave_manager_api_connect";
import { KURTOSIS_CLOUD_UI_URL, KURTOSIS_DEFAULT_EM_API_PORT } from "../constants";
import { DateTime } from "luxon";
import { KURTOSIS_CLOUD_EM_URL, KURTOSIS_CLOUD_UI_URL, KURTOSIS_DEFAULT_EM_API_PORT } from "../constants";
import { KurtosisClient } from "./KurtosisClient";

function constructGatewayURL(remoteHost: string): string {
Expand All @@ -10,6 +11,7 @@ function constructGatewayURL(remoteHost: string): string {

export class AuthenticatedKurtosisClient extends KurtosisClient {
private readonly token: string;
private readonly tokenExpiry: DateTime;

constructor(gatewayHost: string, token: string, parentUrl: URL, childUrl: URL) {
super(
Expand All @@ -21,11 +23,24 @@ export class AuthenticatedKurtosisClient extends KurtosisClient {
childUrl,
);
this.token = token;
const parsedToken = JSON.parse(atob(this.token.split(".")[1]));
this.tokenExpiry = DateTime.fromSeconds(parsedToken["exp"]);
}

validateTokenStillFresh() {
if (this.tokenExpiry < DateTime.now()) {
console.log("Token has expired. Triggering a refresh");
window.location.href = KURTOSIS_CLOUD_EM_URL;
}
}

getHeaderOptions(): { headers?: Headers } {
this.validateTokenStillFresh();
const headers = new Headers();
headers.set("Authorization", `Bearer ${this.token}`);
return { headers: headers };
}
isRunningInCloud(): boolean {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
import { EnclaveFullInfo } from "../../emui/enclaves/types";
import { assertDefined, asyncResult, isDefined } from "../../utils";
import { RemoveFunctions } from "../../utils/types";
import { KURTOSIS_CLOUD_HOST } from "../constants";

export abstract class KurtosisClient {
protected readonly client: PromiseClient<typeof KurtosisEnclaveManagerServer>;
Expand Down Expand Up @@ -62,13 +61,7 @@ export abstract class KurtosisClient {
return undefined;
}

getCloudUrl() {
return this.cloudUrl;
}

isRunningInCloud() {
return this.cloudUrl.host.toLowerCase().includes(KURTOSIS_CLOUD_HOST);
}
abstract isRunningInCloud(): boolean;

abstract getHeaderOptions(): { headers?: Headers };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Flex, Heading, Spinner } from "@chakra-ui/react";
import Cookies from "js-cookie";
import { createContext, PropsWithChildren, useContext, useEffect, useMemo, useState } from "react";
import { KurtosisAlert } from "../../components/KurtosisAlert";
import { assertDefined, isDefined, isStringTrue, stringifyError } from "../../utils";
import { assertDefined, isDefined, stringifyError } from "../../utils";
import { KURTOSIS_CLOUD_EM_PAGE, KURTOSIS_CLOUD_EM_URL } from "../constants";
import { AuthenticatedKurtosisClient } from "./AuthenticatedKurtosisClient";
import { KurtosisClient } from "./KurtosisClient";
import { LocalKurtosisClient } from "./LocalKurtosisClient";
Expand All @@ -14,7 +16,6 @@ const KurtosisClientContext = createContext<KurtosisClientContextState>({ client

export const KurtosisClientProvider = ({ children }: PropsWithChildren) => {
const [client, setClient] = useState<KurtosisClient>();
const [jwtToken, setJwtToken] = useState<string>();
const [error, setError] = useState<string>();

const errorHandlingClient = useMemo(() => {
Expand Down Expand Up @@ -47,47 +48,39 @@ export const KurtosisClientProvider = ({ children }: PropsWithChildren) => {
return undefined;
}, [client]);

useEffect(() => {
const receiveMessage = (event: MessageEvent) => {
const message = event.data.message;
switch (message) {
case "jwtToken":
const value = event.data.value;
if (isDefined(value)) {
setJwtToken(value);
}
break;
}
};
window.addEventListener("message", receiveMessage);
return () => window.removeEventListener("message", receiveMessage);
}, []);

useEffect(() => {
(async () => {
const searchParams = new URLSearchParams(window.location.search);
const requireAuth = isStringTrue(searchParams.get("require-authentication"));
// If the pathname starts with /gateway` then we are trying to use an Authenticated client.
const path = window.location.pathname;

try {
setError(undefined);
let newClient: KurtosisClient | null = null;

if (requireAuth) {
const requestedGatewayHost = searchParams.get("api-host");
assertDefined(requestedGatewayHost, `The parameter 'api-host' is not defined`);
if (path.startsWith("/gateway")) {
const pathConfigPattern = /\/gateway\/ips\/([^/]+)\/ports\/([^/]+)(\/|$)/;
const matches = path.match(pathConfigPattern);
if (!matches) {
throw Error(`Cannot configure an authenticated kurtosis client on this path: \`${path}\``);
}

const gatewayHost = matches[1];
const port = parseInt(matches[2]);
if (isNaN(port)) {
throw Error(`Port ${port} is not a number.`);
}

// Get the parent location and path:
let parentLocationPath = paramToUrl(searchParams, "parent-location-path") || new URL(window.location.href);
// Get the child location and path:
let childLocationPath = paramToUrl(searchParams, "child-location-path") || new URL(window.location.href);
const jwtToken = Cookies.get("kurtosis");

if (isDefined(jwtToken)) {
newClient = new AuthenticatedKurtosisClient(
requestedGatewayHost,
`${gatewayHost}`,
jwtToken,
parentLocationPath,
childLocationPath,
new URL(`${window.location.protocol}//${window.location.host}/${KURTOSIS_CLOUD_EM_PAGE}`),
new URL(`${window.location.protocol}//${window.location.host}${matches[0]}`),
);
} else {
window.location.href = KURTOSIS_CLOUD_EM_URL;
}
} else {
newClient = new LocalKurtosisClient();
Expand All @@ -106,7 +99,7 @@ export const KurtosisClientProvider = ({ children }: PropsWithChildren) => {
setError(stringifyError(e));
}
})();
}, [jwtToken]);
}, []);

if (errorHandlingClient) {
return (
Expand Down Expand Up @@ -138,14 +131,3 @@ export const useKurtosisClient = (): KurtosisClient => {

return client;
};

const paramToUrl = (searchParams: URLSearchParams, param: string) => {
let paramString = searchParams.get(param);
if (paramString === null) {
return null;
} else {
paramString = atob(paramString);
assertDefined(paramString, `The parameter ${param}' is not defined`);
return new URL(paramString);
}
};
Loading

0 comments on commit b3a0ea6

Please sign in to comment.