Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lmenezes authored Jun 20, 2018
2 parents 601f5fc + d57ae28 commit a1ee936
Show file tree
Hide file tree
Showing 61 changed files with 1,655 additions and 642 deletions.
56 changes: 37 additions & 19 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
Cerebro Releases
------------

###v0.1.0 - July 14th, 2016
### v0.1.0 - July 14th, 2016

First cerebro release.

####Features
#### Features
- cluster overview
- rest client
- aliases management
- index creation

###v0.2.0 - August 25th, 2016
### v0.2.0 - August 25th, 2016

#### New features
- analysis api
- index template api
- cluster settings api
- notify regarding created/deleted indices and joining/leaving nodes

###v0.3.0 - November 3rd, 2016
### v0.3.0 - November 3rd, 2016

#### Bug fixes
- rest client format body button
Expand All @@ -31,12 +31,12 @@ First cerebro release.
#### New features
- added index settings module

###v0.3.1 - November 17th, 2016
### v0.3.1 - November 17th, 2016

#### Bug fixes
- displayed node roles

###v0.4.0 - December 2nd, 2016
### v0.4.0 - December 2nd, 2016

#### Bug fixes
- fix favicon for
Expand All @@ -50,12 +50,12 @@ First cerebro release.
- copy to curl to rest client
- repositories / snapshots module

###v0.4.1 - December 6th, 2016
### v0.4.1 - December 6th, 2016

#### Bug fixes
- fix indices selection on snapshot creation

###v0.4.2 - January 4th, 2017
### v0.4.2 - January 4th, 2017

#### Bug fixes
- fixed issue that prevent alias removal
Expand All @@ -66,15 +66,15 @@ First cerebro release.
- support edit index template
- added cat module

###v0.5.0 - January 19th, 2017
### v0.5.0 - January 19th, 2017

#### Bug fixes
- fixed stuck shard state

#### New features
- added authentication support

###v0.5.1 - February 11th, 2017
### v0.5.1 - February 11th, 2017

#### Enhancements
- consistent node sorting on cluster overview
Expand All @@ -84,7 +84,7 @@ First cerebro release.
- avoid parsing errors when ES requests fail
- fixes select shard for relocation menu entry

###v0.6.0 - March 9th, 2017
### v0.6.0 - March 9th, 2017

#### Enhancements
- support aws clusters
Expand All @@ -96,13 +96,13 @@ First cerebro release.
- support rest client history
- nodes module

###v0.6.1 - March 10th, 2017
### v0.6.1 - March 10th, 2017

#### Bug fixes
- correct play.i18n.langs format
- set an application.home default

###v0.6.2 - March 21st, 2017
### v0.6.2 - March 21st, 2017

#### Bug fixes
- consider initializing/relocating/unassigned shards as unhealthy
Expand All @@ -119,7 +119,7 @@ First cerebro release.
- support for custom base path
- added index stats action to overview

###v0.6.3 - March 22nd, 2017
### v0.6.3 - March 22nd, 2017

#### Bug fixes
- fixed node stats danger indication in overview
Expand All @@ -136,7 +136,7 @@ First cerebro release.
#### Enhancements
- support indices with special characters (for ES < 2.X))

###v0.6.5 - April 6th, 2017
### v0.6.5 - April 6th, 2017

#### Bug fixes
- logout action to use relative path
Expand All @@ -162,7 +162,7 @@ First cerebro release.
- display single alias on overview
- improve performance of overview index filtering

###v0.6.7 - September 23rd, 2017
### v0.6.7 - September 23rd, 2017

#### Bug fixes
- use correct host when copying rest request for curl
Expand Down Expand Up @@ -190,7 +190,7 @@ First cerebro release.
- display alias filter/routing on aliases listing
- support linux aarch64 (https://github.com/lmenezes/cerebro/issues/207)

###v0.7.0 - October 13th, 2017
### v0.7.0 - October 13th, 2017

#### Bug fixes
- fixed rest url autocompletion
Expand All @@ -203,7 +203,7 @@ First cerebro release.
- gzip enabled for all api calls
- avoid piling up of slow requests

###v0.7.1 - October 17th, 2017
### v0.7.1 - October 17th, 2017

#### Bug fixes
- fixes mass actions on selected indices
Expand All @@ -214,8 +214,26 @@ First cerebro release.
- optimised ES response parsing
- dropped internal usage of _cat apis in favor of faster alternatives

###v0.7.2 - November 28th, 2017
### v0.7.2 - November 28th, 2017

#### Bug fixes
- fixes unhealty indices filter
- analyse module to work with ES 6.X

###v0.7.3 - April 14th, 2018

### New features
- allow saving cluster settings as persistent/transient

#### Bug fixes
- fix index and repo sorting in snapshot module #236
- fixes missing initializing shard when relocating shard #250
- fix restoring snapshots with dots on name #254
- ignore_unavailable indices for overview stats #247

###v0.8.0 - June 20th, 2018

### New features
- cluster status text added to navbar and tab title
- available cluster/index settings now read from ES
- added dockerfile and published to dockerhub
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM openjdk:8-jre

ENV CEREBRO_VERSION 0.7.3
RUN cd /opt/ \
&& wget -O cerebro-${CEREBRO_VERSION}.tgz https://github.com/lmenezes/cerebro/releases/download/v${CEREBRO_VERSION}/cerebro-${CEREBRO_VERSION}.tgz \
&& tar zxvf cerebro-${CEREBRO_VERSION}.tgz \
&& rm cerebro-${CEREBRO_VERSION}.tgz \
&& mkdir cerebro-${CEREBRO_VERSION}/logs \
&& mv cerebro-${CEREBRO_VERSION} cerebro

WORKDIR /opt/cerebro
EXPOSE 9000
CMD ["./bin/cerebro"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Leonardo Menezes

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ cerebro needs Java 1.8 or newer to run.
- Run bin/cerebro(or bin/cerebro.bat if on Windows)
- Access on http://localhost:9000

### Docker image

- Build docker image: `docker build -t cerebro:development .`
- Run the image: `docker run --rm -it -p 9000:9000 cerebro:development`

### Configuration

#### HTTP server address and port
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package controllers

import com.google.inject.Inject
import controllers.auth.AuthenticationModule
import play.api.mvc.Controller
import play.api.mvc.InjectedController

class Application @Inject()(val authentication: AuthenticationModule) extends Controller with AuthSupport {
class Application @Inject()(val authentication: AuthenticationModule) extends InjectedController with AuthSupport {

def index = AuthAction(authentication, true) { request =>
def index = AuthAction(authentication, true)(defaultExecutionContext) { request =>
Ok(views.html.Index())
}

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/AuthController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import akka.actor.ActorSystem
import controllers.auth.{AuthAction, AuthenticationModule}
import forms.LoginForm
import play.api.Configuration
import play.api.mvc.{Action, Controller}
import play.api.mvc.InjectedController


@Singleton
class AuthController @Inject()(system: ActorSystem,
authentication: AuthenticationModule,
configuration: Configuration)
extends Controller {
extends InjectedController {

import AuthController._

Expand Down Expand Up @@ -60,7 +60,7 @@ class AuthController @Inject()(system: ActorSystem,
}

def logout = Action { _ =>
val prefix = configuration.getString("play.http.context").getOrElse("/")
val prefix = configuration.getOptional[String]("play.http.context").getOrElse("/")
Redirect(s"${prefix}login").withNewSession
}

Expand Down
10 changes: 6 additions & 4 deletions app/controllers/AuthSupport.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package controllers

import controllers.auth.{AuthAction, AuthenticationModule}
import play.api.mvc.Controller
import play.api.mvc.InjectedController

trait AuthSupport { self: Controller =>
import scala.concurrent.ExecutionContext

def AuthAction(authentication: AuthenticationModule, redirect: Boolean = false): AuthAction =
new AuthAction(authentication, redirect)
trait AuthSupport { self: InjectedController =>

def AuthAction(authentication: AuthenticationModule, redirect: Boolean = false)(implicit ec: ExecutionContext): AuthAction =
new AuthAction(authentication, redirect, parse.anyContent)

}
4 changes: 2 additions & 2 deletions app/controllers/BaseController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import exceptions.MissingRequiredParamException
import models.{CerebroRequest, CerebroResponse, Hosts}
import play.api.Logger
import play.api.libs.json.{JsValue, Json}
import play.api.mvc.{Controller, Result}
import play.api.mvc.{Controller, InjectedController, Result}
import services.exception.RequestFailedException

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.util.control.NonFatal

trait BaseController extends Controller with AuthSupport {
trait BaseController extends InjectedController with AuthSupport {

val authentication: AuthenticationModule

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/ConnectController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import controllers.auth.AuthenticationModule
import elastic.ElasticClient
import models.{CerebroRequest, CerebroResponse, Hosts}
import play.api.libs.json.{JsArray, JsString}
import play.api.mvc.Controller
import play.api.mvc.InjectedController

import scala.concurrent.ExecutionContext.Implicits.global

class ConnectController @Inject()(val authentication: AuthenticationModule,
elastic: ElasticClient,
hosts: Hosts) extends Controller with AuthSupport {
hosts: Hosts) extends InjectedController with AuthSupport {

def index = AuthAction(authentication) { _ =>
def index = AuthAction(authentication)(defaultExecutionContext) { _ =>
CerebroResponse(200, JsArray(hosts.getHostNames().map(JsString(_))))
}

def connect = AuthAction(authentication).async(parse.json) { request =>
def connect = AuthAction(authentication)(defaultExecutionContext).async(parse.json) { request =>
val req = CerebroRequest(request, hosts)
elastic.executeRequest("GET", "_cluster/health", None, req.target).map {
response => CerebroResponse(response.status, response.body)
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/auth/AuthAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import models.{CerebroResponse, User}
import play.api.libs.json.JsNull
import play.api.mvc._

import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}

class AuthRequest[A](val user: Option[User], request: Request[A]) extends WrappedRequest[A](request)

final class AuthAction(auth: AuthenticationModule, redirect: Boolean) extends ActionBuilder[AuthRequest] {
final class AuthAction(auth: AuthenticationModule, redirect: Boolean, override val parser: BodyParser[AnyContent])(implicit ec: ExecutionContext)
extends ActionBuilder[AuthRequest, AnyContent] {

def invokeBlock[A](request: Request[A], block: (AuthRequest[A]) => Future[Result]) = {
if (auth.isEnabled) {
Expand All @@ -29,6 +30,7 @@ final class AuthAction(auth: AuthenticationModule, redirect: Boolean) extends Ac
}
}

override protected def executionContext: ExecutionContext = ec
}

object AuthAction {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/AuthConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import play.api.Configuration
trait AuthConfig {

def getSetting(setting: String)(implicit config: Configuration) = {
config.getString(setting).getOrElse(throw MissingSettingException(setting))
config.getOptional[String](setting).getOrElse(throw MissingSettingException(setting))
}

}
2 changes: 1 addition & 1 deletion app/controllers/auth/AuthenticationModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait AuthenticationModule {
@Singleton
class AuthenticationModuleImpl @Inject()(config: Configuration) extends AuthenticationModule {

val service = config.getString("auth.type") match {
val service = config.getOptional[String]("auth.type") match {
case Some("ldap") => Some(new LDAPAuthService(config))
case Some("basic") => Some(new BasicAuthService(config))
case _ => None
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/basic/BasicAuthService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import play.api.Configuration

class BasicAuthService @Inject()(globalConfig: Configuration) extends AuthService {

private implicit final val config = new BasicAuthConfig(globalConfig.getConfig("auth.settings").get)
private implicit final val config = new BasicAuthConfig(globalConfig.get[Configuration]("auth.settings"))

def auth(username: String, password: String): Option[String] = {
(username, password) match {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/ldap/LDAPAuthService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LDAPAuthService @Inject()(globalConfig: Configuration) extends AuthService

private val log = org.slf4j.LoggerFactory.getLogger(classOf[LDAPAuthService])

private final val config = new LDAPAuthConfig(globalConfig.getConfig("auth.settings").get)
private final val config = new LDAPAuthConfig(globalConfig.get[Configuration]("auth.settings"))

def auth(username: String, password: String): Option[String] = {
val env = new Hashtable[String, String](11)
Expand Down
Loading

0 comments on commit a1ee936

Please sign in to comment.