Skip to content

Commit e348e97

Browse files
Fix backend config error 0 17 (#771)
* Fix the error that backendconfig doesn't work when no env specified * fix ci * fix ci
1 parent 9b557b8 commit e348e97

File tree

33 files changed

+757
-137
lines changed

33 files changed

+757
-137
lines changed

.ci/clusters/global_backend_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ kind: BackendConfig
33
metadata:
44
name: global-backend-config
55
spec:
6+
autoUpdate: true
67
env:
78
global1: globalvalue1
89
shared1: fromglobal
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: global-backend-config
5+
spec:
6+
autoUpdate: true
7+
pod:
8+
liveness:
9+
initialDelaySeconds: 10
10+
periodSeconds: 30

.ci/helm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ function ci::verify_log_topic_with_auth() {
598598
}
599599

600600
function ci::verify_env() {
601-
pod="$1-function-0"
601+
pod=$1
602602
key=$2
603603
expect=$3
604604
result=$(kubectl exec -n ${NAMESPACE} ${pod} -- env | grep "${key}")
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: Source
3+
metadata:
4+
name: test-datagen-source
5+
spec:
6+
className: org.apache.pulsar.io.datagenerator.DataGeneratorSource
7+
clusterName: test-pulsar
8+
forwardSourceMessageProperty: true
9+
image: docker.io/streamnative/pulsar-io-data-generator:3.2.2.1
10+
java:
11+
extraDependenciesDir: /pulsar/lib
12+
jar: connectors/pulsar-io-data-generator-3.2.2.1.nar
13+
minReplicas: 1
14+
name: test-datagen-source
15+
namespace: default
16+
output:
17+
producerConf: {}
18+
topic: public/default/test-datagen-source
19+
typeClassName: org.apache.pulsar.io.datagenerator.Person
20+
processingGuarantee: atleast_once
21+
pulsar:
22+
authConfig:
23+
oauth2Config:
24+
audience: urn:sn:pulsar:sndev:test
25+
issuerUrl: https://auth.sncloud-stg.dev/
26+
keySecretName: sn-platform-oauth2-private-key
27+
keySecretKey: auth.json
28+
pulsarConfig: test-source
29+
replicas: 1
30+
resources:
31+
limits:
32+
cpu: "0.2"
33+
memory: 1.1G
34+
requests:
35+
cpu: "0.1"
36+
memory: 1G
37+
sourceConfig:
38+
sleepBetweenMessages: "5000"
39+
tenant: public
40+
---
41+
apiVersion: v1
42+
kind: ConfigMap
43+
metadata:
44+
name: test-source
45+
data:
46+
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
47+
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: backend-config
5+
namespace: default
6+
spec:
7+
env:
8+
namespaced1: namespacedvalue1
9+
shared1: fromnamespace
10+
podenv: backendconfigvalue
11+
pod:
12+
liveness:
13+
initialDelaySeconds: 30
14+
periodSeconds: 10
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
set -e
22+
23+
E2E_DIR=$(dirname "$0")
24+
BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd)
25+
PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"}
26+
PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"}
27+
E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"}
28+
29+
source "${BASE_DIR}"/.ci/helm.sh
30+
31+
if [ ! "$KUBECONFIG" ]; then
32+
export KUBECONFIG=${E2E_KUBECONFIG}
33+
fi
34+
35+
manifests_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/global-and-namespaced-config-without-auto-update/manifests.yaml
36+
mesh_config_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/global-and-namespaced-config-without-auto-update/mesh-config.yaml
37+
global_mesh_config_file="${BASE_DIR}"/.ci/clusters/global_backend_config.yaml
38+
39+
kubectl apply -f "${mesh_config_file}" > /dev/null 2>&1
40+
kubectl apply -f "${manifests_file}" > /dev/null 2>&1
41+
42+
verify_fm_result=$(ci::verify_function_mesh test-datagen-source 2>&1)
43+
if [ $? -ne 0 ]; then
44+
echo "$verify_fm_result"
45+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
46+
exit 1
47+
fi
48+
49+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" global1 global1=globalvalue1 2>&1)
50+
if [ $? -ne 0 ]; then
51+
echo "$verify_env_result"
52+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
53+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
54+
exit 1
55+
fi
56+
57+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 namespaced1=namespacedvalue1 2>&1)
58+
if [ $? -ne 0 ]; then
59+
echo "$verify_env_result"
60+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
61+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
62+
exit 1
63+
fi
64+
65+
# if global and namespaced config has same key, the value from namespace should be used
66+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1)
67+
if [ $? -ne 0 ]; then
68+
echo "$verify_env_result"
69+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
70+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
71+
exit 1
72+
fi
73+
74+
# verify liveness config
75+
verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1)
76+
if [ $? -ne 0 ]; then
77+
echo "$verify_liveness_result"
78+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
79+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
80+
exit 1
81+
fi
82+
83+
# update the namespaced config, it should not trigger the reconcile since the autoUpdate is false
84+
kubectl patch BackendConfig backend-config --type='json' -p='[{"op": "replace", "path": "/spec/env/shared1", "value": "newvalue"}]' > /dev/null 2>&1
85+
sleep 30
86+
87+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1)
88+
if [ $? -ne 0 ]; then
89+
echo "$verify_env_result"
90+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
91+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
92+
exit 1
93+
fi
94+
95+
# delete the namespaced config, the source should not be reconciled since the autoUpdate is false
96+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
97+
sleep 30
98+
99+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 namespaced1=namespacedvalue1 2>&1)
100+
if [ $? -ne 0 ]; then
101+
echo "$verify_env_result"
102+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
103+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
104+
exit 1
105+
fi
106+
107+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1)
108+
if [ $? -ne 0 ]; then
109+
echo "$verify_env_result"
110+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
111+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
112+
exit 1
113+
fi
114+
115+
verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1)
116+
if [ $? -ne 0 ]; then
117+
echo "$verify_liveness_result"
118+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
119+
exit 1
120+
fi
121+
122+
# delete the global config, the source should be reconciled since the autoUpdate is true in the global config
123+
kubectl delete -f "${global_mesh_config_file}" -n $FUNCTION_MESH_NAMESPACE > /dev/null 2>&1 || true
124+
sleep 30
125+
126+
verify_fm_result=$(ci::verify_function_mesh test-datagen-source 2>&1)
127+
if [ $? -ne 0 ]; then
128+
echo "$verify_fm_result"
129+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
130+
exit 1
131+
fi
132+
133+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" global1 "" 2>&1)
134+
if [ $? -ne 0 ]; then
135+
echo "$verify_env_result"
136+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
137+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
138+
exit 1
139+
fi
140+
141+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 "" 2>&1)
142+
if [ $? -ne 0 ]; then
143+
echo "$verify_env_result"
144+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
145+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
146+
exit 1
147+
fi
148+
149+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 "" 2>&1)
150+
if [ $? -ne 0 ]; then
151+
echo "$verify_env_result"
152+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
153+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
154+
exit 1
155+
fi
156+
157+
# it should use liveness config from namespaced config
158+
verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 "" 2>&1)
159+
if [ $? -eq 0 ]; then
160+
echo "e2e-test: ok" | yq eval -
161+
else
162+
echo "$verify_liveness_result"
163+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
164+
exit 1
165+
fi
166+
167+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: Sink
3+
metadata:
4+
name: test-datagen-sink
5+
spec:
6+
autoAck: true
7+
className: org.apache.pulsar.io.datagenerator.DataGeneratorPrintSink
8+
clusterName: test-pulsar
9+
image: docker.io/streamnative/pulsar-io-data-generator:3.2.2.1
10+
input:
11+
sourceSpecs:
12+
public/default/datagen:
13+
receiverQueueSize: 1000
14+
topics:
15+
- public/default/datagen
16+
typeClassName: org.apache.pulsar.io.datagenerator.Person
17+
java:
18+
extraDependenciesDir: /pulsar/lib
19+
jar: connectors/pulsar-io-data-generator-3.2.2.1.nar
20+
minReplicas: 1
21+
namespace: default
22+
processingGuarantee: atleast_once
23+
sinkConfig: {}
24+
pulsar:
25+
authConfig:
26+
oauth2Config:
27+
audience: urn:sn:pulsar:sndev:test
28+
issuerUrl: https://auth.sncloud-stg.dev/
29+
keySecretName: sn-platform-oauth2-private-key
30+
keySecretKey: auth.json
31+
pulsarConfig: test-sink
32+
replicas: 1
33+
resources:
34+
limits:
35+
cpu: "0.2"
36+
memory: 1.1G
37+
requests:
38+
cpu: "0.1"
39+
memory: 1G
40+
subscriptionName: mysub
41+
subscriptionPosition: latest
42+
tenant: public
43+
---
44+
apiVersion: v1
45+
kind: ConfigMap
46+
metadata:
47+
name: test-sink
48+
data:
49+
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
50+
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: backend-config
5+
namespace: kube-system
6+
spec:
7+
autoUpdate: true
8+
pod:
9+
liveness:
10+
initialDelaySeconds: 50
11+
periodSeconds: 60
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: backend-config
5+
namespace: default
6+
spec:
7+
autoUpdate: true
8+
pod:
9+
liveness:
10+
initialDelaySeconds: 30
11+
periodSeconds: 10

0 commit comments

Comments
 (0)