Skip to content

Commit f285887

Browse files
delete pod on test timeout (#256)
* move defer func * bump * added upper boundary to kube version * removed print
1 parent 82cc8d8 commit f285887

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.234
1+
VERSION=v0.0.235
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ func preInstallationChecks(ctx context.Context, opts *RuntimeInstallOptions) err
848848

849849
if !opts.SkipClusterChecks {
850850
err = util.RunNetworkTest(ctx, opts.KubeFactory, cfConfig.GetCurrentContext().URL)
851-
if err != nil {
851+
if err == nil {
852852
log.G(ctx).Info("Network test finished successfully")
853853
}
854854
}

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.234/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.235/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.234/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.235/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: '{{ namespace }}'
66
spec:
77
defVersion: 1.0.0
8-
version: 0.0.234
8+
version: 0.0.235
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

pkg/store/store.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ type Store struct {
136136
NetworkTesterGenerateName string
137137
NetworkTesterImage string
138138
MinKubeVersion string
139+
MaxKubeVersion string
139140
}
140141

141142
// Get returns the global store
@@ -228,6 +229,7 @@ func init() {
228229
s.NetworkTesterGenerateName = "cf-network-tester-"
229230
s.NetworkTesterImage = "quay.io/codefresh/cf-venona-network-tester:latest"
230231
s.MinKubeVersion = "v1.18.0"
232+
s.MaxKubeVersion = "v1.21.9"
231233

232234
initVersion()
233235
}

pkg/util/kube/kube.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ func EnsureClusterRequirements(ctx context.Context, kubeFactory kube.Factory, na
6969
return fmt.Errorf("failed to check the cluster's version: %w", err)
7070
}
7171

72-
delta := version.CompareKubeAwareVersionStrings(store.Get().MinKubeVersion, kubeVersion.String())
72+
minDelta := version.CompareKubeAwareVersionStrings(store.Get().MinKubeVersion, kubeVersion.String())
73+
maxDelta := version.CompareKubeAwareVersionStrings(store.Get().MaxKubeVersion, kubeVersion.String())
7374

74-
if delta < 0 {
75-
return fmt.Errorf("%s: cluster's server version must be %s or higher", requirementsValidationErrorMessage, store.Get().MinKubeVersion)
75+
if minDelta < 0 || maxDelta > 0 {
76+
return fmt.Errorf("%s: cluster's server version must be between %s and %s", requirementsValidationErrorMessage, store.Get().MinKubeVersion, store.Get().MaxKubeVersion)
7677
}
7778

7879
req := validationRequest{

pkg/util/util.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ func RunNetworkTest(ctx context.Context, kubeFactory kube.Factory, urls ...strin
236236
}
237237
}()
238238

239+
defer func(name *string) {
240+
deferErr := client.CoreV1().Pods(store.Get().DefaultNamespace).Delete(ctx, *name, metav1.DeleteOptions{})
241+
if deferErr != nil {
242+
log.G(ctx).Error("fail to delete tester pod '%s': %s", testerPodName, deferErr.Error())
243+
}
244+
}(&testerPodName)
245+
239246
log.G(ctx).Info("Running network test...")
240247

241248
ticker := time.NewTicker(5 * time.Second)
@@ -283,15 +290,8 @@ Loop:
283290
return fmt.Errorf("network test timeout reached!")
284291
}
285292
}
286-
287-
defer func() {
288-
deferErr := client.CoreV1().Pods(store.Get().DefaultNamespace).Delete(ctx, testerPodName, metav1.DeleteOptions{})
289-
if deferErr != nil {
290-
log.G(ctx).Error("fail to delete tester pod '%s': %s", testerPodName, deferErr.Error())
291-
}
292-
}()
293293

294-
return checkPodLastState(ctx, client, testerPodName,podLastState)
294+
return checkPodLastState(ctx, client, testerPodName, podLastState)
295295
}
296296

297297
func prepareEnvVars(vars map[string]string) []v1.EnvVar {

0 commit comments

Comments
 (0)