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

Store UGID in group cache to handle group renames at provider's end #647

Merged
merged 11 commits into from
Dec 19, 2024

Conversation

shiv-tyagi
Copy link
Contributor

@shiv-tyagi shiv-tyagi commented Nov 20, 2024

Closes #620
UDENG-5160

As suggested by @adombeck, to identify if a group is renamed at provider's end, we should store UGID along with the GID and group name in the cache and find if there is already a group record with same UGID in cache. In case we find one, we delete the record being pointed by old name in relevant buckets and populate with record containing new name.

@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch from 483afc8 to fee1ce2 Compare November 20, 2024 13:34
@shiv-tyagi
Copy link
Contributor Author

@adombeck Here is my initial work. Could you please check if I am going in right direction?

@adombeck
Copy link
Contributor

Hi @shiv-tyagi, sorry for the late reply, I've been sick for a week.

Here is my initial work. Could you please check if I am going in right direction?

Yes, I took a quick look and it looks like it's going in the right direction! I'll do a more thorough review once the tests pass and you consider the PR ready for review. Let me know if you need any assistance.

@shiv-tyagi
Copy link
Contributor Author

No worries. Health comes first.
I saw the test failures and found that since we have added the UGID field, we need to update the test data files almost everywhere. There are a lot of them.
Should I proceed updating the test data files? That would add a lot of diffs to the PR and might make it difficult to review. What do you suggest?

@adombeck
Copy link
Contributor

I saw the test failures and found that since we have added the UGID field, we need to update the test data files almost everywhere. There are a lot of them.

Ah, I assume it's the golden files which need to be updated. You can update them all at once by running TESTS_UPDATE_GOLDEN=1 go test ./....

@shiv-tyagi
Copy link
Contributor Author

shiv-tyagi commented Dec 2, 2024

TESTS_UPDATE_GOLDEN=1 go test ./....

I ran this and a lot of golden files did get updated, but the *.db files in the test data like this one still couldn't get updated. Do I need to update them manually or am I missing something?

If I am not wrong, golden files are the ones against which the test output is matched, but we also need to update the initial sample db files on which those tests are performed, right?

@adombeck
Copy link
Contributor

adombeck commented Dec 2, 2024

I ran this and a lot of golden files did get updated, but the *.db files in the test data like this one still couldn't get updated. Do I need to update them manually or am I missing something?

Those should also be updated automatically. I ran TESTS_UPDATE_GOLDEN=1 go test ./internal/services/pam/... locally on your branch and it updated a lot of files, including the cache.db files.

@shiv-tyagi
Copy link
Contributor Author

shiv-tyagi commented Dec 3, 2024

I get this error when I do run the command

Those should also be updated automatically. I ran TESTS_UPDATE_GOLDEN=1 go test ./internal/services/pam/... locally on your branch and it updated a lot of files, including the cache.db files.

internal/users/localgroups/localgroups.go:21:16: undefined: getPasswdUsernames
FAIL    github.com/ubuntu/authd/internal/services/pam [build failed]
FAIL

I get this error when I run the command. Anything I am missing?

@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch 4 times, most recently from fb4c819 to 5346307 Compare December 3, 2024 17:59
@shiv-tyagi
Copy link
Contributor Author

Those should also be updated automatically. I ran TESTS_UPDATE_GOLDEN=1 go test ./internal/services/pam/... locally on your branch and it updated a lot of files, including the cache.db files

Sorry for bugging you so much. I was finally able to run tests and get the cache.db files updated as well. But I still couldn't get these *.db.yaml files updated. Did yours got updated when you ran it locally?

@3v1n0
Copy link
Collaborator

3v1n0 commented Dec 3, 2024

Just use TESTS_UPDATE_GOLDEN=1 go test -C ./internal ./... it should work

@adombeck
Copy link
Contributor

adombeck commented Dec 3, 2024

internal/users/localgroups/localgroups.go:21:16: undefined: getPasswdUsernames
FAIL github.com/ubuntu/authd/internal/services/pam [build failed]
FAIL

I get this error when I run the command. Anything I am missing?

Do you have CGO_ENABLED set to 0? If so, unset it please:

CGO_ENABLED= TESTS_UPDATE_GOLDEN=1 go test ./internal/services/pam/...

@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch from 5346307 to 046924b Compare December 4, 2024 03:30
@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.

Project coverage is 83.10%. Comparing base (36511cd) to head (74e0b9a).
Report is 132 commits behind head on main.

Files with missing lines Patch % Lines
internal/users/cache/delete.go 42.85% 2 Missing and 2 partials ⚠️
internal/users/cache/update.go 78.57% 2 Missing and 1 partial ⚠️
internal/users/cache/getgroups.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #647      +/-   ##
==========================================
- Coverage   83.43%   83.10%   -0.34%     
==========================================
  Files          83       88       +5     
  Lines        8689     8966     +277     
  Branches       74       74              
==========================================
+ Hits         7250     7451     +201     
- Misses       1111     1169      +58     
- Partials      328      346      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch from 046924b to d48b27b Compare December 4, 2024 04:02
@shiv-tyagi
Copy link
Contributor Author

Thanks @3v1n0 and @adombeck, I was able to run the tests and get the golden files updated. There's this one QA and Sanity check failing. I checked the logs but couldn't find any error message. Any idea how to fix that?

@adombeck
Copy link
Contributor

adombeck commented Dec 4, 2024

Thanks @3v1n0 and @adombeck, I was able to run the tests and get the golden files updated. There's this one QA and Sanity check failing. I checked the logs but couldn't find any error message. Any idea how to fix that?

That job unfortunately doesn't print its results on the job page, but on the summary page: https://github.com/ubuntu/authd/actions/runs/12152788489/attempts/1?pr=647

image

@adombeck
Copy link
Contributor

adombeck commented Dec 4, 2024

To catch linter errors earlier, you could install a git pre-push hook which runs golangci-lint locally:

$ cat .git/hooks/pre-push
#!/bin/sh

set -eu
set -x

golangci-lint run

@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch from d48b27b to ee15013 Compare December 4, 2024 15:30
@shiv-tyagi
Copy link
Contributor Author

shiv-tyagi commented Dec 4, 2024

Thanks again @adombeck for patiently answering my questions. I am opening the PR for review.

Last few questions - I promise :),

  • Is there a chat server (discord or slack etc.) where the developers hang out and I can quickly ask my doubts?
  • Are there any regular online meetings which I can join to learn and get involved more in the project?

@shiv-tyagi shiv-tyagi marked this pull request as ready for review December 4, 2024 16:00
@shiv-tyagi shiv-tyagi requested a review from a team as a code owner December 4, 2024 16:00
@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch 2 times, most recently from 4ec2473 to e1ed40b Compare December 5, 2024 15:10
Copy link
Contributor

@adombeck adombeck left a comment

Choose a reason for hiding this comment

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

This looks very good! Just a few comments.

internal/users/manager.go Show resolved Hide resolved
internal/users/cache/update.go Outdated Show resolved Hide resolved
internal/users/cache/update.go Outdated Show resolved Hide resolved
internal/users/cache/update.go Outdated Show resolved Hide resolved
@adombeck
Copy link
Contributor

adombeck commented Dec 5, 2024

Thanks again @adombeck for patiently answering my questions. I am opening the PR for review.

No problem :)

Last few questions - I promise :),

  • Is there a chat server (discord or slack etc.) where the developers hang out and I can quickly ask my doubts?
  • Are there any regular online meetings which I can join to learn and get involved more in the project?

Currently, we don't have a public chat server or public meetings. I'll mention to the team that you're interested in that, but I can't promise anything 🫤

@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch from e1ed40b to 9d54ba1 Compare December 15, 2024 16:52
@shiv-tyagi shiv-tyagi force-pushed the group-name-consistency branch from 9d54ba1 to 16c24ad Compare December 15, 2024 17:18
@shiv-tyagi
Copy link
Contributor Author

@adombeck Sorry it is taking longer because I am getting less time after work. I only get weekends to contribute.
I look forward to get this PR merged soon. I have asked some questions in the comments above.

@adombeck adombeck force-pushed the group-name-consistency branch from 12ab536 to f6d898b Compare December 16, 2024 15:56
Copy link
Contributor

@adombeck adombeck left a comment

Choose a reason for hiding this comment

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

This looks good to me now, thanks a lot @shiv-tyagi!

@adombeck
Copy link
Contributor

@denisonbarbosa @3v1n0 does one of you want to take a look before I merge?

@shiv-tyagi
Copy link
Contributor Author

Thanks @adombeck.

@adombeck
Copy link
Contributor

@denisonbarbosa @3v1n0 does one of you want to take a look before I merge?

@denisonbarbosa @3v1n0 ping

Comment on lines 93 to +96
if err != nil && !errors.Is(err, NoDataFoundError{}) {
return err
}
groupExists := !errors.Is(err, NoDataFoundError{})
Copy link
Collaborator

Choose a reason for hiding this comment

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

A nit, but I think it becomes clearer with:

		groupExists := !errors.Is(err, NoDataFoundError{})
		if err != nil && groupExists {
			return err
		}

Copy link
Collaborator

@3v1n0 3v1n0 left a comment

Choose a reason for hiding this comment

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

LGTM, just a nit to make things a bit more readable.

@adombeck adombeck force-pushed the group-name-consistency branch from f6d898b to 74e0b9a Compare December 19, 2024 22:43
@adombeck adombeck merged commit edd2399 into ubuntu:main Dec 19, 2024
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue: EntraID groups that are renamed result in auth failures because GID conflicts
4 participants