Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into sandbox/tw-expecte…
Browse files Browse the repository at this point in the history
…d-fail-ext
  • Loading branch information
tkonieczny committed Aug 1, 2024
2 parents cad3c39 + 373079c commit 40d7c39
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 13 deletions.
3 changes: 0 additions & 3 deletions build/logs-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ RUN apk --no-cache --update add ca-certificates && (rm -rf /var/cache/apk/* || 0

WORKDIR /root/

RUN mkdir /data
RUN chown -R 1001:0 /data

COPY testkube-logs-server /bin/app
USER 1001
EXPOSE 8088
Expand Down
2 changes: 1 addition & 1 deletion cmd/logs-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func main() {
cfg.StorageCAFile)

minioAdapter.
WithPath(cfg.StorageFilePath)
WithNonEmptyPath(cfg.StorageFilePath)

if err != nil {
log.Errorw("error creating minio adapter", "error", err)
Expand Down
3 changes: 3 additions & 0 deletions cmd/tcl/testworkflow-toolkit/spawn/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ func CreateBaseMachine() expressions.Machine {
"cloud.api.tlsInsecure": strconv.FormatBool(env.Config().Cloud.TlsInsecure),
"cloud.api.skipVerify": strconv.FormatBool(env.Config().Cloud.SkipVerify),
"cloud.api.url": env.Config().Cloud.Url,
"cloud.ui.url": env.Config().Cloud.UiUrl,
"cloud.api.orgId": env.Config().Cloud.OrgId,
"cloud.api.envId": env.Config().Cloud.EnvId,

"dashboard.url": env.Config().System.DashboardUrl,
"api.url": env.Config().System.ApiUrl,
Expand Down
3 changes: 3 additions & 0 deletions cmd/testworkflow-toolkit/env/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type envObjectStorageConfig struct {
type envCloudConfig struct {
Url string `envconfig:"TK_C_URL"`
ApiKey string `envconfig:"TK_C_KEY"`
UiUrl string `envconfig:"TK_C_UI_URL"`
OrgId string `envconfig:"TK_C_ORG_ID"`
EnvId string `envconfig:"TK_C_ENV_ID"`
SkipVerify bool `envconfig:"TK_C_SKIP_VERIFY" default:"false"`
TlsInsecure bool `envconfig:"TK_C_TLS_INSECURE" default:"false"`
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/logs/adapter/minio_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import (
minioconnecter "github.com/kubeshop/testkube/pkg/storage/minio"
)

// DefaultDataDir is a default directory where logs are stored (logs-service Dockerfile creates this directory)
const DefaultDataDir = "/data"

var _ Adapter = &MinioV2Adapter{}

// NewMinioV2Adapter creates new MinioV2Adapter which will send data to local MinIO bucket
func NewMinioV2Adapter(endpoint, accessKeyID, secretAccessKey, region, token, bucket string, ssl, skipVerify bool, certFile, keyFile, caFile string) (*MinioV2Adapter, error) {
dir, err := os.MkdirTemp("", "minio")
if err != nil {
return nil, err
}
ctx := context.Background()
opts := minioconnecter.GetTLSOptions(ssl, skipVerify, certFile, keyFile, caFile)
c := &MinioV2Adapter{
Expand All @@ -30,7 +31,7 @@ func NewMinioV2Adapter(endpoint, accessKeyID, secretAccessKey, region, token, bu
bucket: bucket,
region: region,
files: make(map[string]*os.File),
path: DefaultDataDir,
path: dir,
}
minioClient, err := c.minioConnecter.GetClient()
if err != nil {
Expand Down Expand Up @@ -109,8 +110,10 @@ func (s *MinioV2Adapter) deleteFile(id string) {
delete(s.files, id)
}

func (s *MinioV2Adapter) WithPath(path string) {
s.path = path
func (s *MinioV2Adapter) WithNonEmptyPath(path string) {
if path != "" {
s.path = path
}
}

func (s *MinioV2Adapter) Notify(ctx context.Context, id string, e events.Log) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/adapter/minio_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestLogsV2Local(t *testing.T) {
t.Skip("only local")
ctx := context.Background()
consumer, _ := NewMinioV2Adapter(cfg.StorageEndpoint, cfg.StorageAccessKeyID, cfg.StorageSecretAccessKey, cfg.StorageRegion, cfg.StorageToken, "test-1", cfg.StorageSSL, cfg.StorageSkipVerify, cfg.StorageCertFile, cfg.StorageKeyFile, cfg.StorageCAFile)
consumer.WithPath("./")
consumer.WithNonEmptyPath("./")
id := "test-bla"
err := consumer.Init(ctx, id)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/config/logs_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Config struct {
StorageCertFile string `envconfig:"STORAGE_CERT_FILE" default:""`
StorageKeyFile string `envconfig:"STORAGE_KEY_FILE" default:""`
StorageCAFile string `envconfig:"STORAGE_CA_FILE" default:""`
StorageFilePath string `envconfig:"STORAGE_FILE_PATH" default:"/data"`
StorageFilePath string `envconfig:"STORAGE_FILE_PATH" default:""`
}

func Get() (*Config, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/repository/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (r MinioLogsRepository) readLineLogsV2(file io.Reader, ch chan events.LogRe
err = json.Unmarshal(b, &log)
if err != nil {
r.log.Errorw("error unmarshalling log line", "error", err)
ch <- events.LogResponse{Error: err}
// ch <- events.LogResponse{Error: err}
continue
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/testworkflows/testworkflowexecutor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ func (e *executor) Execute(ctx context.Context, workflow testworkflowsv1.TestWor
"cloud.api.tlsInsecure": common.GetOr(os.Getenv("TESTKUBE_PRO_TLS_INSECURE"), os.Getenv("TESTKUBE_CLOUD_TLS_INSECURE"), "false"),
"cloud.api.skipVerify": common.GetOr(os.Getenv("TESTKUBE_PRO_SKIP_VERIFY"), os.Getenv("TESTKUBE_CLOUD_SKIP_VERIFY"), "false"),
"cloud.api.url": common.GetOr(os.Getenv("TESTKUBE_PRO_URL"), os.Getenv("TESTKUBE_CLOUD_URL")),
"cloud.ui.url": common.GetOr(os.Getenv("TESTKUBE_PRO_UI_URL"), os.Getenv("TESTKUBE_CLOUD_UI_URL")),
"cloud.api.orgId": common.GetOr(os.Getenv("TESTKUBE_PRO_ORG_ID"), os.Getenv("TESTKUBE_CLOUD_ORG_ID")),
"cloud.api.envId": common.GetOr(os.Getenv("TESTKUBE_PRO_ENV_ID"), os.Getenv("TESTKUBE_CLOUD_ENV_ID")),

"serviceaccount.default": e.serviceAccountNames[namespace],

Expand Down
3 changes: 3 additions & 0 deletions pkg/testworkflows/testworkflowprocessor/stage/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ func (c *container) EnableToolkit(ref string) Container {
"TK_C_KEY": "{{internal.cloud.api.key}}",
"TK_C_TLS_INSECURE": "{{internal.cloud.api.tlsInsecure}}",
"TK_C_SKIP_VERIFY": "{{internal.cloud.api.skipVerify}}",
"TK_C_UI_URL": "{{internal.cloud.ui.url}}",
"TK_C_ORG_ID": "{{internal.cloud.api.orgId}}",
"TK_C_ENV_ID": "{{internal.cloud.api.envId}}",
"TK_OS_ENDPOINT": "{{internal.storage.url}}",
"TK_OS_ACCESSKEY": "{{internal.storage.accessKey}}",
"TK_OS_SECRETKEY": "{{internal.storage.secretKey}}",
Expand Down

0 comments on commit 40d7c39

Please sign in to comment.