Skip to content

Commit e49809f

Browse files
author
Eugenio Grosso
committed
flasharray: rate-limit legacy-auth deprecation WARN to once per URL
Copilot pointed out that the legacy-auth deprecation WARN is emitted on every login/refresh; with the default ~14-minute key TTL and multiple legacy-configured pools, that spams the logs without giving the operator any new information. Gate the WARN behind a static Set<String> keyed by FlashArray URL so it fires once per endpoint per JVM lifetime. Subsequent refreshes against the same URL stay silent. Uses ConcurrentHashMap.newKeySet() for thread-safety since multiple pools poll concurrently. Signed-off-by: Eugenio Grosso <eugenio.grosso@gmail.com>
1 parent 2938570 commit e49809f

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray

plugins/storage/volume/flasharray/src/main/java/org/apache/cloudstack/storage/datastore/adapter/flasharray/FlashArrayAdapter.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import java.util.ArrayList;
2828
import java.util.HashMap;
2929
import java.util.Map;
30+
import java.util.Set;
31+
import java.util.concurrent.ConcurrentHashMap;
3032

3133
import javax.net.ssl.HostnameVerifier;
3234
import javax.net.ssl.SSLContext;
@@ -86,6 +88,10 @@ public class FlashArrayAdapter implements ProviderAdapter {
8688
private static final String API_LOGIN_VERSION_DEFAULT = "1.19";
8789
private static final String API_VERSION_DEFAULT = "2.23";
8890

91+
// URLs for which the legacy-auth deprecation WARN has already been emitted,
92+
// so we don't spam the logs once per refresh per pool while it's still configured.
93+
private static final Set<String> WARNED_LEGACY_URLS = ConcurrentHashMap.newKeySet();
94+
8995
static final ObjectMapper mapper = new ObjectMapper();
9096
public String pod = null;
9197
public String hostgroup = null;
@@ -712,10 +718,12 @@ private void login() {
712718
}
713719

714720
if (usingLegacyUserPass) {
715-
logger.warn("FlashArray adapter at [" + url + "] is using deprecated username/password "
716-
+ "login against Purity REST 1.x. Replace with a pre-minted "
717-
+ ProviderAdapter.API_TOKEN_KEY + " detail; the username/password code path will be "
718-
+ "removed in a future release.");
721+
if (WARNED_LEGACY_URLS.add(url)) {
722+
logger.warn("FlashArray adapter at [" + url + "] is using deprecated username/password "
723+
+ "login against Purity REST 1.x. Replace with a pre-minted "
724+
+ ProviderAdapter.API_TOKEN_KEY + " detail; the username/password code path will be "
725+
+ "removed in a future release.");
726+
}
719727
HttpPost request = new HttpPost(url + "/" + apiLoginVersion + "/auth/apitoken");
720728
ArrayList<NameValuePair> postParms = new ArrayList<NameValuePair>();
721729
postParms.add(new BasicNameValuePair("username", username));

0 commit comments

Comments
 (0)