Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys committed Dec 20, 2023
1 parent 832de3d commit 01cf61a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func getBackendEngine(backendCtx context.Context, backendName string, addons []s
return addonBackend.Value, nil
}

backend.Init(backendCtx)
engine, err := backend.FindBackend(backendCtx, backendName)
if err != nil {
log.Error().Err(err).Msgf("cannot find backend engine '%s'", backendName)
Expand Down
10 changes: 5 additions & 5 deletions pipeline/backend/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ func (e *kube) TailStep(ctx context.Context, step *types.Step, taskUUID string)
// return rc, nil
}

func (e *kube) DestroyStep(_ context.Context, step *types.Step, taskUUID string) error {
func (e *kube) DestroyStep(ctx context.Context, step *types.Step, taskUUID string) error {
log.Trace().Str("taskUUID", taskUUID).Msgf("Stopping step: %s", step.Name)
err := stopPod(e.ctx, e, step, defaultDeleteOptions)
err := stopPod(ctx, e, step, defaultDeleteOptions)
return err
}

Expand All @@ -338,13 +338,13 @@ func (e *kube) DestroyWorkflow(ctx context.Context, conf *types.Config, taskUUID
// Use noContext because the ctx sent to this function will be canceled/done in case of error or canceled by user.
for _, stage := range conf.Stages {
for _, step := range stage.Steps {
err := stopPod(e.ctx, e, step, defaultDeleteOptions)
err := stopPod(ctx, e, step, defaultDeleteOptions)
if err != nil {
return err
}

if step.Type == types.StepTypeService {
err := stopService(e.ctx, e, step, defaultDeleteOptions)
err := stopService(ctx, e, step, defaultDeleteOptions)
if err != nil {
return err
}
Expand All @@ -353,7 +353,7 @@ func (e *kube) DestroyWorkflow(ctx context.Context, conf *types.Config, taskUUID
}

for _, vol := range conf.Volumes {
err := stopVolume(e.ctx, e, vol.Name, defaultDeleteOptions)
err := stopVolume(ctx, e, vol.Name, defaultDeleteOptions)
if err != nil {
return err
}
Expand Down
9 changes: 3 additions & 6 deletions pipeline/backend/kubernetes/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

func mkService(namespace, name string, ports []uint16, selector map[string]string) (*v1.Service, error) {
func mkService(namespace, name string, ports []uint16, selector map[string]string) *v1.Service {
log.Trace().Str("name", name).Interface("selector", selector).Interface("ports", ports).Msg("Creating service")

var svcPorts []v1.ServicePort
Expand All @@ -48,7 +48,7 @@ func mkService(namespace, name string, ports []uint16, selector map[string]strin
Selector: selector,
Ports: svcPorts,
},
}, nil
}
}

func serviceName(step *types.Step) (string, error) {
Expand All @@ -69,10 +69,7 @@ func startService(ctx context.Context, engine *kube, step *types.Step) (*v1.Serv
StepLabel: podName,
}

svc, err := mkService(engine.config.Namespace, name, step.Ports, selector)
if err != nil {
return nil, err
}
svc := mkService(engine.config.Namespace, name, step.Ports, selector)

return engine.client.CoreV1().Services(engine.config.Namespace).Create(ctx, svc, metav1.CreateOptions{})
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/backend/kubernetes/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestService(t *testing.T) {
}
}`

s, _ := mkService("foo", "bar", []uint16{1, 2, 3}, map[string]string{"step": "baz"})
s := mkService("foo", "bar", []uint16{1, 2, 3}, map[string]string{"step": "baz"})
j, err := json.Marshal(s)
assert.NoError(t, err)
assert.JSONEq(t, expected, string(j))
Expand Down

0 comments on commit 01cf61a

Please sign in to comment.