Skip to content

Commit

Permalink
Merge branch 'main' into tedi/tail-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Sep 19, 2023
2 parents 9a336dc + 6ce8243 commit c14d9bc
Show file tree
Hide file tree
Showing 108 changed files with 8,845 additions and 30 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.83.4](https://github.com/kurtosis-tech/kurtosis/compare/0.83.3...0.83.4) (2023-09-19)


### Features

* Add format flag to kurtosis port print ([#1319](https://github.com/kurtosis-tech/kurtosis/issues/1319)) ([cbbf260](https://github.com/kurtosis-tech/kurtosis/commit/cbbf260d872344c40fd768ed2226510550a8370d))


### Bug Fixes

* scan for first week of existing logs ([#1343](https://github.com/kurtosis-tech/kurtosis/issues/1343)) ([3905782](https://github.com/kurtosis-tech/kurtosis/commit/3905782b45b8b89d77ee70e231a2e04c19ca1bf0))

## [0.83.3](https://github.com/kurtosis-tech/kurtosis/compare/0.83.2...0.83.3) (2023-09-19)


Expand Down
2 changes: 1 addition & 1 deletion 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.83.3
Licensed Work: Kurtosis 0.83.4
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 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.83.3"
KurtosisVersion = "0.83.4"
// !!!!!!!!!!! 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.83.3"
version = "0.83.4"
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.83.3",
"version": "0.83.4",
"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.83.3"
export const KURTOSIS_VERSION: string = "0.83.4"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
66 changes: 59 additions & 7 deletions cli/cli/commands/port/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package print
import (
"context"
"fmt"
"github.com/kurtosis-tech/kurtosis/api/golang/core/lib/services"
"github.com/kurtosis-tech/kurtosis/api/golang/engine/kurtosis_engine_rpc_api_bindings"
"github.com/kurtosis-tech/kurtosis/api/golang/engine/lib/kurtosis_context"
"github.com/kurtosis-tech/kurtosis/cli/cli/command_framework/highlevel/enclave_id_arg"
Expand All @@ -15,6 +16,8 @@ import (
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface"
metrics_client "github.com/kurtosis-tech/metrics-library/golang/lib/client"
"github.com/kurtosis-tech/stacktrace"
"github.com/sirupsen/logrus"
"strings"
)

const (
Expand All @@ -33,16 +36,39 @@ const (
isPortIdentifierArgOptional = false
isPortIdentifierArgGreedy = false

formatFlagKey = "format"
protocolStr = "protocol"
ipStr = "ip"
numberStr = "number"

ipAddress = "127.0.0.1"
)

var (
formatFlagKeyDefault = fmt.Sprintf("'%s,%s,%s'", protocolStr, ipStr, numberStr)
formatFlagKeyExamples = []string{
fmt.Sprintf("'%s'", ipStr),
fmt.Sprintf("'%s'", numberStr),
fmt.Sprintf("'%s,%s'", protocolStr, ipStr),
}
)

var PortPrintCmd = &engine_consuming_kurtosis_command.EngineConsumingKurtosisCommand{
CommandStr: command_str_consts.PortPrintCmdStr,
ShortDescription: "Get information about port",
LongDescription: "Get information for port using port id",
KurtosisBackendContextKey: kurtosisBackendCtxKey,
EngineClientContextKey: engineClientCtxKey,
Flags: []*flags.FlagConfig{},
Flags: []*flags.FlagConfig{
{
Key: formatFlagKey,
Usage: fmt.Sprintf(
"Allows selecting what pieces of port are printed, using comma separated values (examples: %s). Default %s.",
strings.Join(formatFlagKeyExamples, ", "), formatFlagKeyDefault),
Type: flags.FlagType_String,
Default: formatFlagKeyDefault,
},
},
Args: []*args.ArgConfig{
enclave_id_arg.NewHistoricalEnclaveIdentifiersArgWithValidationDisabled(
enclaveIdentifierArgKey,
Expand Down Expand Up @@ -89,6 +115,11 @@ func run(
return stacktrace.Propagate(err, "An error occurred getting the port identifier using arg key '%v'", portIdentifier)
}

format, err := flags.GetString(formatFlagKey)
if err != nil {
return stacktrace.Propagate(err, "An error occurred getting the output flag key '%v'", formatFlagKey)
}

kurtosisCtx, err := kurtosis_context.NewKurtosisContextFromLocalEngine()
if err != nil {
return stacktrace.Propagate(err, "An error occurred connecting to the local Kurtosis engine")
Expand All @@ -113,13 +144,34 @@ func run(
)
}

fullUrl := fmt.Sprintf("%v:%v", ipAddress, publicPort.GetNumber())
maybeApplicationProtocol := publicPort.GetMaybeApplicationProtocol()

if maybeApplicationProtocol != "" {
fullUrl = fmt.Sprintf("%v://%v", maybeApplicationProtocol, fullUrl)
fullUrl, err := formatOutput(format, ipAddress, publicPort)
if err != nil {
return stacktrace.Propagate(err, "Couldn't format the output according to formatting string '%v'", format)
}

out.PrintOutLn(fullUrl)
return nil
}

func formatOutput(format string, ipAddress string, spec *services.PortSpec) (string, error) {
parts := strings.Split(format, ",")
var resultParts []string
for _, part := range parts {
switch part {
case protocolStr:
if spec.GetMaybeApplicationProtocol() != "" {
resultParts = append(resultParts, spec.GetMaybeApplicationProtocol()+"://")
} else {
// TODO(victor.colombo): What should we do here? Panic? Warn?
// Left it as a debug for now so it doesn't pollute the output
logrus.Debugf("Expected protocol but was empty, skipping")
}
case ipStr:
resultParts = append(resultParts, ipAddress)
case numberStr:
resultParts = append(resultParts, fmt.Sprintf(":%d", spec.GetNumber()))
default:
return "", stacktrace.NewError("Invalid format piece '%v'", part)
}
}
return strings.Join(resultParts, ""), nil
}
57 changes: 57 additions & 0 deletions docs/versioned_docs/version-0.83.4/best-practices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Best Practices
sidebar_label: Best Practices
slug: /best-practices
---

Passing package arguments to the CLI
-------------------------------
Passing [package parameters][package-parameterization] via the CLI can get hairy due to the interaction between Bash and JSON quotes. The following are tips to make your life easier:

1. **When you have a small number of arguments:** surround the arguments with single quotes so you don't have to escape double quotes in your JSON. E.g.:
```bash
kurtosis run github.com/user/repo '{"some_param":5,"some_other_param":"My value"}'
```
1. **When you have a large number of arguments:** put them in a `.json` file and use [Bash command substitution](https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html) _inside double quotes_ to slot them into the `kurtosis run` command. E.g.:
```bash
kurtosis run github.com/user/repo "$(cat my-params.json)"
```
The double quotes around the `$(cat my-params.json)` are important so any spaces inside `my-params.json` don't fool Bash into thinking you're passing in two separate arguments.

Choosing the right wait
-----------------------
Kurtosis has three different types of waits. Described here are the three, with tips on when to use each:

1. Automatic waiting on port availability when a service starts (enabled by default; can be configured with [`PortSpec.wait`][port-spec-starlark-reference])
- Should be sufficient for most usecases
- Requires little-to-no extra configuration
- Will cause parallel `Plan.add_services` to fail, allowing for quick aborting
1. Waiting on [`ReadyCondition`][ready-condition-starlark-reference]s (configured in [`ServiceConfig`][service-config-starlark-reference])
- Allows for more advanced checking (e.g. require a certain HTTP response body, ensure a CLI call returns success, etc.)
- More complex to configure
- Will cause parallel `Plan.add_services` to fail, allowing for quick aborting
1. The [`Plan.wait`][plan-wait-starlark-reference]
- Most useful for asserting the system has reached a desired state in tests (e.g. wait until data shows up after loading)
- More complex to configure
- Cannot be used to short-circuit `Plan.add_services`

Choosing service names in Kurtosis
----------------------------------
Kurtosis service names implements [RFC-1035](https://datatracker.ietf.org/doc/html/rfc1035), meaning the names of all services must be a valid [RFC-1035 Label Name](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names). Tactically this means a service name must:

- contain at most 63 characters
- contain only lowercase alphanumeric characters or '-'
- start with an alphabetic character
- end with an alphanumeric character

Failure to adhere to the above standards will result in errors when running Kurtosis.



<!---------------------------------------- ONLY LINKS BELOW HERE!!! ----------------------------------->
[package-parameterization]: ./concepts-reference/packages.md#parameterization

[service-config-starlark-reference]: ./starlark-reference/service-config.md
[port-spec-starlark-reference]: ./starlark-reference/port-spec.md
[ready-condition-starlark-reference]: ./starlark-reference/ready-condition.md
[plan-wait-starlark-reference]: ./starlark-reference/plan.md#wait

0 comments on commit c14d9bc

Please sign in to comment.