-
Notifications
You must be signed in to change notification settings - Fork 4
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
Read user namespace from file #97
Conversation
It might be a bit hard to test this PR at the moment since we do not have a devfile v2 yet (issue). In general, the steps here from the docs can be followed. Unlike what's mentioned in the docs, we don't need a Additionally, if there's already a default telemetry plugin listening on port 4167, the default telemetry plugin should first be removed before testing this PR. This is because running this project also requires listening on port 4167. |
private String getCurrentNamespace(KubernetesClient client) throws IOException { | ||
BufferedReader br = new BufferedReader(new FileReader(Config.KUBERNETES_NAMESPACE_PATH)); | ||
String namespace = br .readLine(); | ||
br.close(); | ||
return namespace.strip(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got a bit lost with implementation. Why do we pass the client in param? also wondering if it is a reliable way of getting the namespace based on the KUBERNETES_NAMESPACE_PATH
? should not we close reader in finally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thank you for pointing that out.
As for whether getting the namespace based on the KUBERNETES_NAMESPACE_PATH
is reliable, it seems to work well empirically, but are there cases where /var/run/secrets/kubernetes.io/serviceaccount
is not mounted to the container?
I've updated the code so that there is a new approach as well as the file reading approach. The new approach is reading the DEVWORKSPACE_NAMESPACE
environment variable set on the workspace containers by the DWO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks
0fc3132
to
fed60f4
Compare
Signed-off-by: David Kwon <dakwon@redhat.com>
fed60f4
to
25fb30f
Compare
Reads the current namespace from
/var/run/secrets/kubernetes.io/serviceaccount/namespace
.Fixes #92.
Signed-off-by: David Kwon dakwon@redhat.com