You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by tu...@apache.org on 2020/12/12 21:13:23 UTC
[kibble] branch main updated: Fix broken Kibble (#106)
This is an automated email from the ASF dual-hosted git repository.
turbaszek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/kibble.git
The following commit(s) were added to refs/heads/main by this push:
new e437790 Fix broken Kibble (#106)
e437790 is described below
commit e4377906ea344a89324692c94dbe06982bef109c
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Sat Dec 12 21:13:15 2020 +0000
Fix broken Kibble (#106)
Before this commit I got this error when running Kibble locally:
This was because https://github.com/apache/kibble/pull/83 replaced kibble.yaml with kibble.ini
This PR reads the config from `kibble.ini`.
This also adds a network to docker-compose file without which I was getting host not found error.
---
docker-compose-dev.yaml | 17 +++++++++++++++++
kibble/api/handler.py | 13 ++++---------
kibble/api/plugins/database.py | 23 +++++++----------------
3 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml
index 3e67c36..d4d8b88 100644
--- a/docker-compose-dev.yaml
+++ b/docker-compose-dev.yaml
@@ -1,5 +1,9 @@
version: '3'
+networks:
+ kibble:
+ driver: bridge
+
services:
# Helper service to setup the Apache Kibble es node
setup:
@@ -12,6 +16,8 @@ services:
- .:/kibble/
depends_on:
- elasticsearch
+ networks:
+ - kibble
# Apache Kibble API server
kibble:
@@ -25,6 +31,8 @@ services:
- .:/kibble/
depends_on:
- elasticsearch
+ networks:
+ - kibble
# Apache Kibble web ui server
ui:
@@ -36,6 +44,8 @@ services:
- 8000:8000
depends_on:
- kibble
+ networks:
+ - kibble
# Elasticsearch node required as a database for Apache Kibble
elasticsearch:
@@ -51,6 +61,8 @@ services:
ES_JAVA_OPTS: -Xms256m -Xmx256m
volumes:
- "kibble-es-data:/usr/share/elasticsearch/data"
+ networks:
+ - kibble
# Kibana to view and manage Elasticsearch
kibana:
@@ -59,6 +71,11 @@ services:
- 5601:5601
depends_on:
- elasticsearch
+ environment:
+ ELASTICSEARCH_URL: http://elasticsearch:9200
+ ELASTICSEARCH_HOSTS: http://elasticsearch:9200
+ networks:
+ - kibble
volumes:
# named volumes can be managed easier using docker-compose
diff --git a/kibble/api/handler.py b/kibble/api/handler.py
index d409b54..8384d18 100644
--- a/kibble/api/handler.py
+++ b/kibble/api/handler.py
@@ -27,12 +27,11 @@ import re
import sys
import traceback
-import yaml
-
from kibble.api.plugins import openapi
from kibble.api.plugins.database import KibbleDatabase
from kibble.api.plugins.session import KibbleSession
-from kibble.settings import KIBBLE_YAML, YAML_DIRECTORY
+from kibble.configuration import conf
+from kibble.settings import YAML_DIRECTORY
# Compile valid API URLs from the pages library
# Allow backwards compatibility by also accepting .lua URLs
@@ -45,10 +44,6 @@ if __name__ != "__main__":
urls.append((r"^(/api/%s)(/.+)?$" % page, handler.run))
-# Load Kibble master configuration
-with open(KIBBLE_YAML, "r") as f:
- config = yaml.safe_load(f)
-
# Instantiate database connections
DB = None
@@ -156,13 +151,13 @@ def application(environ, start_response):
Checks against the pages library, and if submod found, runs
it and returns the output.
"""
- db = KibbleDatabase(config)
+ db = KibbleDatabase(conf)
path = environ.get("PATH_INFO", "")
for regex, function in urls:
m = re.match(regex, path)
if m:
callback = KibbleAPIWrapper(path, function)
- session = KibbleSession(db, environ, config)
+ session = KibbleSession(db, environ, conf)
a = 0
for bucket in callback(environ, start_response, session):
if a == 0:
diff --git a/kibble/api/plugins/database.py b/kibble/api/plugins/database.py
index fb1a9fa..5746721 100644
--- a/kibble/api/plugins/database.py
+++ b/kibble/api/plugins/database.py
@@ -22,6 +22,8 @@ It stores the elasticsearch handler and config options.
import elasticsearch
+from kibble.configuration import KibbleConfigParser
+
class KibbleESWrapper(object):
"""
@@ -119,24 +121,13 @@ class KibbleESWrapperSeven(object):
class KibbleDatabase(object):
- def __init__(self, config):
+ def __init__(self, config: KibbleConfigParser):
self.config = config
- self.dbname = config["elasticsearch"]["dbname"]
+ self.dbname = config.get("elasticsearch", "dbname")
self.ES = elasticsearch.Elasticsearch(
- [
- {
- "host": config["elasticsearch"]["host"],
- "port": int(config["elasticsearch"]["port"]),
- "use_ssl": config["elasticsearch"]["ssl"],
- "verify_certs": False,
- "url_prefix": config["elasticsearch"]["uri"]
- if "uri" in config["elasticsearch"]
- else "",
- "http_auth": config["elasticsearch"]["auth"]
- if "auth" in config["elasticsearch"]
- else None,
- }
- ],
+ [config.get("elasticsearch", "conn_uri")],
+ use_ssl=config.getboolean("elasticsearch", "ssl"),
+ verify_certs=False,
max_retries=5,
retry_on_timeout=True,
)