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

Slim jimm model #1488

Merged
merged 3 commits into from
Dec 11, 2024
Merged

Slim jimm model #1488

merged 3 commits into from
Dec 11, 2024

Conversation

SimoneDutto
Copy link
Contributor

Description

feature-brach into v3, with merge conflicts

Fixes JIRA/GitHub issue number

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Notes for code reviewers

* remove non-essential fields from model

* remove fields from yaml env

* refactor model summaries
* remove controller watcher
@SimoneDutto SimoneDutto requested a review from a team as a code owner December 10, 2024 11:37
fix migration

fix
@SimoneDutto SimoneDutto requested a review from ale8k December 10, 2024 14:42
Copy link
Contributor

@ale8k ale8k left a comment

Choose a reason for hiding this comment

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

some comments... Feel like we can do them in this branch

// modelSummariesMap is a safe map to add records concurrently because the access is guarded by a Mutex.
// The read operations are not guarded because only inserts are done concurrently.
type modelSummariesMap struct {
mu sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just use sync.Map, no need for mutex @SimoneDutto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://pkg.go.dev/sync#Map

from the go doc, you use sync.Map for very specific use case. Usually they advice you to use a separate mutex.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, so if routine A handles keys 1-10, and routine B handled keys 11-20, then sync.Map is preferred. Never noticed the second part really.

internal/jimm/watcher.go Outdated Show resolved Hide resolved
@@ -71,6 +71,7 @@ type ModelManager interface {
ImportModel(ctx context.Context, user *openfga.User, controllerName string, modelTag names.ModelTag, newOwner string) error
ModelDefaultsForCloud(ctx context.Context, user *dbmodel.Identity, cloudTag names.CloudTag) (jujuparams.ModelDefaultsResult, error)
ModelInfo(ctx context.Context, u *openfga.User, mt names.ModelTag) (*jujuparams.ModelInfo, error)
ModelSummaries(ctx context.Context, user *openfga.User, maskingControllerUUID string) (jujuparams.ModelSummaryResults, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

This interface is confusing lol (not you)


// ModelSummaries returns the list of modelsummary the user has access to.
// It queries the controllers and then merge the info from the JIMM db.
func (j *JIMM) ModelSummaries(ctx context.Context, user *openfga.User, maskingControllerUUID string) (jujuparams.ModelSummaryResults, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probavbly better to just name it ListModelSummaries right?

@SimoneDutto SimoneDutto merged commit ad4e072 into v3 Dec 11, 2024
4 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.

3 participants