Skip to content

Commit

Permalink
fix: don't current timestamp in sidecat container name
Browse files Browse the repository at this point in the history
  • Loading branch information
joshiste committed Nov 30, 2023
1 parent 87198ac commit dcce24a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
21 changes: 9 additions & 12 deletions pkg/diskfill/diskfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/steadybit/extension-kit/extutil"
"strconv"
"sync"
"sync/atomic"
"syscall"
"time"
)
Expand All @@ -21,22 +20,20 @@ type DiskFill struct {
startBundle runc.ContainerBundle
sizeBundle runc.ContainerBundle
runc runc.Runc
method string
ddCond *sync.Cond
rmCond *sync.Cond
ddExited bool
rmExited bool
err error
args []string
method string
ddCond *sync.Cond
rmCond *sync.Cond
ddExited bool
rmExited bool
err error
args []string
}

const MaxBlockSize = 1024 //Megabytes (1GB)
const MaxBlockSize = 1024 //Megabytes (1GB)
const DefaultBlockSize = 5 //Megabytes (5MB)
const cGroupChild = "disk-fill"
const mountPoint = "/disk-fill-temp"

var counter = atomic.Int32{}

type Opts struct {
BlockSize int // in megabytes
Size int // in megabytes or percentage
Expand Down Expand Up @@ -177,7 +174,7 @@ func resolveDiskSpace(ctx context.Context, r runc.Runc, config utils.TargetConta
}

func getNextContainerId(targetId string) string {
return fmt.Sprintf("sb-disk-fill-%d-%s", counter.Add(1), targetId[:8])
return fmt.Sprintf("sb-disk-fill-%d-%s", time.Now().Unix(), targetId[:8])
}

func (df *DiskFill) Exited() (bool, error) {
Expand Down
8 changes: 3 additions & 5 deletions pkg/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import (
"github.com/steadybit/extension-kit/extutil"
"runtime/trace"
"strconv"
"sync/atomic"
"time"
)

var (
counter = atomic.Int32{}
runLock = utils.NewHashedKeyMutex(10)

runLock = utils.NewHashedKeyMutex(10)
sidecarImagePath = utils.SidecarImagePath
)

Expand Down Expand Up @@ -123,7 +121,7 @@ func getNextContainerId(targedId string) string {
if len(targedId) < l {
l = len(targedId)
}
return fmt.Sprintf("sb-network-%d-%s", counter.Add(1), targedId[:l])
return fmt.Sprintf("sb-network-%d-%s", time.Now().Unix(), targedId[:l])
}

func executeIpCommands(ctx context.Context, r runc.Runc, config utils.TargetContainerConfig, family networkutils.Family, cmds []string) error {
Expand Down
5 changes: 1 addition & 4 deletions pkg/stress/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/steadybit/extension-container/pkg/utils"
"strconv"
"sync"
"sync/atomic"
"syscall"
"time"
)
Expand All @@ -27,8 +26,6 @@ type Stress struct {
args []string
}

var counter = atomic.Int32{}

type Opts struct {
CpuWorkers *int
CpuLoad int
Expand Down Expand Up @@ -124,7 +121,7 @@ func New(ctx context.Context, r runc.Runc, config utils.TargetContainerConfig, o
}

func getNextContainerId(targetId string) string {
return fmt.Sprintf("sb-stress-%d-%s", counter.Add(1), targetId[:8])
return fmt.Sprintf("sb-stress-%d-%s", time.Now().Unix(), targetId[:8])
}

func (s *Stress) Exited() (bool, error) {
Expand Down

0 comments on commit dcce24a

Please sign in to comment.