mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-04 20:29:27 +01:00
Merge release branch 4.18 to main
* 4.18: Fixed spelling and added missing states to response (#8248) Let Prometheus exporter plugin support utf8 characters (#8228)
This commit is contained in:
commit
98d643efe6
@ -124,7 +124,7 @@ public class AcquireIPAddressResponse extends BaseResponse implements Controlle
|
||||
private String networkId;
|
||||
|
||||
@SerializedName(ApiConstants.STATE)
|
||||
@Param(description = "State of the ip address. Can be: Allocatin, Allocated and Releasing")
|
||||
@Param(description = "State of the ip address. Can be: Allocating, Allocated and Releasing")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
|
||||
|
||||
@ -128,7 +128,7 @@ public class IPAddressResponse extends BaseResponseWithAnnotations implements Co
|
||||
private String networkId;
|
||||
|
||||
@SerializedName(ApiConstants.STATE)
|
||||
@Param(description = "State of the ip address. Can be: Allocatin, Allocated and Releasing")
|
||||
@Param(description = "State of the ip address. Can be: Allocating, Allocated, Releasing, Reserved and Free")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
|
||||
|
||||
@ -68,7 +68,7 @@ public class PortableIpResponse extends BaseResponse {
|
||||
private Date allocated;
|
||||
|
||||
@SerializedName(ApiConstants.STATE)
|
||||
@Param(description = "State of the ip address. Can be: Allocatin, Allocated and Releasing")
|
||||
@Param(description = "State of the ip address. Can be: Allocating, Allocated, Releasing and Free")
|
||||
private String state;
|
||||
|
||||
public void setRegionId(Integer regionId) {
|
||||
|
||||
@ -28,6 +28,7 @@ import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PrometheusExporterServerImpl extends ManagerBase implements PrometheusExporterServer, Configurable {
|
||||
@ -57,11 +58,21 @@ public class PrometheusExporterServerImpl extends ManagerBase implements Prometh
|
||||
response = prometheusExporter.getMetrics();
|
||||
responseCode = 200;
|
||||
}
|
||||
httpExchange.getResponseHeaders().set("content-type", "text/plain");
|
||||
httpExchange.sendResponseHeaders(responseCode, response.length());
|
||||
byte[] bytesToOutput = response.getBytes(StandardCharsets.UTF_8);
|
||||
httpExchange.getResponseHeaders().set("content-type", "text/plain; charset=UTF-8");
|
||||
httpExchange.sendResponseHeaders(responseCode, bytesToOutput.length);
|
||||
final OutputStream os = httpExchange.getResponseBody();
|
||||
os.write(response.getBytes());
|
||||
os.close();
|
||||
try {
|
||||
os.write(bytesToOutput);
|
||||
} catch (IOException e) {
|
||||
LOG.error(String.format("could not export Prometheus data due to %s", e.getLocalizedMessage()));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Error during Prometheus export: ", e);
|
||||
}
|
||||
os.write("The system could not export Prometheus due to an internal error. Contact your operator to learn about the reason.".getBytes());
|
||||
} finally {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user