Skip to content

Commit b9b8d5f

Browse files
committed
fix(milvus): enforce embedded MinIO credentials
1 parent 554fd84 commit b9b8d5f

2 files changed

Lines changed: 79 additions & 3 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# shellcheck shell=bash
2+
3+
Describe "Milvus embedded MinIO credential contract"
4+
render_contract() {
5+
helm template milvus .. | ruby -ryaml -e '
6+
documents = YAML.load_stream(ARGF.read).compact
7+
component = documents.find do |document|
8+
document["kind"] == "ComponentDefinition" &&
9+
document.dig("spec", "serviceKind") == "milvus-minio"
10+
end
11+
abort "milvus-minio ComponentDefinition not rendered" unless component
12+
13+
account = component.dig("spec", "systemAccounts").find do |item|
14+
item["name"] == "admin"
15+
end
16+
abort "admin system account not rendered" unless account
17+
18+
policy = account["passwordGenerationPolicy"] || {}
19+
puts "policy=#{policy.values_at("length", "numDigits", "numSymbols", "letterCase").join(",")}"
20+
21+
vars = component.dig("spec", "vars").to_h { |item| [item["name"], item] }
22+
user_ref = vars.dig("MINIO_ROOT_USER", "valueFrom", "credentialVarRef") || {}
23+
password_ref = vars.dig("MINIO_ROOT_PASSWORD", "valueFrom", "credentialVarRef") || {}
24+
puts "user=#{user_ref.values_at("name", "optional", "username").join(",")}"
25+
puts "password=#{password_ref.values_at("name", "optional", "password").join(",")}"
26+
puts "server_legacy=#{vars.key?("MINIO_ACCESS_KEY") || vars.key?("MINIO_SECRET_KEY")}"
27+
28+
standalone = documents.find do |document|
29+
document["kind"] == "ComponentDefinition" &&
30+
document.dig("spec", "serviceKind") == "milvus" &&
31+
document["metadata"]["name"].include?("standalone")
32+
end
33+
abort "milvus standalone ComponentDefinition not rendered" unless standalone
34+
35+
client_vars = standalone.dig("spec", "vars").to_h { |item| [item["name"], item] }
36+
access_ref = client_vars.dig("MINIO_ACCESS_KEY", "valueFrom", "credentialVarRef") || {}
37+
secret_ref = client_vars.dig("MINIO_SECRET_KEY", "valueFrom", "credentialVarRef") || {}
38+
puts "client_access=#{access_ref.values_at("name", "optional", "username").join(",")}"
39+
puts "client_secret=#{secret_ref.values_at("name", "optional", "password").join(",")}"
40+
puts "client_root=#{client_vars.key?("MINIO_ROOT_USER") || client_vars.key?("MINIO_ROOT_PASSWORD")}"
41+
42+
clients = documents.select do |document|
43+
document["kind"] == "ComponentDefinition" &&
44+
document.dig("spec", "serviceKind") == "milvus"
45+
end
46+
client_contract = clients.all? do |document|
47+
names = document.dig("spec", "vars").map { |item| item["name"] }
48+
names.include?("MINIO_ACCESS_KEY") &&
49+
names.include?("MINIO_SECRET_KEY") &&
50+
!names.include?("MINIO_ROOT_USER") &&
51+
!names.include?("MINIO_ROOT_PASSWORD")
52+
end
53+
puts "client_components=#{clients.map { |document| document["metadata"]["name"].sub(/-1[.].*$/, "") }.sort.join(",")}"
54+
puts "client_contract=#{client_contract}"
55+
'
56+
}
57+
58+
It "renders an explicit non-empty password policy and separates server and client variables"
59+
When call render_contract
60+
The output should eq "policy=16,4,0,MixedCases
61+
user=admin,false,Required
62+
password=admin,false,Required
63+
server_legacy=false
64+
client_access=admin,false,Required
65+
client_secret=admin,false,Required
66+
client_root=false
67+
client_components=milvus-datanode,milvus-indexnode,milvus-mixcoord,milvus-proxy,milvus-querynode,milvus-standalone
68+
client_contract=true"
69+
The status should be success
70+
End
71+
End

addons/milvus/templates/cmpd-minio.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ spec:
1414
systemAccounts:
1515
- name: admin
1616
initAccount: true
17+
passwordGenerationPolicy:
18+
length: 16
19+
numDigits: 4
20+
numSymbols: 0
21+
letterCase: MixedCases
1722
vars:
18-
- name: MINIO_ACCESS_KEY
23+
- name: MINIO_ROOT_USER
1924
valueFrom:
2025
credentialVarRef:
2126
name: admin
2227
optional: false
2328
username: Required
24-
- name: MINIO_SECRET_KEY
29+
- name: MINIO_ROOT_PASSWORD
2530
valueFrom:
2631
credentialVarRef:
2732
name: admin
@@ -86,4 +91,4 @@ spec:
8691
successThreshold: 1
8792
tcpSocket:
8893
port: 9000
89-
timeoutSeconds: 1
94+
timeoutSeconds: 1

0 commit comments

Comments
 (0)