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: fix pulsar addon typo #1115

Merged
merged 5 commits into from
Oct 25, 2024
Merged
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
16 changes: 2 additions & 14 deletions addons/pulsar/scripts-ut-spec/init_broker_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ Describe "Pulsar Init Broker Bash Script Tests"
return 0
}

quit_script() {
return 0
}

When run init_broker
The status should be success
End
Expand All @@ -158,10 +154,6 @@ Describe "Pulsar Init Broker Bash Script Tests"
return 0
}

quit_script() {
return 0
}

python3() {
return 0
}
Expand All @@ -172,7 +164,7 @@ Describe "Pulsar Init Broker Bash Script Tests"

When run init_broker
The status should be success
The output should include "Cluster already initialized"
The output should include "Waiting for cluster initialize ready"
End

It "skips initialization if cluster is already initialized"
Expand All @@ -198,12 +190,8 @@ Describe "Pulsar Init Broker Bash Script Tests"
return 0
}

quit_script() {
return 0
}

When run init_broker
The stdout should include "Initializing cluster metadata for cluster: my-cluster"
The stdout should include "Cluster already initialized"
The status should be success
End
End
Expand Down
9 changes: 2 additions & 7 deletions addons/pulsar/scripts/init-broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,14 @@ init_broker() {
local idx=${POD_NAME##*-}
if [ $idx -ne 0 ]; then
wait_for_cluster_metadata "$zookeeperServers" "$clusterName"
echo "Cluster already initialized" && quit_script
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to && exit 0 to keep the semantic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to && exit 0 to keep the semantic.

fixed done

echo "Waiting for cluster initialize ready." && exit 0
fi

if check_cluster_initialized "$zookeeperServers" "$clusterName"; then
echo "Cluster already initialized" && quit_script
echo "Cluster already initialized" && exit 0
fi

initialize_cluster_metadata "$clusterName" "$zookeeperServers" "$webServiceUrl" "$brokerServiceUrl"
quit_script
}

quit_script() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function still appears in the file (a few lines above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function still appears in the file (a few lines above).

fixed done

(curl -sf -XPOST http://127.0.0.1:15020/quitquitquit || true) && exit 0
}

# This is magic for shellspec ut framework.
Expand Down
1 change: 1 addition & 0 deletions addons/pulsar/scripts/start-bookies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ start_bookies() {
fi

OPTS="${OPTS} -Dlog4j2.formatMsgNoLookups=true"
export OPTS
exec bin/pulsar bookie
}

Expand Down
50 changes: 17 additions & 33 deletions addons/pulsar/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ Common annotations
helm.sh/resource-policy: keep
{{- end }}

{{/*
Create full image name
*/}}
{{- define "pulsar.imageFullName" -}}
{{- printf "%s/%s:%s" ( .image.registry | default .root.Values.image.registry ) ( .image.repository | default .root.Values.image.repository ) ( .image.tag | default .root.Values.image.tag | default .root.Chart.AppVersion ) -}}
{{- end -}}

{{/*
Create image pull policy
*/}}
{{- define "pulsar.imagePullPolicy" -}}
{{- printf "%s" ( .image.pullPolicy | default .root.Values.image.pullPolicy | default "IfNotPresent" ) -}}
{{- end -}}

{{/*
Generate scripts configmap
*/}}
Expand All @@ -82,30 +68,21 @@ Generate scripts configmap
{{- end }}

{{/*
Generate major version of cluster
*/}}
{{- define "pulsar.major.version" -}}
{{- $version := default .Chart.AppVersion .Values.clusterVersionOverride -}}
{{- $majorVersion := (split "." $version)._0 -}}
{{- printf "%s" ($majorVersion)}}
{{- end }}

{{/*
Define pulsar bookies reovery component definition regex pattern
Define pulsar bookies recovery component definition regex pattern
*/}}
{{- define "pulsar.bkRecoveryCmpdRegexPattern" -}}
^pulsar-bookies-recovery-
{{- end -}}

{{/*
Define pulsar v3.X bookies reovery component definition name
Define pulsar v3.X bookies recovery component definition name
*/}}
{{- define "pulsar3.bkRecoveryCmpdName" -}}
pulsar-bookies-recovery-3-{{ .Chart.Version }}
{{- end -}}

{{/*
Define pulsar v2.X bookies reovery component definition name
Define pulsar v2.X bookies recovery component definition name
*/}}
{{- define "pulsar2.bkRecoveryCmpdName" -}}
pulsar-bookies-recovery-2-{{ .Chart.Version }}
Expand Down Expand Up @@ -154,7 +131,7 @@ Define pulsar v3.X broker component definition regex pattern
{{- end -}}

{{/*
Define pulsar v2.X bookies reovery component definition name
Define pulsar v2.X broker component definition name
*/}}
{{- define "pulsar2.brokerCmpdName" -}}
pulsar-broker-2-{{ .Chart.Version }}
Expand Down Expand Up @@ -182,7 +159,7 @@ pulsar-proxy-3-{{ .Chart.Version }}
{{- end -}}

{{/*
Define pulsar v2.X bookies reovery component definition name
Define pulsar v2.X proxy component definition name
*/}}
{{- define "pulsar2.proxyCmpdName" -}}
pulsar-proxy-2-{{ .Chart.Version }}
Expand Down Expand Up @@ -266,28 +243,28 @@ pulsar-env-constraints
{{- end -}}

{{/*
Define pulsar v3.X bookies recovery config tpl name
Define pulsar v3.X bookies config tpl name
*/}}
{{- define "pulsar3.bookiesConfigTplName" -}}
pulsar3-bookies-config-tpl
{{- end -}}

{{/*
Define pulsar v2.X bookies recovery config tpl name
Define pulsar v2.X bookies config tpl name
*/}}
{{- define "pulsar2.bookiesConfigTplName" -}}
pulsar2-bookies-config-tpl
{{- end -}}

{{/*
Define pulsar v3.X bookies recovery config constraint name
Define pulsar v3.X bookies config constraint name
*/}}
{{- define "pulsar3.bookiesConfigConstraintName" -}}
pulsar3-bookies-config-constraint
{{- end -}}

{{/*
Define pulsar v2.X bookies recovery config constraint name
Define pulsar v2.X bookies config constraint name
*/}}
{{- define "pulsar2.bookiesConfigConstraintName" -}}
pulsar2-bookies-config-constraint
Expand Down Expand Up @@ -403,4 +380,11 @@ Define pulsar v2.X zookeeper image
*/}}
{{- define "pulsar2.zookeeperImage" -}}
{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v2_11_2.zookeeper.tag }}
{{- end }}
{{- end }}

{{/*
Define pulsar tools image
*/}}
{{- define "pulsar.toolsImage" -}}
{{- printf "%s/%s:%s" ( .Values.image.registry | default "docker.io" ) ( .Values.image.repository ) ( .Values.images.pulsarTools.tag ) -}}
{{- end -}}
10 changes: 4 additions & 6 deletions addons/pulsar/templates/configconstraints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
command:
- "update-dynamic-config.sh"
scriptConfig:
scriptConfigMapRef: pulsar-tools-script
scriptConfigMapRef: {{ include "pulsar.toolsScriptsTplName" . }}
namespace: {{ .Release.Namespace }}
toolsSetup:
mountPoint: /kb/tools
Expand All @@ -64,8 +64,7 @@ spec:
- cp
- /bin/pulsar-admin
- /kb/tools/pulsar-admin
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.pulsarTools "root" .) }}"
# imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.pulsarTools "root" .) }}"
image: {{ include "pulsar.toolsImage" . }}
- name: init-pulsar-client-config
command:
- "$(TOOLS_SCRIPTS_PATH)/install-pulsar-client-config.sh"
Expand Down Expand Up @@ -112,7 +111,7 @@ spec:
command:
- "update-dynamic-config.sh"
scriptConfig:
scriptConfigMapRef: pulsar-tools-script
scriptConfigMapRef: {{ include "pulsar.toolsScriptsTplName" . }}
namespace: {{ .Release.Namespace }}
toolsSetup:
mountPoint: /kb/tools
Expand All @@ -122,8 +121,7 @@ spec:
- cp
- /bin/pulsar-admin
- /kb/tools/pulsar-admin
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.pulsarTools "root" .) }}"
# imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.pulsarTools "root" .) }}"
image: {{ include "pulsar.toolsImage" . }}
- name: init-pulsar-client-config
command:
- "$(TOOLS_SCRIPTS_PATH)/install-pulsar-client-config.sh"
Expand Down
Loading