Skip to content

Commit bcd4ca5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into rhoai-3.2
2 parents 026402f + eb9a7b2 commit bcd4ca5

File tree

4 files changed

+136
-46
lines changed

4 files changed

+136
-46
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Setup PostgreSQL
2+
description: Start PostgreSQL for llama-stack
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Start PostgreSQL
7+
shell: bash
8+
run: |
9+
docker run -d \
10+
--name postgres \
11+
--net=host \
12+
-e POSTGRES_USER=llamastack \
13+
-e POSTGRES_PASSWORD=llamastack \
14+
-e POSTGRES_DB=llamastack \
15+
postgres:17
16+
17+
# Wait for PostgreSQL to be ready
18+
echo "Waiting for PostgreSQL to be ready..."
19+
postgres_ready=false
20+
for i in {1..30}; do
21+
if docker exec postgres pg_isready -U llamastack -d llamastack; then
22+
echo "PostgreSQL is ready!"
23+
postgres_ready=true
24+
break
25+
fi
26+
echo "Attempt $i: PostgreSQL not ready yet..."
27+
sleep 1
28+
done
29+
if [ "$postgres_ready" != true ]; then
30+
echo "PostgreSQL failed to start after 30s :("
31+
docker logs postgres || true
32+
exit 1
33+
fi

.github/workflows/redhat-distro-container.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ jobs:
102102
id: vllm
103103
uses: ./.github/actions/setup-vllm
104104

105+
- name: Setup PostgreSQL for llama-stack
106+
if: github.event_name != 'workflow_dispatch'
107+
id: postgres
108+
uses: ./.github/actions/setup-postgres
109+
105110
- name: Start and smoke test LLS distro image
106111
if: github.event_name != 'workflow_dispatch'
107112
id: smoke-test
@@ -123,6 +128,7 @@ jobs:
123128
124129
docker logs llama-stack > logs/llama-stack.log 2>&1 || echo "Failed to get llama-stack logs" > logs/llama-stack.log
125130
docker logs vllm > logs/vllm.log 2>&1 || echo "Failed to get vllm logs" > logs/vllm.log
131+
docker logs postgres > logs/postgres.log 2>&1 || echo "Failed to get postgres logs" > logs/postgres.log
126132
127133
# Gather system information
128134
echo "=== System information ==="
@@ -157,7 +163,7 @@ jobs:
157163
if: always()
158164
shell: bash
159165
run: |
160-
docker rm -f vllm llama-stack
166+
docker rm -f vllm llama-stack postgres
161167
162168
- name: Log in to Quay.io
163169
id: login

distribution/run.yaml

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ providers:
6464
config:
6565
db_path: /opt/app-root/src/.llama/distributions/rh/milvus.db
6666
persistence:
67-
backend: kv_milvus_inline
67+
backend: kv_default
6868
namespace: vector_io::milvus
6969
- provider_id: ${env.ENABLE_FAISS:+faiss}
7070
provider_type: inline::faiss
7171
config:
7272
persistence:
73-
backend: kv_faiss
73+
backend: kv_default
7474
namespace: vector_io::faiss
7575
- provider_id: ${env.MILVUS_ENDPOINT:+milvus-remote}
7676
provider_type: remote::milvus
@@ -83,7 +83,7 @@ providers:
8383
client_pem_path: ${env.MILVUS_CLIENT_PEM_PATH:=}
8484
client_key_path: ${env.MILVUS_CLIENT_KEY_PATH:=}
8585
persistence:
86-
backend: kv_milvus_remote
86+
backend: kv_default
8787
namespace: vector_io::milvus_remote
8888
- provider_id: ${env.ENABLE_PGVECTOR:+pgvector}
8989
provider_type: remote::pgvector
@@ -94,7 +94,7 @@ providers:
9494
user: ${env.PGVECTOR_USER:=}
9595
password: ${env.PGVECTOR_PASSWORD:=}
9696
persistence:
97-
backend: kv_pgvector
97+
backend: kv_default
9898
namespace: vector_io::pgvector
9999
safety:
100100
- provider_id: trustyai_fms
@@ -110,10 +110,10 @@ providers:
110110
config:
111111
persistence:
112112
agent_state:
113-
backend: kv_agents
113+
backend: kv_default
114114
namespace: agents::meta_reference
115115
responses:
116-
backend: sql_agents
116+
backend: sql_default
117117
table_name: agents_responses
118118
max_write_queue_size: 10000
119119
num_writers: 4
@@ -147,13 +147,13 @@ providers:
147147
provider_type: remote::huggingface
148148
config:
149149
kvstore:
150-
backend: kv_datasetio_huggingface
150+
backend: kv_default
151151
namespace: datasetio::huggingface
152152
- provider_id: localfs
153153
provider_type: inline::localfs
154154
config:
155155
kvstore:
156-
backend: kv_datasetio_localfs
156+
backend: kv_default
157157
namespace: datasetio::localfs
158158
scoring:
159159
- provider_id: basic
@@ -189,7 +189,7 @@ providers:
189189
config:
190190
storage_dir: /opt/app-root/src/.llama/distributions/rh/files
191191
metadata_store:
192-
backend: sql_files
192+
backend: sql_default
193193
table_name: files_metadata
194194
- provider_id: ${env.ENABLE_S3:+s3}
195195
provider_type: remote::s3
@@ -201,7 +201,7 @@ providers:
201201
endpoint_url: ${env.S3_ENDPOINT_URL:=}
202202
auto_create_bucket: ${env.S3_AUTO_CREATE_BUCKET:=false}
203203
metadata_store:
204-
backend: sql_files
204+
backend: sql_default
205205
table_name: files_metadata
206206
batches:
207207
- provider_id: reference
@@ -213,48 +213,27 @@ providers:
213213
storage:
214214
backends:
215215
kv_default:
216-
type: kv_sqlite
217-
db_path: /opt/app-root/src/.llama/distributions/rh/kvstore.db
218-
kv_agents:
219-
type: kv_sqlite
220-
db_path: /opt/app-root/src/.llama/distributions/rh/agents_store.db
221-
kv_faiss:
222-
type: kv_sqlite
223-
db_path: /opt/app-root/src/.llama/distributions/rh/faiss.db
224-
kv_milvus_inline:
225-
type: kv_sqlite
226-
db_path: /opt/app-root/src/.llama/distributions/rh/milvus_inline_registry.db
227-
kv_milvus_remote:
228-
type: kv_sqlite
229-
db_path: /opt/app-root/src/.llama/distributions/rh/milvus_remote_registry.db
230-
kv_pgvector:
231-
type: kv_sqlite
232-
db_path: /opt/app-root/src/.llama/distributions/rh/pgvector_registry.db
233-
kv_datasetio_huggingface:
234-
type: kv_sqlite
235-
db_path: /opt/app-root/src/.llama/distributions/rh/huggingface_datasetio.db
236-
kv_datasetio_localfs:
237-
type: kv_sqlite
238-
db_path: /opt/app-root/src/.llama/distributions/rh/localfs_datasetio.db
239-
sql_inference:
240-
type: sql_sqlite
241-
db_path: /opt/app-root/src/.llama/distributions/rh/inference_store.db
242-
sql_agents:
243-
type: sql_sqlite
244-
db_path: /opt/app-root/src/.llama/distributions/rh/responses_store.db
245-
sql_files:
246-
type: sql_sqlite
247-
db_path: /opt/app-root/src/.llama/distributions/rh/files_metadata.db
216+
type: kv_postgres
217+
host: ${env.POSTGRES_HOST:=localhost}
218+
port: ${env.POSTGRES_PORT:=5432}
219+
db: ${env.POSTGRES_DB:=llamastack}
220+
user: ${env.POSTGRES_USER:=llamastack}
221+
password: ${env.POSTGRES_PASSWORD:=llamastack}
222+
table_name: ${env.POSTGRES_TABLE_NAME:=llamastack_kvstore}
248223
sql_default:
249-
type: sql_sqlite
250-
db_path: /opt/app-root/src/.llama/distributions/rh/sql_store.db
224+
type: sql_postgres
225+
host: ${env.POSTGRES_HOST:=localhost}
226+
port: ${env.POSTGRES_PORT:=5432}
227+
db: ${env.POSTGRES_DB:=llamastack}
228+
user: ${env.POSTGRES_USER:=llamastack}
229+
password: ${env.POSTGRES_PASSWORD:=llamastack}
251230
stores:
252231
metadata:
253232
backend: kv_default
254233
namespace: registry
255234
inference:
256-
backend: sql_inference
257235
table_name: inference_store
236+
backend: sql_default
258237
max_write_queue_size: 10000
259238
num_writers: 4
260239
conversations:

tests/smoke.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function start_and_wait_for_llama_stack_container {
1515
--env ENABLE_SENTENCE_TRANSFORMERS=True \
1616
--env EMBEDDING_PROVIDER=sentence-transformers \
1717
--env TRUSTYAI_LMEVAL_USE_K8S=False \
18+
--env POSTGRES_HOST="${POSTGRES_HOST:-localhost}" \
19+
--env POSTGRES_PORT="${POSTGRES_PORT:-5432}" \
20+
--env POSTGRES_DB="${POSTGRES_DB:-llamastack}" \
21+
--env POSTGRES_USER="${POSTGRES_USER:-llamastack}" \
22+
--env POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-llamastack}" \
1823
--name llama-stack \
1924
"$IMAGE_NAME:$GITHUB_SHA"
2025
echo "Started Llama Stack container..."
@@ -70,6 +75,65 @@ function test_model_openai_inference {
7075
fi
7176
}
7277

78+
function test_postgres_tables_exist {
79+
echo "===> Verifying PostgreSQL tables have been created..."
80+
81+
# Expected tables created by llama-stack
82+
expected_tables=("llamastack_kvstore" "inference_store")
83+
84+
# Retry for up to 10 seconds for tables to be created
85+
for i in {1..10}; do
86+
tables=$(docker exec postgres psql -U llamastack -d llamastack -t -c "SELECT tablename FROM pg_tables WHERE schemaname = 'public';" 2>/dev/null | tr -d ' ' | tr '\n' ' ')
87+
all_found=true
88+
for table in "${expected_tables[@]}"; do
89+
if ! echo "$tables" | grep -q "$table"; then
90+
all_found=false
91+
break
92+
fi
93+
done
94+
if [ "$all_found" = true ]; then
95+
echo "===> All expected tables found: ${expected_tables[*]}"
96+
echo "===> Available tables: $tables"
97+
return 0
98+
fi
99+
echo "Attempt $i: Waiting for tables to be created..."
100+
sleep 1
101+
done
102+
103+
echo "===> PostgreSQL tables not created after 10s :("
104+
echo "Expected tables: ${expected_tables[*]}"
105+
echo "Available tables: $tables"
106+
docker exec postgres psql -U llamastack -d llamastack -c "\dt" || true
107+
return 1
108+
}
109+
110+
function test_postgres_populated {
111+
echo "===> Verifying PostgreSQL database has been populated..."
112+
113+
# Check that chat_completions table has data (retry for up to 10 seconds)
114+
echo "Waiting for inference_store table to be populated..."
115+
for i in {1..10}; do
116+
inference_count=$(docker exec postgres psql -U llamastack -d llamastack -t -c "SELECT COUNT(*) FROM inference_store;" 2>/dev/null | tr -d ' ')
117+
if [ -n "$inference_count" ] && [ "$inference_count" -gt 0 ]; then
118+
echo "===> inference_store table has $inference_count record(s)"
119+
break
120+
fi
121+
echo "Attempt $i: inference_store table not yet populated..."
122+
sleep 1
123+
done
124+
if [ -z "$inference_count" ] || [ "$inference_count" -eq 0 ]; then
125+
echo "===> PostgreSQL inference_store table is empty or doesn't exist after 10s :("
126+
echo "Tables in database:"
127+
docker exec postgres psql -U llamastack -d llamastack -c "\dt" || true
128+
echo "inference_store table contents:"
129+
docker exec postgres psql -U llamastack -d llamastack -t -c "SELECT COUNT(*) FROM inference_store;" || true
130+
return 1
131+
fi
132+
133+
echo "===> PostgreSQL database verification passed :)"
134+
return 0
135+
}
136+
73137
main() {
74138
echo "===> Starting smoke test..."
75139
start_and_wait_for_llama_stack_container
@@ -78,6 +142,14 @@ main() {
78142
exit 1
79143
fi
80144
test_model_openai_inference
145+
if ! test_postgres_tables_exist; then
146+
echo "PostgreSQL tables verification failed :("
147+
exit 1
148+
fi
149+
if ! test_postgres_populated; then
150+
echo "PostgreSQL data verification failed :("
151+
exit 1
152+
fi
81153
echo "===> Smoke test completed successfully!"
82154
}
83155

0 commit comments

Comments
 (0)