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

Fix custom log config #765

Merged
merged 4 commits into from
Jun 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
apiVersion: compute.functionmesh.io/v1alpha1
kind: Function
metadata:
name: java-log-config-yaml
namespace: default
spec:
image: streamnative/pulsar-functions-java-sample:3.2.2.1
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
forwardSourceMessageProperty: true
maxPendingAsyncRequests: 1000
replicas: 1
maxReplicas: 5
logTopic: persistent://public/default/logging-function-logs
input:
topics:
- persistent://public/default/input-java-log-config-yaml-topic
typeClassName: java.lang.String
output:
topic: persistent://public/default/output-java-log-config-yaml-topic
typeClassName: java.lang.String
resources:
requests:
cpu: 50m
memory: 1G
limits:
cpu: "0.2"
memory: 1.1G
# each secret will be loaded ad an env variable from the `path` secret with the `key` in that secret in the name of `name`
secretsMap:
"name":
path: "test-secret"
key: "username"
"pwd":
path: "test-secret"
key: "password"
pulsar:
pulsarConfig: "test-pulsar"
tlsConfig:
enabled: false
allowInsecure: false
hostnameVerification: true
certSecretName: sn-platform-tls-broker
certSecretKey: ""
authConfig:
oauth2Config:
audience: urn:sn:pulsar:sndev:test
issuerUrl: https://auth.sncloud-stg.dev/
keySecretName: sn-platform-oauth2-private-key
keySecretKey: auth.json
java:
log:
javaLog4JConfigFileType: yaml
logConfig:
name: "java-log-config-cm"
key: "log.yaml"
jar: /pulsar/examples/api-examples.jar
# to be delete & use admission hook
clusterName: test
autoAck: true
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-pulsar
data:
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
---
apiVersion: v1
data:
username: YWRtaW4=
password: MWYyZDFlMmU2N2Rm
kind: Secret
metadata:
name: test-secret
type: Opaque
---
apiVersion: v1
kind: ConfigMap
metadata:
name: java-log-config-cm
data:
log.yaml: |
Configuration:
name: pulsar-functions-kubernetes-instance
monitorInterval: 30
Properties:
Property:
- name: pulsar.log.level
value: DEBUG
- name: bk.log.level
value: DEBUG

Appenders:
Console:
name: Console
target: SYSTEM_OUT

PatternLayout:
Pattern: "%d{ISO8601_OFFSET_DATE_TIME_HHMM} [%t] %-5level %logger{36} - %msg%n"


RollingRandomAccessFile:
name: RollingRandomAccessFile
fileName: "${sys:pulsar.function.log.dir}/${sys:pulsar.function.log.file}.log"
filePattern: "${sys:pulsar.function.log.dir}/${sys:pulsar.function.log.file}.%d{yyyy-MM-dd}-%i.log.gz"

PatternLayout:
Pattern: "%d{yyyy-MMM-dd HH:mm:ss a} [%t] %-5level %logger{36} - %msg%n"

Policies:
SizeBasedTriggeringPolicy:
size: "10MB"
DefaultRolloverStrategy:
max: 5

Loggers:
Root:
level: "${sys:pulsar.log.level}"
AppenderRef:
- ref: Console
level: "${sys:pulsar.log.level}"
- ref: RollingRandomAccessFile
Logger:
name: org.apache.pulsar.functions.runtime.shaded.org.apache.bookkeeper
level: "${sys:bk.log.level}"
additivity: false
AppenderRef:
- ref: Console
- ref: RollingRandomAccessFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#
# 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.
#

set -e

E2E_DIR=$(dirname "$0")
BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd)
PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"}
PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"}
E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"}

source "${BASE_DIR}"/.ci/helm.sh

if [ ! "$KUBECONFIG" ]; then
export KUBECONFIG=${E2E_KUBECONFIG}
fi

manifests_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/java-log-config-yaml/manifests.yaml

kubectl apply -f "${manifests_file}" > /dev/null 2>&1

verify_fm_result=$(ci::verify_function_mesh java-log-config-yaml 2>&1)
if [ $? -ne 0 ]; then
echo "$verify_fm_result"
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
exit 1
fi

verify_java_result=$(NAMESPACE=${PULSAR_NAMESPACE} CLUSTER=${PULSAR_RELEASE_NAME} ci::verify_exclamation_function_with_auth "persistent://public/default/input-java-log-config-yaml-topic" "persistent://public/default/output-java-log-config-yaml-topic" "test-message" "test-message!" 10 2>&1)
if [ $? -ne 0 ]; then
echo "$verify_java_result"
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
exit 1
fi

verify_log_config_result=$(kubectl logs -l compute.functionmesh.io/name=java-log-config-yaml --tail=-1 | grep "Got result: object:" 2>&1)
if [ $? -eq 0 ]; then
echo "e2e-test: ok" | yq eval -
else
echo "$verify_log_config_result"
fi
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
2 changes: 2 additions & 0 deletions .ci/tests/integration-oauth2/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ verify:
cases:
- query: timeout 5m bash .ci/tests/integration-oauth2/cases/java-function/verify.sh
expected: expected.data.yaml
- query: timeout 5m bash .ci/tests/integration-oauth2/cases/java-log-config-yaml/verify.sh
expected: expected.data.yaml
- query: timeout 5m bash .ci/tests/integration-oauth2/cases/java-download-function/verify.sh
expected: expected.data.yaml
- query: timeout 5m bash .ci/tests/integration-oauth2/cases/java-download-function-generic-auth/verify.sh
Expand Down
3 changes: 0 additions & 3 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,6 @@ func GenerateJavaLogConfigCommand(runtime *v1alpha1.JavaRuntime, agent v1alpha1.
}

func GenerateJavaLogConfigFileName(runtime *v1alpha1.JavaRuntime) string {
if runtime == nil || (runtime.Log != nil && runtime.Log.LogConfig != nil) {
return DefaultJavaLogConfigPath
}
configFileType := v1alpha1.XML
if runtime != nil && runtime.Log != nil && runtime.Log.JavaLog4JConfigFileType != nil {
configFileType = *runtime.Log.JavaLog4JConfigFileType
Expand Down
Loading