Skip to content

Commit 87ffdf6

Browse files
feat: Add pilot logging (+2 squashed commits)
Squashed commits: [bf5618f] feat: Add pilot logging Squashed commits: [490e293] feat: Logging is working, and we can search through the data [09ddffa] fix: Lots of fixes to make it work [b4e3d12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci [f121d21] fix: remove unused code [6f1cb7f] feat: move bulk_insert to logging.py [ea6ecdd] feat: refactor pilot logging to include a business logic layer, rebase and fix _get_columns [15338d5] feat: refactor pilot logging to include a business logic layer [8fe6d31] fix: rename _get_columns to get_columns [9ee07db] fix: remove unused PilotNotFoundError exception [cf61acb] feat: Restructured pilot logger + test send_message and get_logs [9800d11] feat: enable remote pilot logging system [720f302] fix: Add security by preventing a user to access a pilot endpoint and vice-versa [bad03be] fix: Changed the pilot token from a User to a dedicated [f71da78] fix: Split in two pilot route [3feaa56] fix: Add security by preventing to see other pilots [306941f] fix: Fix, bug not caught by CI (sqlite not raising anything) [cc8de96] fix: Change secrets from VARCHAR to BINARY [17ce4e3] feat: Change from SecretID to SecretUUID [5760830] fix: Generating the client [43cfccc] feat: Migrating pilot functionalities from DIRAC, and add DiracX pilot auth Squashed commits: [33cfe17] test: Changing from sleep to freezegun #537 [3e5d677] refactor: Refactorized the exceptions [d84f6fe] doc: Documenting the database [1c0db02] test: Better testing: Tested search engine [cd1caf4] refactor: Refactoring from the auth router to the pilot router [9cc99f1] feat: Adding indexes to the database [de0b580] refactor: Moved the pilot_to_secret_mapping into the pilotagents table itself [14396f6] refactoring: Lots of refactoring of the code [56daac5] refactor: Moving db parts to the logic, and some fixes [79a11cf] fix: Fixed dependency and client [8c45582] test: Tested interval deletion for the db. [dd07bca] feat: We can clear pilots that lived more than n days [7e93153] feat: We can search for pilots [9da8033] feat: DIRAC can associate a pilot with a job [77a59b0] feat: We can modify pilot fields (statuses, benchmarks, ...) [ca0e727] fix: Added pilot management [521164f] fix: Fixed text [8e6e881] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci [adadb68] fix: Semantic [15d9fe6] feat: We can add a number of use max for the secret in pilot registration [4549203] fix: Fixed cli [a9ece0a] feat: Adding a command to add a pilot to the CS, and some fixes [42e4f0b] fix: Changed secret expiration from 600 to 3600s [1dcb4b8] fix: Regenerated client [02a5e31] feat: A user can create secrets, and associate them to a pilot [8072227] feat: Ability to add only secrets, and lots of refactoring in the tests [10205d6] feat: Autodeletion of secrets after full use or expiration. [3f013df] feat: Restricting a secret for a certain VO [c2181aa] fix: Chunky client [d374ec6] feat: Changing the pilot login db, and moved from references to stamps [aa67bda] fix: Regenerating client [135235f] feat: Using pilot user, model for pilot creds, and documentation [0e0a117] feat: Added last_time_used for a pilot secret, and a max value [62977ee] fix: Few fixes with refactoring, and tests (+4 squashed commits) Squashed commits: [5169ee2] refactor: Moved login for pilots into token file [12da5c0] fix: Fixed according the the new commits from main branch [a8e06d8] fix: Fixed client [93b83b4] fix: Fixed the tests and autorest [a78c028] feat: A user can register pilots and get their credentials [1e9f907] fix: Removing the pilot login cli [3f7c632] feat: Adding duration to secrets [8aff5d9] fix: Regenerating client, type ignore for the cli Squashed commits: [06a969b] fix: Type ignore for mypy... [28e1ee1] fix: Generated code broke everything [339ab4f] fix: Fixed cli and pilot endpoints [31af99e] fix: Regenerated client [a171d01] feat: Added pilot login to the cli [54951a6] fix: Correcting client generation with the error patch Squashed commits: [65db1ae] fix: Regenerating clients with autorest [5a4f370] feat: Better handling of refresh tokens for pilots [6da7bb4] fix: Generating client with autorest [2c4d2fb] feat: Adding pilot registrations [a957480] feat: Adding pilot registrations, with secret management
1 parent 8fd7d1c commit 87ffdf6

File tree

67 files changed

+12383
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+12383
-298
lines changed

diracx-cli/src/diracx/cli/internal/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def generate_cs(config_repo: str):
5959
update_config_and_commit(
6060
repo_path=repo_path, config=config, message="Initial commit"
6161
)
62-
typer.echo(f"Successfully created repo in {config_repo}", err=True)
62+
typer.echo(f"Successfully created repo in {config_repo}")
6363

6464

6565
@app.command()
@@ -99,7 +99,7 @@ def add_vo(
9999
config=config,
100100
message=f"Added vo {vo} registry (default group {default_group} and idp {idp_url})",
101101
)
102-
typer.echo(f"Successfully added vo to {config_repo}", err=True)
102+
typer.echo(f"Successfully added vo to {config_repo}")
103103

104104

105105
@app.command()
@@ -130,7 +130,7 @@ def add_group(
130130
update_config_and_commit(
131131
repo_path=repo_path, config=config, message=f"Added group {group} in {vo}"
132132
)
133-
typer.echo(f"Successfully added group to {config_repo}", err=True)
133+
typer.echo(f"Successfully added group to {config_repo}")
134134

135135

136136
@app.command()
@@ -177,7 +177,7 @@ def add_user(
177177
config=config,
178178
message=f"Added user {sub} ({preferred_username}) to vo {vo} and groups {groups}",
179179
)
180-
typer.echo(f"Successfully added user to {config_repo}", err=True)
180+
typer.echo(f"Successfully added user to {config_repo}")
181181

182182

183183
def update_config_and_commit(repo_path: Path, config: Config, message: str):

diracx-cli/tests/test_internal.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,64 @@ def test_add_user(cs_repo, vo, user_group):
222222
assert sub in config.Registry[vo].Users
223223
for group in user_group or [TEST_USER_GROUP]:
224224
assert config.Registry[vo].Groups[group].Users == {sub}
225+
226+
227+
def test_add_pilot_user(cs_repo):
228+
229+
sub = "lhcb:rvandeme"
230+
231+
pilot_group = "pilot_group"
232+
pilot_user = "pilot_user"
233+
234+
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
235+
236+
# Add a second group to it
237+
result = runner.invoke(
238+
app,
239+
[
240+
"internal",
241+
"add-group",
242+
cs_repo,
243+
f"--vo={TEST_VO}",
244+
f"--group={pilot_group}",
245+
"--properties",
246+
"GenericPilot",
247+
],
248+
)
249+
assert result.exit_code == 0, result.output
250+
251+
# Add a user to it
252+
result = runner.invoke(
253+
app,
254+
[
255+
"internal",
256+
"add-user",
257+
cs_repo,
258+
f"--vo={TEST_VO}",
259+
f"--sub={sub}",
260+
f"--preferred-username={pilot_user}",
261+
f"--group={pilot_group}",
262+
],
263+
)
264+
assert result.exit_code == 0, result.output
265+
266+
# Set this user as a pilot
267+
result = runner.invoke(
268+
app,
269+
[
270+
"internal",
271+
"set-user-as-pilot-user",
272+
cs_repo,
273+
f"--vo={TEST_VO}",
274+
f"--sub={sub}",
275+
f"--pilot-preferred-username={pilot_user}",
276+
f"--pilot-group={pilot_group}",
277+
],
278+
)
279+
assert result.exit_code == 0, result.output
280+
281+
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
282+
283+
# User pilot exists, same for pilot group
284+
assert config.Operations[TEST_VO].Pilot["GenericPilotUser"] == pilot_user
285+
assert config.Operations[TEST_VO].Pilot["GenericPilotGroup"] == pilot_group

diracx-client/src/diracx/client/_generated/_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
AuthOperations,
2020
ConfigOperations,
2121
JobsOperations,
22+
PilotOperations,
23+
PilotsOperations,
2224
WellKnownOperations,
2325
)
2426

@@ -34,6 +36,10 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3436
:vartype config: _generated.operations.ConfigOperations
3537
:ivar jobs: JobsOperations operations
3638
:vartype jobs: _generated.operations.JobsOperations
39+
:ivar pilot: PilotOperations operations
40+
:vartype pilot: _generated.operations.PilotOperations
41+
:ivar pilots: PilotsOperations operations
42+
:vartype pilots: _generated.operations.PilotsOperations
3743
:keyword endpoint: Service URL. Required. Default value is "".
3844
:paramtype endpoint: str
3945
"""
@@ -86,6 +92,12 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
8692
self.jobs = JobsOperations(
8793
self._client, self._config, self._serialize, self._deserialize
8894
)
95+
self.pilot = PilotOperations(
96+
self._client, self._config, self._serialize, self._deserialize
97+
)
98+
self.pilots = PilotsOperations(
99+
self._client, self._config, self._serialize, self._deserialize
100+
)
89101

90102
def send_request(
91103
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

diracx-client/src/diracx/client/_generated/aio/_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
AuthOperations,
2020
ConfigOperations,
2121
JobsOperations,
22+
PilotOperations,
23+
PilotsOperations,
2224
WellKnownOperations,
2325
)
2426

@@ -34,6 +36,10 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3436
:vartype config: _generated.aio.operations.ConfigOperations
3537
:ivar jobs: JobsOperations operations
3638
:vartype jobs: _generated.aio.operations.JobsOperations
39+
:ivar pilot: PilotOperations operations
40+
:vartype pilot: _generated.aio.operations.PilotOperations
41+
:ivar pilots: PilotsOperations operations
42+
:vartype pilots: _generated.aio.operations.PilotsOperations
3743
:keyword endpoint: Service URL. Required. Default value is "".
3844
:paramtype endpoint: str
3945
"""
@@ -86,6 +92,12 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
8692
self.jobs = JobsOperations(
8793
self._client, self._config, self._serialize, self._deserialize
8894
)
95+
self.pilot = PilotOperations(
96+
self._client, self._config, self._serialize, self._deserialize
97+
)
98+
self.pilots = PilotsOperations(
99+
self._client, self._config, self._serialize, self._deserialize
100+
)
89101

90102
def send_request(
91103
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

diracx-client/src/diracx/client/_generated/aio/operations/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from ._operations import AuthOperations # type: ignore
1515
from ._operations import ConfigOperations # type: ignore
1616
from ._operations import JobsOperations # type: ignore
17+
from ._operations import PilotOperations # type: ignore
18+
from ._operations import PilotsOperations # type: ignore
1719

1820
from ._patch import __all__ as _patch_all
1921
from ._patch import *
@@ -24,6 +26,8 @@
2426
"AuthOperations",
2527
"ConfigOperations",
2628
"JobsOperations",
29+
"PilotOperations",
30+
"PilotsOperations",
2731
]
2832
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2933
_patch_sdk()

0 commit comments

Comments
 (0)