This is an automated email from the ASF dual-hosted git repository. chesnay pushed a commit to branch release-1.16 in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.16 by this push: new cf027891b3a [FLINK-30116][rest] Do not expose environment variables cf027891b3a is described below commit cf027891b3ab51e8203af39e387f5badd4020a9b Author: ConradJam <jam.gz...@gmail.com> AuthorDate: Mon Dec 12 18:06:22 2022 +0800 [FLINK-30116][rest] Do not expose environment variables --- .../shortcodes/generated/rest_v1_dispatcher.html | 32 +---------- docs/static/generated/rest_v1_dispatcher.yml | 13 +---- .../src/test/resources/rest_api_v1.snapshot | 30 ---------- .../runtime/rest/messages/EnvironmentInfo.java | 64 +--------------------- .../job/JobManagerJobEnvironmentHeaders.java | 2 +- 5 files changed, 6 insertions(+), 135 deletions(-) diff --git a/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html b/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html index 050d3750d8e..d96cee05d24 100644 --- a/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html +++ b/docs/layouts/shortcodes/generated/rest_v1_dispatcher.html @@ -929,21 +929,6 @@ Using 'curl' you can upload a jar via 'curl -X POST -H "Expect:" -F "jarfile=@pa "type" : "string" } }, - "environment" : { - "type" : "array", - "items" : { - "type" : "object", - "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:EnvironmentVariableItem", - "properties" : { - "key" : { - "type" : "string" - }, - "value" : { - "type" : "string" - } - } - } - }, "jvm" : { "type" : "object", "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:JVMInfo", @@ -3110,7 +3095,7 @@ Using 'curl' you can upload a jar via 'curl -X POST -H "Expect:" -F "jarfile=@pa <td class="text-left">Response code: <code>200 OK</code></td> </tr> <tr> - <td colspan="2">Returns the jobmanager's environment variables of a specific job.</td> + <td colspan="2">Returns the jobmanager's environment of a specific job.</td> </tr> <tr> <td colspan="2">Path parameters</td> @@ -3163,21 +3148,6 @@ Using 'curl' you can upload a jar via 'curl -X POST -H "Expect:" -F "jarfile=@pa "type" : "string" } }, - "environment" : { - "type" : "array", - "items" : { - "type" : "object", - "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:EnvironmentVariableItem", - "properties" : { - "key" : { - "type" : "string" - }, - "value" : { - "type" : "string" - } - } - } - }, "jvm" : { "type" : "object", "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:JVMInfo", diff --git a/docs/static/generated/rest_v1_dispatcher.yml b/docs/static/generated/rest_v1_dispatcher.yml index e0c7855c589..b2500ee831b 100644 --- a/docs/static/generated/rest_v1_dispatcher.yml +++ b/docs/static/generated/rest_v1_dispatcher.yml @@ -664,7 +664,7 @@ paths: $ref: '#/components/schemas/ConfigurationInfoEntry' /jobs/{jobid}/jobmanager/environment: get: - description: Returns the jobmanager's environment variables of a specific job. + description: Returns the jobmanager's environment of a specific job. operationId: getJobManagerJobEnvironment parameters: - name: jobid @@ -3041,10 +3041,6 @@ components: EnvironmentInfo: type: object properties: - environment: - type: array - items: - $ref: '#/components/schemas/EnvironmentVariableItem' jvm: $ref: '#/components/schemas/JVMInfo' classpath: @@ -3078,13 +3074,6 @@ components: type: string value: type: string - EnvironmentVariableItem: - type: object - properties: - key: - type: string - value: - type: string TriggerResponse: type: object properties: diff --git a/flink-runtime-web/src/test/resources/rest_api_v1.snapshot b/flink-runtime-web/src/test/resources/rest_api_v1.snapshot index b13156998af..4258dab16ce 100644 --- a/flink-runtime-web/src/test/resources/rest_api_v1.snapshot +++ b/flink-runtime-web/src/test/resources/rest_api_v1.snapshot @@ -501,21 +501,6 @@ "type" : "object", "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo", "properties" : { - "environment" : { - "type" : "array", - "items" : { - "type" : "object", - "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:EnvironmentVariableItem", - "properties" : { - "key" : { - "type" : "string" - }, - "value" : { - "type" : "string" - } - } - } - }, "jvm" : { "type" : "object", "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:JVMInfo", @@ -1941,21 +1926,6 @@ "type" : "object", "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo", "properties" : { - "environment" : { - "type" : "array", - "items" : { - "type" : "object", - "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:EnvironmentVariableItem", - "properties" : { - "key" : { - "type" : "string" - }, - "value" : { - "type" : "string" - } - } - } - }, "jvm" : { "type" : "object", "id" : "urn:jsonschema:org:apache:flink:runtime:rest:messages:EnvironmentInfo:JVMInfo", diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EnvironmentInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EnvironmentInfo.java index 44c80388ebe..097ef4d0b43 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EnvironmentInfo.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/EnvironmentInfo.java @@ -23,7 +23,6 @@ import org.apache.flink.runtime.util.EnvironmentInformation; import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator; import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -31,15 +30,10 @@ import java.util.Objects; /** The response of environment info. */ public class EnvironmentInfo implements ResponseBody { - private static final String FIELD_NAME_ENVIRONMENT_INFO = "environment"; - private static final String FIELD_NAME_JVM_INFO = "jvm"; private static final String FIELD_NAME_CLASSPATH = "classpath"; - @JsonProperty(FIELD_NAME_ENVIRONMENT_INFO) - private final List<EnvironmentVariableItem> environmentVariables; - @JsonProperty(FIELD_NAME_JVM_INFO) private final JVMInfo jvmInfo; @@ -48,11 +42,8 @@ public class EnvironmentInfo implements ResponseBody { @JsonCreator public EnvironmentInfo( - @JsonProperty(FIELD_NAME_ENVIRONMENT_INFO) - List<EnvironmentVariableItem> environmentVariables, @JsonProperty(FIELD_NAME_JVM_INFO) JVMInfo jvmInfo, @JsonProperty(FIELD_NAME_CLASSPATH) List<String> classpath) { - this.environmentVariables = environmentVariables; this.jvmInfo = jvmInfo; this.classpath = classpath; } @@ -66,66 +57,17 @@ public class EnvironmentInfo implements ResponseBody { return false; } EnvironmentInfo that = (EnvironmentInfo) o; - return environmentVariables.equals(that.environmentVariables) - && jvmInfo.equals(that.jvmInfo) - && classpath.equals(that.classpath); + return jvmInfo.equals(that.jvmInfo) && classpath.equals(that.classpath); } @Override public int hashCode() { - return Objects.hash(environmentVariables, jvmInfo, classpath); + return Objects.hash(jvmInfo, classpath); } public static EnvironmentInfo create() { - List<EnvironmentVariableItem> environmentVariableItems = new ArrayList<>(); - System.getenv() - .forEach( - (key, value) -> - environmentVariableItems.add( - new EnvironmentVariableItem(key, value))); - return new EnvironmentInfo( - environmentVariableItems, - JVMInfo.create(), - Arrays.asList(System.getProperty("java.class.path").split(":"))); - } - - /** A single key-value pair entry in the {@link EnvironmentInfo} response. */ - private static class EnvironmentVariableItem { - private static final String FIELD_NAME_KEY = "key"; - - private static final String FIELD_NAME_VALUE = "value"; - - @JsonProperty(FIELD_NAME_KEY) - private final String key; - - @JsonProperty(FIELD_NAME_VALUE) - private final String value; - - @JsonCreator - public EnvironmentVariableItem( - @JsonProperty(FIELD_NAME_KEY) String key, - @JsonProperty(FIELD_NAME_VALUE) String value) { - this.key = key; - this.value = value; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EnvironmentVariableItem that = (EnvironmentVariableItem) o; - return key.equals(that.key) && value.equals(that.value); - } - - @Override - public int hashCode() { - return Objects.hash(key, value); - } + JVMInfo.create(), Arrays.asList(System.getProperty("java.class.path").split(":"))); } /** JVM information. */ diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/job/JobManagerJobEnvironmentHeaders.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/job/JobManagerJobEnvironmentHeaders.java index 256c1f6149c..a5e3e4846ed 100644 --- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/job/JobManagerJobEnvironmentHeaders.java +++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/job/JobManagerJobEnvironmentHeaders.java @@ -75,6 +75,6 @@ public class JobManagerJobEnvironmentHeaders @Override public String getDescription() { - return "Returns the jobmanager's environment variables of a specific job."; + return "Returns the jobmanager's environment of a specific job."; } }