Skip to content

fix: NPE when no namespace is provided in kube config #899

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

Merged
merged 2 commits into from
Feb 4, 2022
Merged

Conversation

metacosm
Copy link
Collaborator

@metacosm metacosm commented Feb 1, 2022

  • fix: fail explicitly if current namespace is requested but not available
  • fix: retain annotation for reflective access

Fixes #897

@metacosm metacosm self-assigned this Feb 1, 2022
@metacosm metacosm requested a review from csviri February 1, 2022 21:48
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 1, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 49 Code Smells

29.4% 29.4% Coverage
0.8% 0.8% Duplication

Copy link
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -67,7 +68,12 @@ static boolean currentNamespaceWatched(Set<String> namespaces) {
throw new IllegalStateException(
"Parent ConfigurationService must be set before calling this method");
}
targetNamespaces = Collections.singleton(parent.getClientConfiguration().getNamespace());
String namespace = parent.getClientConfiguration().getNamespace();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this change, is possibly going to break user's (especially CIs) environment when a provider doesn't set the default namespace.

I would suggest that if the namespace is null you can output a warning message and automatically set it to default.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Btw not sure if this can happen in a real environment (I mean pod), probably just locally, for that purpose might be better to have an exception, so developer won't search for the problem unnecessarily.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A possibility, for the deployment, is to use a downwardAPI.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean, a default namespace will be always there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this should only happen when outside of the cluster…

Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure if this can happen in a real environment

I'm mostly worried about CI ... but, well, an additional command doesn't hurt as well 🤷

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's see how it goes and maybe revisit if needed?

@metacosm metacosm merged commit eeed323 into next Feb 4, 2022
@metacosm metacosm deleted the fix-npe branch February 4, 2022 08:43
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