Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 6f128a2

Browse files
cleanup the wiretap container specific to the broker in case of tmctl stop (#333)
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
1 parent 01c6621 commit 6f128a2

27 files changed

+53
-25
lines changed

cmd/stop/stop.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ func (o *CliOptions) stop() error {
7272
continue
7373
}
7474
if object.Kind == tmbroker.BrokerKind {
75+
wiretapContainerName := object.Metadata.Name + "-wiretap"
76+
if err := docker.ForceStop(ctx, wiretapContainerName, client); err != nil {
77+
log.Printf("Stopping %q: %v", wiretapContainerName, err)
78+
}
79+
7580
object.Metadata.Name += "-broker"
7681
}
7782
log.Printf("Stopping %s\n", object.Metadata.Name)

cmd/watch/watch.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ import (
2222
"encoding/json"
2323
"fmt"
2424
"io"
25+
"net"
2526
"os"
2627
"os/signal"
2728
"strings"
2829
"syscall"
30+
"time"
2931

3032
"github.com/spf13/cobra"
3133

@@ -72,6 +74,7 @@ func NewCmd(config *config.Config) *cobra.Command {
7274
func (o *CliOptions) watch() error {
7375
c := make(chan os.Signal, 1)
7476
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
77+
defer close(c)
7578

7679
ctx := context.Background()
7780

@@ -99,6 +102,8 @@ func (o *CliOptions) watch() error {
99102
log.Println("Watching...")
100103
go listenBroker(brokerLogs, c)
101104
go listenEvents(eventDisplayLogs, c)
105+
go checkConnectivity(w.Destination, c)
106+
102107
<-c
103108
log.Println("Cleaning up")
104109
return nil
@@ -142,3 +147,21 @@ func readLogs(output io.ReadCloser, done chan os.Signal, handler func([]byte)) {
142147
}
143148
}
144149
}
150+
151+
func checkConnectivity(destination string, done chan os.Signal) {
152+
port := strings.TrimPrefix(destination, "http://host.docker.internal")
153+
ticker := time.NewTicker(3 * time.Second)
154+
defer ticker.Stop()
155+
for {
156+
select {
157+
case <-done:
158+
return
159+
case <-ticker.C:
160+
if _, err := net.Dial("tcp", "localhost"+port); err != nil {
161+
log.Printf("Wiretap container is unreachable: %v", err)
162+
done <- syscall.SIGTERM
163+
return
164+
}
165+
}
166+
}
167+
}

docs/tmctl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Find more information at: https://docs.triggermesh.io
1212

1313
```
1414
-h, --help help for tmctl
15-
--version string TriggerMesh components version. (default "v1.25.0")
15+
--version string TriggerMesh components version. (default "v1.25.1")
1616
```
1717

1818
### SEE ALSO

docs/tmctl_brokers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tmctl brokers [--set <broker>] [flags]
1616
### Options inherited from parent commands
1717

1818
```
19-
--version string TriggerMesh components version. (default "v1.25.0")
19+
--version string TriggerMesh components version. (default "v1.25.1")
2020
```
2121

2222
### SEE ALSO

docs/tmctl_config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tmctl config [set|get] [flags]
1515
### Options inherited from parent commands
1616

1717
```
18-
--version string TriggerMesh components version. (default "v1.25.0")
18+
--version string TriggerMesh components version. (default "v1.25.1")
1919
```
2020

2121
### SEE ALSO

docs/tmctl_config_get.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tmctl config get [key] [flags]
1515
### Options inherited from parent commands
1616

1717
```
18-
--version string TriggerMesh components version. (default "v1.25.0")
18+
--version string TriggerMesh components version. (default "v1.25.1")
1919
```
2020

2121
### SEE ALSO

docs/tmctl_config_set.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tmctl config set <key> <value> [flags]
1515
### Options inherited from parent commands
1616

1717
```
18-
--version string TriggerMesh components version. (default "v1.25.0")
18+
--version string TriggerMesh components version. (default "v1.25.1")
1919
```
2020

2121
### SEE ALSO

docs/tmctl_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Create TriggerMesh component
1111
### Options inherited from parent commands
1212

1313
```
14-
--version string TriggerMesh components version. (default "v1.25.0")
14+
--version string TriggerMesh components version. (default "v1.25.1")
1515
```
1616

1717
### SEE ALSO

docs/tmctl_create_source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tmctl create source httppoller \
2525
### Options inherited from parent commands
2626

2727
```
28-
--version string TriggerMesh components version. (default "v1.25.0")
28+
--version string TriggerMesh components version. (default "v1.25.1")
2929
```
3030

3131
### SEE ALSO

docs/tmctl_create_target.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tmctl create target http \
2424
### Options inherited from parent commands
2525

2626
```
27-
--version string TriggerMesh components version. (default "v1.25.0")
27+
--version string TriggerMesh components version. (default "v1.25.1")
2828
```
2929

3030
### SEE ALSO

0 commit comments

Comments
 (0)