Skip to content

Commit 10135da

Browse files
committed
debug stale webhook config map
1 parent f698e61 commit 10135da

File tree

5 files changed

+141
-114
lines changed

5 files changed

+141
-114
lines changed

.golangci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ linters:
182182
- legacy
183183
- std-error-handling
184184
rules:
185-
- linters:
186-
- staticcheck
187-
text: corev1.Endpoint.* is deprecated
185+
# - linters:
186+
# - staticcheck
187+
# text: corev1.Endpoint.* is deprecated
188188
- linters:
189189
- staticcheck
190190
text: NewSimpleClientset is deprecated

test/e2e-tests.sh

Lines changed: 103 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -67,106 +67,109 @@ if (( SHORT )); then
6767
GO_TEST_FLAGS+=("-short")
6868
fi
6969

70-
go_test_e2e -timeout=50m \
71-
"${GO_TEST_FLAGS[@]}" \
72-
./test/conformance/api/... \
73-
./test/conformance/runtime/... \
74-
./test/e2e \
75-
"${E2E_TEST_FLAGS[@]}" || failed=1
76-
77-
toggle_feature tag-header-based-routing Enabled
78-
go_test_e2e -timeout=2m ./test/e2e/tagheader "${E2E_TEST_FLAGS[@]}" || failed=1
79-
toggle_feature tag-header-based-routing Disabled
80-
81-
toggle_feature allow-zero-initial-scale true config-autoscaler || fail_test
82-
go_test_e2e -timeout=2m ./test/e2e/initscale "${E2E_TEST_FLAGS[@]}" || failed=1
83-
toggle_feature allow-zero-initial-scale false config-autoscaler || fail_test
84-
85-
go_test_e2e -timeout=2m ./test/e2e/domainmapping "${E2E_TEST_FLAGS[@]}" || failed=1
86-
87-
toggle_feature cluster-local-domain-tls enabled config-network || fail_test
88-
go_test_e2e -timeout=2m ./test/e2e/clusterlocaldomaintls "${E2E_TEST_FLAGS[@]}" || failed=1
89-
toggle_feature cluster-local-domain-tls disabled config-network || fail_test
90-
91-
toggle_feature system-internal-tls enabled config-network || fail_test
92-
toggle_feature "logging.enable-request-log" true config-observability || fail_test
93-
toggle_feature "logging.request-log-template" "TLS: {{.Request.TLS}}" config-observability || fail_test
94-
# with current implementation, Activator must be restarted when configuring system-internal-tls. See https://github.com/knative/serving/issues/13754
95-
restart_pod "${SYSTEM_NAMESPACE}" "app=activator"
96-
97-
# we need to restart the pod in order to start the net-certmanager-controller
98-
if (( ! HTTPS )); then
99-
restart_pod "${SYSTEM_NAMESPACE}" "app=controller"
100-
fi
101-
go_test_e2e -timeout=3m ./test/e2e/systeminternaltls "${E2E_TEST_FLAGS[@]}" || failed=1
102-
toggle_feature system-internal-tls disabled config-network || fail_test
103-
toggle_feature "logging.enable-request-log" false config-observability || fail_test
104-
toggle_feature "logging.request-log-template" '' config-observability || fail_test
105-
# with the current implementation, Activator is always in the request path, and needs to be restarted after configuring system-internal-tls
106-
restart_pod "${SYSTEM_NAMESPACE}" "app=activator"
107-
108-
# we need to restart the pod to stop the net-certmanager-controller
109-
if (( ! HTTPS )); then
110-
restart_pod "${SYSTEM_NAMESPACE}" "app=controller"
111-
kubectl get leases -n "${SYSTEM_NAMESPACE}" -o json | jq -r '.items[] | select(.metadata.name | test("controller.knative.dev.serving.pkg.reconciler.certificate.reconciler")).metadata.name' | xargs kubectl delete lease -n "${SYSTEM_NAMESPACE}"
112-
fi
113-
114-
kubectl get cm "config-gc" -n "${SYSTEM_NAMESPACE}" -o yaml > "${TMP_DIR}"/config-gc.yaml
115-
add_trap "kubectl replace cm 'config-gc' -n ${SYSTEM_NAMESPACE} -f ${TMP_DIR}/config-gc.yaml" SIGKILL SIGTERM SIGQUIT
116-
immediate_gc
117-
go_test_e2e -timeout=2m ./test/e2e/gc "${E2E_TEST_FLAGS[@]}" || failed=1
118-
kubectl replace cm "config-gc" -n "${SYSTEM_NAMESPACE}" -f "${TMP_DIR}"/config-gc.yaml
119-
120-
# Run scale tests.
121-
# Note that we use a very high -parallel because each ksvc is run as its own
122-
# sub-test. If this is not larger than the maximum scale tested then the test
123-
# simply cannot pass.
124-
# TODO - Renable once we get this reliably passing on GKE 1.21
125-
# go_test_e2e -timeout=20m -parallel=300 ./test/scale "${E2E_TEST_FLAGS[@]}" || failed=1
126-
127-
# Run HPA tests
128-
go_test_e2e -timeout=30m -tags=hpa ./test/e2e "${E2E_TEST_FLAGS[@]}" || failed=1
129-
130-
# Run initContainers tests with alpha enabled avoiding any issues with the testing options guard above
131-
# InitContainers test uses emptyDir.
132-
toggle_feature kubernetes.podspec-init-containers Enabled
133-
go_test_e2e -timeout=2m ./test/e2e/initcontainers "${E2E_TEST_FLAGS[@]}" || failed=1
134-
toggle_feature kubernetes.podspec-init-containers Disabled
135-
136-
# Run multi-container probe tests
137-
toggle_feature multi-container-probing Enabled
138-
go_test_e2e -timeout=2m ./test/e2e/multicontainerprobing "${E2E_TEST_FLAGS[@]}" || failed=1
139-
toggle_feature multi-container-probing Disabled
140-
141-
# RUN PVC tests with default storage class.
142-
toggle_feature kubernetes.podspec-persistent-volume-claim Enabled
143-
toggle_feature kubernetes.podspec-persistent-volume-write Enabled
144-
toggle_feature kubernetes.podspec-securitycontext Enabled
145-
go_test_e2e -timeout=5m ./test/e2e/pvc "${E2E_TEST_FLAGS[@]}" || failed=1
146-
toggle_feature kubernetes.podspec-securitycontext Disabled
147-
toggle_feature kubernetes.podspec-persistent-volume-write Disabled
148-
toggle_feature kubernetes.podspec-persistent-volume-claim Disabled
149-
150-
# RUN secure pod defaults test in a separate install.
151-
toggle_feature secure-pod-defaults Enabled
152-
go_test_e2e -timeout=3m ./test/e2e/securedefaults "${E2E_TEST_FLAGS[@]}" || failed=1
153-
toggle_feature secure-pod-defaults Disabled
154-
155-
# Run HA tests separately as they're stopping core Knative Serving pods.
156-
# Define short -spoofinterval to ensure frequent probing while stopping pods.
157-
go_test_e2e -timeout=30m -failfast -parallel=1 ./test/ha \
158-
"${E2E_TEST_FLAGS[@]}" \
159-
-replicas="${REPLICAS:-1}" \
160-
-buckets="${BUCKETS:-1}" \
161-
-spoofinterval="10ms" || failed=1
162-
163-
if (( HTTPS )); then
164-
kubectl delete -f "${E2E_YAML_DIR}"/test/config/externaldomaintls/certmanager/caissuer/ --ignore-not-found
165-
toggle_feature external-domain-tls Disabled config-network
166-
# we need to restart the pod to stop the net-certmanager-controller
167-
restart_pod "${SYSTEM_NAMESPACE}" "app=controller"
168-
kubectl get leases -n "${SYSTEM_NAMESPACE}" -o json | jq -r '.items[] | select(.metadata.name | test("controller.knative.dev.serving.pkg.reconciler.certificate.reconciler")).metadata.name' | xargs kubectl delete lease -n "${SYSTEM_NAMESPACE}"
169-
fi
70+
# go_test_e2e -timeout=50m \
71+
# "${GO_TEST_FLAGS[@]}" \
72+
# ./test/conformance/api/... \
73+
# ./test/conformance/runtime/... \
74+
# ./test/e2e \
75+
# "${E2E_TEST_FLAGS[@]}" || failed=1
76+
#
77+
# toggle_feature tag-header-based-routing Enabled
78+
# go_test_e2e -timeout=2m ./test/e2e/tagheader "${E2E_TEST_FLAGS[@]}" || failed=1
79+
# toggle_feature tag-header-based-routing Disabled
80+
81+
for i in {1..20}; do
82+
export TEST_RUN=$i
83+
toggle_feature allow-zero-initial-scale true config-autoscaler || fail_test
84+
go_test_e2e -timeout=2m ./test/e2e/initscale "${E2E_TEST_FLAGS[@]}" || failed=1
85+
toggle_feature allow-zero-initial-scale false config-autoscaler || fail_test
86+
done
87+
88+
# go_test_e2e -timeout=2m ./test/e2e/domainmapping "${E2E_TEST_FLAGS[@]}" || failed=1
89+
#
90+
# toggle_feature cluster-local-domain-tls enabled config-network || fail_test
91+
# go_test_e2e -timeout=2m ./test/e2e/clusterlocaldomaintls "${E2E_TEST_FLAGS[@]}" || failed=1
92+
# toggle_feature cluster-local-domain-tls disabled config-network || fail_test
93+
#
94+
# toggle_feature system-internal-tls enabled config-network || fail_test
95+
# toggle_feature "logging.enable-request-log" true config-observability || fail_test
96+
# toggle_feature "logging.request-log-template" "TLS: {{.Request.TLS}}" config-observability || fail_test
97+
# # with current implementation, Activator must be restarted when configuring system-internal-tls. See https://github.com/knative/serving/issues/13754
98+
# restart_pod "${SYSTEM_NAMESPACE}" "app=activator"
99+
#
100+
# # we need to restart the pod in order to start the net-certmanager-controller
101+
# if (( ! HTTPS )); then
102+
# restart_pod "${SYSTEM_NAMESPACE}" "app=controller"
103+
# fi
104+
# go_test_e2e -timeout=3m ./test/e2e/systeminternaltls "${E2E_TEST_FLAGS[@]}" || failed=1
105+
# toggle_feature system-internal-tls disabled config-network || fail_test
106+
# toggle_feature "logging.enable-request-log" false config-observability || fail_test
107+
# toggle_feature "logging.request-log-template" '' config-observability || fail_test
108+
# # with the current implementation, Activator is always in the request path, and needs to be restarted after configuring system-internal-tls
109+
# restart_pod "${SYSTEM_NAMESPACE}" "app=activator"
110+
#
111+
# # we need to restart the pod to stop the net-certmanager-controller
112+
# if (( ! HTTPS )); then
113+
# restart_pod "${SYSTEM_NAMESPACE}" "app=controller"
114+
# kubectl get leases -n "${SYSTEM_NAMESPACE}" -o json | jq -r '.items[] | select(.metadata.name | test("controller.knative.dev.serving.pkg.reconciler.certificate.reconciler")).metadata.name' | xargs kubectl delete lease -n "${SYSTEM_NAMESPACE}"
115+
# fi
116+
#
117+
# kubectl get cm "config-gc" -n "${SYSTEM_NAMESPACE}" -o yaml > "${TMP_DIR}"/config-gc.yaml
118+
# add_trap "kubectl replace cm 'config-gc' -n ${SYSTEM_NAMESPACE} -f ${TMP_DIR}/config-gc.yaml" SIGKILL SIGTERM SIGQUIT
119+
# immediate_gc
120+
# go_test_e2e -timeout=2m ./test/e2e/gc "${E2E_TEST_FLAGS[@]}" || failed=1
121+
# kubectl replace cm "config-gc" -n "${SYSTEM_NAMESPACE}" -f "${TMP_DIR}"/config-gc.yaml
122+
#
123+
# # Run scale tests.
124+
# # Note that we use a very high -parallel because each ksvc is run as its own
125+
# # sub-test. If this is not larger than the maximum scale tested then the test
126+
# # simply cannot pass.
127+
# # TODO - Renable once we get this reliably passing on GKE 1.21
128+
# # go_test_e2e -timeout=20m -parallel=300 ./test/scale "${E2E_TEST_FLAGS[@]}" || failed=1
129+
#
130+
# # Run HPA tests
131+
# go_test_e2e -timeout=30m -tags=hpa ./test/e2e "${E2E_TEST_FLAGS[@]}" || failed=1
132+
#
133+
# # Run initContainers tests with alpha enabled avoiding any issues with the testing options guard above
134+
# # InitContainers test uses emptyDir.
135+
# toggle_feature kubernetes.podspec-init-containers Enabled
136+
# go_test_e2e -timeout=2m ./test/e2e/initcontainers "${E2E_TEST_FLAGS[@]}" || failed=1
137+
# toggle_feature kubernetes.podspec-init-containers Disabled
138+
#
139+
# # Run multi-container probe tests
140+
# toggle_feature multi-container-probing Enabled
141+
# go_test_e2e -timeout=2m ./test/e2e/multicontainerprobing "${E2E_TEST_FLAGS[@]}" || failed=1
142+
# toggle_feature multi-container-probing Disabled
143+
#
144+
# # RUN PVC tests with default storage class.
145+
# toggle_feature kubernetes.podspec-persistent-volume-claim Enabled
146+
# toggle_feature kubernetes.podspec-persistent-volume-write Enabled
147+
# toggle_feature kubernetes.podspec-securitycontext Enabled
148+
# go_test_e2e -timeout=5m ./test/e2e/pvc "${E2E_TEST_FLAGS[@]}" || failed=1
149+
# toggle_feature kubernetes.podspec-securitycontext Disabled
150+
# toggle_feature kubernetes.podspec-persistent-volume-write Disabled
151+
# toggle_feature kubernetes.podspec-persistent-volume-claim Disabled
152+
#
153+
# # RUN secure pod defaults test in a separate install.
154+
# toggle_feature secure-pod-defaults Enabled
155+
# go_test_e2e -timeout=3m ./test/e2e/securedefaults "${E2E_TEST_FLAGS[@]}" || failed=1
156+
# toggle_feature secure-pod-defaults Disabled
157+
#
158+
# # Run HA tests separately as they're stopping core Knative Serving pods.
159+
# # Define short -spoofinterval to ensure frequent probing while stopping pods.
160+
# go_test_e2e -timeout=30m -failfast -parallel=1 ./test/ha \
161+
# "${E2E_TEST_FLAGS[@]}" \
162+
# -replicas="${REPLICAS:-1}" \
163+
# -buckets="${BUCKETS:-1}" \
164+
# -spoofinterval="10ms" || failed=1
165+
#
166+
# if (( HTTPS )); then
167+
# kubectl delete -f "${E2E_YAML_DIR}"/test/config/externaldomaintls/certmanager/caissuer/ --ignore-not-found
168+
# toggle_feature external-domain-tls Disabled config-network
169+
# # we need to restart the pod to stop the net-certmanager-controller
170+
# restart_pod "${SYSTEM_NAMESPACE}" "app=controller"
171+
# kubectl get leases -n "${SYSTEM_NAMESPACE}" -o json | jq -r '.items[] | select(.metadata.name | test("controller.knative.dev.serving.pkg.reconciler.certificate.reconciler")).metadata.name' | xargs kubectl delete lease -n "${SYSTEM_NAMESPACE}"
172+
# fi
170173

171174
(( failed )) && fail_test
172175

test/e2e/initscale/initial_scale_zero_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ limitations under the License.
2020
package initscale
2121

2222
import (
23+
"os"
2324
"testing"
2425

2526
"knative.dev/serving/test"
@@ -30,16 +31,18 @@ import (
3031
// the revision level. This test runs after the cluster wide flag allow-zero-initial-scale
3132
// is set to true.
3233
func TestInitScaleZero(t *testing.T) {
33-
t.Parallel()
34+
t.Run(os.Getenv("TEST_RUN"), func(t *testing.T) {
35+
t.Parallel()
3436

35-
clients := e2e.Setup(t)
36-
names := test.ResourceNames{
37-
Config: test.ObjectNameForTest(t),
38-
Image: test.HelloWorld,
39-
}
37+
clients := e2e.Setup(t)
38+
names := test.ResourceNames{
39+
Config: test.ObjectNameForTest(t),
40+
Image: test.HelloWorld,
41+
}
4042

41-
test.EnsureTearDown(t, clients, &names)
43+
test.EnsureTearDown(t, clients, &names)
4244

43-
t.Log("Creating a new Configuration with initial scale zero and verifying that no pods are created")
44-
e2e.CreateAndVerifyInitialScaleConfiguration(t, clients, names, 0)
45+
t.Log("Creating a new Configuration with initial scale zero and verifying that no pods are created")
46+
e2e.CreateAndVerifyInitialScaleConfiguration(t, clients, names, 0)
47+
})
4548
}

vendor/knative.dev/pkg/configmap/informer/informed_watcher.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222

23+
"go.uber.org/zap"
2324
corev1 "k8s.io/api/core/v1"
2425
"k8s.io/apimachinery/pkg/api/equality"
2526
k8serrors "k8s.io/apimachinery/pkg/api/errors"
@@ -99,6 +100,8 @@ type InformedWatcher struct {
99100
// of registering and notifying observers. This simplifies the
100101
// InformedWatcher to just setting up the Kubernetes informer.
101102
configmap.ManualWatcher
103+
104+
Logger *zap.SugaredLogger
102105
}
103106

104107
// Asserts that InformedWatcher implements Watcher.
@@ -218,15 +221,27 @@ func (i *InformedWatcher) checkObservedResourcesExist() error {
218221
func (i *InformedWatcher) addConfigMapEvent(obj interface{}) {
219222
configMap := obj.(*corev1.ConfigMap)
220223
i.OnChange(configMap)
224+
225+
if i.Logger != nil {
226+
i.Logger.Warnf("config map %q added: %#v", configMap)
227+
}
221228
}
222229

223230
func (i *InformedWatcher) updateConfigMapEvent(o, n interface{}) {
231+
configMap := n.(*corev1.ConfigMap)
232+
224233
// Ignore updates that are idempotent. We are seeing those
225234
// periodically.
226235
if equality.Semantic.DeepEqual(o, n) {
236+
if i.Logger != nil {
237+
i.Logger.Warnf("config map update ignored %s", configMap.Name)
238+
}
227239
return
228240
}
229-
configMap := n.(*corev1.ConfigMap)
241+
242+
if i.Logger != nil {
243+
i.Logger.Warnf("config map %q updated: %#v", configMap)
244+
}
230245
i.OnChange(configMap)
231246
}
232247

@@ -246,6 +261,10 @@ func (i *InformedWatcher) deleteConfigMapEvent(obj interface{}) {
246261
return
247262
}
248263

264+
if i.Logger != nil {
265+
i.Logger.Warnf("config map %q deleted: %#v", configMap)
266+
}
267+
249268
if def, ok := i.defaults[configMap.Name]; ok {
250269
i.OnChange(def)
251270
}

vendor/knative.dev/pkg/injection/sharedmain/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ func SetupConfigMapWatchOrDie(ctx context.Context, logger *zap.SugaredLogger) *c
479479
cmLabelReqs = append(cmLabelReqs, *req)
480480
}
481481
// TODO(mattmoor): This should itself take a context and be injection-based.
482-
return cminformer.NewInformedWatcher(kc, system.Namespace(), cmLabelReqs...)
482+
cmw := cminformer.NewInformedWatcher(kc, system.Namespace(), cmLabelReqs...)
483+
cmw.Logger = logger.Named("cmw")
484+
return cmw
483485
}
484486

485487
// WatchLoggingConfigOrDie establishes a watch of the logging config or dies by

0 commit comments

Comments
 (0)