Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DSIP-76] Support ssl in netty #16673

Open
wants to merge 80 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
4ab065a
tmp store
xdu-chenrj Oct 11, 2024
9d0515b
format the code
xdu-chenrj Oct 12, 2024
7c5b8c2
Merge branch 'dev' into dev
xdu-chenrj Oct 12, 2024
71a167a
fix ut
xdu-chenrj Oct 12, 2024
60fc3ee
Merge branch 'dev' into dev
xdu-chenrj Oct 12, 2024
d3dc34f
add e2e gluster-test
xdu-chenrj Oct 16, 2024
18ab0df
Merge branch 'dev' into dev
xdu-chenrj Oct 16, 2024
8252269
Merge branch 'dev' into dev
xdu-chenrj Oct 16, 2024
006581a
add SslShellTaskE2ETest
xdu-chenrj Oct 16, 2024
46e9db3
add doc and fix package
xdu-chenrj Oct 17, 2024
32d0edb
format doc
xdu-chenrj Oct 17, 2024
0333f83
change docker-compose name
xdu-chenrj Oct 17, 2024
332fdfd
remove unnecessary content
xdu-chenrj Oct 17, 2024
289dd80
fix e2e-test
xdu-chenrj Oct 17, 2024
a23a59c
change e2e-test workflow name ad task name
xdu-chenrj Oct 17, 2024
be8df43
delete unnecessary functions
xdu-chenrj Oct 17, 2024
a4ed1d0
change SslPythonTaskE2ETest
xdu-chenrj Oct 17, 2024
a9638b4
change SslShellTaskE2ETest
xdu-chenrj Oct 18, 2024
60ed520
change ssl-test docker-compose
xdu-chenrj Oct 18, 2024
7a0e835
chanage e2e-k8s.yml
xdu-chenrj Oct 18, 2024
3bc797e
chanage
xdu-chenrj Oct 18, 2024
190546b
fix doc and remove unnecessary modifications
xdu-chenrj Oct 18, 2024
9607b2d
fix
xdu-chenrj Oct 19, 2024
932d5ea
Merge branch 'dev' into dev
xdu-chenrj Oct 19, 2024
5fb575a
add ssl-e2e.yml
xdu-chenrj Oct 21, 2024
3e29c45
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
e01ee10
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
6355226
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
829a29d
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
9307642
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
5a1b13d
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
5890d8a
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
d79514e
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
614d584
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
452f51c
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
edbe7aa
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
e9038fd
update ssl-e2e.yml
xdu-chenrj Oct 21, 2024
526d82b
Merge branch 'dev' into dev
xdu-chenrj Oct 21, 2024
6b4c53c
update ssl-e2e.yml
xdu-chenrj Oct 22, 2024
852f155
update ssl-e2e.yml
xdu-chenrj Oct 22, 2024
80cc92d
increase build time
xdu-chenrj Oct 22, 2024
c24b79c
update
xdu-chenrj Oct 22, 2024
37797c6
update
xdu-chenrj Oct 22, 2024
c85215b
update
xdu-chenrj Oct 22, 2024
d53d050
update
xdu-chenrj Oct 22, 2024
734038c
update
xdu-chenrj Oct 22, 2024
5d836e9
update
xdu-chenrj Oct 22, 2024
e403cb0
update
xdu-chenrj Oct 22, 2024
d642c1f
update
xdu-chenrj Oct 22, 2024
4feeb56
update
xdu-chenrj Oct 23, 2024
35d256c
update
xdu-chenrj Oct 23, 2024
ba980d4
update
xdu-chenrj Oct 23, 2024
1354ab6
update
xdu-chenrj Oct 23, 2024
35ecb71
update
xdu-chenrj Oct 23, 2024
88f8512
update
xdu-chenrj Oct 23, 2024
f91ab40
update
xdu-chenrj Oct 24, 2024
7839def
update
xdu-chenrj Oct 24, 2024
d0ca502
update
xdu-chenrj Oct 24, 2024
865a4f5
Merge branch 'dev' into dev
davidzollo Oct 25, 2024
136f298
update
xdu-chenrj Oct 25, 2024
a3b0d07
Merge branch 'dev' into dev
xdu-chenrj Oct 25, 2024
fb39e08
update
xdu-chenrj Oct 26, 2024
fbfb5b9
update
xdu-chenrj Oct 26, 2024
cd5055c
update
xdu-chenrj Oct 26, 2024
e6806a3
update
xdu-chenrj Oct 26, 2024
0ccc213
update
xdu-chenrj Oct 26, 2024
d6797c9
update
xdu-chenrj Oct 26, 2024
5b5046d
update
xdu-chenrj Oct 26, 2024
ac36bc2
update
xdu-chenrj Oct 26, 2024
800ee93
update
xdu-chenrj Oct 26, 2024
13ef350
update
xdu-chenrj Oct 26, 2024
21a8025
update
xdu-chenrj Oct 26, 2024
2b08d2f
update
xdu-chenrj Oct 26, 2024
8dcbf9f
update
xdu-chenrj Oct 26, 2024
d1bbd7e
update
xdu-chenrj Oct 27, 2024
7d798bb
update
xdu-chenrj Oct 30, 2024
c1c4386
update
xdu-chenrj Oct 30, 2024
c9e4352
update
xdu-chenrj Oct 31, 2024
876a4a4
update
xdu-chenrj Oct 31, 2024
5961df6
update
xdu-chenrj Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.dolphinscheduler.common.thread.DefaultUncaughtExceptionHandler;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.dao.DaoConfiguration;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.registry.api.RegistryConfiguration;

import javax.annotation.PostConstruct;
Expand All @@ -40,7 +41,8 @@
@Slf4j
@Import({CommonConfiguration.class,
DaoConfiguration.class,
RegistryConfiguration.class})
RegistryConfiguration.class,
NettySslConfig.class})
Comment on lines +44 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RegistryConfiguration.class,
NettySslConfig.class})
RegistryConfiguration.class})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mark these resolved?

@SpringBootApplication
public class AlertServer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.alert.config;

import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;

import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -47,6 +48,8 @@ public final class AlertConfig implements Validator {

private String alertServerAddress;

private NettySslConfig nettySslConfig;

@Override
public boolean supports(Class<?> clazz) {
return AlertConfig.class.isAssignableFrom(clazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ alert:
max-heartbeat-interval: 60s
# The maximum number of alerts that can be processed in parallel
sender-parallelism: 100
rpc:
ssl:
enabled: false
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

registry:
type: zookeeper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.dolphinscheduler.common.thread.DefaultUncaughtExceptionHandler;
import org.apache.dolphinscheduler.dao.DaoConfiguration;
import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceProcessorProvider;
import org.apache.dolphinscheduler.plugin.storage.api.StorageConfiguration;
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
Expand All @@ -44,14 +45,18 @@
CommonConfiguration.class,
ServiceConfiguration.class,
StorageConfiguration.class,
RegistryConfiguration.class})
RegistryConfiguration.class,
NettySslConfig.class})
@ServletComponentScan
@SpringBootApplication
public class ApiApplicationServer {

@Autowired
private PluginDao pluginDao;

@Autowired
NettySslConfig nettySslConfig;

public static void main(String[] args) {
ApiServerMetrics.registerUncachedException(DefaultUncaughtExceptionHandler::getUncaughtExceptionCount);
Thread.setDefaultUncaughtExceptionHandler(DefaultUncaughtExceptionHandler.getInstance());
Expand Down
5 changes: 5 additions & 0 deletions dolphinscheduler-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ api:
# Close each active connection of socket server if python program not active after x milliseconds. Define value is
# (0 = infinite), and socket server would never close even though no requests accept
read-timeout: 0
rpc:
ssl:
enabled: false
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

metrics:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.dolphinscheduler.extract.base.IRpcResponse;
import org.apache.dolphinscheduler.extract.base.SyncRequestDto;
import org.apache.dolphinscheduler.extract.base.config.NettyClientConfig;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.extract.base.exception.RemotingException;
import org.apache.dolphinscheduler.extract.base.exception.RemotingTimeoutException;
import org.apache.dolphinscheduler.extract.base.future.ResponseFuture;
Expand All @@ -33,6 +34,7 @@
import org.apache.dolphinscheduler.extract.base.utils.Host;
import org.apache.dolphinscheduler.extract.base.utils.NettyUtils;

import java.io.File;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -41,6 +43,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;

import javax.net.ssl.SSLException;

import lombok.extern.slf4j.Slf4j;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
Expand All @@ -52,6 +56,8 @@
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.timeout.IdleStateHandler;

@Slf4j
Expand All @@ -70,8 +76,20 @@ public class NettyRemotingClient implements AutoCloseable {

private final NettyClientHandler clientHandler;

private SslContext sslContext = null;

public NettyRemotingClient(final NettyClientConfig clientConfig) {
this.clientConfig = clientConfig;
NettySslConfig nettySslConfig = clientConfig.getNettySslConfig();
if (nettySslConfig.isEnabled()) {
try {
sslContext =
SslContextBuilder.forClient().trustManager(new File(nettySslConfig.getCertFilePath())).build();
} catch (SSLException e) {
throw new IllegalArgumentException("Initialize SslContext error, please check the cert-file", e);
}
}

ThreadFactory nettyClientThreadFactory = ThreadUtils.newDaemonThreadFactory("NettyClientThread-");
if (Epoll.isAvailable()) {
this.workerGroup = new EpollEventLoopGroup(clientConfig.getWorkerThreads(), nettyClientThreadFactory);
Expand All @@ -97,6 +115,10 @@ private void start() {

@Override
public void initChannel(SocketChannel ch) {
NettySslConfig nettySslConfig = clientConfig.getNettySslConfig();
if (nettySslConfig.isEnabled()) {
ch.pipeline().addLast(sslContext.newHandler(ch.alloc()));
}
ch.pipeline()
.addLast("client-idle-handler",
new IdleStateHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ public class NettyClientConfig {
@Builder.Default
private int defaultRpcTimeoutMillis = 10_000;

@Builder.Default
private NettySslConfig nettySslConfig = new NettySslConfig();

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,9 @@ public class NettyServerConfig {
*/
private int listenPort;

/**
* nettySslConfig
*/
xdu-chenrj marked this conversation as resolved.
Show resolved Hide resolved
@Builder.Default
private NettySslConfig nettySslConfig = new NettySslConfig();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.dolphinscheduler.extract.base.config;

import lombok.Data;

import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class NettySslConfig {

public boolean enabled;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public boolean enabled;
public boolean enabled = false;


public String certFilePath;

public String keyFilePath;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@

import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.extract.base.config.NettyServerConfig;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.extract.base.exception.RemoteException;
import org.apache.dolphinscheduler.extract.base.protocal.TransporterDecoder;
import org.apache.dolphinscheduler.extract.base.protocal.TransporterEncoder;
import org.apache.dolphinscheduler.extract.base.utils.NettyUtils;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import javax.net.ssl.SSLException;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import io.netty.bootstrap.ServerBootstrap;
Expand All @@ -40,8 +44,9 @@
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.timeout.IdleStateHandler;

/**
* remoting netty server
*/
Expand All @@ -66,7 +71,18 @@ class NettyRemotingServer {

private final AtomicBoolean isStarted = new AtomicBoolean(false);

NettyRemotingServer(final NettyServerConfig serverConfig) {
private SslContext sslContext = null;

public NettyRemotingServer(final NettyServerConfig serverConfig) {
NettySslConfig nettySslConfig = serverConfig.getNettySslConfig();
if (nettySslConfig.isEnabled()) {
try {
sslContext = SslContextBuilder.forServer(new File(nettySslConfig.getCertFilePath()),
new File(nettySslConfig.getKeyFilePath())).build();
} catch (SSLException e) {
throw new RuntimeException(e);
}
}
this.serverConfig = serverConfig;
this.serverName = serverConfig.getServerName();
this.methodInvokerExecutor = ThreadUtils.newDaemonFixedThreadExecutor(
Expand Down Expand Up @@ -130,6 +146,10 @@ protected void initChannel(SocketChannel ch) {
* @param ch socket channel
*/
private void initNettyChannel(SocketChannel ch) {
NettySslConfig nettySslConfig = serverConfig.getNettySslConfig();
if (nettySslConfig.isEnabled()) {
ch.pipeline().addLast("ssl", sslContext.newHandler(ch.alloc()));
}
ch.pipeline()
.addLast("encoder", new TransporterEncoder())
.addLast("decoder", new TransporterDecoder())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.dolphinscheduler.common.thread.DefaultUncaughtExceptionHandler;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.dao.DaoConfiguration;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.meter.metrics.MetricsProvider;
import org.apache.dolphinscheduler.meter.metrics.SystemMetrics;
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceProcessorProvider;
Expand Down Expand Up @@ -60,7 +61,8 @@
ServiceConfiguration.class,
CommonConfiguration.class,
StorageConfiguration.class,
RegistryConfiguration.class})
RegistryConfiguration.class,
NettySslConfig.class})
xdu-chenrj marked this conversation as resolved.
Show resolved Hide resolved
@SpringBootApplication
public class MasterServer implements IStoppable {

Expand Down Expand Up @@ -94,6 +96,9 @@ public class MasterServer implements IStoppable {
@Autowired
private SystemEventBusFireWorker systemEventBusFireWorker;

@Autowired
NettySslConfig nettySslConfig;

xdu-chenrj marked this conversation as resolved.
Show resolved Hide resolved
public static void main(String[] args) {
MasterServerMetrics.registerUncachedException(DefaultUncaughtExceptionHandler::getUncaughtExceptionCount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.server.master.config;

import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.registry.api.ConnectStrategyProperties;
import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType;
import org.apache.dolphinscheduler.server.master.cluster.loadbalancer.WorkerLoadBalancerConfigurationProperties;
Expand Down Expand Up @@ -79,6 +80,8 @@ public class MasterConfig implements Validator {
*/
private String masterRegistryPath;

private NettySslConfig nettySslConfig;

@Override
public boolean supports(Class<?> clazz) {
return MasterConfig.class.isAssignableFrom(clazz);
Expand Down
5 changes: 5 additions & 0 deletions dolphinscheduler-master/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ master:
memory-usage-weight: 30
cpu-usage-weight: 30
task-thread-pool-usage-weight: 40
rpc:
ssl:
enabled: false
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

server:
port: 5679
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
import org.apache.dolphinscheduler.common.thread.DefaultUncaughtExceptionHandler;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.meter.metrics.MetricsProvider;
import org.apache.dolphinscheduler.meter.metrics.SystemMetrics;
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceProcessorProvider;
Expand Down Expand Up @@ -55,7 +56,8 @@
@Slf4j
@Import({CommonConfiguration.class,
StorageConfiguration.class,
RegistryConfiguration.class})
RegistryConfiguration.class,
NettySslConfig.class})
xdu-chenrj marked this conversation as resolved.
Show resolved Hide resolved
@SpringBootApplication
public class WorkerServer implements IStoppable {

Expand All @@ -71,6 +73,8 @@ public class WorkerServer implements IStoppable {
@Autowired
private MetricsProvider metricsProvider;

@Autowired
NettySslConfig nettySslConfig;
xdu-chenrj marked this conversation as resolved.
Show resolved Hide resolved
/**
* worker server startup, not use web service
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.server.worker.config;

import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.extract.base.config.NettySslConfig;
import org.apache.dolphinscheduler.registry.api.ConnectStrategyProperties;
import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType;

Expand Down Expand Up @@ -47,7 +48,7 @@ public class WorkerConfig implements Validator {
private int hostWeight = 100;
private WorkerServerLoadProtection serverLoadProtection = new WorkerServerLoadProtection();
private ConnectStrategyProperties registryDisconnectStrategy = new ConnectStrategyProperties();

private NettySslConfig nettySslConfig;
/**
* This field doesn't need to set at config file, it will be calculated by workerIp:listenPort
*/
Expand Down
5 changes: 5 additions & 0 deletions dolphinscheduler-worker/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ worker:
auto-create-tenant-enabled: true
# If set true, will use worker bootstrap user as the tenant to execute task when the tenant is `default`.
default-tenant-enabled: false
rpc:
ssl:
enabled: false
cert-file-path: /path/cert.crt
key-file-path: /path/private.pem

server:
port: 1235
Expand Down
Loading