Skip to content

Commit dcce24a

Browse files
committed
fix: don't current timestamp in sidecat container name
1 parent 87198ac commit dcce24a

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

pkg/diskfill/diskfill.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/steadybit/extension-kit/extutil"
1313
"strconv"
1414
"sync"
15-
"sync/atomic"
1615
"syscall"
1716
"time"
1817
)
@@ -21,22 +20,20 @@ type DiskFill struct {
2120
startBundle runc.ContainerBundle
2221
sizeBundle runc.ContainerBundle
2322
runc runc.Runc
24-
method string
25-
ddCond *sync.Cond
26-
rmCond *sync.Cond
27-
ddExited bool
28-
rmExited bool
29-
err error
30-
args []string
23+
method string
24+
ddCond *sync.Cond
25+
rmCond *sync.Cond
26+
ddExited bool
27+
rmExited bool
28+
err error
29+
args []string
3130
}
3231

33-
const MaxBlockSize = 1024 //Megabytes (1GB)
32+
const MaxBlockSize = 1024 //Megabytes (1GB)
3433
const DefaultBlockSize = 5 //Megabytes (5MB)
3534
const cGroupChild = "disk-fill"
3635
const mountPoint = "/disk-fill-temp"
3736

38-
var counter = atomic.Int32{}
39-
4037
type Opts struct {
4138
BlockSize int // in megabytes
4239
Size int // in megabytes or percentage
@@ -177,7 +174,7 @@ func resolveDiskSpace(ctx context.Context, r runc.Runc, config utils.TargetConta
177174
}
178175

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

183180
func (df *DiskFill) Exited() (bool, error) {

pkg/network/network.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ import (
1717
"github.com/steadybit/extension-kit/extutil"
1818
"runtime/trace"
1919
"strconv"
20-
"sync/atomic"
20+
"time"
2121
)
2222

2323
var (
24-
counter = atomic.Int32{}
25-
runLock = utils.NewHashedKeyMutex(10)
26-
24+
runLock = utils.NewHashedKeyMutex(10)
2725
sidecarImagePath = utils.SidecarImagePath
2826
)
2927

@@ -123,7 +121,7 @@ func getNextContainerId(targedId string) string {
123121
if len(targedId) < l {
124122
l = len(targedId)
125123
}
126-
return fmt.Sprintf("sb-network-%d-%s", counter.Add(1), targedId[:l])
124+
return fmt.Sprintf("sb-network-%d-%s", time.Now().Unix(), targedId[:l])
127125
}
128126

129127
func executeIpCommands(ctx context.Context, r runc.Runc, config utils.TargetContainerConfig, family networkutils.Family, cmds []string) error {

pkg/stress/stress.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/steadybit/extension-container/pkg/utils"
1313
"strconv"
1414
"sync"
15-
"sync/atomic"
1615
"syscall"
1716
"time"
1817
)
@@ -27,8 +26,6 @@ type Stress struct {
2726
args []string
2827
}
2928

30-
var counter = atomic.Int32{}
31-
3229
type Opts struct {
3330
CpuWorkers *int
3431
CpuLoad int
@@ -124,7 +121,7 @@ func New(ctx context.Context, r runc.Runc, config utils.TargetContainerConfig, o
124121
}
125122

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

130127
func (s *Stress) Exited() (bool, error) {

0 commit comments

Comments
 (0)