Skip to content

Commit 172729a

Browse files
authored
Merge pull request #2694 from project-koku/rc-2021.03.01
Rc 2021.03.01
2 parents d1b4a66 + cb83dc9 commit 172729a

151 files changed

Lines changed: 3085 additions & 621 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ DEVELOPMENT=True
1313
prometheus_multiproc_dir='/tmp'
1414
AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY
1515
AWS_SECRET_ACCESS_KEY=AWS_SECRET_KEY
16-
ENABLE_S3_ARCHIVING=False
17-
ENABLE_PARQUET_PROCESSING=False
16+
17+
ENABLE_S3_ARCHIVING=True
18+
ENABLE_PARQUET_PROCESSING=True
1819
S3_BUCKET_NAME=koku-bucket
19-
S3_BUCKET_PATH=data_archive
20-
S3_ENDPOINT=s3.us-east-1.amazonaws.com
21-
S3_ACCESS_KEY=S3_ACCESS_KEY
22-
S3_SECRET=S3_SECRET
20+
S3_ENDPOINT=http://kokuminio:9000
21+
S3_ACCESS_KEY=kokuminioaccess
22+
S3_SECRET=kokuminiosecret
2323

2424
# Local MinIO. Defaults are set for docker-compose settings
2525
#S3_BUCKET_NAME=koku-bucket

.github/workflows/unittests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ jobs:
3333
ports:
3434
- 5432:5432
3535
steps:
36-
- name: Checkout repsository
36+
- name: Checkout repository
3737
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
3840

3941
- name: Display build environment
4042
run: printenv

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,6 @@ testing/
134134
# Local OpenShift folders
135135
openshift.local.clusterup/
136136
scripts/openshift.local.clusterup/
137+
138+
# Localdev Certs
139+
certs/

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ OC_TEMPLATES = $(wildcard $(OC_TEMPLATE_DIR))
3737

3838
# Docker compose specific file
3939
ifdef compose_file
40-
DOCKER_COMPOSE = docker-compose -f $(compose_file)
40+
DOCKER_COMPOSE = $(DOCKER)-compose -f $(compose_file)
4141
else
42-
DOCKER_COMPOSE = docker-compose
42+
DOCKER_COMPOSE = $(DOCKER)-compose
4343
endif
4444

4545
# Platform differences
@@ -115,6 +115,9 @@ help:
115115
@echo " password: admin12"
116116
@echo " docker-up-min run database, koku/masu servers and worker"
117117
@echo " docker-down shut down all containers"
118+
@echo " docker-up-min-presto start minimum targets for Presto usage"
119+
@echo " docker-up-min-presto-no-build start minimum targets for Presto usage without building koku base"
120+
@echo " docker-presto-down-all Tear down Presto and Koku containers"
118121
@echo " docker-rabbit run RabbitMQ container"
119122
@echo " docker-reinitdb drop and recreate the database"
120123
@echo " docker-reinitdb-with-sources drop and recreate the database with fake sources"
@@ -168,7 +171,7 @@ create-test-customer-no-sources: run-migrations docker-up-koku
168171
$(PYTHON) $(TOPDIR)/scripts/create_test_customer.py --no-sources --bypass-api || echo "WARNING: create_test_customer failed unexpectedly!"
169172

170173
load-test-customer-data:
171-
$(TOPDIR)/scripts/load_test_customer_data.sh $(TOPDIR) $(start) $(end)
174+
$(TOPDIR)/scripts/load_test_customer_data.sh $(start) $(end)
172175
make load-aws-org-unit-tree
173176

174177
load-aws-org-unit-tree:
@@ -400,6 +403,8 @@ docker-presto-down:
400403
docker-compose -f ./testing/compose_files/docker-compose-presto.yml down -v
401404
make docker-presto-cleanup
402405

406+
docker-presto-down-all: docker-presto-down docker-down
407+
403408
### Source targets ###
404409
ocp-source-from-yaml:
405410
#parameter validation

Pipfile.lock

Lines changed: 220 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ If you see this error, run the following command (assuming you are at the projec
173173

174174
setfacl -m u:26:-wx ./pg_data
175175

176+
If you need to run PostgreSQL using SSL for local development:
177+
178+
1. Ensure that you have ``openssl`` installed.
179+
2. Ensure that you have the ``KOKU_PATH`` environment set to the koku source root directory.
180+
3. Execute ``${KOKU_PATH}/scripts/genssc`` and follow the prompts to create local a self-signed certificate for PostgreSQL.
181+
4. In the ``docker-compose.yml`` file, there are two commented sections labeled "PostgreSQL SSL". Follow the directions in these comments to enable the volume mounts and command options to use SSL.
182+
176183
See https://access.redhat.com/containers/?tab=overview#/registry.access.redhat.com/rhel8/postgresql-12
177184

178185

@@ -217,6 +224,51 @@ Information about PostgreSQL statistics can be found here: https://www.postgresq
217224
Information about Grafana dashboards can be found here: https://grafana.com/docs/grafana/latest/features/dashboard/dashboards/
218225

219226

227+
Using Trino and MinIO
228+
^^^^^^^^^^^^^^^^^^^^^
229+
230+
We have a special docker-compose file specifically for running Trino (formerly Presto) with MinIO for object storage. With the proper environment variables set the app will run circumventing our conventional Postgres processing in favor of using Trino.
231+
232+
Set the following environment variables ::
233+
234+
ENABLE_PARQUET_PROCESSING=True
235+
S3_BUCKET_NAME=koku-bucket
236+
S3_ENDPOINT=http://kokuminio:9000
237+
S3_ACCESS_KEY=kokuminioaccess
238+
S3_SECRET=kokuminiosecret
239+
240+
To spin up the minimum targets for Trino use ::
241+
242+
make docker-up-min-presto
243+
244+
To skip building the koku image base ::
245+
246+
make docker-up-min-presto-no-build
247+
248+
To tear down containers ::
249+
250+
make docker-presto-down-all
251+
252+
With all containers running any source added will be processed by saving CSV files in MinIO and storing Parquet files in MinIO. The source's data will be summarized via Trino. Summarized data will land in the appropriate daily_summary table for the source type for consumption by the API.
253+
254+
To add test sources and data ::
255+
256+
make create-test-customer
257+
make load-test-customer-data (optional)start={start_date} (optional)end={end_date}
258+
259+
The MinIO UI will be available at http://127.0.0.1:9000/minio/. Use the S3_ACCESS_KEY and S3_SECRET set in your env as login credentials.
260+
261+
The Trinio UI will be available at http://127.0.0.1:8080/ui/. Login as `admin`. Details can be found there on queries. This is particularly useful for troubleshooting failures.
262+
263+
For command line interactions with Trino install the CLI from https://trino.io/docs/current/installation/cli.html and follow instructions there. Use the following to login ::
264+
265+
trino --server localhost:8080 --catalog hive --schema acct10001 --user admin --debug
266+
267+
Example usage ::
268+
269+
SHOW tables;
270+
SELECT * from aws_line_items WHERE source='{source}' AND year='2021' AND month='02' LIMIT 100;
271+
220272
Developing with OpenShift
221273
-------------------------
222274

db_functions/app_needs_migrations_func.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DECLARE
3030
latest_migrations jsonb;
3131
required_tables int := 0;
3232
do_migrations boolean := false;
33+
objects_exist boolean := false;
3334
BEGIN
3435
/*
3536
* Verify that the necessary tables are present
@@ -68,6 +69,27 @@ BEGIN
6869
else schema_name
6970
END::text
7071
LOOP
72+
/* Check for race condition if someone deletes a source, etc during processing */
73+
SELECT EXISTS (
74+
SELECT c.oid
75+
FROM pg_class c
76+
JOIN pg_namespace n
77+
ON n.oid = c.relnamespace
78+
WHERE c.relname = 'django_migrations'
79+
AND n.nspname = schema_rec.schema_name
80+
)::boolean
81+
INTO objects_exist;
82+
83+
IF NOT objects_exist
84+
THEN
85+
RAISE WARNING 'Object %.% does not exist. Skipping schema %',
86+
schema_rec.schema_name,
87+
'django_migrations',
88+
schema_rec.schema_name;
89+
END IF;
90+
91+
CONTINUE WHEN NOT objects_exist;
92+
7193
/* Get the latest recorded migrations by app for this tenant schema */
7294
IF _verbose
7395
THEN

docker-compose.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
- prometheus_multiproc_dir=/tmp
4343
- API_PATH_PREFIX=${API_PATH_PREFIX-/api/cost-management}
4444
- GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}
45-
- DEMO_ACCOUNTS=${DEMO_ACCOUNTS-{}}
45+
- DEMO_ACCOUNTS
4646
- ACCOUNT_ENHANCED_METRICS=${ACCOUNT_ENHANCED_METRICS-False}
4747
- RUN_GUNICORN=${RUN_GUNICORN}
4848
privileged: true
@@ -125,13 +125,24 @@ services:
125125
volumes:
126126
- ./pg_data:/var/lib/${DATABASE_DATA_DIR-postgresql}/data
127127
- ./pg_init:/docker-entrypoint-initdb.d
128+
# PostgreSQL SSL: Un-comment the next two lines after running ./scripts/genssc to use sslmode in Postgres
129+
# - ./certs/koku.crt:/etc/certs/koku.crt
130+
# - ./certs/private/koku.key:/etc/certs/private/koku.key
128131
command:
129132
# This command give more precise control over the parameter settings
130133
# Included are loading the pg_stat_statements lib
131134
# as well as autovacuum settings that are designed to make more efficient
132135
# use of the autovacuum processes
133136
# The pg_init mount is still needed to enable the necesary extensions.
134137
- postgres
138+
# PostgreSQL SSL: Run ./scripts/genssc to create self-signed cert and key files to support ssl
139+
# Un-comment the three options below to utilize ssl mode and use the certificate and key
140+
# - -c
141+
# - ssl=on
142+
# - -c
143+
# - ssl_cert_file=/etc/certs/koku.crt
144+
# - -c
145+
# - ssl_key_file=/etc/certs/private/koku.key
135146
- -c
136147
- max_connections=1710
137148
- -c
@@ -248,7 +259,7 @@ services:
248259
- KOKU_CELERY_ENABLE_SENTRY
249260
- KOKU_CELERY_SENTRY_DSN
250261
- KOKU_SENTRY_ENVIRONMENT
251-
- DEMO_ACCOUNTS=${DEMO_ACCOUNTS-{}}
262+
- DEMO_ACCOUNTS
252263
- INITIAL_INGEST_OVERRIDE=${INITIAL_INGEST_OVERRIDE-False}
253264
- INITIAL_INGEST_NUM_MONTHS=${INITIAL_INGEST_NUM_MONTHS-2}
254265
- AUTO_DATA_INGEST=${AUTO_DATA_INGEST-True}
@@ -358,6 +369,7 @@ services:
358369
- SOURCES_KAFKA_PORT=${SOURCES_KAFKA_PORT-29092}
359370
- KOKU_SOURCES_CLIENT_PORT=${KOKU_SOURCES_CLIENT_PORT-9000}
360371
- GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}
372+
- DEMO_ACCOUNTS
361373
- prometheus_multiproc_dir=/tmp
362374
privileged: true
363375
ports:

docs/rtd_requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ azure-mgmt-storage==11.2.0
1111
azure-storage-blob==12.7.1
1212
beautifulsoup4==4.9.3
1313
billiard==3.6.3.0
14-
boto3==1.17.8
15-
botocore==1.20.8; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
14+
boto3==1.17.12
15+
botocore==1.20.12; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
1616
bs4==0.0.1
1717
cachetools==4.2.1
1818
celery-prometheus-exporter==1.7.0
@@ -23,23 +23,23 @@ chardet==4.0.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2
2323
ciso8601==2.1.3
2424
click==7.1.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
2525
confluent-kafka==1.6.0
26-
cryptography==3.4.5; python_version >= '3.6'
26+
cryptography==3.4.6; python_version >= '3.6'
2727
django-cors-headers==3.7.0
2828
django-environ==0.4.5
2929
django-extensions==3.1.1
3030
django-filter==2.4.0
3131
django-prometheus==2.1.0
3232
django-redis==4.12.1
3333
django-tenant-schemas==1.10.0
34-
django==3.1.6
34+
django==3.1.7
3535
djangorestframework-csv==2.1.0
3636
djangorestframework==3.12.2
3737
flake8==3.8.4
3838
google-api-core[grpc]==1.26.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
3939
google-api-python-client==1.12.8
4040
google-auth-httplib2==0.0.4
41-
google-auth==1.26.1
42-
google-cloud-bigquery==2.8.0
41+
google-auth==1.27.0
42+
google-cloud-bigquery==2.9.0
4343
google-cloud-core==1.6.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
4444
google-crc32c==1.1.2; python_version >= '3.5'
4545
google-resumable-media==1.2.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
@@ -69,7 +69,7 @@ pint==0.16.1
6969
presto-python-client==0.7.0
7070
prometheus-client==0.9.0
7171
proto-plus==1.13.0; python_version >= '3.6'
72-
protobuf==3.14.0
72+
protobuf==3.15.1
7373
psutil==5.8.0
7474
psycopg2-binary==2.8.6; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
7575
pyarrow==3.0.0
@@ -88,8 +88,8 @@ requests-oauthlib==1.3.0
8888
requests==2.25.1
8989
rsa==4.7.1; python_version >= '3.6'
9090
s3transfer==0.3.4
91-
scipy==1.6.0; python_version >= '3.7'
92-
sentry-sdk==0.20.2
91+
scipy==1.6.1; python_version >= '3.7'
92+
sentry-sdk==0.20.3
9393
six==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
9494
soupsieve==2.2; python_version >= '3.0'
9595
sqlparse==0.4.1; python_version >= '3.5'

0 commit comments

Comments
 (0)