Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snseventd
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OTDI Middleware
snseventd
Commits
7365034d
Commit
7365034d
authored
4 years ago
by
Edward Hicks
Browse files
Options
Downloads
Patches
Plain Diff
determine ec2 instance id instead of node's dns name - it's safer to
reference
parent
a354b079
No related branches found
No related tags found
No related merge requests found
Pipeline
#92209
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snseventd.py
+15
-6
15 additions, 6 deletions
snseventd.py
with
15 additions
and
6 deletions
snseventd.py
+
15
−
6
View file @
7365034d
...
...
@@ -184,7 +184,7 @@ args = parser.parse_args()
ret
=
1
# init as a failure code
logFile
=
False
Session
=
{}
Session
[
'
nodename
'
]
=
str
(
os
.
uname
().
nodename
.
split
(
'
.
'
)[
0
])
Session
[
'
ec2id
'
]
=
"
This is the actual EC2 instance name (i-blahblahblah)
"
Config
=
{}
Config
[
'
debug
'
]
=
False
...
...
@@ -319,6 +319,17 @@ except Exception as e:
sys
.
exit
(
ret
)
# Get the EC2 session ID for this node
printLog
(
"
Retrieving EC2 instance ID
"
,
loglevels
.
INFO
)
try
:
Session
[
'
ec2
'
]
=
boto3
.
resource
(
'
ec2
'
)
Session
[
'
ec2id
'
]
=
str
(
Session
[
'
ec2
'
].
Instance
(
'
id
'
))
except
Exception
as
e
:
printLog
(
e
)
cleanup
()
sys
.
exit
(
ret
)
printLog
(
"
This instance is
"
+
Session
[
'
ec2id
'
],
loglevels
.
DEBUG
)
# Retrieve the account number from the session so we can build arns
printLog
(
"
Retrieving account info for generating ARNs
"
,
loglevels
.
INFO
)
try
:
...
...
@@ -335,7 +346,7 @@ except Exception as e:
# Create an SQS queue to subscribe to the SNS topic
Session
[
'
queue
'
]
=
Config
[
'
sqsQueuePrefix
'
]
+
Session
[
'
nodename
'
]
Session
[
'
queue
'
]
=
Config
[
'
sqsQueuePrefix
'
]
+
str
(
os
.
uname
().
nodename
.
split
(
'
.
'
)[
0
])
printLog
(
"
Creating SQS queue
"
+
Session
[
'
queue
'
],
loglevels
.
INFO
)
try
:
Session
[
'
sqs
'
]
=
Session
[
'
boto3
'
].
client
(
'
sqs
'
)
...
...
@@ -440,16 +451,14 @@ while True:
raise
Exception
(
"
Invalid JSON in message body
"
)
# TODO: Add crypto signing support to verify message's origin
# TODO: Add crypto signing support to verify message's origin
# Verify the message is sane
sanityCheckMessage
(
body
,
payload
)
# Only proceed if the message is meant for either everyone or us explicitly
if
'
*
'
not
in
payload
[
'
nodes
'
]
and
Session
[
'
nodename
'
]
not
in
payload
[
'
nodes
'
]:
if
'
*
'
not
in
payload
[
'
nodes
'
]
and
Session
[
'
ec2id
'
]
not
in
payload
[
'
nodes
'
]:
printLog
(
"
Message not meant for us - ignoring it
"
,
loglevels
.
DEBUG
)
continue
...
...
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