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

Manage contributor add failure - rolebinding unique name issue #4970

Closed
lalithvaka opened this issue Apr 20, 2020 · 4 comments
Closed

Manage contributor add failure - rolebinding unique name issue #4970

lalithvaka opened this issue Apr 20, 2020 · 4 comments

Comments

@lalithvaka
Copy link
Contributor

/kind bug

What steps did you take and what happened:
Manage contributor screen. Adding a contributor creates a role binding / service role binding with name including userID's first character by ignoring the digits and not able to add other users with similar numbers.
our Org uses UserIDs as a1234@xx.org, a2345@xx.org.

image
image

What did you expect to happen:
rolebinding and service role bindings names to use digits too

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

  • Kubeflow version: (version number can be found at the bottom left corner of the Kubeflow dashboard):1.0.2
  • kfctl version: (use kfctl version):
  • Kubernetes platform: (e.g. minikube)
  • Kubernetes version: (use kubectl version):
  • OS (e.g. from /etc/os-release):
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the labels:

Label Probability
kind/bug 0.95

Please mark this comment with 👍 or 👎 to give our bot feedback!
Links: app homepage, dashboard and code for this bot.

@kubeflow-bot kubeflow-bot added this to To Do in Needs Triage Apr 20, 2020
@lalithvaka lalithvaka changed the title Manage contributor add failure - rolebinding using first character or ignoring the numbers to create the name Manage contributor add failure - rolebinding unique name issue Apr 21, 2020
@yanniszark
Copy link
Contributor

yanniszark commented Apr 26, 2020

This is the code that decides the name of RoleBindings/ServiceRoleBindings:

//getBindingName returns bindingName, which is combination of user kind, username, RoleRef kind, RoleRef name.
func getBindingName(binding *Binding) (string, error) {
nameRaw := strings.ToLower(
strings.Join([]string{
binding.User.Kind,
url.QueryEscape(binding.User.Name),
binding.RoleRef.Kind,
binding.RoleRef.Name,
},"-"),
)
// Only keep lower case letters, replace other with -
reg, err := regexp.Compile("[^a-z]+")
if err != nil {
return "", err
}
return reg.ReplaceAllString(nameRaw, "-"), nil
}

We should probably amend that logic.
I'm not sure what priority to put on this.
We should decide our plans for the contributor UI first, because if we are moving towards a GitOps approach, the contributor UI becomes less valuable.
On the other hand, this should be an easy fix if we can decide on what naming rule to use.

/area multiuser
cc @jlewi @kunmingg

@lalithvaka
Copy link
Contributor Author

lalithvaka commented Apr 26, 2020

Thank you @yanniszark , I was able to fix this code(with my limited go knowledge) to support numbers in the email address. This changes email address to i397401@zq.msds.kp.org to i397401-zq-msds-kp-org which is being used in the role binding names.

//getBindingName returns bindingName, which is combination of user kind, username, RoleRef kind, RoleRef name.
func getBindingName(binding *Binding) (string, error) {
	// Only keep lower case letters, replace other with -
	reg, err := regexp.Compile("[^a-z0-9]+")
	if err != nil {
		return "", err
	}
	nameRaw := strings.ToLower(
		strings.Join([]string{
			binding.User.Kind,
			url.QueryEscape(reg.ReplaceAllString(binding.User.Name, "-")),
			binding.RoleRef.Kind,
			binding.RoleRef.Name,
		}, "-"),
	)

	return reg.ReplaceAllString(nameRaw, "-"), nil
}

@lalithvaka
Copy link
Contributor Author

@yanniszark submitted a pull request - #4979

/area multiuser
cc @jlewi @kunmingg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants