Skip to content

Add UserRefs in Group spec to support User membership - #985

Open
chenwng wants to merge 1 commit into
k-orc:mainfrom
chenwng:group-membership
Open

chenwng wants to merge 1 commit into
k-orc:mainfrom
chenwng:group-membership

Conversation

@chenwng

@chenwng chenwng commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds UserRefs field in the Group spec to allow user to manage Users in a Group in OpenStack.

Notes to reviewers:

MaxItems of UserRefs is set to 1024 to allow a large group. Please suggest if you consider this value is inappropriate.

Close #905

@github-actions github-actions Bot added the semver:major Breaking change label Oct 14, 2026

@mandre mandre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a first pass for now, I'll look again after you've moved the update logic into its own reconciler.

Comment thread internal/controllers/group/actuator.go Outdated
Comment thread internal/controllers/group/actuator.go Outdated
Comment thread internal/controllers/group/actuator.go
Comment thread internal/controllers/group/actuator.go Outdated
@chenwng
chenwng force-pushed the group-membership branch 2 times, most recently from b0820fd to 7fb0cc4 Compare October 15, 2026 16:47

@mandre mandre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for the quick iteration. Let me know if you want to add the UserIDs in status in a follow-up change or here.

Comment thread internal/osclients/group.go Outdated
Comment on lines +128 to +138
func (c groupErrorClient) AddUser(ctx context.Context, groupID, userID string) error {
return c.error
}

func (c groupErrorClient) RemoveUser(ctx context.Context, groupID, userID string) error {
return c.error
}

func (c groupErrorClient) ListUsers(ctx context.Context, groupID string) ([]users.User, error) {
return nil, c.error
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in order to be consistent:

Suggested change
func (c groupErrorClient) AddUser(ctx context.Context, groupID, userID string) error {
return c.error
}
func (c groupErrorClient) RemoveUser(ctx context.Context, groupID, userID string) error {
return c.error
}
func (c groupErrorClient) ListUsers(ctx context.Context, groupID string) ([]users.User, error) {
return nil, c.error
}
func (e groupErrorClient) AddUser(_ context.Context, _, _ string) error {
return e.error
}
func (e groupErrorClient) RemoveUser(_ context.Context, _, _ string) error {
return e.error
}
func (e groupErrorClient) ListUsers(_ context.Context, _ string) ([]users.User, error) {
return nil, e.error
}

commands:
- script: |-
export OS_CLOUD=openstack-admin OS_CLIENT_CONFIG_FILE=${E2E_KUTTL_OSCLOUDS}
result=`openstack group contains user group-create-full-override group-create-full 2>&1`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that begs the question whether we should add a UserIDs field to the GroupResourceStatus. I think we should, possibly as a follow-up (up to you if you want to tackle it in this PR or later).

This would make for a nice cleanup in all the tests (if you need to shell out to openstack this typically indicates that something is missing in ORC).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it would be better to have UserIDs in the status. Not just for testing but also for user visibility. I just haven't found a good way to achive this without breaking the existing status update pattern.

One idea I have is reuse the Group.Extra field to carry the user name/ids from reconcileUserRefs to ApplyResourceStatus within osResourceT. I know it is a hack and might not be the best way. What do you think? If there is a better way, I would be happy to hear.

Also I'd like to have the user info in the status like below to be more verbose for user:

status:
  resource:
    users:
     - name: user1
       id: 12345
     - name: user2
       id: 67890

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can create a custom osResource under osclients/group.go, and add to it the User struct, like we do for ports. For example:

type GroupExt struct {
    groups.Group
    users.Users
}

Then we could populate it as desired and write on status. That's another alternative that I've thought.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with a more complex struct that just user IDs is that we're only duplicating data that is already in the User object own status (which should be the source or truth).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems creating a wrapper struct for Group and UserIDs is a way to go. I will follow this.

Containing UserName/UserID in the status is surely kind of duplcated, but from the point of view of an admin/user, it would save efforts to match between UserName and UserID when he looks at the output of a Group. If conciseness is prefered, I have no issue with it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a concern about drifting the states. If someone does a change in the User user-a, and this user is part of a group, will a new event be triggered on the Group to reconcile the user list?

Answering myself: I think so, since we register a WatchEventHandler. And yeah, I agree that's a downside having duplicated data for users =/.


Delete one of the Users from the group. Verify if only that specific user is not in the group in OpenStack anymore.

# Step 04

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent heading

Suggested change
# Step 04
## Step 04

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems I need to push AI harder to find things like this :D

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:major Breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manage user group membership

3 participants