From b766ef45c0f8b6ac1012aea71a6a3410fd7fcecf Mon Sep 17 00:00:00 2001 From: Gabriel Brascher Date: Mon, 31 Aug 2020 23:31:22 -0300 Subject: [PATCH 1/3] Re-try Redfish HTTP request --- .../RedfishOutOfBandManagementDriver.java | 8 ++- .../utils/redfish/RedfishClient.java | 32 ++++++++- .../utils/redfish/RedfishClientTest.java | 69 ++++++++++++++++--- 3 files changed, 97 insertions(+), 12 deletions(-) diff --git a/plugins/outofbandmanagement-drivers/redfish/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/redfish/RedfishOutOfBandManagementDriver.java b/plugins/outofbandmanagement-drivers/redfish/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/redfish/RedfishOutOfBandManagementDriver.java index 3e863342badd..14a41e131a0c 100644 --- a/plugins/outofbandmanagement-drivers/redfish/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/redfish/RedfishOutOfBandManagementDriver.java +++ b/plugins/outofbandmanagement-drivers/redfish/src/main/java/org/apache/cloudstack/outofbandmanagement/driver/redfish/RedfishOutOfBandManagementDriver.java @@ -51,6 +51,10 @@ public class RedfishOutOfBandManagementDriver extends AdapterBase implements Out public static final ConfigKey USE_HTTPS = new ConfigKey("Advanced", Boolean.class, "redfish.use.https", "true", "Use HTTPS/SSL for all connections.", true, ConfigKey.Scope.Global); + public static final ConfigKey REDFISHT_REQUEST_MAX_RETRIES = new ConfigKey("Advanced", Integer.class, "redfish.retries", "2", + "Number of retries allowed if a Redfish REST request experiment connection issues. If set to 0 (zero) there will be no retries.", true, ConfigKey.Scope.Global); + + private static final String HTTP_STATUS_OK = String.valueOf(HttpStatus.SC_OK); @Override @@ -74,7 +78,7 @@ private OutOfBandManagementDriverResponse execute(final OutOfBandManagementDrive String username = outOfBandOptions.get(OutOfBandManagement.Option.USERNAME); String password = outOfBandOptions.get(OutOfBandManagement.Option.PASSWORD); String hostAddress = outOfBandOptions.get(OutOfBandManagement.Option.ADDRESS); - RedfishClient redfishClient = new RedfishClient(username, password, USE_HTTPS.value(), IGNORE_SSL_CERTIFICATE.value()); + RedfishClient redfishClient = new RedfishClient(username, password, USE_HTTPS.value(), IGNORE_SSL_CERTIFICATE.value(), REDFISHT_REQUEST_MAX_RETRIES.value()); RedfishClient.RedfishPowerState powerState = null; if (cmd.getPowerOperation() == OutOfBandManagement.PowerOperation.STATUS) { @@ -114,7 +118,7 @@ public String getConfigComponentName() { @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {IGNORE_SSL_CERTIFICATE, USE_HTTPS}; + return new ConfigKey[] {IGNORE_SSL_CERTIFICATE, USE_HTTPS, REDFISHT_REQUEST_MAX_RETRIES}; } } diff --git a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java index 8166b703a023..536aa3a6ee06 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java @@ -28,6 +28,7 @@ import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.util.Base64; +import java.util.concurrent.TimeUnit; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -71,6 +72,7 @@ public class RedfishClient { private String password; private boolean useHttps; private boolean ignoreSsl; + private int redfishRequestMaxRetries; private final static String SYSTEMS_URL_PATH = "redfish/v1/Systems/"; private final static String COMPUTER_SYSTEM_RESET_URL_PATH = "/Actions/ComputerSystem.Reset"; @@ -81,6 +83,8 @@ public class RedfishClient { private final static String ODATA_ID = "@odata.id"; private final static String MEMBERS = "Members"; private final static String EXPECTED_HTTP_STATUS = "2XX"; + private final static int WAIT_FOR_REQUEST_RETRY = 3; + /** * Redfish Command type:
@@ -126,11 +130,12 @@ public enum RedfishResetCmd { ForceOff, ForceOn, ForceRestart, GracefulRestart, GracefulShutdown, Nmi, On, PowerCycle, PushPowerButton } - public RedfishClient(String username, String password, boolean useHttps, boolean ignoreSsl) { + public RedfishClient(String username, String password, boolean useHttps, boolean ignoreSsl, int redfishRequestRetries) { this.username = username; this.password = password; this.useHttps = useHttps; this.ignoreSsl = ignoreSsl; + this.redfishRequestMaxRetries = redfishRequestRetries; } protected String buildRequestUrl(String hostAddress, RedfishCmdType cmd, String resourceId) { @@ -213,8 +218,31 @@ private HttpResponse executeHttpRequest(String url, HttpRequestBase httpReq) { try { return client.execute(httpReq); } catch (IOException e) { - throw new RedfishException(String.format("Failed to execute POST request [URL: %s] due to exception.", url, e)); + if (redfishRequestMaxRetries == 0) { + throw new RedfishException(String.format("Failed to execute HTTP %s request [URL: %s] due to exception.", httpReq.getMethod(), url), e); + } + return retryHttpRequest(url, httpReq, client); + } + } + + protected HttpResponse retryHttpRequest(String url, HttpRequestBase httpReq, HttpClient client) { + LOGGER.error(String.format("Failed to execute HTTP %s request [URL: %s]. Executing the request again.", httpReq.getMethod(), url)); + for (int attempt = 1; attempt < redfishRequestMaxRetries + 1; attempt++) { + try { + TimeUnit.SECONDS.sleep(WAIT_FOR_REQUEST_RETRY); + LOGGER.debug(String.format("Retry HTTP %s request [URL: %s], attempt %d/%d.", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries)); + return client.execute(httpReq); + } catch (IOException | InterruptedException e) { + if (attempt == redfishRequestMaxRetries) { + throw new RedfishException(String.format("Failed to execute HTTP %s request attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries,url, e)); + } else { + LOGGER.error( + String.format("Failed to execute HTTP %s request attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries, + url, e)); + } + } } + throw new RedfishException(String.format("Failed to execute HTTP %s request [URL: %s].", httpReq.getMethod(), url)); } /** diff --git a/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java b/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java index 552f1874a4f0..18c23176477b 100644 --- a/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java +++ b/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java @@ -18,24 +18,46 @@ // package org.apache.cloudstack.utils.redfish; +import com.cloud.utils.rest.HttpClientHelper; import org.apache.commons.httpclient.HttpStatus; import org.apache.http.StatusLine; +import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.impl.client.CloseableHttpClient; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; -@RunWith(MockitoJUnitRunner.class) public class RedfishClientTest { +import java.io.IOException; +import java.net.http.HttpRequest; + +@RunWith(MockitoJUnitRunner.class) +public class RedfishClientTest { private static final String USERNAME = "user"; private static final String PASSWORD = "password"; private static final String oobAddress = "oob.host.address"; private static final String systemId = "SystemID.1"; private final static String COMPUTER_SYSTEM_RESET_URL_PATH = "/Actions/ComputerSystem.Reset"; + private final static Integer REDFISHT_REQUEST_RETRIES = Integer.valueOf(2); + private static final String url = "https://address.system.net/redfish/v1/Systems/"; + private static final HttpRequestBase httpReq = new HttpGet(url); + + @Mock + HttpClient client; - RedfishClient redfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true)); + RedfishClient redfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES)); + +// @Before +// public void prepareHttpClient() throws IOException { +// Mockito.when(client.execute(httpReq)).thenThrow(IOException.class); +// } @Test(expected = RedfishException.class) public void validateAddressAndPrepareForUrlTestExpect() { @@ -68,7 +90,7 @@ public void validateAddressAndPrepareForUrlTestIpv6() { @Test public void buildRequestUrlTestHttpsGetSystemId() { - RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, true, false); + RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, true, false, REDFISHT_REQUEST_RETRIES); String result = redfishclient.buildRequestUrl(oobAddress, RedfishClient.RedfishCmdType.GetSystemId, systemId); String expected = String.format("https://%s/redfish/v1/Systems/", oobAddress, systemId); Assert.assertEquals(expected, result); @@ -76,7 +98,7 @@ public void buildRequestUrlTestHttpsGetSystemId() { @Test public void buildRequestUrlTestGetSystemId() { - RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, false, false); + RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, false, false, REDFISHT_REQUEST_RETRIES); String result = redfishclient.buildRequestUrl(oobAddress, RedfishClient.RedfishCmdType.GetSystemId, systemId); String expected = String.format("http://%s/redfish/v1/Systems/", oobAddress, systemId); Assert.assertEquals(expected, result); @@ -84,7 +106,7 @@ public void buildRequestUrlTestGetSystemId() { @Test public void buildRequestUrlTestHttpsComputerSystemReset() { - RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, true, false); + RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, true, false, REDFISHT_REQUEST_RETRIES); String result = redfishclient.buildRequestUrl(oobAddress, RedfishClient.RedfishCmdType.ComputerSystemReset, systemId); String expected = String.format("https://%s/redfish/v1/Systems/%s%s", oobAddress, systemId, COMPUTER_SYSTEM_RESET_URL_PATH); Assert.assertEquals(expected, result); @@ -92,7 +114,7 @@ public void buildRequestUrlTestHttpsComputerSystemReset() { @Test public void buildRequestUrlTestComputerSystemReset() { - RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, false, false); + RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, false, false, REDFISHT_REQUEST_RETRIES); String result = redfishclient.buildRequestUrl(oobAddress, RedfishClient.RedfishCmdType.ComputerSystemReset, systemId); String expected = String.format("http://%s/redfish/v1/Systems/%s%s", oobAddress, systemId, COMPUTER_SYSTEM_RESET_URL_PATH); Assert.assertEquals(expected, result); @@ -100,7 +122,7 @@ public void buildRequestUrlTestComputerSystemReset() { @Test public void buildRequestUrlTestHttpsGetPowerState() { - RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, true, false); + RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, true, false, REDFISHT_REQUEST_RETRIES); String result = redfishclient.buildRequestUrl(oobAddress, RedfishClient.RedfishCmdType.GetPowerState, systemId); String expected = String.format("https://%s/redfish/v1/Systems/%s", oobAddress, systemId); Assert.assertEquals(expected, result); @@ -108,7 +130,7 @@ public void buildRequestUrlTestHttpsGetPowerState() { @Test public void buildRequestUrlTestGetPowerState() { - RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, false, false); + RedfishClient redfishclient = new RedfishClient(USERNAME, PASSWORD, false, false, REDFISHT_REQUEST_RETRIES); String result = redfishclient.buildRequestUrl(oobAddress, RedfishClient.RedfishCmdType.GetPowerState, systemId); String expected = String.format("http://%s/redfish/v1/Systems/%s", oobAddress, systemId); Assert.assertEquals(expected, result); @@ -160,4 +182,35 @@ public void getSystemIdTestHttpStatusNotOk() { redfishClientspy.getSystemId(oobAddress); } + @Test(expected = RedfishException.class) + public void retryHttpRequestDefaultRetries() throws IOException { + Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenReturn(null); + redfishClientspy.retryHttpRequest(url, httpReq, client); + + Mockito.verify(redfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); + Mockito.verify(client, Mockito.times(2)).execute(Mockito.any()); + } + + @Test(expected = RedfishException.class) + public void retryHttpRequestNoRetries() throws IOException { + Mockito.when(client.execute(httpReq)).thenThrow(IOException.class); + + RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(0))); + newRedfishClientspy.retryHttpRequest(url, httpReq, client); + + Mockito.verify(newRedfishClientspy, Mockito.times(12)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); + Mockito.verify(client, Mockito.times(10)).execute(Mockito.any()); +// Mockito.never(client) TODO + } + + @Test + public void retryHttpRequestNoException() throws IOException { + Mockito.when(client.execute(httpReq)).thenReturn(null); + + RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(1))); + newRedfishClientspy.retryHttpRequest(url, httpReq, client); + + Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); + Mockito.verify(client, Mockito.times(1)).execute(Mockito.any()); + } } From 294338c7f6d06e0c3062539baa853803e6769d5a Mon Sep 17 00:00:00 2001 From: Gabriel Brascher Date: Fri, 25 Sep 2020 16:24:20 -0300 Subject: [PATCH 2/3] Code enhancements and tests --- .../utils/redfish/RedfishClient.java | 21 ++++++---- .../utils/redfish/RedfishClientTest.java | 40 ++++++++----------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java index 536aa3a6ee06..6214c4b131c7 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java @@ -83,7 +83,7 @@ public class RedfishClient { private final static String ODATA_ID = "@odata.id"; private final static String MEMBERS = "Members"; private final static String EXPECTED_HTTP_STATUS = "2XX"; - private final static int WAIT_FOR_REQUEST_RETRY = 3; + private final static int WAIT_FOR_REQUEST_RETRY = 1; /** @@ -226,23 +226,30 @@ private HttpResponse executeHttpRequest(String url, HttpRequestBase httpReq) { } protected HttpResponse retryHttpRequest(String url, HttpRequestBase httpReq, HttpClient client) { - LOGGER.error(String.format("Failed to execute HTTP %s request [URL: %s]. Executing the request again.", httpReq.getMethod(), url)); + LOGGER.warn(String.format("Failed to execute HTTP %s request [URL: %s]. Executing the request again.", httpReq.getMethod(), url)); + HttpResponse response = null; for (int attempt = 1; attempt < redfishRequestMaxRetries + 1; attempt++) { try { TimeUnit.SECONDS.sleep(WAIT_FOR_REQUEST_RETRY); LOGGER.debug(String.format("Retry HTTP %s request [URL: %s], attempt %d/%d.", httpReq.getMethod(), url, attempt, redfishRequestMaxRetries)); - return client.execute(httpReq); + response = client.execute(httpReq); } catch (IOException | InterruptedException e) { if (attempt == redfishRequestMaxRetries) { - throw new RedfishException(String.format("Failed to execute HTTP %s request attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries,url, e)); + throw new RedfishException(String.format("Failed to execute HTTP %s request retry attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries,url, e)); } else { - LOGGER.error( - String.format("Failed to execute HTTP %s request attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries, + LOGGER.warn( + String.format("Failed to execute HTTP %s request retry attempt %d/%d [URL: %s] due to exception %s", httpReq.getMethod(), attempt, redfishRequestMaxRetries, url, e)); } } } - throw new RedfishException(String.format("Failed to execute HTTP %s request [URL: %s].", httpReq.getMethod(), url)); + + if (response == null) { + throw new RedfishException(String.format("Failed to execute HTTP %s request [URL: %s].", httpReq.getMethod(), url)); + } + + LOGGER.debug(String.format("Successfully executed HTTP %s request [URL: %s].", httpReq.getMethod(), url)); + return response; } /** diff --git a/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java b/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java index 18c23176477b..15a75bab2121 100644 --- a/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java +++ b/utils/src/test/java/org/apache/cloudstack/utils/redfish/RedfishClientTest.java @@ -18,16 +18,14 @@ // package org.apache.cloudstack.utils.redfish; -import com.cloud.utils.rest.HttpClientHelper; import org.apache.commons.httpclient.HttpStatus; +import org.apache.http.HttpResponse; import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.impl.client.CloseableHttpClient; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -35,7 +33,6 @@ import org.mockito.junit.MockitoJUnitRunner; import java.io.IOException; -import java.net.http.HttpRequest; @RunWith(MockitoJUnitRunner.class) public class RedfishClientTest { @@ -52,12 +49,10 @@ public class RedfishClientTest { @Mock HttpClient client; - RedfishClient redfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES)); + @Mock + HttpResponse httpResponse; -// @Before -// public void prepareHttpClient() throws IOException { -// Mockito.when(client.execute(httpReq)).thenThrow(IOException.class); -// } + RedfishClient redfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, REDFISHT_REQUEST_RETRIES)); @Test(expected = RedfishException.class) public void validateAddressAndPrepareForUrlTestExpect() { @@ -183,34 +178,33 @@ public void getSystemIdTestHttpStatusNotOk() { } @Test(expected = RedfishException.class) - public void retryHttpRequestDefaultRetries() throws IOException { - Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenReturn(null); - redfishClientspy.retryHttpRequest(url, httpReq, client); + public void retryHttpRequestNoRetries() throws IOException { + RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(0))); + newRedfishClientspy.retryHttpRequest(url, httpReq, client); - Mockito.verify(redfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); - Mockito.verify(client, Mockito.times(2)).execute(Mockito.any()); + Mockito.verify(newRedfishClientspy, Mockito.never()).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); + Mockito.verify(client, Mockito.never()).execute(Mockito.any()); } @Test(expected = RedfishException.class) - public void retryHttpRequestNoRetries() throws IOException { - Mockito.when(client.execute(httpReq)).thenThrow(IOException.class); + public void retryHttpRequestExceptionAfterOneRetry() throws IOException { + Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenReturn(httpResponse); - RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(0))); + RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(1))); newRedfishClientspy.retryHttpRequest(url, httpReq, client); - Mockito.verify(newRedfishClientspy, Mockito.times(12)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); - Mockito.verify(client, Mockito.times(10)).execute(Mockito.any()); -// Mockito.never(client) TODO + Mockito.verify(newRedfishClientspy, Mockito.never()).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); + Mockito.verify(client, Mockito.never()).execute(Mockito.any()); } @Test public void retryHttpRequestNoException() throws IOException { - Mockito.when(client.execute(httpReq)).thenReturn(null); + Mockito.when(client.execute(httpReq)).thenThrow(IOException.class).thenThrow(IOException.class).thenReturn(httpResponse); - RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(1))); + RedfishClient newRedfishClientspy = Mockito.spy(new RedfishClient(USERNAME, PASSWORD, true, true, Integer.valueOf(3))); newRedfishClientspy.retryHttpRequest(url, httpReq, client); Mockito.verify(newRedfishClientspy, Mockito.times(1)).retryHttpRequest(Mockito.anyString(), Mockito.any(), Mockito.any()); - Mockito.verify(client, Mockito.times(1)).execute(Mockito.any()); + Mockito.verify(client, Mockito.times(3)).execute(Mockito.any()); } } From 1bd225469e3b292a65a1764d59f26ed8f5abf35e Mon Sep 17 00:00:00 2001 From: Gabriel Brascher Date: Mon, 28 Sep 2020 07:01:23 -0300 Subject: [PATCH 3/3] Longer wait for request retry --- .../org/apache/cloudstack/utils/redfish/RedfishClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java index 6214c4b131c7..8b211c026060 100644 --- a/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java +++ b/utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java @@ -83,7 +83,7 @@ public class RedfishClient { private final static String ODATA_ID = "@odata.id"; private final static String MEMBERS = "Members"; private final static String EXPECTED_HTTP_STATUS = "2XX"; - private final static int WAIT_FOR_REQUEST_RETRY = 1; + private final static int WAIT_FOR_REQUEST_RETRY = 2; /** @@ -219,7 +219,7 @@ private HttpResponse executeHttpRequest(String url, HttpRequestBase httpReq) { return client.execute(httpReq); } catch (IOException e) { if (redfishRequestMaxRetries == 0) { - throw new RedfishException(String.format("Failed to execute HTTP %s request [URL: %s] due to exception.", httpReq.getMethod(), url), e); + throw new RedfishException(String.format("Failed to execute HTTP %s request [URL: %s] due to exception %s.", httpReq.getMethod(), url, e), e); } return retryHttpRequest(url, httpReq, client); }