Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
rabbitmq_agents
Commits
4ff2ffe1
Commit
4ff2ffe1
authored
3 years ago
by
Eesaan Atluri
Browse files
Options
Downloads
Patches
Plain Diff
Move away from using RPC queues and use regular queues
parent
08141d63
No related branches found
Branches containing commit
No related tags found
2 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!119
Feat account management
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
prod_rmq_agents/expire_account.py
+8
-15
8 additions, 15 deletions
prod_rmq_agents/expire_account.py
prod_rmq_agents/new_jobs.py
+9
-16
9 additions, 16 deletions
prod_rmq_agents/new_jobs.py
prod_rmq_agents/ssh_access.py
+9
-13
9 additions, 13 deletions
prod_rmq_agents/ssh_access.py
with
26 additions
and
44 deletions
prod_rmq_agents/expire_account.py
+
8
−
15
View file @
4ff2ffe1
...
@@ -22,13 +22,10 @@ def expire_account(ch, method, properties, body):
...
@@ -22,13 +22,10 @@ def expire_account(ch, method, properties, body):
msg
=
json
.
loads
(
body
)
msg
=
json
.
loads
(
body
)
username
=
msg
[
"
username
"
]
username
=
msg
[
"
username
"
]
action
=
msg
[
"
action
"
]
action
=
msg
[
"
action
"
]
msg
[
"
success
"
]
=
{}
msg
[
"
task
"
]
=
task
msg
[
"
success
"
][
task
]
=
False
queuename
=
msg
[
"
queuename
"
]
yesterday
=
date
.
today
()
-
timedelta
(
days
=
1
)
yesterday
=
date
.
today
()
-
timedelta
(
days
=
1
)
corr_id
=
properties
.
correlation_id
reply_to
=
properties
.
reply_to
try
:
try
:
expire_account_cmd
=
f
'
/cm/local/apps/cmd/bin/cmsh -n -c
"
user;use
{
username
}
; set expirationdate
{
yesterday
}
; commit;
"'
expire_account_cmd
=
f
'
/cm/local/apps/cmd/bin/cmsh -n -c
"
user;use
{
username
}
; set expirationdate
{
yesterday
}
; commit;
"'
unexpire_account_cmd
=
f
'
/cm/local/apps/cmd/bin/cmsh -n -c
"
user;use
{
username
}
; set expirationdate 2037/12/31; commit;
"'
unexpire_account_cmd
=
f
'
/cm/local/apps/cmd/bin/cmsh -n -c
"
user;use
{
username
}
; set expirationdate 2037/12/31; commit;
"'
...
@@ -38,23 +35,19 @@ def expire_account(ch, method, properties, body):
...
@@ -38,23 +35,19 @@ def expire_account(ch, method, properties, body):
elif
action
==
'
unlock
'
:
elif
action
==
'
unlock
'
:
unblock_ssh
=
popen
(
unexpire_account_cmd
).
read
().
rstrip
()
unblock_ssh
=
popen
(
unexpire_account_cmd
).
read
().
rstrip
()
msg
[
"
success
"
]
[
task
]
=
True
msg
[
"
success
"
]
=
True
logger
.
info
(
f
"
ssh expiration set to yesterday for user
{
username
}
"
)
logger
.
info
(
f
"
ssh expiration set to yesterday for user
{
username
}
"
)
except
Exception
:
except
Exception
:
msg
[
"
success
"
]
[
task
]
=
False
msg
[
"
success
"
]
=
False
msg
[
"
errmsg
"
]
=
"
Exception raised, while expiring user
'
s ssh access, check the logs for stack trace
"
msg
[
"
errmsg
"
]
=
"
Exception raised, while expiring user
'
s ssh access, check the logs for stack trace
"
logger
.
error
(
""
,
exc_info
=
True
)
logger
.
error
(
""
,
exc_info
=
True
)
# send response to callback queue with it's correlation ID
# send response to callback queue with it's correlation ID
if
reply_to
:
rc_rmq
.
publish_msg
(
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
f
'
acctmgr.done.
{
queuename
}
'
,
{
"
routing_key
"
:
reply_to
,
"
msg
"
:
msg
}
"
props
"
:
pika
.
BasicProperties
(
)
correlation_id
=
corr_id
,
),
"
msg
"
:
msg
}
)
logger
.
debug
(
f
"
User
{
username
}
confirmation sent for
{
action
}
ing
{
task
}
"
)
logger
.
debug
(
f
"
User
{
username
}
confirmation sent for
{
action
}
ing
{
task
}
"
)
...
...
This diff is collapsed.
Click to expand it.
prod_rmq_agents/new_jobs.py
+
9
−
16
View file @
4ff2ffe1
...
@@ -21,11 +21,8 @@ def new_jobs(ch, method, properties, body):
...
@@ -21,11 +21,8 @@ def new_jobs(ch, method, properties, body):
msg
=
json
.
loads
(
body
)
msg
=
json
.
loads
(
body
)
username
=
msg
[
"
username
"
]
username
=
msg
[
"
username
"
]
action
=
msg
[
"
action
"
]
action
=
msg
[
"
action
"
]
msg
[
"
success
"
]
=
{}
msg
[
"
task
"
]
=
task
msg
[
"
success
"
][
task
]
=
False
queuename
=
msg
[
"
queuename
"
]
corr_id
=
properties
.
correlation_id
reply_to
=
properties
.
reply_to
try
:
try
:
block_new_jobs_cmd
=
f
"
/cm/shared/apps/slurm/19.05.5/bin/sacctmgr --immediate update user
{
username
}
set maxjobs=0
"
block_new_jobs_cmd
=
f
"
/cm/shared/apps/slurm/19.05.5/bin/sacctmgr --immediate update user
{
username
}
set maxjobs=0
"
...
@@ -36,23 +33,19 @@ def new_jobs(ch, method, properties, body):
...
@@ -36,23 +33,19 @@ def new_jobs(ch, method, properties, body):
elif
action
==
'
unlock
'
:
elif
action
==
'
unlock
'
:
unblock_new_jobs
=
popen
(
unblock_new_jobs_cmd
).
read
().
rstrip
()
unblock_new_jobs
=
popen
(
unblock_new_jobs_cmd
).
read
().
rstrip
()
msg
[
"
success
"
]
[
task
]
=
True
msg
[
"
success
"
]
=
True
logger
.
info
(
f
"
Succeeded in blocking
{
username
}
'
s jobs getting to run state
"
)
logger
.
info
(
f
"
Succeeded in blocking
{
username
}
'
s jobs getting to run state
"
)
except
Exception
:
except
Exception
:
msg
[
"
success
"
]
[
task
]
=
False
msg
[
"
success
"
]
=
False
msg
[
"
errmsg
"
]
=
"
Exception raised while setting maxjobs that can enter run state, check the logs for stack trace
"
msg
[
"
errmsg
"
]
=
"
Exception raised while setting maxjobs that can enter run state, check the logs for stack trace
"
logger
.
error
(
""
,
exc_info
=
True
)
logger
.
error
(
""
,
exc_info
=
True
)
# send response to callback queue with it's correlation ID
if
reply_to
:
rc_rmq
.
publish_msg
(
rc_rmq
.
publish_msg
(
{
"
routing_key
"
:
f
'
acctmgr.done.
{
queuename
}
'
,
{
"
routing_key
"
:
reply_to
,
"
msg
"
:
msg
}
"
props
"
:
pika
.
BasicProperties
(
)
correlation_id
=
corr_id
,
),
"
msg
"
:
msg
}
)
logger
.
debug
(
f
"
User
{
username
}
confirmation sent for
{
action
}
ing
{
task
}
"
)
logger
.
debug
(
f
"
User
{
username
}
confirmation sent for
{
action
}
ing
{
task
}
"
)
...
...
This diff is collapsed.
Click to expand it.
prod_rmq_agents/ssh_access.py
+
9
−
13
View file @
4ff2ffe1
...
@@ -21,9 +21,7 @@ def ssh_access(ch, method, properties, body):
...
@@ -21,9 +21,7 @@ def ssh_access(ch, method, properties, body):
msg
=
json
.
loads
(
body
)
msg
=
json
.
loads
(
body
)
username
=
msg
[
"
username
"
]
username
=
msg
[
"
username
"
]
action
=
msg
[
"
action
"
]
action
=
msg
[
"
action
"
]
msg
[
"
success
"
]
=
{}
msg
[
"
task
"
]
=
task
msg
[
"
success
"
][
task
]
=
False
corr_id
=
properties
.
correlation_id
corr_id
=
properties
.
correlation_id
reply_to
=
properties
.
reply_to
reply_to
=
properties
.
reply_to
...
@@ -36,23 +34,21 @@ def ssh_access(ch, method, properties, body):
...
@@ -36,23 +34,21 @@ def ssh_access(ch, method, properties, body):
elif
action
==
'
unlock
'
:
elif
action
==
'
unlock
'
:
unblock_ssh
=
popen
(
unblock_ssh_cmd
).
read
().
rstrip
()
unblock_ssh
=
popen
(
unblock_ssh_cmd
).
read
().
rstrip
()
msg
[
"
success
"
]
[
task
]
=
True
msg
[
"
success
"
]
=
True
logger
.
info
(
f
"
User
{
username
}
is added to nossh group
"
)
logger
.
info
(
f
"
User
{
username
}
is added to nossh group
"
)
except
Exception
:
except
Exception
:
msg
[
"
success
"
]
[
task
]
=
False
msg
[
"
success
"
]
=
False
msg
[
"
errmsg
"
]
=
"
Exception raised, while blocking user
'
s ssh access, check the logs for stack trace
"
msg
[
"
errmsg
"
]
=
"
Exception raised, while blocking user
'
s ssh access, check the logs for stack trace
"
logger
.
error
(
""
,
exc_info
=
True
)
logger
.
error
(
""
,
exc_info
=
True
)
# send response to callback queue with it's correlation ID
# send response to callback queue with it's correlation ID
if
reply_to
:
rc_rmq
.
publish_msg
(
rc_rmq
.
publish_msg
(
{
{
"
routing_key
"
:
reply_to
,
"
routing_key
"
:
f
'
acctmgr.done.
{
queuename
}
'
,
"
props
"
:
pika
.
BasicProperties
(
"
msg
"
:
msg
correlation_id
=
corr_id
,
}
),
)
"
msg
"
:
msg
}
)
logger
.
debug
(
f
"
User
{
username
}
confirmation sent for
{
action
}
ing
{
task
}
"
)
logger
.
debug
(
f
"
User
{
username
}
confirmation sent for
{
action
}
ing
{
task
}
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment