Skip to content

Commit

Permalink
chore: refactor enableMTLS in kuma addon and update CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Aug 5, 2022
1 parent aed3e4e commit 32d053d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## v0.19.0

### Added
- Added feature to support waiting for a port of a service to be connective
by TCP.
[#338](https://github.com/Kong/kubernetes-testing-framework/pull/338)

### Improved
- Increased retry times to increase the timeout to wait for kuma webhook
to be ready to serve.
[#341](https://github.com/Kong/kubernetes-testing-framework/pull/341)
[#342](https://github.com/Kong/kubernetes-testing-framework/pull/342)

## v0.18.0

### Added
Expand Down
22 changes: 15 additions & 7 deletions pkg/clusters/addons/kuma/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,21 @@ spec:
// enableMTLS attempts to apply a Mesh resource with a basic retry mechanism to deal with delays in the Kuma webhook
// startup
func (a *Addon) enableMTLS(ctx context.Context, cluster clusters.Cluster) (err error) {
for i := 0; i < 12; i++ {
err = clusters.ApplyManifestByYAML(ctx, cluster, mtlsEnabledDefaultMesh)
if err != nil {
time.Sleep(time.Second * 5) //nolint:gomnd
} else {
break
ticker := time.NewTicker(5 * time.Second) // nolint:gomnd
timeoutTimer := time.NewTimer(time.Minute) // nolint:gomnd

for {
select {
case <-ctx.Done():
return fmt.Errorf("context completed while retrying to apply Mesh")
case <-ticker.C:
err = clusters.ApplyManifestByYAML(ctx, cluster, mtlsEnabledDefaultMesh)
if err == nil {
return nil
}
case <-timeoutTimer.C:
// return the error of last retry.
return err
}
}
return err
}

0 comments on commit 32d053d

Please sign in to comment.