From 0635d304dea83b8ce0ba62e06d22f50fa5746234 Mon Sep 17 00:00:00 2001 From: Chris Capurso <1036769+ccapurso@users.noreply.github.com> Date: Wed, 4 Jan 2023 11:09:51 -0500 Subject: [PATCH] only update SCADA metadata if status changes (#18585) * only update SCADA metadata if status changes * add changelog entry --- changelog/18585.txt | 3 +++ vault/hcp_link/link.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog/18585.txt diff --git a/changelog/18585.txt b/changelog/18585.txt new file mode 100644 index 000000000..a0832e2d4 --- /dev/null +++ b/changelog/18585.txt @@ -0,0 +1,3 @@ +```release-note:improvement +hcp/connectivity: Only update SCADA session metadata if status changes +``` diff --git a/vault/hcp_link/link.go b/vault/hcp_link/link.go index 9192603e9..ea1e9fc71 100644 --- a/vault/hcp_link/link.go +++ b/vault/hcp_link/link.go @@ -222,6 +222,8 @@ func (h *HCPLinkVault) start() error { // API. In addition, it checks replication status of Vault and sets that in // Scada provider metadata status func (h *HCPLinkVault) reportStatus() { + var currentNodeStatus string + ticker := time.NewTicker(SetLinkStatusCadence) defer ticker.Stop() for { @@ -249,7 +251,11 @@ func (h *HCPLinkVault) reportStatus() { nodeStatus = activeStatus } - h.linkConfig.SCADAProvider.UpdateMeta(map[string]string{metaDataNodeStatus: nodeStatus}) + // Only update SCADA session metadata if status has changed + if currentNodeStatus != nodeStatus { + currentNodeStatus = nodeStatus + h.linkConfig.SCADAProvider.UpdateMeta(map[string]string{metaDataNodeStatus: currentNodeStatus}) + } } } }