Skip to content

Conversation

metacosm
Copy link
Collaborator

If the exception occurred from an HTTP request, use that information
to populate information about the target resource.

Fixes #3491

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

@centos-ci
Copy link

Can one of the admins verify this patch?

If the exception occurred from an HTTP request, use that information
to populate information about the target resource.

Fixes #3491
Copy link
Member

@oscerd oscerd left a comment

Choose a reason for hiding this comment

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

it makes sense

metacosm added a commit to operator-framework/java-operator-sdk that referenced this pull request Sep 23, 2021
Note that this relies on fabric8io/kubernetes-client#3492 so won't build
until this PR is merged and available in a release.
Fixes #552
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

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

52.5% 52.5% Coverage
0.0% 0.0% Duplication

Comment on lines +728 to +740
static RequestMetadata from(Request request) {
final List<String> segments = request.url().pathSegments();
switch (segments.size()) {
case 4:
// cluster URL
return new RequestMetadata(segments.get(1), segments.get(2), segments.get(3), null);
case 6:
// namespaced URL
return new RequestMetadata(segments.get(1), segments.get(2), segments.get(5), segments.get(4));
default:
return EMPTY;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this switch handles all the use-cases?
e.g. subresources, cluster-scoped resources targeting a namesoace, non-standard resources (metrics server, pod exec...), etc.?

Copy link
Member

Choose a reason for hiding this comment

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

I'll merge this PR because this is apparently harmless as it's provided as a new feature.

@manusa manusa added this to the 5.8.0 milestone Sep 23, 2021
@manusa manusa merged commit 519b041 into master Sep 23, 2021
@manusa manusa deleted the improve-exceptions-2 branch September 23, 2021 16:04
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.

Make KubernetesClientException more detailed so that we can get information about what went wrong
5 participants