ROX-28861: Make Berserker connection load more configurable#40
ROX-28861: Make Berserker connection load more configurable#40JoukoVirtanen merged 8 commits intomainfrom
Conversation
| fn get_local_addr_port( | ||
| &self, | ||
| addr: Ipv4Address, | ||
| index: usize, |
There was a problem hiding this comment.
usize can be u64 or u32 depending upon the system. In practice it is always u64. Setting it to u64 seems a bit clearer.
There was a problem hiding this comment.
I'm not sure I agree that it's clearer now that we have numerous additional casts elsewhere in the code base
There was a problem hiding this comment.
I think the only new cast that we need as a result of this change is
let index = i as u64;
The other casts would have been needed anyway.
src/worker/network.rs
Outdated
| // 254 (a2 octet) * 254 (a3 octet) * ports_per_address (port) | ||
| // gives us maximum 6451600 connections that could be opened | ||
| let local_port = 49152 + (index % 100) as u16; | ||
| let local_port = 49152 + (index % ports_per_addr as u64) as u16; |
There was a problem hiding this comment.
I set ports_per_addr to u16, but I am always converting it to u64. Seems a bit strange.
There was a problem hiding this comment.
it is a little strange, but upcasting at least means we can guarantee that we're not losing precision. It's probably fine as-is.
src/worker/network.rs
Outdated
| // 254 (a2 octet) * 254 (a3 octet) * ports_per_address (port) | ||
| // gives us maximum 6451600 connections that could be opened | ||
| let local_port = 49152 + (index % 100) as u16; | ||
| let local_port = 49152 + (index % ports_per_addr as u64) as u16; |
There was a problem hiding this comment.
it is a little strange, but upcasting at least means we can guarantee that we're not losing precision. It's probably fine as-is.
| fn get_local_addr_port( | ||
| &self, | ||
| addr: Ipv4Address, | ||
| index: usize, |
There was a problem hiding this comment.
I'm not sure I agree that it's clearer now that we have numerous additional casts elsewhere in the code base
26eb849 to
80d8771
Compare
| /// Map socket index to a local port and address. The address octets are | ||
| /// incremented every conns_per_addr sockets, whithin this interval the local port | ||
| /// is incremented. | ||
| fn get_local_addr_port( |
There was a problem hiding this comment.
self was not used, so I removed it and moved this function outside of the class.
e0585d4 to
7171d1b
Compare
For the network load Berserker cycles through IP addresses and ports. Currently for every one hundred ports it increments the IP address once. This PR makes it so that the number of ports per IP address is not hard coded, but can be configured.
Also makes it so that the exact starting IP address can be set, instead of starting from x.x.0.2, and makes it so that the full range of IP addresses can be incremented through instead of just cycling through the last two octets.
Testing
Summary
The image produced by this PR was used in kube-burner. Stackrox was deployed in the same cluster and the network graph was checked. Connections between pods and external IPs generated by berserker were observed.
Details
Starting from the root of the berserker repository
Build and push the berserker image with a client and server.
The image was then used in a kube-burner configuration file. Here stackrox/stackrox#14790
A GKE cluster was created. Stackrox was deployed there.
Starting from the root of the stacrox/actions repository.
The network graph UI was checked and the following was seen.
For each deployment in the cluster-density-1 namespace about 50 connections to different external IPs was observed. This is what is expected as each pod makes 100 connections and for each IP there are two ports.