Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
39757aa5
Unverified
Commit
39757aa5
authored
Dec 13, 2017
by
Eric Fischer
Committed by
GitHub
Dec 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16906 from edx/efischer/zendesk_503
Log payload on 503 errors
parents
310279c7
fde77005
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
openedx/core/djangoapps/zendesk_proxy/utils.py
+7
-7
No files found.
openedx/core/djangoapps/zendesk_proxy/utils.py
View file @
39757aa5
...
...
@@ -20,9 +20,9 @@ def create_zendesk_ticket(requester_name, requester_email, subject, body, tags=N
common/djangoapps/util/views.py). Both of those callers use basic auth, and should be switched over to this oauth
implementation once the immediate pressures of zendesk_proxy are resolved.
"""
if
not
(
settings
.
ZENDESK_URL
and
settings
.
ZENDESK_OAUTH_ACCESS_TOKEN
):
log
.
debug
(
'Zendesk is not configured. Cannot create a ticket.'
)
return
status
.
HTTP_503_SERVICE_UNAVAILABLE
def
_std_error_message
(
details
,
payload
):
"""Internal helper to standardize error message. This allows for simpler splunk alerts."""
return
'zendesk_proxy action required
\n
{}
\n
No ticket created for payload {}'
.
format
(
details
,
payload
)
# Remove duplicates from tags list
tags
=
list
(
set
(
tags
))
...
...
@@ -42,6 +42,10 @@ def create_zendesk_ticket(requester_name, requester_email, subject, body, tags=N
# Encode the data to create a JSON payload
payload
=
json
.
dumps
(
data
)
if
not
(
settings
.
ZENDESK_URL
and
settings
.
ZENDESK_OAUTH_ACCESS_TOKEN
):
log
.
error
(
_std_error_message
(
"zendesk not configured"
,
payload
))
return
status
.
HTTP_503_SERVICE_UNAVAILABLE
# Set the request parameters
url
=
urljoin
(
settings
.
ZENDESK_URL
,
'/api/v2/tickets.json'
)
headers
=
{
...
...
@@ -49,10 +53,6 @@ def create_zendesk_ticket(requester_name, requester_email, subject, body, tags=N
'Authorization'
:
"Bearer {}"
.
format
(
settings
.
ZENDESK_OAUTH_ACCESS_TOKEN
),
}
def
_std_error_message
(
details
,
payload
):
"""Internal helper to standardize error message. This allows for simpler splunk alerts."""
return
'zendesk_proxy action required
\n
{}
\n
No ticket created for payload {}'
.
format
(
details
,
payload
)
try
:
response
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment