mirror of
https://github.com/drone-plugins/drone-docker.git
synced 2026-06-04 18:24:24 +08:00
[feat]: [CI-20260]: Make daemon retry count configurable (#503)
This commit is contained in:
@@ -30,6 +30,7 @@ type (
|
||||
MTU string // Docker daemon mtu setting
|
||||
IPv6 bool // Docker daemon IPv6 networking
|
||||
Experimental bool // Docker daemon enable experimental mode
|
||||
RetryCount int // Number of retry attempts to reach Docker daemon
|
||||
RegistryType drone.RegistryType // Docker registry type
|
||||
}
|
||||
|
||||
@@ -137,14 +138,18 @@ func (p Plugin) Exec() error {
|
||||
|
||||
// poll the docker daemon until it is started. This ensures the daemon is
|
||||
// ready to accept connections before we proceed.
|
||||
maxRetries := p.Daemon.RetryCount
|
||||
if maxRetries <= 0 {
|
||||
maxRetries = 15 // default value
|
||||
}
|
||||
for i := 0; ; i++ {
|
||||
cmd := commandInfo()
|
||||
err := cmd.Run()
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if i == 15 {
|
||||
fmt.Println("Unable to reach Docker Daemon after 15 attempts.")
|
||||
if i == maxRetries {
|
||||
fmt.Printf("Unable to reach Docker Daemon after %d attempts.\n", maxRetries)
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second * 1)
|
||||
|
||||
Reference in New Issue
Block a user