Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
fix(deploy,storage,controlplane): add PostgreSQL ping retries, fail-fast curl in bootstrap-job, and DiscardUnknown in HandlePolicies
Antonio Ojeab708903960c9
diff --git a/charts/sam-mesh/templates/bootstrap-job.yaml b/charts/sam-mesh/templates/bootstrap-job.yamlindex 5c784cb1..f3e9c094 100644--- a/charts/sam-mesh/templates/bootstrap-job.yaml+++ b/charts/sam-mesh/templates/bootstrap-job.yaml@@ -88,7 +88,7 @@ spec:(dict "role" "sam:role:node" "members" (list "group:data-scientist" "group:users"))-}}{{- end }}- curl -s -X POST \+ curl -sf -X POST \-H "Content-Type: application/json" \-H "Authorization: Bearer ${ADMIN_TOKEN}" \-d '{@@ -104,7 +104,7 @@ spec:echo "Generating bootstrap token for sam-router..."- TOKEN_RESP=$(curl -s -X POST \+ TOKEN_RESP=$(curl -sf -X POST \-H "Content-Type: application/json" \-H "Authorization: Bearer ${ADMIN_TOKEN}" \-d '{"role": "sam:role:router", "max_usages": 999999}' \diff --git a/internal/controlplane/server.go b/internal/controlplane/server.goindex a7b0f935..fd4ea5a8 100644--- a/internal/controlplane/server.go+++ b/internal/controlplane/server.go@@ -860,7 +860,8 @@ func (s *Server) HandlePolicies(w http.ResponseWriter, r *http.Request) {var req api.PolicyConfigUpdateRequestif strings.HasPrefix(r.Header.Get("Content-Type"), "application/json") {- if err := protojson.Unmarshal(body, &req); err != nil {+ unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}+ if err := unmarshaler.Unmarshal(body, &req); err != nil {http.Error(w, "Invalid JSON format: "+err.Error(), http.StatusBadRequest)return}diff --git a/internal/storage/sql_store.go b/internal/storage/sql_store.goindex bdce875f..020b24a5 100644--- a/internal/storage/sql_store.go+++ b/internal/storage/sql_store.go@@ -58,6 +58,22 @@ func NewSQLStore(driverName, dataSourceName string) (*SQLStore, error) {return nil, fmt.Errorf("failed to open database: %w", err)}+ // For postgres, retry Ping() to allow DB container to finish booting+ if actualDriver == "pgx" {+ var pingErr error+ for i := 0; i < 30; i++ {+ pingErr = db.Ping()+ if pingErr == nil {+ break+ }+ time.Sleep(1 * time.Second)+ }+ if pingErr != nil {+ _ = db.Close()+ return nil, fmt.Errorf("failed to ping database: %w", pingErr)+ }+ }+store := &SQLStore{db: db,driverName: driverName,