Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Hsin-Yu Chien
edx-platform-release
Commits
39757aa5
Unverified
Commit
39757aa5
authored
7 years ago
by
Eric Fischer
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #16906 from edx/efischer/zendesk_503
Log payload on 503 errors
parents
310279c7
fde77005
No related branches found
Branches containing commit
Tags
release-2021-02-03-12.16
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/core/djangoapps/zendesk_proxy/utils.py
+7
-7
7 additions, 7 deletions
openedx/core/djangoapps/zendesk_proxy/utils.py
with
7 additions
and
7 deletions
openedx/core/djangoapps/zendesk_proxy/utils.py
+
7
−
7
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
)
...
...
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