Skip to content

Commit

Permalink
feat: [TKC-2684] docker image meta (#5936)
Browse files Browse the repository at this point in the history
* fix: remove docker example

Signed-off-by: Vladislav Sukhin <[email protected]>

* feat: pass docker image version to cloud

Signed-off-by: Vladislav Sukhin <[email protected]>

---------

Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin authored Oct 16, 2024
1 parent 451fb22 commit c0d0afd
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 259 deletions.
6 changes: 1 addition & 5 deletions build/kind/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,10 @@ else
fi
log "Testkube is up and running."

# Step 9: Create Testkube k6 Test Workflow
log "Creating and running Testkube k6 Test Workflow..."
kubectl apply -f /examples/k6.yaml -n testkube

log "Testkube installation succeed!"
log "You can now use Testkube in your Kind Kubernetes cluster."
send_telenetry "docker_installation_succeed"
fi

# Step 10: Bring docker service back to foreground
# Step 9: Bring docker service back to foreground
fg %1
239 changes: 0 additions & 239 deletions build/kind/k6.yaml

This file was deleted.

1 change: 0 additions & 1 deletion build/kind/kind.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ RUN chmod +x /usr/local/bin/entrypoint.sh

# Step 7: Example K6 Test Workflow CRD and preload Kind images
COPY ./images /images
COPY k6.yaml /examples/k6.yaml

ARG segmentio_key

Check warning on line 30 in build/kind/kind.Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image for Testkube Agent

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "segmentio_key") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV SEGMENTIO_KEY=$segmentio_key

Check warning on line 31 in build/kind/kind.Dockerfile

View workflow job for this annotation

GitHub Actions / Build a Docker image for Testkube Agent

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SEGMENTIO_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
Expand Down
1 change: 1 addition & 0 deletions cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ func main() {
envs,
features,
proContext,
cfg.TestkubeDockerImageVersion,
)
if err != nil {
exitOnError("Starting agent", err)
Expand Down
27 changes: 16 additions & 11 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ import (
)

const (
timeout = 10 * time.Second
apiKeyMeta = "api-key"
clusterIDMeta = "cluster-id"
cloudMigrateMeta = "migrate"
orgIdMeta = "environment-id"
envIdMeta = "organization-id"
healthcheckCommand = "healthcheck"
timeout = 10 * time.Second
apiKeyMeta = "api-key"
clusterIDMeta = "cluster-id"
cloudMigrateMeta = "migrate"
orgIdMeta = "environment-id"
envIdMeta = "organization-id"
healthcheckCommand = "healthcheck"
dockerImageVersionMeta = "docker-image-version"
)

// buffer up to five messages per worker
Expand Down Expand Up @@ -150,10 +151,11 @@ type Agent struct {
receiveTimeout time.Duration
healthcheckInterval time.Duration

clusterID string
clusterName string
envs map[string]string
features featureflags.FeatureFlags
clusterID string
clusterName string
envs map[string]string
features featureflags.FeatureFlags
dockerImageVersion string

proContext config.ProContext
}
Expand All @@ -168,6 +170,7 @@ func NewAgent(logger *zap.SugaredLogger,
envs map[string]string,
features featureflags.FeatureFlags,
proContext config.ProContext,
dockerImageVersion string,
) (*Agent, error) {
return &Agent{
handler: handler,
Expand All @@ -194,6 +197,7 @@ func NewAgent(logger *zap.SugaredLogger,
envs: envs,
features: features,
proContext: proContext,
dockerImageVersion: dockerImageVersion,
}, nil
}

Expand Down Expand Up @@ -313,6 +317,7 @@ func (ag *Agent) runCommandLoop(ctx context.Context) error {
ctx = metadata.AppendToOutgoingContext(ctx, cloudMigrateMeta, ag.proContext.Migrate)
ctx = metadata.AppendToOutgoingContext(ctx, envIdMeta, ag.proContext.EnvID)
ctx = metadata.AppendToOutgoingContext(ctx, orgIdMeta, ag.proContext.OrgID)
ctx = metadata.AppendToOutgoingContext(ctx, dockerImageVersionMeta, ag.dockerImageVersion)

ag.logger.Infow("initiating streaming connection with control plane")
// creates a new Stream from the client side. ctx is used for the lifetime of the stream.
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestCommandExecution(t *testing.T) {

logger, _ := zap.NewDevelopment()
proContext := config.ProContext{APIKey: "api-key", WorkerCount: 5, LogStreamWorkerCount: 5, WorkflowNotificationsWorkerCount: 5}
agent, err := agent.NewAgent(logger.Sugar(), m, grpcClient, logStreamFunc, workflowNotificationsStreamFunc, "", "", nil, featureflags.FeatureFlags{}, proContext)
agent, err := agent.NewAgent(logger.Sugar(), m, grpcClient, logStreamFunc, workflowNotificationsStreamFunc, "", "", nil, featureflags.FeatureFlags{}, proContext, "")
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestEventLoop(t *testing.T) {
var workflowNotificationsStreamFunc func(ctx context.Context, executionID string) (chan testkube.TestWorkflowExecutionNotification, error)

proContext := config.ProContext{APIKey: "api-key", WorkerCount: 5, LogStreamWorkerCount: 5, WorkflowNotificationsWorkerCount: 5}
agent, err := agent.NewAgent(logger.Sugar(), nil, grpcClient, logStreamFunc, workflowNotificationsStreamFunc, "", "", nil, featureflags.FeatureFlags{}, proContext)
agent, err := agent.NewAgent(logger.Sugar(), nil, grpcClient, logStreamFunc, workflowNotificationsStreamFunc, "", "", nil, featureflags.FeatureFlags{}, proContext, "")
assert.NoError(t, err)
go func() {
l, err := agent.Load()
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestLogStream(t *testing.T) {

logger, _ := zap.NewDevelopment()
proContext := config.ProContext{APIKey: "api-key", WorkerCount: 5, LogStreamWorkerCount: 5, WorkflowNotificationsWorkerCount: 5}
agent, err := agent.NewAgent(logger.Sugar(), m, grpcClient, logStreamFunc, workflowNotificationsStreamFunc, "", "", nil, featureflags.FeatureFlags{}, proContext)
agent, err := agent.NewAgent(logger.Sugar(), m, grpcClient, logStreamFunc, workflowNotificationsStreamFunc, "", "", nil, featureflags.FeatureFlags{}, proContext, "")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit c0d0afd

Please sign in to comment.