Skip to content

Commit

Permalink
fix the display of non-existing cluster information in cluster list
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Oct 13, 2023
1 parent a1d60b2 commit 4c47cfc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bin/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ command_socket = "./sozu.sock"
# buffer will grow up to max_command_buffer_size. If the buffer is still not large
# enough sozu will close the connection
# defaults to 1000000
command_buffer_size = 1_000_000
command_buffer_size = 16384
# defaults to command_buffer_size * 2
max_command_buffer_size = 2_000_000
max_command_buffer_size = 163840

# the number of worker processes that will handle traffic
# defaults to 2 workers
Expand Down Expand Up @@ -89,7 +89,7 @@ buffer_size = 16393

# how much time (in milliseconds) sozu command line will wait for a command to complete.
# Defaults to 1000 milliseconds
ctl_command_timeout = 60_000
# ctl_command_timeout = 1000

# PID file is a file containing the PID of the main process of sozu.
# It can be helpful to help systemd or any other service system to keep track
Expand Down
8 changes: 5 additions & 3 deletions bin/src/ctl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,10 @@ pub fn print_cluster_responses(
for (worker_id, response_content) in worker_responses.map.iter() {
if let Some(ContentType::Clusters(clusters)) = &response_content.content_type {
for cluster in clusters.vec.iter() {
let entry = cluster_infos.entry(cluster).or_insert(Vec::new());
entry.push(worker_id.to_owned());
if cluster.configuration.is_some() {
let entry = cluster_infos.entry(cluster).or_insert(Vec::new());
entry.push(worker_id.to_owned());
}

for frontend in cluster.http_frontends.iter() {
let entry = http_frontends.entry(frontend).or_insert(Vec::new());
Expand Down Expand Up @@ -485,7 +487,7 @@ pub fn print_cluster_responses(
.configuration
.as_ref()
.map(|conf| conf.cluster_id.to_owned())
.unwrap_or_else(String::new)));
.unwrap_or_else(|| String::from("None"))));
row.push(cell!(cluster_info
.configuration
.as_ref()
Expand Down
5 changes: 3 additions & 2 deletions command/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ impl ConfigState {

// FIXME: what about deny rules?
pub fn hash_state(&self) -> BTreeMap<ClusterId, u64> {
let mut hm: HashMap<String, DefaultHasher> = self
let mut hm: HashMap<ClusterId, DefaultHasher> = self
.clusters
.keys()
.map(|cluster_id| {
Expand All @@ -1141,10 +1141,11 @@ impl ConfigState {
if let Some(tcp_fronts) = self.tcp_fronts.get(cluster_id) {
tcp_fronts.iter().collect::<BTreeSet<_>>().hash(&mut hasher)
}
(cluster_id.to_string(), hasher)
(cluster_id.to_owned(), hasher)
})
.collect();


for front in self.http_fronts.values() {
if let Some(cluster_id) = &front.cluster_id {
if let Some(hasher) = hm.get_mut(cluster_id) {
Expand Down

0 comments on commit 4c47cfc

Please sign in to comment.