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

[DNM] Add some logging to AddProjectMember #331

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions extensions/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/rancher/norman/types"
v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
authzv1 "k8s.io/api/authorization/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -79,6 +80,7 @@ func CreateUserWithRole(rancherClient *rancher.Client, user *management.User, ro
func AddProjectMember(rancherClient *rancher.Client, project *management.Project,
user *management.User, projectRole string, attrs []*authzv1.ResourceAttributes,
) error {
logrus.Infof("AddProjectMember")
role := &management.ProjectRoleTemplateBinding{
ProjectID: project.ID,
UserPrincipalID: user.PrincipalIDs[0],
Expand Down Expand Up @@ -117,6 +119,7 @@ func AddProjectMember(rancherClient *rancher.Client, project *management.Project
return false, nil
}

logrus.Infof("Watch for project conversion and NamespaceBackedResource")
err = wait.WatchWait(watchInterface, checkFunc)
if err != nil {
return err
Expand All @@ -126,13 +129,20 @@ func AddProjectMember(rancherClient *rancher.Client, project *management.Project
if err != nil {
return err
}
logrus.Infof("PRTB: %v", roleTemplateResp)

var prtb *management.ProjectRoleTemplateBinding
err = kwait.Poll(500*time.Millisecond, 2*time.Minute, func() (done bool, err error) {
prtb, err = rancherClient.Management.ProjectRoleTemplateBinding.ByID(roleTemplateResp.ID)
if err != nil {
logrus.Infof("failed to get by id %v", err)
return false, err
}
if prtb != nil {
logrus.Infof("prtb.UserID: %v user.ID: %v prtb.ProjectID: %v project.ID: %v", prtb.UserID, user.ID, prtb.ProjectID, project.ID)
} else {
logrus.Infof("prtb is nil")
}
if prtb != nil && prtb.UserID == user.ID && prtb.ProjectID == project.ID {
return true, nil
}
Expand All @@ -143,6 +153,7 @@ func AddProjectMember(rancherClient *rancher.Client, project *management.Project
return err
}

logrus.Infof("waitForPRTBRollout")
err = waitForPRTBRollout(adminClient, prtb, createOp)
if err != nil {
return err
Expand Down
Loading