Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Release/v2.0.4 #5636

Merged
merged 23 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e249f5d
fix: 'fetch' operation for parallel steps (#5615)
rangoo94 Jun 27, 2024
f994ef3
whitelist containers for which logs should be extracted (#5612)
dejanzele Jun 27, 2024
4b47821
build(deps): bump amannn/action-semantic-pull-request
dependabot[bot] Jun 28, 2024
bd6de5b
feat: improved debug cmd (#5617)
exu Jun 28, 2024
7b2ad57
fix: (TKC-2164) valid container executor exit code handling (#5614)
exu Jul 2, 2024
b343903
feat: check for test workflow execution for execute action
vsukhin Jun 26, 2024
acb57f0
fix: add extended model
vsukhin Jun 26, 2024
e3f8a56
feat: queued cd event for test workflow
vsukhin Jun 27, 2024
cc70b45
feat: start event for test workflow
vsukhin Jun 27, 2024
becb554
feat: finish cd event for test workflow
vsukhin Jun 27, 2024
667ed79
feat: log cd event for test workflow
vsukhin Jun 27, 2024
d7903fe
feat: cd event test workflow atifact
vsukhin Jun 28, 2024
8778b28
feat: unit tests for cd events mapper test workflows
vsukhin Jul 1, 2024
8f14515
fix: rename field
vsukhin Jul 1, 2024
21fe239
fix: integration test
vsukhin Jul 1, 2024
1444718
fix: unmarshaling typo
vsukhin Jul 2, 2024
79bddc4
fix: error handling when creating TW (#5631)
exu Jul 3, 2024
811d1b7
fix: user friendly oss error
vsukhin Jul 2, 2024
8141bad
fix: add comment
vsukhin Jul 2, 2024
a01b222
fix: paarse error message
vsukhin Jul 3, 2024
678df05
Update CODEOWNERS
ed382 Jul 4, 2024
5597434
fix: Conflicting KV create (#5635)
exu Jul 4, 2024
7da22fd
Merge branch 'main' into develop
vsukhin Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# Please look up the latest version from
# https://github.com/amannn/action-semantic-pull-request/releases
- name: Lint PR
uses: amannn/[email protected].2
uses: amannn/[email protected].3

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: third-party GitHubAction not pinned by hash
Click Remediation section below to solve this issue
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
3 changes: 3 additions & 0 deletions cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ func main() {
logsStream,
features,
cfg.TestkubeDefaultStorageClassName,
cfg.WhitelistedContainers,
)
if err != nil {
exitOnError("Creating executor client", err)
Expand Down Expand Up @@ -509,6 +510,7 @@ func main() {
logsStream,
features,
cfg.TestkubeDefaultStorageClassName,
cfg.WhitelistedContainers,
)
if err != nil {
exitOnError("Creating container executor", err)
Expand Down Expand Up @@ -571,6 +573,7 @@ func main() {
cfg.EnableImageDataPersistentCache,
cfg.ImageDataPersistentCacheKey,
cfg.TestkubeDashboardURI,
clusterId,
)

go testWorkflowExecutor.Recover(context.Background())
Expand Down
45 changes: 3 additions & 42 deletions cmd/kubectl-testkube/commands/agent/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,13 @@ package agent

import (
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/config"
"github.com/kubeshop/testkube/pkg/ui"
)

func NewDebugAgentCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "debug",
Short: "Debug Agent info",
Run: func(cmd *cobra.Command, args []string) {
cfg, err := config.Load()
ui.ExitOnError("loading config file", err)
ui.NL()

if cfg.ContextType != config.ContextTypeCloud {
ui.Errf("Agent debug is only available for cloud context")
ui.NL()
ui.ShellCommand("Please try command below to set your context into Cloud mode", `testkube set context -o <org> -e <env> -k <api-key> `)
ui.NL()
return
}

common.UiPrintContext(cfg)

client, _, err := common.GetClient(cmd)
ui.ExitOnError("getting client", err)

i, err := client.GetServerInfo()
if err != nil {
ui.Errf("Error %v", err)
ui.NL()
ui.Info("Possible reasons:")
ui.Warn("- Please check if your agent organization and environment are set correctly")
ui.Warn("- Please check if your API token is set correctly")
ui.NL()
} else {
ui.Warn("Agent correctly connected to cloud:\n")
ui.InfoGrid(map[string]string{
"Agent version ": i.Version,
"Agent namespace": i.Namespace,
})
}
ui.NL()
},
Use: "debug",
Short: "Debug Agent info",
Deprecated: "use `testkube debug agent` instead",
}

return cmd
Expand Down
28 changes: 28 additions & 0 deletions cmd/kubectl-testkube/commands/common/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,31 @@ func ProcessMasterFlags(cmd *cobra.Command, opts *HelmOptions, cfg *config.Data)
func IsBothEnabledAndDisabledSet(cmd *cobra.Command) bool {
return cmd.Flag("enable-webhooks").Changed && cmd.Flag("disable-webhooks").Changed
}

// CommaList is a custom flag type for features
type CommaList []string

func (s CommaList) String() string {
return strings.Join(s, ",")
}
func (s *CommaList) Type() string {
return "[]string"
}

func (s *CommaList) Set(value string) error {
*s = strings.Split(value, ",")
return nil
}

// Enabled returns true if the feature is enabled, defaults to all
func (s *CommaList) Enabled(value string) bool {
if len(*s) == 0 {
return true
}
for _, f := range *s {
if f == value {
return true
}
}
return false
}
110 changes: 108 additions & 2 deletions cmd/kubectl-testkube/commands/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func uiGetToken(tokenChan chan cloudlogin.Tokens) (string, string, error) {
return token.IDToken, token.RefreshToken, nil
}

func KubectlPrintLogs(namespace string, labels map[string]string) error {
func KubectlLogs(namespace string, labels map[string]string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
Expand Down Expand Up @@ -491,6 +491,24 @@ func KubectlPrintEvents(namespace string) error {
return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlDescribePods(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
}

args := []string{
"describe",
"pods",
"-n", namespace,
}

ui.ShellCommand(kubectl, args...)
ui.NL()

return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlPrintPods(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
Expand All @@ -510,7 +528,7 @@ func KubectlPrintPods(namespace string) error {
return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlPrintStorageClass(namespace string) error {
func KubectlGetStorageClass(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
Expand All @@ -526,3 +544,91 @@ func KubectlPrintStorageClass(namespace string) error {

return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlGetServices(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
}

args := []string{
"get",
"services",
"-n", namespace,
}

ui.ShellCommand(kubectl, args...)
ui.NL()

return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlDescribeServices(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
}

args := []string{
"get",
"services",
"-n", namespace,
"-o", "yaml",
}

ui.ShellCommand(kubectl, args...)
ui.NL()

return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlGetIngresses(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
}

args := []string{
"get",
"ingresses",
"-n", namespace,
}

ui.ShellCommand(kubectl, args...)
ui.NL()

return process.ExecuteAndStreamOutput(kubectl, args...)
}

func KubectlDescribeIngresses(namespace string) error {
kubectl, err := exec.LookPath("kubectl")
if err != nil {
return err
}

args := []string{
"get",
"ingresses",
"-n", namespace,
"-o", "yaml",
}

ui.ShellCommand(kubectl, args...)
ui.NL()

return process.ExecuteAndStreamOutput(kubectl, args...)
}

func UiGetNamespace(cmd *cobra.Command, defaultNamespace string) string {
var namespace string
var err error

if cmd.Flag("namespace").Changed {
namespace, err = cmd.Flags().GetString("namespace")
ui.ExitOnError("getting namespace", err)
} else {
namespace = ui.TextInput("Please provide namespace for Control Plane", defaultNamespace)
}

return namespace
}
67 changes: 4 additions & 63 deletions cmd/kubectl-testkube/commands/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,19 @@ package commands
import (
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common/validator"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/debug"
"github.com/kubeshop/testkube/cmd/kubectl-testkube/config"
"github.com/kubeshop/testkube/pkg/ui"
)

// NewDebugCmd creates the 'testkube debug' command
func NewDebugCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "debug",
Aliases: []string{"dbg", "d"},
Short: "Print environment information for debugging",
Run: func(cmd *cobra.Command, args []string) {
Short: "Print debugging info",
}

cfg, err := config.Load()
ui.ExitOnError("loading config file", err)

if cfg.ContextType == config.ContextTypeCloud {
cfg, err := config.Load()
ui.ExitOnError("loading config file", err)
ui.NL()

if cfg.ContextType != config.ContextTypeCloud {
ui.Errf("Agent debug is only available for cloud context")
ui.NL()
ui.ShellCommand("Please try command below to set your context into Cloud mode", `testkube set context -o <org> -e <env> -k <api-key> `)
ui.NL()
return
}

common.UiPrintContext(cfg)

client, _, err := common.GetClient(cmd)
ui.ExitOnError("getting client", err)

i, err := client.GetServerInfo()
if err != nil {
ui.Errf("Error %v", err)
ui.NL()
ui.Info("Possible reasons:")
ui.Warn("- Please check if your agent organization and environment are set correctly")
ui.Warn("- Please check if your API token is set correctly")
ui.NL()
} else {
ui.Warn("Agent correctly connected to cloud:\n")
ui.InfoGrid(map[string]string{
"Agent version ": i.Version,
"Agent namespace": i.Namespace,
})
}
ui.NL()
} else {
client, _, err := common.GetClient(cmd)
ui.ExitOnError("getting client", err)

d, err := debug.GetDebugInfo(client)
ui.ExitOnError("get debug info", err)

debug.PrintDebugInfo(d)

}
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cfg, err := config.Load()
ui.ExitOnError("loading config", err)
common.UiContextHeader(cmd, cfg)

validator.PersistentPreRunVersionCheck(cmd, common.Version)
}}

cmd.AddCommand(debug.NewShowDebugInfoCmd())
cmd.AddCommand(debug.NewDebugOssCmd())
cmd.AddCommand(debug.NewDebugAgentCmd())
cmd.AddCommand(debug.NewDebugControlPlaneCmd())

return cmd
Expand Down
Loading
Loading