Skip to content

Commit

Permalink
fix iptables init
Browse files Browse the repository at this point in the history
  • Loading branch information
myrrc committed Nov 25, 2024
1 parent 52960a0 commit a8af9ad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions neonvm-runner/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ func listenForHTTPRequests(
}
}

func incNetBytesCounter(iptables iptables.IPTables, chain string, cnt *vmv1.NetworkBytes) error {
func incNetBytesCounter(iptables *iptables.IPTables, chain string, cnt *vmv1.NetworkBytes) error {
// TODO(myrrc) neon_private_cidr?
rules, err := iptables.StructuredStats("filter", chain)
if err != nil {
Expand All @@ -1241,7 +1241,12 @@ func handleGetNetworkUsage(logger *zap.Logger, w http.ResponseWriter, r *http.Re

counts := vmv1.VirtualMachineNetworkUsage{IngressBytes: 0, EgressBytes: 0}
// Rules configured at github.com/neondatabase/cloud/blob/main/compute-init/compute-init.sh#L98
iptables := iptables.IPTables{}
iptables, err := iptables.New()
if err != nil {
logger.Error("error initializing iptables", zap.Error(err))
w.WriteHeader(500)
return
}
if err := incNetBytesCounter(iptables, "INPUT", &counts.IngressBytes); err != nil {
logger.Error("error reading ingress byte counts", zap.Error(err))
w.WriteHeader(500)
Expand Down

0 comments on commit a8af9ad

Please sign in to comment.