-
Notifications
You must be signed in to change notification settings - Fork 97
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
Changes on HTTPScaledObjects don't update routing table #605
Comments
@JorTurFer and @tomkerkhove, could I get some input here so I can start working on a fix for this issue? |
Hi, WDYT @tomkerkhove ? |
I think this is good that we do not support this, similarly to core where you can only have 1 scaledObject for a scale target. With regards to the proposed designs, I think watching the objects is only acceptable if it's done by the operator. If we'll start querying Kubernetes for it then it adds load we can avoid and flaky scenarios where the routing table is outdated because it didn't receive the message. What is the information is kept in the operator that the interceptor queries? |
The current implementation of the interceptor doesn't fetch data directly from the controller, the controller writes data to a ConfigMap and all interceptor instances watch that ConfigMap. The information contained on the ConfigMap is a list of all registered hosts and for each host we have their service name, port number, deployment name, namespace name, and target pending requests. That's used by the interceptor proxy to route requests properly. What I would like to do is to remove this indirection and grab the data directly from HTTPScaledObjects instead of relying on this ConfigMap containing a single big JSON. We can have a fourth option where the interceptors fetch the data from the controller, instead of using the K8s API. But I worry that in case something goes wrong with the controller, we won't be able to route traffic, causing an outage on services using the add-on. With the current implementation, when the controller is down, new changes don't take effect but the interceptors are able to use existing routes until the problem is addressed. |
Some extra information here. I was taking a look at the RBAC configuration for the add-on and noticed that both the scaler and interceptor are watching K8s resources and it's not only the routing table ConfigMap. Both watch Deployments and the scaler also watches Endpoints. Right now, all three components share the same ServiceAccount with way too much access. We may decide to change that as well and grab all the information from the controller or rely on DNS information for the readiness data, but I don't know if that's a good idea. I believe it's okay to watch K8s resources as long as you have well-scoped read-only access. |
This should be fixed with #612 so let's keep that out-of-scope here. I am fine with going the HTTPScaledObject route; let's do that as @JorTurFer agreed on it as well - Thanks for the proposals! |
+1000
I prefer this way indeed. Configuring the interceptors based on HTTPScaledObjects we will be always up to date, not have sync issues because new interceptors will read all the HTTPScaledObject and configure themselves. |
Perfect! I'll start working on working this on Monday. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
Don’t close |
Report
The current implementation of the HTTP Add-on allows users to modify all attributes of the HTTPScaledObject, but the internal routing table implementation also assumes some of these fields are immutable. Modifying these fields causes unexpected behaviour, the routing table is never updated but the K8s objects are. I experienced that after changing the value of
.spec.targetPendingRequests
and having the scaler not behave as expected.Expected Behavior
Either
.spec.scaleTargetRef
and.spec.targetPendingRequests
should be immutable, or we should update the routing table when these fields get updated on the K8s object.Actual Behavior
Changes to
.spec.scaleTargetRef
and.spec.targetPendingRequests
are successfully applied to K8s, but the internal routing table is not updated to reflect these new values.Steps to Reproduce the Problem
.spec.targetPendingRequests
set to 2.spec.targetPendingRequests
set to 1TargetPendingRequests
is still 2, not 1 (http://keda-add-ons-http-interceptor-admin.svc.cluster.local:9090/routing_table)Logs from KEDA HTTP operator
What version of the KEDA HTTP Add-on are you running?
0.4.0
Kubernetes Version
1.24
Platform
Microsoft Azure
Anything else?
I think the current behaviour is related to our lack of support for multiple HTTPScaledObject to have the same host. This implementation prevents a new HTTPScaledObject that uses the host of an existing HTTPScaledObject to override the configuration of the latter. This would also be a security issue, as users that have access to some namespace on a cluster could after resources on other namespaces.
I took a look at the implementation details of the routing table and propose we move from having it stored in a ConfigMap to compute its state based on the HTTPScaledObject present on the cluster and have the built routing table cached in-memory, having it refreshed periodically. Another option is to keep the current ConfigMap-based implementation, but it has some drawbacks that I'll list bellow.
Proposal 1 - HTTPScaledObject-based Routing Table
Rework the routing table implementation by relying on HTTPScaledObjects. Interceptors would compute the routing table based on these objects and cache the result in-memory. The cache would be updated based on K8s events and a full reconciliation performed periodically.
Benefits
Drawbacks
Proposal 2 - ConfigMap-based Routing Table
Fix the current routing table implementation based on ConfigMap to have it updated when HTTPScaledObjects change.
Benefits
Drawbacks
Proposal 3 - Make fields immutable
Update the CRD to make immutable the fields the routing table rely on.
Benefits
Drawbacks
The text was updated successfully, but these errors were encountered: