Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7a8c6a9b
Unverified
Commit
7a8c6a9b
authored
Nov 18, 2019
by
Jon Gyllenswärd
Committed by
GitHub
Nov 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reporting: Handle timeouts in rendering (#20415)
* Added timeout in grpc call to plugins for rendering
parent
e7e416cf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
pkg/api/render.go
+2
-1
pkg/services/rendering/interface.go
+3
-1
pkg/services/rendering/plugin_mode.go
+3
-0
pkg/services/rendering/rendering.go
+12
-3
No files found.
pkg/api/render.go
View file @
7a8c6a9b
...
...
@@ -40,6 +40,7 @@ func (hs *HTTPServer) RenderToPng(c *m.ReqContext) {
return
}
maxConcurrentLimitForApiCalls
:=
30
result
,
err
:=
hs
.
RenderService
.
Render
(
c
.
Req
.
Context
(),
rendering
.
Opts
{
Width
:
width
,
Height
:
height
,
...
...
@@ -50,7 +51,7 @@ func (hs *HTTPServer) RenderToPng(c *m.ReqContext) {
Path
:
c
.
Params
(
"*"
)
+
queryParams
,
Timezone
:
queryReader
.
Get
(
"tz"
,
""
),
Encoding
:
queryReader
.
Get
(
"encoding"
,
""
),
ConcurrentLimit
:
30
,
ConcurrentLimit
:
maxConcurrentLimitForApiCalls
,
})
if
err
!=
nil
&&
err
==
rendering
.
ErrTimeout
{
...
...
pkg/services/rendering/interface.go
View file @
7a8c6a9b
...
...
@@ -26,11 +26,13 @@ type Opts struct {
}
type
RenderResult
struct
{
FilePath
string
FilePath
string
KeepFileAfterRender
bool
}
type
renderFunc
func
(
ctx
context
.
Context
,
options
Opts
)
(
*
RenderResult
,
error
)
type
Service
interface
{
Render
(
ctx
context
.
Context
,
opts
Opts
)
(
*
RenderResult
,
error
)
RenderErrorImage
(
error
error
)
(
*
RenderResult
,
error
)
}
pkg/services/rendering/plugin_mode.go
View file @
7a8c6a9b
...
...
@@ -63,6 +63,9 @@ func (rs *RenderingService) renderViaPlugin(ctx context.Context, opts Opts) (*Re
return
nil
,
err
}
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
opts
.
Timeout
)
defer
cancel
()
rsp
,
err
:=
rs
.
grpcPlugin
.
Render
(
ctx
,
&
pluginModel
.
RenderRequest
{
Url
:
rs
.
getURL
(
opts
.
Path
),
Width
:
int32
(
opts
.
Width
),
...
...
pkg/services/rendering/rendering.go
View file @
7a8c6a9b
...
...
@@ -3,12 +3,11 @@ package rendering
import
(
"context"
"fmt"
plugin
"github.com/hashicorp/go-plugin"
"net/url"
"os"
"path/filepath"
plugin
"github.com/hashicorp/go-plugin"
pluginModel
"github.com/grafana/grafana-plugin-model/go/renderer"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/middleware"
...
...
@@ -93,10 +92,20 @@ func (rs *RenderingService) Run(ctx context.Context) error {
return
err
}
func
(
rs
*
RenderingService
)
RenderErrorImage
(
err
error
)
(
*
RenderResult
,
error
)
{
imgUrl
:=
"public/img/rendering_error.png"
return
&
RenderResult
{
FilePath
:
filepath
.
Join
(
setting
.
HomePath
,
imgUrl
),
KeepFileAfterRender
:
true
,
},
nil
}
func
(
rs
*
RenderingService
)
Render
(
ctx
context
.
Context
,
opts
Opts
)
(
*
RenderResult
,
error
)
{
if
rs
.
inProgressCount
>
opts
.
ConcurrentLimit
{
return
&
RenderResult
{
FilePath
:
filepath
.
Join
(
setting
.
HomePath
,
"public/img/rendering_limit.png"
),
FilePath
:
filepath
.
Join
(
setting
.
HomePath
,
"public/img/rendering_limit.png"
),
KeepFileAfterRender
:
true
,
},
nil
}
...
...
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