Skip to content

Commit

Permalink
feat(influxdb): upgrade to influxdb 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
duanhongyi committed Dec 17, 2020
1 parent a8227ee commit 658fac1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
20 changes: 10 additions & 10 deletions charts/controller/templates/controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,25 @@ spec:
secretKeyRef:
name: influxdb-creds
key: url
- name: "INFLUXDB_DATABASE"
{{- else }}
- name: "INFLUXDB_URL"
value: http://$(DRYCC_INFLUXDB_SERVICE_HOST):$(DRYCC_INFLUXDB_SERVICE_PORT_TRANSPORT)
{{- end }}
- name: "INFLUXDB_BUCKET"
valueFrom:
secretKeyRef:
name: influxdb-creds
key: database
- name: "INFLUXDB_USER"
key: bucket
- name: "INFLUXDB_ORG"
valueFrom:
secretKeyRef:
name: influxdb-creds
key: user
- name: "INFLUXDB_PASSWORD"
key: org
- name: "INFLUXDB_TOKEN"
valueFrom:
secretKeyRef:
name: influxdb-creds
key: password
{{- else }}
- name: "INFLUXDB_URL"
value: http://$(DRYCC_INFLUXDB_SERVICE_HOST):$(DRYCC_INFLUXDB_SERVICE_PORT_TRANSPORT)
{{- end }}
key: token
{{- range $key, $value := .Values.environment }}
- name: {{ $key }}
value: {{ $value | quote }}
Expand Down
2 changes: 1 addition & 1 deletion rootfs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-alpine
FROM python:3.8-alpine

COPY requirements.txt /app/requirements.txt

Expand Down
2 changes: 1 addition & 1 deletion rootfs/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-alpine
FROM python:3.8-alpine

COPY requirements.txt /app/requirements.txt
COPY dev_requirements.txt /app/dev_requirements.txt
Expand Down
6 changes: 3 additions & 3 deletions rootfs/api/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,6 @@

# Influxdb Configuration Options
INFLUXDB_URL = os.environ.get('DRYCC_INFLUXDB_URL', 'http://localhost:8086')
INFLUXDB_DATABASE = os.environ.get('DRYCC_INFLUXDB_DATABASE', 'drycc')
INFLUXDB_USER = os.environ.get('DRYCC_INFLUXDB_USER', 'root')
INFLUXDB_PASSWORD = os.environ.get('DRYCC_INFLUXDB_PASSWORD', 'root')
INFLUXDB_BUCKET = os.environ.get('DRYCC_INFLUXDB_BUCKET', 'drycc')
INFLUXDB_ORG = os.environ.get('DRYCC_INFLUXDB_ORG', 'root')
INFLUXDB_TOKEN = os.environ.get('DRYCC_INFLUXDB_TOKEN', 'root')
17 changes: 4 additions & 13 deletions rootfs/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import random
import threading
from copy import deepcopy
from urllib.parse import urlparse
from django.conf import settings
from influxdb import InfluxDBClient

from influxdb_client import InfluxDBClient

local = threading.local()
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -168,17 +166,10 @@ def apply_tasks(tasks):

def get_influxdb_client():
if not hasattr(local, "influxdb_client"):
addr = urlparse(settings.INFLUXDB_URL).netloc
if ":" in addr:
host, port = addr.rsplit(":")
else:
host, port = addr, 8086
local.influxdb_client = InfluxDBClient(
host,
port,
settings.INFLUXDB_USER,
settings.INFLUXDB_PASSWORD,
settings.INFLUXDB_DATABASE
url=settings.INFLUXDB_URL,
token=settings.INFLUXDB_TOKEN,
org=settings.INFLUXDB_ORG
)
return local.influxdb_client

Expand Down
2 changes: 1 addition & 1 deletion rootfs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ requests==2.24.0
requests-toolbelt==0.9.1
celery==5.0.2
django_redis==4.12.1
influxdb==5.3.1
influxdb-client==1.13.0

0 comments on commit 658fac1

Please sign in to comment.