Skip to content

Commit fa0bfaf

Browse files
committed
ambex: remove watch node (inotify)
This was only used for development/experimentation, never enabled when started via the entrypoint.
1 parent 25d263f commit fa0bfaf

File tree

4 files changed

+4
-68
lines changed

4 files changed

+4
-68
lines changed

go.mod

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ require (
108108
github.com/datawire/dlib v1.3.1
109109
github.com/datawire/dtest v0.0.0-20210928162311-722b199c4c2f
110110
github.com/envoyproxy/protoc-gen-validate v1.2.1
111-
github.com/fsnotify/fsnotify v1.8.0
112111
github.com/go-logr/zapr v1.3.0
113112
github.com/google/go-cmp v0.6.0
114113
github.com/google/uuid v1.6.0
@@ -163,13 +162,13 @@ require (
163162
github.com/blang/semver/v4 v4.0.0 // indirect
164163
github.com/chai2010/gettext-go v1.0.3 // indirect
165164
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
166-
github.com/distribution/reference v0.6.0 // indirect
167165
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
168166
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
169167
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
170168
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
171169
github.com/fatih/camelcase v1.0.0 // indirect
172170
github.com/fatih/color v1.18.0 // indirect
171+
github.com/fsnotify/fsnotify v1.8.0 // indirect
173172
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
174173
github.com/go-errors/errors v1.5.1 // indirect
175174
github.com/go-logr/logr v1.4.2 // indirect
@@ -208,7 +207,6 @@ require (
208207
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
209208
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
210209
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
211-
github.com/opencontainers/go-digest v1.0.0 // indirect
212210
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
213211
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
214212
github.com/prometheus/client_golang v1.20.5 // indirect
@@ -244,8 +242,6 @@ require (
244242
gopkg.in/yaml.v3 v3.0.1 // indirect
245243
k8s.io/apiserver v0.32.1 // indirect
246244
k8s.io/component-base v0.32.1 // indirect
247-
k8s.io/component-helpers v0.32.1 // indirect
248-
k8s.io/controller-manager v0.32.1 // indirect
249245
k8s.io/gengo/v2 v2.0.0-20250130153323-76c5745d3511 // indirect
250246
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect
251247
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
4646
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4747
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
4848
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
49-
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
50-
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
5149
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=
5250
github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
5351
github.com/emissary-ingress/code-generator v0.32.2-0.20250205235421-4d5bf4656f71 h1:4qz46p0myZmWQTJBonFZsHHoORicUjjC3OQKIcheotk=
@@ -192,8 +190,6 @@ github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM
192190
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
193191
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
194192
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
195-
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
196-
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
197193
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
198194
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
199195
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
@@ -399,10 +395,6 @@ k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU=
399395
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
400396
k8s.io/component-base v0.32.1 h1:/5IfJ0dHIKBWysGV0yKTFfacZ5yNV1sulPh3ilJjRZk=
401397
k8s.io/component-base v0.32.1/go.mod h1:j1iMMHi/sqAHeG5z+O9BFNCF698a1u0186zkjMZQ28w=
402-
k8s.io/component-helpers v0.32.1 h1:TwdsSM1vW9GjnfX18lkrZbwE5G9psCIS2/rhenTDXd8=
403-
k8s.io/component-helpers v0.32.1/go.mod h1:1JT1Ei3FD29yFQ18F3laj1WyvxYdHIhyxx6adKMFQXI=
404-
k8s.io/controller-manager v0.32.1 h1:z3oQp1O5l0cSzM/MKf8V4olhJ9TmnELoJRPcV/v1s+Y=
405-
k8s.io/controller-manager v0.32.1/go.mod h1:dVA1UZPbqHH4hEhrrnLvQ4d5qVQCklNB8GEzYV59v/4=
406398
k8s.io/gengo/v2 v2.0.0-20250130153323-76c5745d3511 h1:75RK5sziSA/Ip/nJb5BnQrmJm2OXXs8VtaqeSR7pnf4=
407399
k8s.io/gengo/v2 v2.0.0-20250130153323-76c5745d3511/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
408400
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=

pkg/ambex/README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ pain, given that it's not well documented, but here's the deal:
6969
- it interprets `*.pb` files as [text-encoded protobuf](https://pkg.go.dev/google.golang.org/protobuf/encoding/prototext)
7070
- all other files are ignored
7171
As for when it loads those files:
72-
- By default when we get a SIGHUP we reload the configuration.
73-
- When passed the `--watch` argument we reload whenever any file in
74-
the directory changes. Be careful about updating files
75-
atomically if you use this!
72+
- When we get a SIGHUP we reload the configuration.
7673

7774
[^1]: The Envoy `go-control-plane` usually refers to
7875
`github.com/envoyproxy/go-control-plane`, but we've "forked" it
@@ -106,12 +103,6 @@ boostrap config pointing at that `ambex.
106103
go run github.com/datawire/ambassador/cmd/busyambassador ambex ./example/ambex/
107104
```
108105

109-
or
110-
111-
```shell
112-
go run github.com/datawire/ambassador/cmd/busyambassador ambex --watch ./example/ambex/
113-
```
114-
115106
2. Second, in another shell, start the `envoy`:
116107

117108
```shell
@@ -141,9 +132,7 @@ $ curl localhost:8080/get
141132

142133
Edit and/or add more files to the `./example/ambex/` directory in
143134
order to play with more configurations and see them reload
144-
_instantaneously_ (if you used the `--watch` flag), or when-triggered
145-
(if you didn't use the `--watch` flag; trigger a relead by signaling
146-
the process with `killall -HUP ambex`).
135+
when triggered by signaling the process with `killall -HUP ambex`.
147136

148137
Clean up
149138
--------

pkg/ambex/main.go

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ package ambex
3333
* will get sent to the Envoy.
3434
* - We manage the SnapshotCache by loading envoy configuration from
3535
* json and/or protobuf files on disk.
36-
* - By default when we get a SIGHUP, we reload configuration.
37-
* - When passed the -watch argument we reload whenever any file in
38-
* the directory changes.
36+
* - When we get a SIGHUP, we reload configuration.
3937
*/
4038

4139
import (
@@ -55,7 +53,6 @@ import (
5553
"syscall"
5654

5755
// third-party libraries
58-
"github.com/fsnotify/fsnotify"
5956
"google.golang.org/grpc"
6057
"google.golang.org/protobuf/encoding/protojson"
6158
"google.golang.org/protobuf/encoding/prototext"
@@ -113,8 +110,6 @@ import (
113110
)
114111

115112
type Args struct {
116-
watch bool
117-
118113
adsNetwork string
119114
adsAddress string
120115

@@ -132,8 +127,6 @@ func parseArgs(ctx context.Context, rawArgs ...string) (*Args, error) {
132127
var args Args
133128
flagset := flag.NewFlagSet("ambex", flag.ContinueOnError)
134129

135-
flagset.BoolVar(&args.watch, "watch", false, "Watch for file changes")
136-
137130
// TODO(lukeshu): Consider changing the default here so we don't need to put it in entrypoint.sh
138131
flagset.StringVar(&args.adsNetwork, "ads-listen-network", "tcp", "network for ADS to listen on")
139132
flagset.StringVar(&args.adsAddress, "ads-listen-address", ":18000", "address (on --ads-listen-network) for ADS to listen on")
@@ -647,20 +640,6 @@ func Main(
647640

648641
dlog.Infof(ctx, "Ambex %s starting, snapdirPath %s", Version, args.snapdirPath)
649642

650-
watcher, err := fsnotify.NewWatcher()
651-
if err != nil {
652-
return err
653-
}
654-
defer watcher.Close()
655-
656-
if args.watch {
657-
for _, d := range args.dirs {
658-
if err := watcher.Add(d); err != nil {
659-
return err
660-
}
661-
}
662-
}
663-
664643
// The golang signal package does not block when it writes to the channel. We therefore need a
665644
// nonzero buffer for the channel to minimize the possiblity that we miss out on a signal that
666645
// comes in while we are doing work and not reading from the channel. To minimize the chance
@@ -762,26 +741,6 @@ func Main(
762741
if err != nil {
763742
return err
764743
}
765-
case <-watcher.Events:
766-
// Non-fastpath update. Just update.
767-
err := update(
768-
ctx,
769-
args.snapdirPath,
770-
args.numsnaps,
771-
args.edsBypass,
772-
configv3,
773-
&generation,
774-
args.dirs,
775-
edsEndpointsV3,
776-
fastpathSnapshot,
777-
updates,
778-
)
779-
if err != nil {
780-
return err
781-
}
782-
case err := <-watcher.Errors:
783-
// Something went wrong, so scream about that.
784-
dlog.Warnf(ctx, "Watcher error: %v", err)
785744
case <-ctx.Done():
786745
return nil
787746
}

0 commit comments

Comments
 (0)