Skip to content

Commit 3a75f15

Browse files
nryan100cmulk
authored andcommitted
fix(mirror): named exp bridge as default
1 parent 025b0a0 commit 3a75f15

File tree

5 files changed

+52
-27
lines changed

5 files changed

+52
-27
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ traffic, except for the cluster host the `monitor` VM is scheduled on, which
9696
will instead use the tap of the `IF0` interface for the `monitor` VM as the
9797
mirror destination.
9898

99-
> **NOTE**: the `mirror` app is currently not namespace aware, and will fail
100-
> miserably if two different experiments use the same name for a VM that
101-
> mirrored traffic is to be sent to. This will be addressed in a future
102-
> version of the app.
103-
10499
### Additional apps
105100

106101
- [caldera](src/python/phenix_apps/apps/caldera)

src/go/cmd/phenix-app-mirror/main.go

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ func configure(exp *types.Experiment) error {
115115
if err != nil {
116116
return fmt.Errorf("extracting app metadata: %w", err)
117117
}
118+
amd.Init()
119+
if amd.MirrorBridge == "" {
120+
amd.MirrorBridge = exp.Spec.DefaultBridge()
121+
}
118122

119123
nw, err := mirrorNet(&amd)
120124
if err != nil {
@@ -248,6 +252,11 @@ func postStart(exp *types.Experiment, dryrun bool) (ferr error) {
248252
if err != nil {
249253
return fmt.Errorf("extracting app metadata: %w", err)
250254
}
255+
amd.Init()
256+
if amd.MirrorBridge == "" {
257+
amd.MirrorBridge = exp.Spec.DefaultBridge()
258+
}
259+
251260

252261
nw, err := mirrorNet(&amd)
253262
if err != nil {
@@ -358,7 +367,6 @@ func postStart(exp *types.Experiment, dryrun bool) (ferr error) {
358367
name := util.RandomString(15)
359368

360369
cfg := MirrorConfig{MirrorName: name, MirrorBridge: amd.MirrorBridge, IP: ip.String()}
361-
362370
status.Mirrors[host.Hostname()] = cfg
363371

364372
for h := range cluster {
@@ -481,8 +489,10 @@ func cleanup(exp *types.Experiment, dryrun bool) error {
481489
if err != nil {
482490
return fmt.Errorf("extracting app metadata: %w", err)
483491
}
484-
485492
amd.Init()
493+
if amd.MirrorBridge == "" {
494+
amd.MirrorBridge = exp.Spec.DefaultBridge()
495+
}
486496

487497
cluster := cluster(exp)
488498

@@ -496,7 +506,6 @@ func cleanup(exp *types.Experiment, dryrun bool) error {
496506
slog.Error("removing mirror from cluster", "mirror", cfg.MirrorName, "err", err)
497507
}
498508
}
499-
500509
if err := deleteTap(status.TapName, exp.Metadata.Name, cluster); err != nil {
501510
slog.Error("deleting tap from cluster", "tap", status.TapName, "err", err)
502511
}
@@ -564,13 +573,13 @@ func deleteMirrorFromHost(mirror, bridge, host string) error {
564573

565574
func mirrorNet(md *MirrorAppMetadataV1) (netaddr.IPPrefix, error) {
566575
md.Init()
567-
576+
568577
subnet, err := netaddr.ParseIPPrefix(md.MirrorNet)
569578
if err != nil {
570579
return netaddr.IPPrefix{}, fmt.Errorf("parsing mirror net: %w", err)
571580
}
572581

573-
running, err := types.RunningExperiments()
582+
running, err := runningExperiments()
574583
if err != nil {
575584
// Log the error, but don't escalate it. Instead, just assume there's no
576585
// other experiments running and let things (potentially) fail
@@ -691,3 +700,25 @@ func vlanTaps(ns string, vms, vlans []string) []string {
691700

692701
return taps
693702
}
703+
704+
func runningExperiments() ([]*types.Experiment, error) {
705+
configs, err := store.List("Experiment")
706+
if err != nil {
707+
return nil, fmt.Errorf("getting list of experiment configs from store: %w", err)
708+
}
709+
710+
var experiments []*types.Experiment
711+
712+
for _, c := range configs {
713+
exp, err := types.DecodeExperimentFromConfig(c)
714+
if err != nil {
715+
return nil, fmt.Errorf("decoding experiment %s from config: %w", c.Metadata.Name, err)
716+
}
717+
718+
if exp.Running() {
719+
experiments = append(experiments, exp)
720+
}
721+
}
722+
723+
return experiments, nil
724+
}

src/go/cmd/phenix-app-mirror/types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ func (this *MirrorAppMetadataV1) Init() {
5252
this.MirrorNet += "/24" // default to class C network
5353
}
5454

55-
if this.MirrorBridge == "" {
56-
this.MirrorBridge = "phenix"
57-
}
58-
5955
if this.MirrorVLAN == "" {
6056
this.MirrorVLAN = "mirror"
6157
}

src/go/go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module phenix-apps
22

33
go 1.20
44

5-
replace phenix => github.com/sandialabs/sceptre-phenix/src/go v0.0.0-20230726231243-4754da61aae8
5+
replace phenix => github.com/sandialabs/sceptre-phenix/src/go v0.0.0-20250228200416-4b27dea19734
66

77
require (
88
github.com/hashicorp/go-multierror v1.0.0
@@ -13,7 +13,7 @@ require (
1313
)
1414

1515
require (
16-
github.com/activeshadow/libminimega v0.0.0-20190412123224-5384445d4b63 // indirect
16+
github.com/activeshadow/libminimega v0.0.0-20230607190319-9d6487572f76 // indirect
1717
github.com/activeshadow/structs v1.3.0 // indirect
1818
github.com/coreos/go-semver v0.3.0 // indirect
1919
github.com/coreos/go-systemd/v22 v22.0.0 // indirect
@@ -28,6 +28,7 @@ require (
2828
github.com/hashicorp/errwrap v1.0.0 // indirect
2929
github.com/invopop/yaml v0.1.0 // indirect
3030
github.com/josharian/intern v1.0.0 // indirect
31+
github.com/lmittmann/tint v0.3.4 // indirect
3132
github.com/mailru/easyjson v0.7.7 // indirect
3233
github.com/mattn/go-colorable v0.1.4 // indirect
3334
github.com/mattn/go-isatty v0.0.11 // indirect
@@ -43,9 +44,9 @@ require (
4344
go.uber.org/zap v1.15.0 // indirect
4445
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
4546
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
46-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
47+
golang.org/x/net v0.1.0 // indirect
4748
golang.org/x/sys v0.1.0 // indirect
48-
golang.org/x/text v0.3.7 // indirect
49+
golang.org/x/text v0.4.0 // indirect
4950
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
5051
google.golang.org/grpc v1.27.0 // indirect
5152
google.golang.org/protobuf v1.25.0 // indirect

src/go/go.sum

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
33
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4-
github.com/activeshadow/libminimega v0.0.0-20190412123224-5384445d4b63 h1:i6MTIv6gKNo6LiUWvImMpbSZGY3pIrF4TTS0cqphmg0=
5-
github.com/activeshadow/libminimega v0.0.0-20190412123224-5384445d4b63/go.mod h1:Y09dvSAoxSu+uVxC/+pvXYgmENf71+FFli+ehB9V+pY=
4+
github.com/activeshadow/libminimega v0.0.0-20230607190319-9d6487572f76 h1:HCkhS0gW/oHq0pZsVBIJn6DrTyWpeG5Bv0EJHSJHW4Q=
5+
github.com/activeshadow/libminimega v0.0.0-20230607190319-9d6487572f76/go.mod h1:Y09dvSAoxSu+uVxC/+pvXYgmENf71+FFli+ehB9V+pY=
66
github.com/activeshadow/structs v1.3.0 h1:T/TZ9olm3oSKz3oPyG8GVeVM7jPpm2qg+n6R003/aXY=
77
github.com/activeshadow/structs v1.3.0/go.mod h1:WzbsdEG2b9nJB0jGD3l+tfNqkEH1Zpi6GEdu+US1KGc=
88
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -115,6 +115,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
115115
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
116116
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
117117
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
118+
github.com/lmittmann/tint v0.3.4 h1:QOr2U9GKQfNsNhKPhL7PexQm0mqkRmvuy1UrZb6AidM=
119+
github.com/lmittmann/tint v0.3.4/go.mod h1:vYasuAV5qbz2TYeUK+sj8iURGIl9T/WOlh4qzYGP16I=
118120
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
119121
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
120122
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
@@ -167,8 +169,8 @@ github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNG
167169
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
168170
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
169171
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
170-
github.com/sandialabs/sceptre-phenix/src/go v0.0.0-20230726231243-4754da61aae8 h1:53FuCUAZrD/y64vALM2u7hyDHAkINSqP97xH7FWET6M=
171-
github.com/sandialabs/sceptre-phenix/src/go v0.0.0-20230726231243-4754da61aae8/go.mod h1:YBAjGovLLVY7olvZ+RH/ipIKAnnlXAPNhEs29LP+MoU=
172+
github.com/sandialabs/sceptre-phenix/src/go v0.0.0-20250228200416-4b27dea19734 h1:pahKK4r9za+ii0PThgSHTZlxLghXYLxzsytUcWI4jos=
173+
github.com/sandialabs/sceptre-phenix/src/go v0.0.0-20250228200416-4b27dea19734/go.mod h1:rE7tLca8kuCX8Sr5cLgBmxbCE6XD4KAFX0IS5u17nbI=
172174
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
173175
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
174176
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@@ -225,7 +227,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
225227
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
226228
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
227229
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
228-
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
230+
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
229231
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
230232
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
231233
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
@@ -247,8 +249,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
247249
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
248250
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
249251
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
250-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
251-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
252+
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
253+
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
252254
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
253255
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
254256
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -271,8 +273,8 @@ golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
271273
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
272274
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
273275
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
274-
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
275-
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
276+
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
277+
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
276278
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
277279
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
278280
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

0 commit comments

Comments
 (0)