Add OOC check and error on new session creation
This commit is contained in:
@@ -57,6 +57,12 @@ func Register() {
|
|||||||
corsRouter.HandleFunc("/sessions/{sessionId}/instances/{instanceName}", DeleteInstance).Methods("DELETE")
|
corsRouter.HandleFunc("/sessions/{sessionId}/instances/{instanceName}", DeleteInstance).Methods("DELETE")
|
||||||
corsRouter.HandleFunc("/sessions/{sessionId}/instances/{instanceName}/exec", Exec).Methods("POST")
|
corsRouter.HandleFunc("/sessions/{sessionId}/instances/{instanceName}/exec", Exec).Methods("POST")
|
||||||
|
|
||||||
|
r.HandleFunc("/ooc", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
http.ServeFile(rw, r, "./www/ooc.html")
|
||||||
|
}).Methods("GET")
|
||||||
|
r.HandleFunc("/503", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
http.ServeFile(rw, r, "./www/503.html")
|
||||||
|
}).Methods("GET")
|
||||||
r.HandleFunc("/p/{sessionId}", Home).Methods("GET")
|
r.HandleFunc("/p/{sessionId}", Home).Methods("GET")
|
||||||
r.PathPrefix("/assets").Handler(http.FileServer(http.Dir("./www")))
|
r.PathPrefix("/assets").Handler(http.FileServer(http.Dir("./www")))
|
||||||
r.HandleFunc("/robots.txt", func(rw http.ResponseWriter, r *http.Request) {
|
r.HandleFunc("/robots.txt", func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/play-with-docker/play-with-docker/config"
|
"github.com/play-with-docker/play-with-docker/config"
|
||||||
|
"github.com/play-with-docker/play-with-docker/provisioner"
|
||||||
"github.com/play-with-docker/play-with-docker/recaptcha"
|
"github.com/play-with-docker/play-with-docker/recaptcha"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -46,7 +47,13 @@ func NewSession(rw http.ResponseWriter, req *http.Request) {
|
|||||||
duration := config.GetDuration(reqDur)
|
duration := config.GetDuration(reqDur)
|
||||||
s, err := core.SessionNew(duration, stack, stackName, imageName)
|
s, err := core.SessionNew(duration, stack, stackName, imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if provisioner.OutOfCapacity(err) {
|
||||||
|
http.Redirect(rw, req, "/ooc", http.StatusFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
http.Redirect(rw, req, "/500", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
//TODO: Return some error code
|
//TODO: Return some error code
|
||||||
} else {
|
} else {
|
||||||
hostname := req.Host
|
hostname := req.Host
|
||||||
|
|||||||
33
www/503.html
Normal file
33
www/503.html
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html ng-app="DockerPlay" ng-controller="PlayController">
|
||||||
|
<head>
|
||||||
|
<title>Docker Playground</title>
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic|Material+Icons" />
|
||||||
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
|
||||||
|
<link rel="stylesheet" href="/assets/style.css" />
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||||
|
ga('create', 'UA-89019737-1', 'auto');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout="column" style="height:100%;">
|
||||||
|
An error has occured. If you have some time, please report it. Thanks!
|
||||||
|
</div>
|
||||||
|
<script
|
||||||
|
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||||
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
33
www/ooc.html
Normal file
33
www/ooc.html
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html ng-app="DockerPlay" ng-controller="PlayController">
|
||||||
|
<head>
|
||||||
|
<title>Docker Playground</title>
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic|Material+Icons" />
|
||||||
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
|
||||||
|
<link rel="stylesheet" href="/assets/style.css" />
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||||
|
ga('create', 'UA-89019737-1', 'auto');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout="column" style="height:100%;">
|
||||||
|
We are really sorry but we are out of capacity and cannot create your session at the moment. Please try again later.
|
||||||
|
</div>
|
||||||
|
<script
|
||||||
|
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||||
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
Reference in New Issue
Block a user