Skip to content

Commit

Permalink
enhance logger info detail when create kubeClient
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Mar 21, 2024
1 parent 4734970 commit 99b71ac
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
1 change: 1 addition & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mvn compile deploy -Pscala-${scala_version} -Dfast -DskipTests=true -Ptis-repo
,flink-table/flink-table-runtime\
,flink-test-utils-parent/flink-test-utils\
,flink-test-utils-parent/flink-connector-test-utils\
,flink-formats/flink-avro-confluent-registry\
,flink-core\
,flink-streaming-java\
,flink-table/flink-table-common\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.NamespacedKubernetesClient;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -45,16 +46,18 @@ public class FlinkKubeClientFactory {
public static FlinkKubeClientFactory getInstance() {
return INSTANCE;
}

public static Config kubeConfig;

/**
* Create a Flink Kubernetes client with the given configuration.
*
* @param flinkConfig Flink configuration
* @param useCase Flink Kubernetes client use case (e.g. client, resourcemanager,
* kubernetes-ha-services)
* kubernetes-ha-services)
*
* @return Return the Flink Kubernetes client with the specified configuration and dedicated IO
* executor.
* executor.
*/
public FlinkKubeClient fromConfiguration(Configuration flinkConfig, String useCase) {
final Config config;
Expand All @@ -66,11 +69,13 @@ public FlinkKubeClient fromConfiguration(Configuration flinkConfig, String useCa

final String kubeConfigFile =
flinkConfig.getString(KubernetesConfigOptions.KUBE_CONFIG_FILE);
// baisui 20211104 modify for config inject form context
LOG.info(KubernetesConfigOptions.KUBE_CONFIG_FILE.key() + " path: {}.", kubeConfigFile);
// baisui 20211104 modify for config inject form context
if (kubeConfig != null) {
LOG.info( "Trying to load kubernetes config from kubeConfig static" );
config = kubeConfig;
}else if (kubeConfigFile != null) {
LOG.debug("Trying to load kubernetes config from file: {}.", kubeConfigFile);
} else if (kubeConfigFile != null) {
LOG.info("Trying to load kubernetes config from file: {}.", kubeConfigFile);
try {
// If kubeContext is null, the default context in the kubeConfigFile will be used.
// Note: the third parameter kubeconfigPath is optional and is set to null. It is
Expand All @@ -87,17 +92,19 @@ public FlinkKubeClient fromConfiguration(Configuration flinkConfig, String useCa
throw new KubernetesClientException("Load kubernetes config failed.", e);
}
} else {
LOG.debug("Trying to load default kubernetes config.");

config = Config.autoConfigure(kubeContext);
throw new UnsupportedOperationException(
"Trying to load default kubernetes config is not support .");
// LOG.debug("Trying to load default kubernetes config.");
//
// config = Config.autoConfigure(kubeContext);
}

final String namespace = flinkConfig.getString(KubernetesConfigOptions.NAMESPACE);
final String userAgent =
flinkConfig.getString(KubernetesConfigOptions.KUBERNETES_CLIENT_USER_AGENT);
config.setNamespace(namespace);
config.setUserAgent(userAgent);
LOG.debug("Setting Kubernetes client namespace: {}, userAgent: {}", namespace, userAgent);
LOG.info("Setting Kubernetes client namespace: {}, userAgent: {}", namespace, userAgent);

final NamespacedKubernetesClient client =
new KubernetesClientBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public interface ClassLoaderFactory {
}

// baisui modfiy
public static final class DefaultClassLoaderFactory implements ClassLoaderFactory {
public static class DefaultClassLoaderFactory implements ClassLoaderFactory {

/** The resolve order to use when creating a {@link ClassLoader}. */
protected final FlinkUserCodeClassLoaders.ResolveOrder classLoaderResolveOrder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public default ClassLoaderFactory buildServerLoaderFactory(
String[] alwaysParentFirstPatterns,
@Nullable Consumer<Throwable> exceptionHander,
boolean checkClassLoaderLeak){
throw new UnsupportedOperationException();
throw new UnsupportedOperationException(this.getClass().getName());
}

public default ClassLoaderFactory buildClientLoaderFactory(
FlinkUserCodeClassLoaders.ResolveOrder classLoaderResolveOrder,
String[] alwaysParentFirstPatterns,
@Nullable Consumer<Throwable> exceptionHander,
boolean checkClassLoaderLeak){
throw new UnsupportedOperationException();
throw new UnsupportedOperationException(this.getClass().getName());
}
}
32 changes: 16 additions & 16 deletions flink-table/flink-table-planner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ under the License.
<pattern>org.apache.calcite</pattern>
<shadedPattern>org.apache.flink.calcite.shaded.org.apache.calcite</shadedPattern>
</relocation>-->
<relocation>
<pattern>org.codehaus</pattern>
<shadedPattern>org.apache.flink.calcite.shaded.org.codehaus</shadedPattern>
</relocation>
<!-- <relocation>-->
<!-- <pattern>org.codehaus</pattern>-->
<!-- <shadedPattern>org.apache.flink.calcite.shaded.org.codehaus</shadedPattern>-->
<!-- </relocation>-->


<!-- Calcite's dependencies -->
Expand Down Expand Up @@ -364,18 +364,18 @@ under the License.
<shadedPattern>org.apache.flink.table.shaded.com.ibm.icu</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.properties.PropertiesTransformer">
<!-- required configuration -->
<resource>org.codehaus.commons.compiler.properties</resource>
<ordinalKey>ordinal</ordinalKey>
<!-- optional configuration -->
<alreadyMergedKey>already_merged</alreadyMergedKey>
<defaultOrdinal>0</defaultOrdinal>
<reverseOrder>false</reverseOrder>
</transformer>
</transformers>
<!-- <transformers>-->
<!-- <transformer-->
<!-- implementation="org.apache.maven.plugins.shade.resource.properties.PropertiesTransformer">-->
<!-- &lt;!&ndash; required configuration &ndash;&gt;-->
<!-- <resource>org.codehaus.commons.compiler.properties</resource>-->
<!-- <ordinalKey>ordinal</ordinalKey>-->
<!-- &lt;!&ndash; optional configuration &ndash;&gt;-->
<!-- <alreadyMergedKey>already_merged</alreadyMergedKey>-->
<!-- <defaultOrdinal>0</defaultOrdinal>-->
<!-- <reverseOrder>false</reverseOrder>-->
<!-- </transformer>-->
<!-- </transformers>-->
</configuration>
</plugin>

Expand Down

0 comments on commit 99b71ac

Please sign in to comment.