-
Notifications
You must be signed in to change notification settings - Fork 1k
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
discoveryserver: readiness probe shouldn't pass when permissions are incorrect #1583
Comments
ps the following helm test passes despite errors in the logs apiVersion: v1
kind: Pod
metadata:
name: "{{ include "spring-cloud-kubernetes-discoveryserver.fullname" . }}-test-connection"
labels:
{{- include "spring-cloud-kubernetes-discoveryserver.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget', '-qO', '-']. # for debug print the whole response to console
args: ['{{ include "spring-cloud-kubernetes-discoveryserver.fullname" . }}:{{ .Values.service.port }}/apps']
restartPolicy: Never again #1580 fixed this, but there should have been something that failed and maybe folks closer to the project can figure a fail-fast!
|
so I looked into this and basically the API doesn't use this pod data. It is grabbed just in case there is a consumer of What fails and makes the large error should be reconsidered. For example, if this binary has no consumers of the data, don't ask for the pod (and avoid the permissions or scary error if they aren't there). This seems better from both an experience and a security pov. cc @iocanel not because you intended this, but because some old version of a file in question has your author tag ;) p.s. hi again! @PostConstruct
private void postConstruct() {
LOG.debug(() -> "publishing InstanceRegisteredEvent");
InstanceRegisteredEvent<RegisteredEventSource> instanceRegisteredEvent = new InstanceRegisteredEvent<>(
new RegisteredEventSource("kubernetes", podUtils.isInsideKubernetes(), podUtils.currentPod().get()),
null);
this.applicationEventPublisher.publishEvent(instanceRegisteredEvent);
} |
hello and thank you for raising this issue, let's see if I can understand it completely. What you want is when you deploy discoveryserver, is to have a proper readiness probe in place. Let me make it may be even simpler, to see if we are on the same page:
Now, there are a couple of things here.
(this can be added to the documentation and that sample you recently worked on).
To me, this is indeed a bug, but one that can be fixed. @ryanjbaxter if you agree, please add the proper label and I will present a fix soon. |
So the issue is without the pod resource permissions when the instance registered event is fired we get the permissions issue? |
thanks for the analysis. I think there are a lot of projects who silently (like not log at WARN level) handle errors that don't affect functionality. If there's a way to make this error not visible I wouldn't notice. For now, the yaml adds the permission only needed to make this log warning go away. Any way to roll back that permission and also by default not have to do anything special to have a clean boot is positive! |
yep exactly this. several stack traces, but the actual data isn't used. |
I guess I am curious as to why we would publish an instance registered event when starting the discovery server, something to look at. anyways we should not be producing the error so I agree it’s something we should address |
I went down the rabbit hole on this, and there are consumes of this but only in tests. Maybe someone added it for a custom server 🤷 |
That is one problem, yes. We do not need such an event in case of discovery-server, so the first fix is to disable it from being produced. The second problem, is how we treat a "failure" in the health indicator, that is the actual bug that needs to be addressed. (I hope it will all make sense in the PR I am working on)
As said, this comes from a dependency that we use. Now, that dependency might be included in other source code, that in turn could have spring-cloud-commons in its classpath and that is when InstanceRegisteredEvent matters. I don't want to burden you with the details, but to make it simpler: this InstanceRegisteredEvent is needed, just not in discovery-server. |
another glitch you can see on this is that it is not using the bean for the api client, which means it isn't instrumented or configured. this leads to visibility gaps also. I really think this should be disabled by default as the benefit is too small. Something else can enable it and accept the problems it has. my 2p |
@wind57 I happened upon this type |
Describe the bug
something like #1580 should be detected by a readiness probe, but it wasn't.
subject to opinion, but I think one of ready or health or both should fail if permissions are wrong, as otherwise you need to look at logs to notice something is amok.
Sample
I used a helm chart by @andreasfritz which also doesn't add the required permission, yet the readiness probe seems to pass (correct if wrong)
The text was updated successfully, but these errors were encountered: