Skip to content

Commit

Permalink
remove docker changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nadim-az committed Jan 20, 2025
1 parent 1ad307f commit 6a7a2f5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 39 deletions.
2 changes: 0 additions & 2 deletions core/provider/docker/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ func (p *Provider) nextAvailableIP() (string, error) {
return "", err
}

p.state.AllocatedIPs = append(p.state.AllocatedIPs, ip.To4().String())

return ip.String(), nil
}

Expand Down
1 change: 0 additions & 1 deletion core/provider/docker/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func (p *Provider) CreateTask(ctx context.Context, definition provider.TaskDefin

logger.Debug("creating container", zap.String("name", definition.Name), zap.String("image", definition.Image.Image))

// network map is volatile, so we need to mutex update it
ip, err := p.nextAvailableIP()
if err != nil {
return nil, err
Expand Down
36 changes: 19 additions & 17 deletions core/provider/docker/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package docker_test
import (
"context"
"fmt"
"sync"
"testing"
"time"

"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
gonanoid "github.com/matoous/go-nanoid/v2"
"github.com/matoous/go-nanoid/v2"
"github.com/skip-mev/petri/core/v2/provider/docker"
"go.uber.org/zap/zaptest"
"sync"
"testing"
"time"

"github.com/skip-mev/petri/core/v2/provider"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -48,9 +47,9 @@ func TestCreateProviderDuplicateNetwork(t *testing.T) {

p1, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer func() {
require.NoError(t, p1.Teardown(context.Background()))
}()
defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p1)

p2, err := docker.CreateProvider(ctx, logger, providerName)
require.Error(t, err)
Expand All @@ -67,9 +66,9 @@ func TestCreateProvider(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer func() {
defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}()
}(ctx, p)

state := p.GetState()
assert.Equal(t, providerName, state.Name)
Expand Down Expand Up @@ -107,9 +106,10 @@ func TestCreateTask(t *testing.T) {

p, err := docker.CreateProvider(context.Background(), logger, providerName)
require.NoError(t, err)
defer func() {

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}()
}(ctx, p)

tests := []struct {
name string
Expand Down Expand Up @@ -182,9 +182,10 @@ func TestConcurrentTaskCreation(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer func() {

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}()
}(ctx, p)

numTasks := 10
var wg sync.WaitGroup
Expand Down Expand Up @@ -248,9 +249,10 @@ func TestProviderSerialization(t *testing.T) {

p1, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer func() {
require.NoError(t, p1.Teardown(ctx))
}()

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p1)

_, err = p1.CreateTask(ctx, provider.TaskDefinition{
Name: fmt.Sprintf("%s-test-task", providerName),
Expand Down
23 changes: 4 additions & 19 deletions core/provider/docker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@ import (
"bytes"
"context"
"fmt"
"sync"

"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stdcopy"
"github.com/docker/go-connections/nat"
"github.com/skip-mev/petri/core/v2/util"

// "github.com/docker/docker/api/types/filters"
// "github.com/docker/docker/api/types/image"
// "github.com/docker/docker/api/types/mount"
// "github.com/docker/docker/api/types/network"
// "github.com/docker/docker/pkg/stdcopy"
// "github.com/docker/go-connections/nat"
"time"

"github.com/skip-mev/petri/core/v2/provider"
"github.com/skip-mev/petri/core/v2/util"
"go.uber.org/zap"
"sync"
"time"
)

type TaskState struct {
Expand All @@ -29,7 +20,7 @@ type TaskState struct {
Volume *VolumeState `json:"volumes"`
Definition provider.TaskDefinition `json:"definition"`
Status provider.TaskStatus `json:"status"`
IpAddress string `json:"ip_address"`
IpAddress string `json:"ip_address"`
}

type VolumeState struct {
Expand Down Expand Up @@ -162,8 +153,6 @@ func (t *Task) GetStatus(ctx context.Context) (provider.TaskStatus, error) {
return provider.TASK_STATUS_UNDEFINED, err
}

fmt.Println(containerJSON.State.Status)

switch state := containerJSON.State.Status; state {
case "created":
return provider.TASK_STOPPED, nil
Expand All @@ -184,10 +173,6 @@ func (t *Task) GetStatus(ctx context.Context) (provider.TaskStatus, error) {
return provider.TASK_STATUS_UNDEFINED, nil
}

func (t *Task) Initialize(ctx context.Context) error {
return nil
}

func (t *Task) Modify(ctx context.Context, td provider.TaskDefinition) error {
panic("unimplemented")
}
Expand Down

0 comments on commit 6a7a2f5

Please sign in to comment.