Jx: users.jenkins.io "<user>" already exists

Created on 7 Oct 2019  路  6Comments  路  Source: jenkins-x/jx

Summary

Creating a preview can fail with:

users.jenkins.io "foo" already exists

This happens when there is already a User CRD with the name foo and GitUserResolver.Resolve fails tries to create a new User CRD with the same name.

aregit good first issue kinbug prioritimportant-longterm

All 6 comments

The problem is that GitHub user names are case sensitive, but our CRD is lowercased, hence this code to generate a unique id does not work:

        new := r.GitUserToUser(gitUser)
        id = gitUser.Login
        // Check if the user id is available, if not append "-<n>" where <n> is some integer
        for i := 0; true; i++ {
            _, err := r.JXClient.JenkinsV1().Users(r.Namespace).Get(id, v1.GetOptions{})
            if k8serrors.IsNotFound(err) {
                break
            }
            id = fmt.Sprintf("%s-%d", gitUser.Login, i)
        }
        new.Name = naming.ToValidName(id)
        return id, possibles, new, nil

It might be as easy as moving naming.ToValidName(id) higher up.

Hi! I am an outreachy applicant, can i take this issue to be my first contribution and work on ?

or can we use strings.ToLower() and render github username lower case !!

@khansaAmrouni are you still working on this issue? If not I'd be happy to jump on it

@mrageh Yes ! Go a head
good luck 馃憤

Was this page helpful?
0 / 5 - 0 ratings