Commit 9e69221
authored
[Projects] Fix leader project creation flow (#9146)
### 📝 Description
This PR addresses a few issues that were found in the project creation
flow when MLRun is the project Leader:
1. Ensures that project permissions are properly established after
project creation and storage operations, by adding a retry mechanism to
wait for permission propagation before returning from the API endpoints,
preventing race conditions where clients may immediately try to access
the newly created project before permissions are fully available.
1. Note that this doesn't ensure both chief and worker have the updated
copies, but it is a best effort and the delay margins between the two
should be small enough.
2. When running operations on all followers (such as create/store
project), run them on the `sorted` list of followers. When the followers
are defined `['igz', 'nuclio']` this ensures the project policies are
created before the project is created on Nuclio.
1. This is quite hacky, I agree, but until we provide a more robust
project leader mechanism it will have to do.
3. Refactor iguazio v4's `store_project` to decide if it a "create" or
"update" based on if `create_project` raises a 409 Conflict error. If
conflict - it is an "update", if not - it is a "create".
1. This was needed because in the old implementation which used
`get_project_policy_assignments`, we would get a 403 and not a 404, so
we couldn't really tell if that 403 is because the project doesn't exist
or we really don't have permissions.
---
### 🛠️ Changes Made
- **Added `ensure_project_permissions()` method to `AuthVerifier`**
(`server/py/framework/utils/auth/verifier.py`):
- New async method that retries project read permission checks with a
1-second backoff and 10-second timeout
- Handles race conditions where the auth provider may not immediately
have permissions available after project creation
- **Updated project endpoints**
(`server/py/services/api/api/endpoints/projects.py`):
- Added `ensure_project_permissions()` call after `create_project`
completes (before returning 201)
- Added `ensure_project_permissions()` call after `store_project`
completes
- **Refactored iguazio's `store_project`**
(`server/py/framework/utils/clients/iguazio/v4.py`):
- Resolving create or updated according to a 409 Conflict status
- **Sorted followers list when running all on all followers**
(`server/py/framework/utils/projects/leader.py`):
- Minimal effort to ensure `igz` follower operations run before `nuclio`
follwer.
---
### ✅ Checklist
- [ ] I updated the documentation (if applicable)
- [x] I have tested the changes in this PR
- [ ] I confirmed whether my changes are covered by system tests
- [ ] If yes, I ran all relevant system tests and ensured they passed
before submitting this PR
- [ ] I updated existing system tests and/or added new ones if needed to
cover my changes
- [ ] If I introduced a deprecation:
- [ ] I followed the [Deprecation Guidelines](./DEPRECATION.md)
- [ ] I updated the relevant Jira ticket for documentation
---
### 🧪 Testing
- Manual testing to verify permissions are available immediately after
project creation
- Verified retry mechanism properly waits for permission propagation
- Tested both in IG3 and IG4
---
### 🔗 References
- Ticket link: https://iguazio.atlassian.net/browse/IG4-1002,
https://iguazio.atlassian.net/browse/IG4-1044
- Design docs links:
- External links:
---
### 🚨 Breaking Changes?
- [ ] Yes (explain below)
- [x] No
---
### 🔍️ Additional Notes1 parent 1fa3a07 commit 9e69221
File tree
5 files changed
+69
-13
lines changed- server/py
- framework/utils
- auth
- clients/iguazio
- projects
- services/api
- api/endpoints
- tests/unit/utils/clients/iguazio
5 files changed
+69
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
301 | 303 | | |
302 | 304 | | |
303 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
304 | 330 | | |
305 | 331 | | |
306 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
194 | 211 | | |
195 | 212 | | |
196 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
| |||
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
110 | 122 | | |
111 | 123 | | |
112 | 124 | | |
| |||
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
491 | 492 | | |
492 | | - | |
493 | | - | |
| 493 | + | |
| 494 | + | |
494 | 495 | | |
495 | 496 | | |
496 | 497 | | |
| |||
501 | 502 | | |
502 | 503 | | |
503 | 504 | | |
504 | | - | |
| 505 | + | |
| 506 | + | |
505 | 507 | | |
506 | 508 | | |
507 | 509 | | |
508 | 510 | | |
509 | | - | |
510 | | - | |
511 | | - | |
| 511 | + | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
| |||
0 commit comments