From c331a1a05af95fc9b77d6e1ce579dc0fcce2f331 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Fri, 10 Sep 2021 01:14:42 +0000 Subject: [PATCH] policy: Detect when a server's protocol changes Currently, the policy controller's indexing does not detect when a server update changes its protocol (due to an incorrect comparison). This change fixes this comparison so that protocol hint changes are properly honored. --- policy-controller/k8s/index/src/server.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/policy-controller/k8s/index/src/server.rs b/policy-controller/k8s/index/src/server.rs index 2ff1545c3a3a5..b713632cfa873 100644 --- a/policy-controller/k8s/index/src/server.rs +++ b/policy-controller/k8s/index/src/server.rs @@ -178,6 +178,7 @@ impl SrvIndex { /// Update the index with a server instance. fn apply(&mut self, srv: policy::Server, ns_authzs: &AuthzIndex) { + trace!(?srv, "Applying server"); let srv_name = srv.name(); let port = srv.spec.port; let protocol = Self::mk_protocol(srv.spec.proxy_protocol.as_ref()); @@ -209,6 +210,8 @@ impl SrvIndex { } HashEntry::Occupied(mut entry) => { + trace!(srv = ?entry.get(), "Updating existing server"); + // If something about the server changed, we need to update the config to reflect // the change. let new_labels = if entry.get().labels != srv.metadata.labels { @@ -217,7 +220,7 @@ impl SrvIndex { None }; - let new_protocol = if entry.get().protocol == protocol { + let new_protocol = if entry.get().protocol != protocol { Some(protocol) } else { None