Skip to content

Commit 004f62f

Browse files
authored
Merge pull request #16 from Cryptophobia/master
ref(azure): start using new azure storage BlobServiceClient
2 parents 2a3ae35 + bcaab90 commit 004f62f

File tree

7 files changed

+26
-20
lines changed

7 files changed

+26
-20
lines changed

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ ENV WALE_ENVDIR /etc/wal-e.d/env
55
ENV PGDATA_RECOVERY /var/lib/postgresql/recovery
66

77
RUN mkdir -p $WALE_ENVDIR $PGDATA_RECOVERY \
8-
&& echo 'http://dl-cdn.alpinelinux.org/alpine/v3.5/main' >> /etc/apk/repositories \
98
&& apk add --update --virtual .build-deps \
109
git \
1110
build-base \
12-
libffi-dev \
1311
openssl-dev \
14-
python3-dev=3.5.6-r0 \
12+
libffi-dev \
13+
python3-dev \
1514
linux-headers \
1615
&& apk add \
1716
lzo \
1817
pv \
1918
util-linux \
2019
ca-certificates \
21-
python3=3.5.6-r0 \
20+
python3 \
21+
py-pip \
2222
&& pip3 install --upgrade pip setuptools \
2323
&& pip install --disable-pip-version-check --no-cache-dir \
24-
psycopg2-binary==2.7.6.1 \
24+
psycopg2-binary==2.8.4 \
2525
envdir==1.0.1 \
26-
wal-e[aws,azure,google,swift]==1.1.0 \
26+
wal-e[aws,azure,google,swift]==1.1.1 \
2727
gcloud==0.18.3 \
2828
oauth2client==4.1.3 \
29-
azure-storage==0.20.0 \
29+
azure-storage-blob==12.5.0 \
3030
&& apk del .build-deps \
3131
&& rm -rf /var/cache/apk/*
3232

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# - Kubernetes service, rc, pod, secret, volume names
55
SHORT_NAME := postgres
66
DEIS_REGISTY ?= ${DEV_REGISTRY}/
7-
IMAGE_PREFIX ?= deis
7+
IMAGE_PREFIX ?= hephy
88

99
include versioning.mk
1010

1111
SHELL_SCRIPTS = $(wildcard _scripts/*.sh contrib/ci/*.sh rootfs/bin/*backup rootfs/bin/do_upgrade) rootfs/bin/is_running
1212

1313
# The following variables describe the containerized development environment
1414
# and other build options
15-
DEV_ENV_IMAGE := quay.io/deis/go-dev:0.20.0
15+
DEV_ENV_IMAGE := hephy/go-dev:v1.28.3
1616
DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
1717
DEV_ENV_CMD := docker run --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}
1818
DEV_ENV_CMD_INT := docker run -it --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_IMAGE}

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
Hephy - A Fork of Deis Workflow
55

6-
[![Build Status](https://ci.deis.io/job/postgres/badge/icon)](https://ci.deis.io/job/postgres)
76
[![Docker Repository on Quay](https://quay.io/repository/deis/postgres/status "Docker Repository on Quay")](https://quay.io/repository/deis/postgres)
87

98
Deis (pronounced DAY-iss) Workflow is an open source Platform as a Service (PaaS) that adds a developer-friendly layer to any [Kubernetes](http://kubernetes.io) cluster, making it easy to deploy and manage applications on your own servers.

charts/database/Chart.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
name: database
22
home: https://github.com/teamhephy/postgres
33
version: <Will be populated by the ci before publishing the chart>
4-
description: A PostgreSQL database used by Deis Workflow.
4+
description: A PostgreSQL database used by Hephy Workflow.
55
keywords:
66
- database
77
- postgres
88
maintainers:
9-
- name: Deis Team
10-
email: engineering@deis.com
9+
- email: team@teamhephy.com

contrib/ci/test-minio.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ MINIO_JOB=$(docker run -d \
4646
-v "${CURRENT_DIR}"/tmp/aws-admin:/var/run/secrets/deis/minio/admin \
4747
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/deis/minio/user \
4848
-v "${CURRENT_DIR}"/tmp/k8s:/var/run/secrets/kubernetes.io/serviceaccount \
49-
quay.io/deisci/minio:canary boot server /home/minio/)
49+
hephy/minio:latest boot server /home/minio/)
5050

5151
# boot postgres, linking the minio container and setting DEIS_MINIO_SERVICE_HOST and DEIS_MINIO_SERVICE_PORT
5252
PG_CMD="docker run -d --link ${MINIO_JOB}:minio -e PGCTLTIMEOUT=1200 \

rootfs/bin/create_bucket

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ from boto.s3.connection import S3Connection, OrdinaryCallingFormat
1111
from oauth2client.service_account import ServiceAccountCredentials
1212
from gcloud.storage.client import Client
1313
from gcloud import exceptions
14-
from azure.storage.blob import BlobService
14+
from azure.storage.blob import BlobServiceClient
15+
1516

1617
def bucket_exists(conn, name):
1718
bucket = conn.lookup(name)
1819
if not bucket:
1920
return False
2021
return True
2122

23+
2224
bucket_name = os.getenv('BUCKET_NAME')
2325
region = os.getenv('S3_REGION')
2426

@@ -37,15 +39,17 @@ if os.getenv('DATABASE_STORAGE') == "s3":
3739
# TODO(bacongobbler): deprecate this once we drop support for v2.8.0 and lower
3840
except S3CreateError as err:
3941
if region != 'us-east-1':
40-
print('Failed to create bucket in {}. We are now assuming that the bucket was created in us-east-1.'.format(region))
42+
print(
43+
'Failed to create bucket in {}. We are now assuming that the bucket was created in us-east-1.'.format(region))
4144
with open(os.path.join(os.environ['WALE_ENVDIR'], "WALE_S3_ENDPOINT"), "w+") as file:
4245
file.write('https+path://s3.amazonaws.com:443')
4346
else:
4447
raise
4548

4649
elif os.getenv('DATABASE_STORAGE') == "gcs":
4750
scopes = ['https://www.googleapis.com/auth/devstorage.full_control']
48-
credentials = ServiceAccountCredentials.from_json_keyfile_name(os.getenv('GOOGLE_APPLICATION_CREDENTIALS'), scopes=scopes)
51+
credentials = ServiceAccountCredentials.from_json_keyfile_name(
52+
os.getenv('GOOGLE_APPLICATION_CREDENTIALS'), scopes=scopes)
4953
with open(os.getenv('GOOGLE_APPLICATION_CREDENTIALS')) as data_file:
5054
data = json.load(data_file)
5155
conn = Client(credentials=credentials, project=data['project_id'])
@@ -59,10 +63,12 @@ elif os.getenv('DATABASE_STORAGE') == "gcs":
5963
if not exists:
6064
conn.create_bucket(bucket_name)
6165

66+
# WIP: Currently broken and needs to be update using the new BlobServiceClient
6267
elif os.getenv('DATABASE_STORAGE') == "azure":
63-
conn = BlobService(account_name=os.getenv('WABS_ACCOUNT_NAME'), account_key=os.getenv('WABS_ACCESS_KEY'))
64-
#It doesn't throw an exception if the container exists by default(https://github.com/Azure/azure-storage-python/blob/master/azure/storage/blob/baseblobservice.py#L504).
65-
conn.create_container(bucket_name)
68+
connection_string = os.getenv("AZURE_STORAGE_CONNECTION_STRING")
69+
azure_blob_service_client = BlobServiceClient.from_connection_string(connection_string)
70+
71+
azure_blob_service_client.create_container(bucket_name)
6672

6773
elif os.getenv('DATABASE_STORAGE') == "swift":
6874
conn = swiftclient.Connection(

rootfs/docker-entrypoint-initdb.d/001_setup_envdir.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ elif [ "$DATABASE_STORAGE" == "gcs" ]; then
4545
echo $GOOGLE_APPLICATION_CREDENTIALS > GOOGLE_APPLICATION_CREDENTIALS
4646
echo $BUCKET_NAME > BUCKET_NAME
4747
elif [ "$DATABASE_STORAGE" == "azure" ]; then
48+
AZURE_STORAGE_CONNECTION_STRING=$(cat /var/run/secrets/deis/objectstore/creds/azure-storage-conn-string)
4849
WABS_ACCOUNT_NAME=$(cat /var/run/secrets/deis/objectstore/creds/accountname)
4950
WABS_ACCESS_KEY=$(cat /var/run/secrets/deis/objectstore/creds/accountkey)
5051
BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-container)
52+
echo $AZURE_STORAGE_CONNECTION_STRING > AZURE_STORAGE_CONNECTION_STRING
5153
echo $WABS_ACCOUNT_NAME > WABS_ACCOUNT_NAME
5254
echo $WABS_ACCESS_KEY > WABS_ACCESS_KEY
5355
echo "wabs://$BUCKET_NAME" > WALE_WABS_PREFIX

0 commit comments

Comments
 (0)