Skip to content

Commit

Permalink
Merge branch 'vsukhin/feature/stream-service-logs' into sandbox/twrc
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>

# Conflicts:
#	cmd/kubectl-testkube/commands/testworkflows/run.go
#	cmd/tcl/testworkflow-toolkit/commands/execute.go
#	go.mod
#	go.sum
  • Loading branch information
vsukhin committed Nov 28, 2024
2 parents 6ea76ad + 9c03fe4 commit c220ccf
Show file tree
Hide file tree
Showing 129 changed files with 7,038 additions and 1,226 deletions.
1 change: 1 addition & 0 deletions .builds-darwin.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ builds:
- -X main.builtBy=goreleaser
- -X github.com/kubeshop/testkube/pkg/telemetry.TestkubeMeasurementID={{.Env.ANALYTICS_TRACKING_ID}}
- -X github.com/kubeshop/testkube/pkg/telemetry.TestkubeMeasurementSecret={{.Env.ANALYTICS_API_KEY}}
- -X github.com/kubeshop/testkube/pkg/diagnostics/validators/license.KeygenOfflinePublicKey={{.Env.KEYGEN_PUBLIC_KEY}}
archives:
- format: binary
1 change: 1 addition & 0 deletions .builds-linux.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ builds:
- -X main.builtBy=goreleaser
- -X github.com/kubeshop/testkube/pkg/telemetry.TestkubeMeasurementID={{.Env.ANALYTICS_TRACKING_ID}}
- -X github.com/kubeshop/testkube/pkg/telemetry.TestkubeMeasurementSecret={{.Env.ANALYTICS_API_KEY}}
- -X github.com/kubeshop/testkube/pkg/diagnostics/validators/license.KeygenOfflinePublicKey={{.Env.KEYGEN_PUBLIC_KEY}}
archives:
- format: binary

Expand Down
1 change: 1 addition & 0 deletions .builds-windows.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ builds:
- -X main.builtBy=goreleaser
- -X github.com/kubeshop/testkube/pkg/telemetry.TestkubeMeasurementID={{.Env.ANALYTICS_TRACKING_ID}}
- -X github.com/kubeshop/testkube/pkg/telemetry.TestkubeMeasurementSecret={{.Env.ANALYTICS_API_KEY}}
- -X github.com/kubeshop/testkube/pkg/diagnostics/validators/license.KeygenOfflinePublicKey={{.Env.KEYGEN_PUBLIC_KEY}}
archives:
- format: binary
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/[email protected].0
uses: github/codeql-action/[email protected].5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand Down Expand Up @@ -82,4 +82,4 @@ jobs:
test-${{ runner.os }}-go-
- name: Perform CodeQL Analysis
uses: github/codeql-action/[email protected].0
uses: github/codeql-action/[email protected].5
51 changes: 18 additions & 33 deletions .github/workflows/docker-build-api-executors-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -442,7 +442,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -510,7 +510,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -669,7 +669,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -741,7 +741,7 @@ jobs:
uses: docker/setup-qemu-action@v3

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -790,7 +790,7 @@ jobs:
uses: actions/checkout@v4

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -863,7 +863,7 @@ jobs:
fetch-depth: 0

- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -942,25 +942,10 @@ jobs:
with:
strip_v: false

- name: Editing helm-release repo with version based on a Tag pushed.
run: |
# Setting up Git:
git clone https://kubeshop-bot:[email protected]/kubeshop/helm-charts
cd ./helm-charts
git config user.name "kubeshop-bot"
git config user.email "[email protected]"
export GH_TOKEN
export RELEASE_VERSION
export SERVICE
git fetch origin main
git checkout main
cd ./scripts
./chart_releaser.sh --helm-chart-folder testkube-$SERVICE
env:
SERVICE: api
GH_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
RELEASE_VERSION: ${{ steps.tag.outputs.tag }}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.CI_BOT_TOKEN }}
repository: kubeshop/helm-charts
event-type: release-testkube-api-charts
client-payload: '{"RELEASE_VERSION": "${{ steps.tag.outputs.tag }}", "SERVICE": "api"}'
3 changes: 2 additions & 1 deletion .github/workflows/release-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_ID}}"
ANALYTICS_API_KEY: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_SECRET}}"
KEYGEN_PUBLIC_KEY: "${{secrets.KEYGEN_PUBLIC_KEY}}"
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
Expand Down Expand Up @@ -185,7 +186,7 @@ jobs:
with:
fetch-depth: 0
- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7
- name: Download Artifacts for Linux
uses: actions/download-artifact@master
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_ID}}"
ANALYTICS_API_KEY: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_SECRET}}"
KEYGEN_PUBLIC_KEY: "${{secrets.KEYGEN_PUBLIC_KEY}}"
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
Expand Down Expand Up @@ -177,7 +178,7 @@ jobs:
with:
fetch-depth: 0
- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected].6
- uses: anchore/sbom-action/[email protected].7
- name: Download Artifacts for Linux
uses: actions/download-artifact@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@b7cdb7fd39e52d1018799033ccd11eeb108aed85 # v2.25.3
uses: github/codeql-action/upload-sarif@f8e782af5670be7b12c0acb5b25c1c5703b931b9 # v2.25.3
with:
sarif_file: results.sarif
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Send coverage report to Codecov
if: always()
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.out
flags: unittests
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:

- name: Send coverage report to Codecov
if: always()
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
file: ./coverage.out
flags: integrationtests
Expand Down
25 changes: 13 additions & 12 deletions cmd/api-server/commons/commons.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,19 @@ func ReadDefaultExecutors(cfg *config.Config) (executors []testkube.ExecutorDeta

func ReadProContext(ctx context.Context, cfg *config.Config, grpcClient cloud.TestKubeCloudAPIClient) config.ProContext {
proContext := config.ProContext{
APIKey: cfg.TestkubeProAPIKey,
URL: cfg.TestkubeProURL,
TLSInsecure: cfg.TestkubeProTLSInsecure,
WorkerCount: cfg.TestkubeProWorkerCount,
LogStreamWorkerCount: cfg.TestkubeProLogStreamWorkerCount,
WorkflowNotificationsWorkerCount: cfg.TestkubeProWorkflowNotificationsWorkerCount,
SkipVerify: cfg.TestkubeProSkipVerify,
EnvID: cfg.TestkubeProEnvID,
OrgID: cfg.TestkubeProOrgID,
Migrate: cfg.TestkubeProMigrate,
ConnectionTimeout: cfg.TestkubeProConnectionTimeout,
DashboardURI: cfg.TestkubeDashboardURI,
APIKey: cfg.TestkubeProAPIKey,
URL: cfg.TestkubeProURL,
TLSInsecure: cfg.TestkubeProTLSInsecure,
WorkerCount: cfg.TestkubeProWorkerCount,
LogStreamWorkerCount: cfg.TestkubeProLogStreamWorkerCount,
WorkflowNotificationsWorkerCount: cfg.TestkubeProWorkflowNotificationsWorkerCount,
WorkflowServiceNotificationsWorkerCount: cfg.TestkubeProWorkflowServiceNotificationsWorkerCount,
SkipVerify: cfg.TestkubeProSkipVerify,
EnvID: cfg.TestkubeProEnvID,
OrgID: cfg.TestkubeProOrgID,
Migrate: cfg.TestkubeProMigrate,
ConnectionTimeout: cfg.TestkubeProConnectionTimeout,
DashboardURI: cfg.TestkubeDashboardURI,
}

if cfg.TestkubeProAPIKey == "" || grpcClient == nil {
Expand Down
20 changes: 19 additions & 1 deletion cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/kubeshop/testkube/cmd/api-server/commons"
"github.com/kubeshop/testkube/cmd/api-server/services"
"github.com/kubeshop/testkube/internal/app/api/debug"
agentclient "github.com/kubeshop/testkube/pkg/agent/client"
cloudartifacts "github.com/kubeshop/testkube/pkg/cloud/data/artifact"
cloudtestworkflow "github.com/kubeshop/testkube/pkg/cloud/data/testworkflow"
"github.com/kubeshop/testkube/pkg/event/kind/cdevent"
Expand Down Expand Up @@ -134,7 +135,7 @@ func main() {
if strings.HasPrefix(controlPlaneUrl, fmt.Sprintf("%s:%d", cfg.APIServerFullname, cfg.GRPCServerPort)) {
controlPlaneUrl = fmt.Sprintf("127.0.0.1:%d", cfg.GRPCServerPort)
}
grpcConn, err = agent.NewGRPCConnection(
grpcConn, err = agentclient.NewGRPCConnection(
ctx,
cfg.TestkubeProTLSInsecure,
cfg.TestkubeProSkipVerify,
Expand Down Expand Up @@ -324,6 +325,22 @@ func main() {
}
return notifications.Channel(), nil
}
getTestWorkflowServiceNotificationsStream := func(ctx context.Context, executionID, serviceName string, serviceIndex int) (<-chan testkube.TestWorkflowExecutionNotification, error) {
execution, err := testWorkflowResultsRepository.Get(ctx, executionID)
if err != nil {
return nil, err
}
notifications := executionWorker.Notifications(ctx, fmt.Sprintf("%s-%s-%d", execution.Id, serviceName, serviceIndex), executionworkertypes.NotificationsOptions{
Hints: executionworkertypes.Hints{
Namespace: execution.Namespace,
ScheduledAt: common.Ptr(execution.ScheduledAt),
},
})
if notifications.Err() != nil {
return nil, notifications.Err()
}
return notifications.Channel(), nil
}
getDeprecatedLogStream := func(ctx context.Context, executionID string) (chan output.Output, error) {
return nil, errors.New("deprecated features have been disabled")
}
Expand All @@ -336,6 +353,7 @@ func main() {
grpcClient,
getDeprecatedLogStream,
getTestWorkflowNotificationsStream,
getTestWorkflowServiceNotificationsStream,
clusterId,
cfg.TestkubeClusterName,
features,
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-testkube/commands/common/cloudcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func UiPrintContext(cfg config.Data) {
}

// add agent information only when need to change agent data, it's usually not needed in usual workflow
if ui.Verbose {
if ui.IsVerbose() {
contextData["Agent Key"] = text.Obfuscate(cfg.CloudContext.AgentKey)
contextData["Agent URI"] = cfg.CloudContext.AgentUri
}
Expand Down
33 changes: 26 additions & 7 deletions cmd/kubectl-testkube/commands/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"fmt"
"os"
"strings"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -52,13 +53,14 @@ const (
const helpUrl = "https://testkubeworkspace.slack.com"

type CLIError struct {
Code ErrorCode
Title string
Description string
ActualError error
StackTrace string
MoreInfo string
Telemetry *ErrorTelemetry
Code ErrorCode
Title string
Description string
ActualError error
StackTrace string
MoreInfo string
ExecutedCommand string
Telemetry *ErrorTelemetry
}

type ErrorTelemetry struct {
Expand Down Expand Up @@ -86,6 +88,15 @@ func (e *CLIError) Print() {

pterm.DefaultSection.Println("Error Details")

cmd := ""
if e.ExecutedCommand != "" {
pterm.FgDarkGray.Printfln("Executed command: %s", e.ExecutedCommand)
params := strings.Split(e.ExecutedCommand, " ")
if len(params) > 0 {
cmd = params[0]
}
}

items := []pterm.BulletListItem{
{Level: 0, Text: pterm.Sprintf("[%s]: %s", e.Code, e.Title), TextStyle: pterm.NewStyle(pterm.FgRed)},
{Level: 0, Text: pterm.Sprintf("%s", e.Description), TextStyle: pterm.NewStyle(pterm.FgLightWhite)},
Expand All @@ -94,6 +105,9 @@ func (e *CLIError) Print() {
items = append(items, pterm.BulletListItem{Level: 0, Text: pterm.Sprintf("%s", e.MoreInfo), TextStyle: pterm.NewStyle(pterm.FgGray)})
}
pterm.DefaultBulletList.WithItems(items).Render()
if cmd != "" {
pterm.DefaultBox.Printfln("Error description is provided in context of binary execution %s", cmd)
}

pterm.Println()
pterm.Println("Let us help you!")
Expand All @@ -111,6 +125,11 @@ func NewCLIError(code ErrorCode, title, moreInfoURL string, err error) *CLIError
}
}

func (err *CLIError) WithExecutedCommand(executedCommand string) *CLIError {
err.ExecutedCommand = executedCommand
return err
}

// HandleCLIError checks does the error exist, and if it does, prints the error and exits the program.
func HandleCLIError(err *CLIError) {
if err != nil {
Expand Down
Loading

0 comments on commit c220ccf

Please sign in to comment.