Skip to content

Commit a66b3a0

Browse files
committed
fix hubble enable flag
Signed-off-by: l1b0k <[email protected]>
1 parent 04728da commit a66b3a0

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

cmd/terway-cli/policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type PolicyConfig struct {
3030
}
3131

3232
type CNIConfig struct {
33-
HubbleEnabled bool `json:"cilium_enable_hubble,omitempty"`
33+
HubbleEnabled string `json:"cilium_enable_hubble,omitempty"`
3434
HubbleMetrics string `json:"cilium_hubble_metrics,omitempty"`
3535
HubbleListenAddress string `json:"cilium_hubble_listen_address,omitempty"`
3636
HubbleMetricServer string `json:"cilium_hubble_metrics_server,omitempty"`
@@ -272,7 +272,7 @@ func policyConfig(container *gabs.Container) ([]string, error) {
272272
return nil, fmt.Errorf("failed to unmarshal args: %w", err)
273273
}
274274

275-
if h.HubbleEnabled {
275+
if h.HubbleEnabled == "true" {
276276
if h.HubbleMetrics == "" {
277277
h.HubbleMetrics = "drop"
278278
}

cmd/terway-cli/policy_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,46 @@ func Test_policyConfig(t *testing.T) {
150150
assert.Contains(t, strings, "--other=false")
151151
},
152152
},
153+
{
154+
name: "test hubble",
155+
args: args{container: func() *gabs.Container {
156+
cniJSON, _ := gabs.ParseJSON([]byte(`{
157+
"cniVersion": "0.4.0",
158+
"name": "terway-chainer",
159+
"plugins": [
160+
{
161+
"bandwidth_mode": "edt",
162+
"capabilities": {
163+
"bandwidth": true
164+
},
165+
"cilium_args": "disable-per-package-lb=true",
166+
"eniip_virtual_type": "datapathv2",
167+
"network_policy_provider": "ebpf",
168+
"cilium_enable_hubble": "true",
169+
"cilium_hubble_listen_address": ":4244",
170+
"cilium_hubble_metrics_server": ":9091",
171+
"cilium_hubble_metrics": "drop,tcp,flow,port-distribution,icmp",
172+
"type": "terway"
173+
},
174+
{
175+
"data-path": "datapathv2",
176+
"enable-debug": false,
177+
"log-file": "/var/run/cilium/cilium-cni.log",
178+
"type": "cilium-cni"
179+
}
180+
]
181+
}`))
182+
return cniJSON
183+
}()},
184+
readFunc: func(name string) ([]byte, error) {
185+
return []byte("#define DIRECT_ROUTING_DEV_IFINDEX 0\n#define DISABLE_PER_PACKET_LB 1\n"), nil
186+
},
187+
checkFunc: func(t *testing.T, strings []string, err error) {
188+
assert.NoError(t, err)
189+
assert.Contains(t, strings, "--disable-per-package-lb=true")
190+
assert.Contains(t, strings, "--enable-hubble=true")
191+
},
192+
},
153193
}
154194
for _, tt := range tests {
155195
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)