-
Notifications
You must be signed in to change notification settings - Fork 448
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
katib ui: adapt environment in which cluster role is unavailable #1141
Conversation
@andreyvelich @johnugeorge Could you help to review this PR? |
pkg/ui/v1alpha3/const.go
Outdated
availableNameSpaces, hasClusterRole = func() ([]string, bool) { | ||
ns := env.GetEnvOrDefault(AvailableNameSpaceEnvName, ClusterRoleKey) | ||
if ns == ClusterRoleKey { | ||
return []string{""}, true |
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.
I'm not confident but do you mistake it for []string{}
?
And I think you can use init()
function like:
var (
availableNameSpaces []string
hasClusterRole bool
)
func init() {
ns := env.GetEnvOrDefault(AvailableNameSpaceEnvName, ClusterRoleKey)
...
}
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.
@c-bata Thanks for your suggestions!
- It should be
[]string{""}
which means no namespace options(restriction). If[]string{}
, it will use default name space defined bycontroller.v1alpha3/consts.DefaultKatibNamespace
. - I have replaced with init function
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.
I see. Thank you for your explanation!
pkg/ui/v1alpha3/const.go
Outdated
) | ||
|
||
func init() { | ||
ns := env.GetEnvOrDefault(AvailableNameSpaceEnvName, ClusterRoleKey) |
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.
Couple of questions here
- Is it right to get the namespaces during init function? What happens if env variable is changed later?
- GetEnvOrDefault has fallback value as the second argument. Did you mean to keep ClusterRoleKey as the default value?
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.
- To me, this env variable should be set via manifest yaml file. I can't see any motivation to modify this env variable later.
- Yes.
pkg/ui/v1alpha3/nas.go
Outdated
// Use "" to get experiments in all namespaces. | ||
jobs, err := k.getExperimentList("", JobTypeNAS) | ||
// Get NAS-related experiments in all available namespaces. | ||
jobs, err := k.getExperimentList(availableNameSpaces, JobTypeNAS) |
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.
What do you expect when you have multiple namespaces passed?
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.
Currently, in Katib Client: https://github.com/kubeflow/katib/blob/master/pkg/util/v1alpha3/katibclient/katib_client.go#L210, we extract only first namespace from the list, so it will not give you all available namespaces.
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.
@andreyvelich Yes, but value of namespace is fixed on "" (https://github.com/kubeflow/katib/blob/master/pkg/ui/v1alpha3/hp.go#L22) which leads to list experiments in cluster scope.
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.
@johnugeorge It seems only first namespace will be taken. It is a problem.
Btwn, what is your use case? Can you explain the deployment requirement? |
|
For this reason, do you have access only for the namespace where Katib UI was deployed? |
In my company, all machine learning related resources are shared the same namespace. So, cluster role is not required. |
If Katib UI can't fetch all namespaces, just get Experiments and Namespaces only from namespace where Katib UI is deployed. |
Good idea! |
In this case, do you really need extra environment variable? If you do not have permissions, get experiments from own namespace else do the current way. |
@johnugeorge I think we need know from env variable whether cluster role is permitted. In alternative, katib will try to get objects in cluster scope at first. If failed then fallback to get objects from own namespace. |
+1 to this. |
I agree with it. Katib UI should try to get objects from all namespaces and if it fails, just get object from own namespace. |
@johnugeorge @andreyvelich I think current PR is ready. |
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.
@sperlingxx Thanks!
/lgtm
/cc @johnugeorge
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: johnugeorge The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…eflow#1141) * katib ui: adapt environments which cluster role is unavailable * use init_fn * fix gofmt * update * fix error message * fallback plan
Katib UI fails to get experiment list when cluster role is unavailable. This problem is fixed in this PR through additional environment variable representing available namespaces.