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

chore: support parameters api for pulsar #1365

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion addons-cluster/pulsar/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
{{- end }}
spec:
terminationPolicy: {{ $.Values.terminationPolicy }}
{{- $topologyEnable := eq .Values.mode "" | default false }}
{{- $topologyEnable := ne .Values.mode "" | default false }}
{{- if $topologyEnable}}
clusterDef: pulsar
topology: {{ .Values.mode }}
Expand Down
4 changes: 3 additions & 1 deletion addons/pulsar/config/2.11.2/bookies-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ zkLedgersRootPath=/ledgers
{{- $autoRecoveryDaemonEnabled = "false" }}
{{- end }}
{{- end }}
autoRecoveryDaemonEnabled={{ $autoRecoveryDaemonEnabled }}
autoRecoveryDaemonEnabled={{ $autoRecoveryDaemonEnabled }}

zkServers={{ .ZOOKEEPER_SERVERS }}
9 changes: 9 additions & 0 deletions addons/pulsar/config/2.11.2/bookies-recovery-config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
httpServerEnabled=true
httpServerPort=8000
prometheusStatsHttpPort=8000
useHostNameAsBookieID=true
# how long to wait, in seconds, before starting autorecovery of a lost bookie.
# TODO: set to 0 after opsRequest for rollingUpdate supports hooks
lostBookieRecoveryDelay=300

zkServers={{ .ZOOKEEPER_SERVERS }}
3 changes: 3 additions & 0 deletions addons/pulsar/config/2.11.2/broker-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ brokerDeleteInactiveTopicsEnabled=false
# configurations in KoP because of KIP-679.
kafkaTransactionCoordinatorEnabled=true
brokerDeduplicationEnabled=true

zookeeperServers={{ .ZOOKEEPER_SERVERS }}
configurationStoreServers={{ .ZOOKEEPER_SERVERS }}
4 changes: 3 additions & 1 deletion addons/pulsar/config/2.11.2/proxy-config.tpl
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
statusFilePath=/pulsar/status
maxMessageSize=5242880
maxMessageSize=5242880

metadataStoreUrl={{ .ZOOKEEPER_SERVERS }}
2 changes: 2 additions & 0 deletions addons/pulsar/config/2.11.2/zookeeper-config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dataDir=/pulsar/data/zookeeper
serverCnxnFactory=org.apache.zookeeper.server.NIOServerCnxnFactory
2 changes: 2 additions & 0 deletions addons/pulsar/config/3.0.2/bookies-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ zkLedgersRootPath=/ledgers
{{- end }}
{{- end }}
autoRecoveryDaemonEnabled={{ $autoRecoveryDaemonEnabled }}

zkServers={{ .ZOOKEEPER_SERVERS }}
9 changes: 9 additions & 0 deletions addons/pulsar/config/3.0.2/bookies-recovery-config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
httpServerEnabled=true
httpServerPort=8000
prometheusStatsHttpPort=8000
useHostNameAsBookieID=true
# how long to wait, in seconds, before starting autorecovery of a lost bookie.
# TODO: set to 0 after opsRequest for rollingUpdate supports hooks
lostBookieRecoveryDelay=300

zkServers={{ .ZOOKEEPER_SERVERS }}
3 changes: 3 additions & 0 deletions addons/pulsar/config/3.0.2/broker-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ brokerDeleteInactiveTopicsEnabled=false
# configurations in KoP because of KIP-679.
kafkaTransactionCoordinatorEnabled=true
brokerDeduplicationEnabled=true

zookeeperServers={{ .ZOOKEEPER_SERVERS }}
configurationStoreServers={{ .ZOOKEEPER_SERVERS }}
4 changes: 3 additions & 1 deletion addons/pulsar/config/3.0.2/proxy-config.tpl
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
statusFilePath=/pulsar/status
maxMessageSize=5242880
maxMessageSize=5242880

metadataStoreUrl={{ .ZOOKEEPER_SERVERS }}
2 changes: 2 additions & 0 deletions addons/pulsar/config/3.0.2/zookeeper-config.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dataDir=/pulsar/data/zookeeper
serverCnxnFactory=org.apache.zookeeper.server.NIOServerCnxnFactory
35 changes: 0 additions & 35 deletions addons/pulsar/config/bookies-env.tpl

This file was deleted.

48 changes: 0 additions & 48 deletions addons/pulsar/config/bookies-recovery-env.tpl

This file was deleted.

35 changes: 0 additions & 35 deletions addons/pulsar/config/broker-env.tpl

This file was deleted.

34 changes: 0 additions & 34 deletions addons/pulsar/config/proxy-env.tpl

This file was deleted.

9 changes: 9 additions & 0 deletions addons/pulsar/config/pulsar-env-optimize.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## for proxy or broker
export PULSAR_EXTRA_OPTS="-Dpulsar.allocator.exit_on_oom=true -Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024 -Dnetworkaddress.cache.ttl=60 -XX:ActiveProcessorCount=1 -XshowSettings:vm -Ddepth=64"
export PULSAR_GC="-XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB"
{{- $maxDirectMemorySize := "" }}
{{- $phyMemory := getContainerMemory ( index $.podSpec.containers 0 ) }}
{{- if gt $phyMemory 0 }}
{{- $maxDirectMemorySize = printf "-XX:MaxDirectMemorySize=%dm" (mul (div $phyMemory ( mul 1024 1024 10)) 6) }}
{{- end }}
export PULSAR_MEM="-XX:MinRAMPercentage=30 -XX:MaxRAMPercentage=30 {{ $maxDirectMemorySize }}"
8 changes: 8 additions & 0 deletions addons/pulsar/config/pulsar-env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export PULSAR_GC="-XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=4 -XX:ConcGCThreads=4 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem -XshowSettings:vm -Ddepth=64"
{{- $maxDirectMemorySize := "" }}
{{- $phyMemory := getContainerMemory ( index $.podSpec.containers 0 ) }}
{{- if gt $phyMemory 0 }}
{{- $phyMemoryMB := div $phyMemory ( mul 1024 1024 ) }}
{{- $maxDirectMemorySize = printf "-XX:MaxDirectMemorySize=%dm" (div ( mul $phyMemoryMB 3 ) 4 ) }}
{{- end }}
export PULSAR_MEM="-XX:MinRAMPercentage=25 -XX:MaxRAMPercentage=50 {{ $maxDirectMemorySize }}"
7 changes: 2 additions & 5 deletions addons/pulsar/config/zookeeper-env.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
PULSAR_GC: -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -Dcom.sun.management.jmxremote -Djute.maxbuffer=10485760 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:+DisableExplicitGC -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem -XX:ActiveProcessorCount=1
PULSAR_MEM: -XX:MinRAMPercentage=40 -XX:MaxRAMPercentage=60
PULSAR_PREFIX_serverCnxnFactory: org.apache.zookeeper.server.NIOServerCnxnFactory
dataDir: /pulsar/data/zookeeper
serverCnxnFactory: org.apache.zookeeper.server.NIOServerCnxnFactory
export PULSAR_GC="-XX:+UseG1GC -XX:MaxGCPauseMillis=10 -Dcom.sun.management.jmxremote -Djute.maxbuffer=10485760 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:+DisableExplicitGC -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem -XX:ActiveProcessorCount=1"
export PULSAR_MEM="-XX:MinRAMPercentage=40 -XX:MaxRAMPercentage=60"
8 changes: 4 additions & 4 deletions addons/pulsar/scripts-ut-spec/init_bookies_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Describe "Pulsar Init Bookies Bash Script Tests"

Describe "init_bookies()"
It "initializes bookies"
export zkServers="zookeeper.example.com:2181"
export ZOOKEEPER_SERVERS="zookeeper.example.com:2181"

wait_for_zookeeper() {
echo "wait_for_zookeeper called"
Expand All @@ -114,11 +114,11 @@ Describe "Pulsar Init Bookies Bash Script Tests"
The output should include "init_bookkeeper_cluster called"
End

It "exits with status 1 when zkServers environment variable is not set"
unset zkServers
It "exits with status 1 when ZOOKEEPER_SERVERS environment variable is not set"
unset ZOOKEEPER_SERVERS

When run init_bookies
The output should include "Error: zkServers environment variable is not set, Please set the zkServers environment variable and try again."
The output should include "Error: ZOOKEEPER_SERVERS environment variable is not set, Please set the ZOOKEEPER_SERVERS environment variable and try again."
The status should be failure
End
End
Expand Down
20 changes: 20 additions & 0 deletions addons/pulsar/scripts/check-bookies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ wait_for_bookkeeper() {
echo "Bookkeeper started successfully"
}

merge_bookkeeper_config() {
local src_config="conf/bookkeeper.conf"
local dest_config="/opt/pulsar/conf/bookkeeper.conf"

echo "Merging Pulsar configuration files:"
echo " - Source: $src_config"
echo " - Destination: $dest_config"
python3 /kb-scripts/merge_pulsar_config.py "$src_config" "$dest_config"
}

load_env_file() {
local pulsar_env_config="/opt/pulsar/conf/pulsar.env"

if [ -f "${pulsar_env_config}" ];then
source ${pulsar_env_config}
fi
}

set_tcp_keepalive() {
local keepalive_time=1
local keepalive_intvl=11
Expand All @@ -46,6 +64,8 @@ set_tcp_keepalive() {
${__SOURCED__:+false} : || return 0

# main
load_env_file
merge_bookkeeper_config
apply_config_from_env
wait_for_bookkeeper
set_tcp_keepalive
13 changes: 11 additions & 2 deletions addons/pulsar/scripts/init-bookies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ init_bookkeeper_cluster() {
fi
}

load_env_file() {
local pulsar_env_config="/opt/pulsar/conf/pulsar.env"

if [ -f "${pulsar_env_config}" ];then
source ${pulsar_env_config}
fi
}

init_bookies() {
if [[ -z "$zkServers" ]]; then
if [[ -z "$ZOOKEEPER_SERVERS" ]]; then
echo "Error: zkServers environment variable is not set, Please set the zkServers environment variable and try again."
exit 1
fi

wait_for_zookeeper "$zkServers"
wait_for_zookeeper "$ZOOKEEPER_SERVERS"
merge_bookkeeper_config
apply_config_from_env
load_env_file
init_bookkeeper_cluster
}

Expand Down
Loading
Loading