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

unrecognized paths OOM fix #746

Merged
merged 4 commits into from
Jul 23, 2024
Merged

Conversation

Ian-Nara
Copy link
Contributor

No description provided.

@@ -25,5 +25,6 @@ public class Config extends com.uid2.shared.Const.Config {
public static final String GcpSecretVersionNameProp = "gcp_secret_version_name";
public static final String OptOutStatusApiEnabled = "optout_status_api_enabled";
public static final String OptOutStatusMaxRequestSize = "optout_status_max_request_size";
public static String MaxInvalidPaths = "logging_limit_max_invalid_paths_per_interval";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final?

@@ -113,7 +116,11 @@ public void handleMessage(Message message) {

EndpointStat endpointStat = new EndpointStat(endpoint, siteId, apiVersion, domain);

pathMap.merge(path, endpointStat, this::mergeEndpoint);
Set<String> endpoints = Endpoints.pathSet();
if(endpoints.contains(path) || pathMap.containsKey(path) || (pathMap.size() < this.maxInvalidPaths + endpoints.size() && messageItem.getApiContact() != null)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot going on in this if. Can we break it up a little to make it easier to read?

@@ -0,0 +1,59 @@
package com.uid2.operator.vertx;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can autogenerate this? I am worried people will forget to add new paths here. I think vertx has a list of all our paths in it after we add them all to the router

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, there's a getRoutes() method, hopefully we can use that rather than specifying the paths twice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been able to use the getRoutes method but it requires us to create and dispose of a verticle to retrieve the path definition. This is because the route definition has to be associated with a particular instance of the verticle (we deploy 8 of them but only 1 StatsCollectorVerticle and only 1 setupMetrics()) because we need to use the methods of the class, the auth middleware, etc in the route definition. They cant be defined statically. We also then have to work around the healthcheck as we never deploy the instance of the verticle we use to retrieve the routes in Main.java, and so never mark the HTTP server as started. This commit shows the setup with getRoutes() 988ea51

For this reason, I prefer the ENUM. The strings of the paths are only defined in one place, and since the routes are all defined together in createRoutesSetup() people will see the ENUM being used and know to define the string there. Similar to how we define our config keys in Const.Config.Java and people adhere to it and define their keys there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also the option to send the paths from the operator verticle instances to the StatsCollectorVerticle over the event bus, but I still prefer the ENUM to this.

@Ian-Nara Ian-Nara merged commit 55a99fb into main Jul 23, 2024
4 checks passed
@Ian-Nara Ian-Nara deleted the ian-UID2-3548-unrecognized-paths-fix branch July 23, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants