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

fix #5036: addressing the handling of non-connection errors #5047

Merged
merged 1 commit into from
Apr 27, 2023

Conversation

shawkins
Copy link
Contributor

Description

Addresses the additional concerns raised in #5036

This still needs to increase or allow setting the relevant limits in vertx and jetty.

cc @vietj

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@shawkins shawkins force-pushed the iss5036 branch 2 times, most recently from 78b8674 to d4824ca Compare April 17, 2023 13:30
@shawkins shawkins marked this pull request as ready for review April 17, 2023 13:31
@shawkins
Copy link
Contributor Author

Updated the max frame and message values for jetty and vertx using 2 MB - which roughly comes from accommodating the max size of a configmap https://kubernetes.io/docs/concepts/configuration/configmap/#motivation

The other option is to just set the values to unlimited - which seems to be what okhttp and jdk effectively do.

@vmuzikar
Copy link

@shawkins Thank you for providing the fix!

What are the implications of having unlimited frame size at the client side?

IMHO it'd make sense to align with other HTTP Clients (OkHttp) and set it to unlimited.

@shawkins
Copy link
Contributor Author

What are the implications of having unlimited frame size at the client side?

I don't believe there is much risk, it just provides a more friendly error than an OOM should an unexpectedly large resources be retrieved. Given that OkHttp was used for years without explicit limits and we didn't have any issues that I'm aware of, I'm okay with unlimited - but without additional input from @vietj and @manusa I thought I'd start off with at least what could be a "principled" bound.

@@ -39,6 +39,8 @@
extends StandardHttpClientBuilder<JettyHttpClient, JettyHttpClientFactory, JettyHttpClientBuilder> {

private static final int MAX_CONNECTIONS = Integer.MAX_VALUE;
// the max data in a config map is 1 MiB, so pad a little beyond that
private static final int MAX_WS_MESSAGE_SIZE = 1 << 21;
Copy link
Collaborator

Choose a reason for hiding this comment

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

1 MiB ? or 2 ?

Updated the max frame and message values for jetty and vertx using 2 MB - which roughly comes from accommodating the max size of a configmap https://kubernetes.io/docs/concepts/configuration/configmap/#motivation

Copy link
Member

Choose a reason for hiding this comment

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

2097152 bytes

Copy link
Contributor Author

@shawkins shawkins Apr 19, 2023

Choose a reason for hiding this comment

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

With some further searching using etcd as a keyword it looks like kubernetes sets the limit on the etcd server to 3 MB per request - kubernetes/kubernetes#105863
https://stackoverflow.com/questions/73549236/argo-and-kubernetes-request-entity-to-large-limit-is-3145728
Rather than the etcd default of 1.5 MB. So the 1 MB limit for a configmap is some other limit that is being enforced. After discussion I'll update this pr to be unlimited and note in the resolution the concern about protecting the client memory from attack, which in this case would imply the api server has been compromised in some way.

@shawkins
Copy link
Contributor Author

@manusa updated to umlimited, and logged the issue of configuration as a separate concern #5062

logger.debug("WebSocket error received", t);
manager.scheduleReconnect(state);
} else {
manager.close(new WatcherException("Could not process websocket message", t));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The downside to the approach is that we have not fully captured what the recoverable error types are, and we'll need to update the handling further. The alternative here is to log at an error level and still try to reconnect - we'll still potentially need to refine the handling further to avoid looping on something that is non-recoverable.

@sonarcloud
Copy link

sonarcloud bot commented Apr 27, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

54.5% 54.5% Coverage
0.0% 0.0% Duplication

@manusa manusa merged commit 4bd80e1 into fabric8io:master Apr 27, 2023
19 of 20 checks passed
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.

None yet

6 participants