Skip to content

Commit 4cef005

Browse files
Saas-7140
* on runtime-attach need to wait for old pod to terminate
1 parent 3af66fe commit 4cef005

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

venonactl/pkg/plugins/runtime-attach.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"encoding/base64"
55
"fmt"
66
"strings"
7+
"time"
78

89
"github.com/codefresh-io/venona/venonactl/pkg/logger"
910
templates "github.com/codefresh-io/venona/venonactl/pkg/templates/kubernetes"
1011
"gopkg.in/yaml.v2"
12+
kerrors "k8s.io/apimachinery/pkg/api/errors"
1113
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1214
)
1315

@@ -171,6 +173,24 @@ func (u *runtimeAttachPlugin) Install(opt *InstallOptions, v Values) (Values, er
171173
return nil, err
172174
}
173175

176+
ticker := time.NewTicker(5 * time.Second)
177+
for {
178+
select {
179+
case <-ticker.C:
180+
u.logger.Debug("Validating old runner pod termination")
181+
_, err = cs.CoreV1().Pods(opt.ClusterNamespace).Get(podName, metav1.GetOptions{})
182+
if err != nil {
183+
if statusError, errIsStatusError := err.(*kerrors.StatusError); errIsStatusError {
184+
if statusError.ErrStatus.Reason == metav1.StatusReasonNotFound {
185+
return v, nil
186+
}
187+
}
188+
}
189+
case <-time.After(45 * time.Second):
190+
u.logger.Error("Failed to validate old venona pod termination")
191+
return v, fmt.Errorf("Failed to validate old venona pod termination")
192+
}
193+
}
174194
}
175195

176196
return v, nil

0 commit comments

Comments
 (0)