From c677ca34173825f12d18a6c9d71c8694434b6524 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 28 Nov 2023 10:58:12 +0100 Subject: [PATCH 1/3] [transporturl] support tls query The rabbitmq transport url requested needs to be in the following format for tls: rabbit://:@:5671/?ssl=1 * pass query `?ssl=1/0` depending of enabled disabled * When tls is enabled a different port is used by the cluster. The information is part of the rabbitmq secret. Lets get the port information always from the secret. Jira: OSPRH-1919 --- apis/go.mod | 31 +++---- apis/go.sum | 59 ++++++------ .../rabbitmq/transporturl_controller.go | 90 +++++++++++++++---- go.mod | 30 +++---- go.sum | 58 ++++++------ 5 files changed, 166 insertions(+), 102 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index db1fbdf6..e97b2c27 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -6,12 +6,12 @@ require ( github.com/go-logr/logr v1.3.0 github.com/onsi/ginkgo/v2 v2.13.1 github.com/onsi/gomega v1.30.0 - github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231114102008-65eb1b13d3a7 - golang.org/x/exp v0.0.0-20231006140011-7918f672742d - k8s.io/api v0.26.10 - k8s.io/apimachinery v0.26.10 - k8s.io/client-go v0.26.10 - k8s.io/utils v0.0.0-20230726121419-3b25d923346b + github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63 + golang.org/x/exp v0.0.0-20231127185646-65229373498e + k8s.io/api v0.26.11 + k8s.io/apimachinery v0.26.11 + k8s.io/client-go v0.26.11 + k8s.io/utils v0.0.0-20231127182322-b307cd553661 sigs.k8s.io/controller-runtime v0.14.7 ) @@ -51,23 +51,24 @@ require ( github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/testify v1.8.3 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.4.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.14.0 // indirect + golang.org/x/tools v0.16.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.26.10 // indirect - k8s.io/component-base v0.26.10 // indirect + k8s.io/apiextensions-apiserver v0.26.11 // indirect + k8s.io/component-base v0.26.11 // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect diff --git a/apis/go.sum b/apis/go.sum index aa4319b2..7d1f9d8d 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -232,8 +232,8 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openshift/api v3.9.0+incompatible h1:fJ/KsefYuZAjmrr3+5U9yZIZbTOpVkDDLDLFresAeYs= github.com/openshift/api v3.9.0+incompatible/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231114102008-65eb1b13d3a7 h1:UEgV9NNx0XbQlwiebhtS4qdt3mPsMs6c8DMyv+i5tBc= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231114102008-65eb1b13d3a7/go.mod h1:mxh1HCiMTZm4cAqUK5yPigbZ5JJs3gOVgDVwbTbFAYk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63 h1:iA/8vt+o2bMxYvvenNB7VArBvM8UyDLw3G7S/teMLc0= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63/go.mod h1:OYad2L+OD4j5CR49di7gu3Q1UkLBmpYwvtdoGlnasL4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -288,8 +288,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= @@ -329,8 +330,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= +golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -353,7 +354,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -363,8 +364,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= +golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -418,11 +419,12 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -430,8 +432,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -482,8 +485,8 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -573,8 +576,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -605,22 +608,22 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.10 h1:skTnrDR0r8dg4MMLf6YZIzugxNM0BjFsWKPkNc5kOvk= -k8s.io/api v0.26.10/go.mod h1:ou/H3yviqrHtP/DSPVTfsc7qNfmU06OhajytJfYXkXw= -k8s.io/apiextensions-apiserver v0.26.10 h1:wAriTUc6l7gUqJKOxhmXnYo/VNJzk4oh4QLCUR4Uq+k= -k8s.io/apiextensions-apiserver v0.26.10/go.mod h1:N2qhlxkhJLSoC4f0M1/1lNG627b45SYqnOPEVFoQXw4= -k8s.io/apimachinery v0.26.10 h1:aE+J2KIbjctFqPp3Y0q4Wh2PD+l1p2g3Zp4UYjSvtGU= -k8s.io/apimachinery v0.26.10/go.mod h1:iT1ZP4JBP34wwM+ZQ8ByPEQ81u043iqAcsJYftX9amM= -k8s.io/client-go v0.26.10 h1:4mDzl+1IrfRxh4Ro0s65JRGJp14w77gSMUTjACYWVRo= -k8s.io/client-go v0.26.10/go.mod h1:sh74ig838gCckU4ElYclWb24lTesPdEDPnlyg5vcbkA= -k8s.io/component-base v0.26.10 h1:vl3Gfe5aC09mNxfnQtTng7u3rnBVrShOK3MAkqEleb0= -k8s.io/component-base v0.26.10/go.mod h1:/IDdENUHG5uGxqcofZajovYXE9KSPzJ4yQbkYQt7oN0= +k8s.io/api v0.26.11 h1:hLhTZRdYc3vBBOY4wbEyTLWgMyieOAk2Ws9NG57QqO4= +k8s.io/api v0.26.11/go.mod h1:bSr/A0TKRt5W2OMDdexkM/ER1NxOxiQqNNFXW2nMZrM= +k8s.io/apiextensions-apiserver v0.26.11 h1:6/T0Jm9c+Aw1AYUflPOz2sAsty304/DDSkciTr8+HuE= +k8s.io/apiextensions-apiserver v0.26.11/go.mod h1:xMqWxAB+AvSTdmFRVWlpavY9bJl/3g6yWiPn/fwZbT0= +k8s.io/apimachinery v0.26.11 h1:w//840HHdwSRKqD15j9YX9HLlU6RPlfrvW0xEhLk2+0= +k8s.io/apimachinery v0.26.11/go.mod h1:2/HZp0l6coXtS26du1Bk36fCuAEr/lVs9Q9NbpBtd1Y= +k8s.io/client-go v0.26.11 h1:RjfZr5+vQjjTRmk4oCqHyC0cgrZXPjw+X+ge35sk4GI= +k8s.io/client-go v0.26.11/go.mod h1:+emNszw9va/uRJIM5ALTBtFnlZMTjwBrNjRfEh0iuw8= +k8s.io/component-base v0.26.11 h1:1/JmB6fexefGByfFyIK6aHksZZVtaDskttzXOzmZ6zA= +k8s.io/component-base v0.26.11/go.mod h1:jYNisnoM6iWFRUg51pxaQabzL5fBYTr5CMpsLjUYGp0= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI= +k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/controllers/rabbitmq/transporturl_controller.go b/controllers/rabbitmq/transporturl_controller.go index c380970a..0968cf83 100644 --- a/controllers/rabbitmq/transporturl_controller.go +++ b/controllers/rabbitmq/transporturl_controller.go @@ -69,7 +69,7 @@ type TransportURLReconciler struct { // GetLogger returns a logger object with a prefix of "controller.name" and additional controller context fields func (r *TransportURLReconciler) GetLogger(ctx context.Context) logr.Logger { - return log.FromContext(ctx).WithName("Controllers").WithName("DNSData") + return log.FromContext(ctx).WithName("Controllers").WithName("TransportURL") } //+kubebuilder:rbac:groups=rabbitmq.openstack.org,resources=transporturls,verbs=get;list;watch;create;update;patch;delete @@ -148,6 +148,8 @@ func (r *TransportURLReconciler) Reconcile(ctx context.Context, req ctrl.Request } func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance *rabbitmqv1beta1.TransportURL, helper *helper.Helper) (ctrl.Result, error) { + Log := r.GetLogger(ctx) + Log.Info("Reconciling Service") //TODO (implement a watch on the rabbitmq cluster resources to update things if there are changes) rabbit, err := getRabbitmqCluster(ctx, helper, instance) @@ -174,8 +176,16 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * // TODO(dprince): Future we may want to use vhosts for each OpenStackService instead. // vhosts would likely require use of https://github.com/rabbitmq/messaging-topology-operator/ which we do not yet include - username, ctrlResult, err := oko_secret.GetDataFromSecret(ctx, helper, rabbit.Status.DefaultUser.SecretReference.Name, time.Duration(10)*time.Second, "username") + rabbitSecret, _, err := oko_secret.GetSecret(ctx, helper, rabbit.Status.DefaultUser.SecretReference.Name, instance.Namespace) if err != nil { + if k8s_errors.IsNotFound(err) { + instance.Status.Conditions.Set(condition.FalseCondition( + rabbitmqv1beta1.TransportURLReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + rabbitmqv1beta1.TransportURLInProgressMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil + } instance.Status.Conditions.Set(condition.FalseCondition( rabbitmqv1beta1.TransportURLReadyCondition, condition.ErrorReason, @@ -183,12 +193,13 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * rabbitmqv1beta1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err - } else if (ctrlResult != ctrl.Result{}) { - return ctrlResult, nil } - password, ctrlResult, err := oko_secret.GetDataFromSecret(ctx, helper, rabbit.Status.DefaultUser.SecretReference.Name, time.Duration(10)*time.Second, "password") - if err != nil { + var username string + if u, ok := rabbitSecret.Data["username"]; ok { + username = string(u) + } else { + err := fmt.Errorf("username does not exist in rabbitmq secret %s", rabbitSecret.Name) instance.Status.Conditions.Set(condition.FalseCondition( rabbitmqv1beta1.TransportURLReadyCondition, condition.ErrorReason, @@ -196,12 +207,27 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * rabbitmqv1beta1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err - } else if (ctrlResult != ctrl.Result{}) { - return ctrlResult, nil } - host, ctrlResult, err := oko_secret.GetDataFromSecret(ctx, helper, rabbit.Status.DefaultUser.SecretReference.Name, time.Duration(10)*time.Second, "host") - if err != nil { + var password string + if p, ok := rabbitSecret.Data["password"]; ok { + password = string(p) + } else { + err := fmt.Errorf("password does not exist in rabbitmq secret %s", rabbitSecret.Name) + instance.Status.Conditions.Set(condition.FalseCondition( + rabbitmqv1beta1.TransportURLReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + rabbitmqv1beta1.TransportURLReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + var host string + if h, ok := rabbitSecret.Data["host"]; ok { + host = string(h) + } else { + err := fmt.Errorf("host does not exist in rabbitmq secret %s", rabbitSecret.Name) instance.Status.Conditions.Set(condition.FalseCondition( rabbitmqv1beta1.TransportURLReadyCondition, condition.ErrorReason, @@ -209,12 +235,30 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * rabbitmqv1beta1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err - } else if (ctrlResult != ctrl.Result{}) { - return ctrlResult, nil } + var port string + if p, ok := rabbitSecret.Data["port"]; ok { + port = string(p) + } else { + err := fmt.Errorf("port does not exist in rabbitmq secret %s", rabbitSecret.Name) + instance.Status.Conditions.Set(condition.FalseCondition( + rabbitmqv1beta1.TransportURLReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + rabbitmqv1beta1.TransportURLReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + + tlsEnabled := false + if rabbit.Spec.TLS.SecretName != "" { + tlsEnabled = true + } + Log.Info(fmt.Sprintf("rabbitmq cluster %s has TLS enabled: %t", rabbit.Name, tlsEnabled)) + // Create a new secret with the transport URL for this CR - secret := r.createTransportURLSecret(instance, string(username), string(password), string(host)) + secret := r.createTransportURLSecret(instance, string(username), string(password), string(host), string(port), tlsEnabled) _, op, err := oko_secret.CreateOrPatchSecret(ctx, helper, instance, secret) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( @@ -239,12 +283,26 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * instance.Status.Conditions.MarkTrue(rabbitmqv1beta1.TransportURLReadyCondition, rabbitmqv1beta1.TransportURLReadyMessage) + Log.Info("Reconciled Service successfully") return ctrl.Result{}, nil - } // Create k8s secret with transport URL -func (r *TransportURLReconciler) createTransportURLSecret(instance *rabbitmqv1beta1.TransportURL, username string, password string, host string) *corev1.Secret { +func (r *TransportURLReconciler) createTransportURLSecret( + instance *rabbitmqv1beta1.TransportURL, + username string, + password string, + host string, + port string, + tlsEnabled bool, +) *corev1.Secret { + query := "" + if tlsEnabled { + query += "?ssl=1" + } else { + query += "?ssl=0" + } + // Create a new secret with the transport URL for this CR return &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -252,7 +310,7 @@ func (r *TransportURLReconciler) createTransportURLSecret(instance *rabbitmqv1be Namespace: instance.Namespace, }, Data: map[string][]byte{ - "transport_url": []byte(fmt.Sprintf("rabbit://%s:%s@%s:5672", username, password, host)), + "transport_url": []byte(fmt.Sprintf("rabbit://%s:%s@%s:%s/%s", username, password, host, port, query)), }, } } diff --git a/go.mod b/go.mod index 428e7309..de855c4f 100644 --- a/go.mod +++ b/go.mod @@ -8,14 +8,14 @@ require ( github.com/onsi/ginkgo/v2 v2.13.1 github.com/onsi/gomega v1.30.0 github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230920125017-2c76cd203b44 - github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231114102008-65eb1b13d3a7 + github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63 github.com/rabbitmq/cluster-operator v1.14.0 go.uber.org/zap v1.26.0 - golang.org/x/exp v0.0.0-20231006140011-7918f672742d - k8s.io/api v0.26.10 - k8s.io/apimachinery v0.26.10 - k8s.io/client-go v0.26.10 - k8s.io/utils v0.0.0-20230726121419-3b25d923346b + golang.org/x/exp v0.0.0-20231127185646-65229373498e + k8s.io/api v0.26.11 + k8s.io/apimachinery v0.26.11 + k8s.io/client-go v0.26.11 + k8s.io/utils v0.0.0-20231127182322-b307cd553661 sigs.k8s.io/controller-runtime v0.14.7 ) @@ -55,21 +55,21 @@ require ( github.com/prometheus/procfs v0.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.4.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.14.0 // indirect + golang.org/x/tools v0.16.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.26.10 // indirect - k8s.io/component-base v0.26.10 // indirect + k8s.io/apiextensions-apiserver v0.26.11 // indirect + k8s.io/component-base v0.26.11 // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect diff --git a/go.sum b/go.sum index 5d25c667..24251cf7 100644 --- a/go.sum +++ b/go.sum @@ -232,8 +232,8 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxCMwNRnMjhhIDOWHJowi6q8G6koI= github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231114102008-65eb1b13d3a7 h1:UEgV9NNx0XbQlwiebhtS4qdt3mPsMs6c8DMyv+i5tBc= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231114102008-65eb1b13d3a7/go.mod h1:mxh1HCiMTZm4cAqUK5yPigbZ5JJs3gOVgDVwbTbFAYk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63 h1:iA/8vt+o2bMxYvvenNB7VArBvM8UyDLw3G7S/teMLc0= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63/go.mod h1:OYad2L+OD4j5CR49di7gu3Q1UkLBmpYwvtdoGlnasL4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -290,8 +290,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= @@ -331,8 +331,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= +golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -355,7 +355,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -365,8 +365,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= +golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -420,11 +420,12 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -432,8 +433,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -484,8 +486,8 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -575,8 +577,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -607,22 +609,22 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.10 h1:skTnrDR0r8dg4MMLf6YZIzugxNM0BjFsWKPkNc5kOvk= -k8s.io/api v0.26.10/go.mod h1:ou/H3yviqrHtP/DSPVTfsc7qNfmU06OhajytJfYXkXw= -k8s.io/apiextensions-apiserver v0.26.10 h1:wAriTUc6l7gUqJKOxhmXnYo/VNJzk4oh4QLCUR4Uq+k= -k8s.io/apiextensions-apiserver v0.26.10/go.mod h1:N2qhlxkhJLSoC4f0M1/1lNG627b45SYqnOPEVFoQXw4= -k8s.io/apimachinery v0.26.10 h1:aE+J2KIbjctFqPp3Y0q4Wh2PD+l1p2g3Zp4UYjSvtGU= -k8s.io/apimachinery v0.26.10/go.mod h1:iT1ZP4JBP34wwM+ZQ8ByPEQ81u043iqAcsJYftX9amM= -k8s.io/client-go v0.26.10 h1:4mDzl+1IrfRxh4Ro0s65JRGJp14w77gSMUTjACYWVRo= -k8s.io/client-go v0.26.10/go.mod h1:sh74ig838gCckU4ElYclWb24lTesPdEDPnlyg5vcbkA= -k8s.io/component-base v0.26.10 h1:vl3Gfe5aC09mNxfnQtTng7u3rnBVrShOK3MAkqEleb0= -k8s.io/component-base v0.26.10/go.mod h1:/IDdENUHG5uGxqcofZajovYXE9KSPzJ4yQbkYQt7oN0= +k8s.io/api v0.26.11 h1:hLhTZRdYc3vBBOY4wbEyTLWgMyieOAk2Ws9NG57QqO4= +k8s.io/api v0.26.11/go.mod h1:bSr/A0TKRt5W2OMDdexkM/ER1NxOxiQqNNFXW2nMZrM= +k8s.io/apiextensions-apiserver v0.26.11 h1:6/T0Jm9c+Aw1AYUflPOz2sAsty304/DDSkciTr8+HuE= +k8s.io/apiextensions-apiserver v0.26.11/go.mod h1:xMqWxAB+AvSTdmFRVWlpavY9bJl/3g6yWiPn/fwZbT0= +k8s.io/apimachinery v0.26.11 h1:w//840HHdwSRKqD15j9YX9HLlU6RPlfrvW0xEhLk2+0= +k8s.io/apimachinery v0.26.11/go.mod h1:2/HZp0l6coXtS26du1Bk36fCuAEr/lVs9Q9NbpBtd1Y= +k8s.io/client-go v0.26.11 h1:RjfZr5+vQjjTRmk4oCqHyC0cgrZXPjw+X+ge35sk4GI= +k8s.io/client-go v0.26.11/go.mod h1:+emNszw9va/uRJIM5ALTBtFnlZMTjwBrNjRfEh0iuw8= +k8s.io/component-base v0.26.11 h1:1/JmB6fexefGByfFyIK6aHksZZVtaDskttzXOzmZ6zA= +k8s.io/component-base v0.26.11/go.mod h1:jYNisnoM6iWFRUg51pxaQabzL5fBYTr5CMpsLjUYGp0= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI= +k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= From d112a5868f5777cbe183878f70e34f738331ffff Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 28 Nov 2023 12:31:00 +0100 Subject: [PATCH 2/3] [transporturl] watch for named rabbit cluster --- .../rabbitmq/transporturl_controller.go | 121 +++++++++++++----- 1 file changed, 92 insertions(+), 29 deletions(-) diff --git a/controllers/rabbitmq/transporturl_controller.go b/controllers/rabbitmq/transporturl_controller.go index 0968cf83..ca8a212b 100644 --- a/controllers/rabbitmq/transporturl_controller.go +++ b/controllers/rabbitmq/transporturl_controller.go @@ -24,16 +24,22 @@ import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + "sigs.k8s.io/controller-runtime/pkg/source" - rabbitmqv1beta1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper" oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret" - rabbitmqv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" + rabbitmqclusterv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" k8s_errors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" @@ -82,7 +88,7 @@ func (r *TransportURLReconciler) GetLogger(ctx context.Context) logr.Logger { func (r *TransportURLReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { Log := r.GetLogger(ctx) // Fetch the TransportURL instance - instance := &rabbitmqv1beta1.TransportURL{} + instance := &rabbitmqv1.TransportURL{} err := r.Client.Get(ctx, req.NamespacedName, instance) if err != nil { if k8s_errors.IsNotFound(err) { @@ -101,7 +107,7 @@ func (r *TransportURLReconciler) Reconcile(ctx context.Context, req ctrl.Request if instance.Status.Conditions == nil { instance.Status.Conditions = condition.Conditions{} - cl := condition.CreateList(condition.UnknownCondition(rabbitmqv1beta1.TransportURLReadyCondition, condition.InitReason, rabbitmqv1beta1.TransportURLReadyInitMessage)) + cl := condition.CreateList(condition.UnknownCondition(rabbitmqv1.TransportURLReadyCondition, condition.InitReason, rabbitmqv1.TransportURLReadyInitMessage)) instance.Status.Conditions.Init(&cl) @@ -147,7 +153,7 @@ func (r *TransportURLReconciler) Reconcile(ctx context.Context, req ctrl.Request } -func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance *rabbitmqv1beta1.TransportURL, helper *helper.Helper) (ctrl.Result, error) { +func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance *rabbitmqv1.TransportURL, helper *helper.Helper) (ctrl.Result, error) { Log := r.GetLogger(ctx) Log.Info("Reconciling Service") @@ -167,10 +173,10 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * } if !rabbitReady { instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.RequestedReason, condition.SeverityInfo, - rabbitmqv1beta1.TransportURLInProgressMessage)) + rabbitmqv1.TransportURLInProgressMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } @@ -180,17 +186,17 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * if err != nil { if k8s_errors.IsNotFound(err) { instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.RequestedReason, condition.SeverityInfo, - rabbitmqv1beta1.TransportURLInProgressMessage)) + rabbitmqv1.TransportURLInProgressMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - rabbitmqv1beta1.TransportURLReadyErrorMessage, + rabbitmqv1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -201,10 +207,10 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * } else { err := fmt.Errorf("username does not exist in rabbitmq secret %s", rabbitSecret.Name) instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - rabbitmqv1beta1.TransportURLReadyErrorMessage, + rabbitmqv1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -215,10 +221,10 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * } else { err := fmt.Errorf("password does not exist in rabbitmq secret %s", rabbitSecret.Name) instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - rabbitmqv1beta1.TransportURLReadyErrorMessage, + rabbitmqv1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -229,10 +235,10 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * } else { err := fmt.Errorf("host does not exist in rabbitmq secret %s", rabbitSecret.Name) instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - rabbitmqv1beta1.TransportURLReadyErrorMessage, + rabbitmqv1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -243,10 +249,10 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * } else { err := fmt.Errorf("port does not exist in rabbitmq secret %s", rabbitSecret.Name) instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - rabbitmqv1beta1.TransportURLReadyErrorMessage, + rabbitmqv1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } @@ -262,26 +268,26 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * _, op, err := oko_secret.CreateOrPatchSecret(ctx, helper, instance, secret) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.ErrorReason, condition.SeverityWarning, - rabbitmqv1beta1.TransportURLReadyErrorMessage, + rabbitmqv1.TransportURLReadyErrorMessage, err.Error())) return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { instance.Status.Conditions.Set(condition.FalseCondition( - rabbitmqv1beta1.TransportURLReadyCondition, + rabbitmqv1.TransportURLReadyCondition, condition.RequestedReason, condition.SeverityInfo, - rabbitmqv1beta1.TransportURLReadyInitMessage)) + rabbitmqv1.TransportURLReadyInitMessage)) return ctrl.Result{RequeueAfter: time.Second * 5}, nil } // Update the CR and return instance.Status.SecretName = secret.Name - instance.Status.Conditions.MarkTrue(rabbitmqv1beta1.TransportURLReadyCondition, rabbitmqv1beta1.TransportURLReadyMessage) + instance.Status.Conditions.MarkTrue(rabbitmqv1.TransportURLReadyCondition, rabbitmqv1.TransportURLReadyMessage) Log.Info("Reconciled Service successfully") return ctrl.Result{}, nil @@ -289,7 +295,7 @@ func (r *TransportURLReconciler) reconcileNormal(ctx context.Context, instance * // Create k8s secret with transport URL func (r *TransportURLReconciler) createTransportURLSecret( - instance *rabbitmqv1beta1.TransportURL, + instance *rabbitmqv1.TransportURL, username string, password string, host string, @@ -315,21 +321,78 @@ func (r *TransportURLReconciler) createTransportURLSecret( } } +// fields to index to reconcile when change +const ( + rabbitmqClusterNameField = ".spec.rabbitmqClusterName" +) + +var ( + allWatchFields = []string{ + rabbitmqClusterNameField, + } +) + // SetupWithManager sets up the controller with the Manager. func (r *TransportURLReconciler) SetupWithManager(mgr ctrl.Manager) error { + // index caSecretName + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &rabbitmqv1.TransportURL{}, rabbitmqClusterNameField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*rabbitmqv1.TransportURL) + if cr.Spec.RabbitmqClusterName == "" { + return nil + } + return []string{cr.Spec.RabbitmqClusterName} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). - For(&rabbitmqv1beta1.TransportURL{}). + For(&rabbitmqv1.TransportURL{}). Owns(&corev1.Secret{}). + Watches( + &source.Kind{Type: &rabbitmqclusterv1.RabbitmqCluster{}}, + handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc), + builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}), + ). Complete(r) } +func (r *TransportURLReconciler) findObjectsForSrc(src client.Object) []reconcile.Request { + requests := []reconcile.Request{} + + for _, field := range allWatchFields { + crList := &rabbitmqv1.TransportURLList{} + listOps := &client.ListOptions{ + FieldSelector: fields.OneTermEqualSelector(field, src.GetName()), + Namespace: src.GetNamespace(), + } + err := r.List(context.TODO(), crList, listOps) + if err != nil { + return []reconcile.Request{} + } + + for _, item := range crList.Items { + requests = append(requests, + reconcile.Request{ + NamespacedName: types.NamespacedName{ + Name: item.GetName(), + Namespace: item.GetNamespace(), + }, + }, + ) + } + } + + return requests +} + // GetRabbitmqCluster - get RabbitmqCluster object in namespace func getRabbitmqCluster( ctx context.Context, h *helper.Helper, - instance *rabbitmqv1beta1.TransportURL, -) (*rabbitmqv1.RabbitmqCluster, error) { - rabbitMqCluster := &rabbitmqv1.RabbitmqCluster{} + instance *rabbitmqv1.TransportURL, +) (*rabbitmqclusterv1.RabbitmqCluster, error) { + rabbitMqCluster := &rabbitmqclusterv1.RabbitmqCluster{} err := h.GetClient().Get(ctx, types.NamespacedName{Name: instance.Spec.RabbitmqClusterName, Namespace: instance.Namespace}, rabbitMqCluster) From bca900ba785f1c92c211d3e2397f00f63ce43cca Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Wed, 29 Nov 2023 18:07:19 +0100 Subject: [PATCH 3/3] [transporturl] Add envtest for default and tls use case --- go.mod | 2 + go.sum | 3 + tests/functional/base_test.go | 207 ++++++++++++++++++ tests/functional/suite_test.go | 32 ++- .../transporturl_controller_test.go | 182 +++++++++++++++ 5 files changed, 425 insertions(+), 1 deletion(-) create mode 100644 tests/functional/transporturl_controller_test.go diff --git a/go.mod b/go.mod index de855c4f..99db8533 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/onsi/gomega v1.30.0 github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20230920125017-2c76cd203b44 github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63 + github.com/openstack-k8s-operators/lib-common/modules/test v0.3.0 github.com/rabbitmq/cluster-operator v1.14.0 go.uber.org/zap v1.26.0 golang.org/x/exp v0.0.0-20231127185646-65229373498e @@ -55,6 +56,7 @@ require ( github.com/prometheus/procfs v0.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/multierr v1.10.0 // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect golang.org/x/sys v0.15.0 // indirect diff --git a/go.sum b/go.sum index 24251cf7..25308ec0 100644 --- a/go.sum +++ b/go.sum @@ -234,6 +234,8 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4= github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63 h1:iA/8vt+o2bMxYvvenNB7VArBvM8UyDLw3G7S/teMLc0= github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20231128145648-956f4d361a63/go.mod h1:OYad2L+OD4j5CR49di7gu3Q1UkLBmpYwvtdoGlnasL4= +github.com/openstack-k8s-operators/lib-common/modules/test v0.3.0 h1:w2YR0OEXxmE1kQWhyyGPmQUY6s46xxnF3AnvpMpYjRU= +github.com/openstack-k8s-operators/lib-common/modules/test v0.3.0/go.mod h1:RfLOPJbmPzPZ4XHwwDc2tFbbw5zxZL15JFGwb5c6VaU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -356,6 +358,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= diff --git a/tests/functional/base_test.go b/tests/functional/base_test.go index 1537b15f..86efb25c 100644 --- a/tests/functional/base_test.go +++ b/tests/functional/base_test.go @@ -25,13 +25,18 @@ import ( "github.com/google/uuid" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/intstr" + k8s_errors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + rabbitmqclusterv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" ) const ( @@ -136,6 +141,195 @@ func GetDefaultDNSDataSpec() map[string]interface{} { return spec } +func CreateTransportURL(name types.NamespacedName, spec map[string]interface{}) client.Object { + raw := map[string]interface{}{ + "apiVersion": "rabbitmq.openstack.org/v1beta1", + "kind": "TransportURL", + "metadata": map[string]interface{}{ + "name": name.Name, + "namespace": name.Namespace, + }, + "spec": spec, + } + + return th.CreateUnstructured(raw) +} + +func CreateRabbitMQCluster(name types.NamespacedName, spec map[string]interface{}) client.Object { + raw := map[string]interface{}{ + "apiVersion": "rabbitmq.com/v1beta1", + "kind": "RabbitmqCluster", + "metadata": map[string]interface{}{ + "name": name.Name, + "namespace": name.Namespace, + }, + "spec": spec, + } + + return th.CreateUnstructured(raw) +} + +func UpdateRabbitMQClusterToTLS(name types.NamespacedName) { + Eventually(func(g Gomega) { + mq := GetRabbitMQCluster(name) + g.Expect(mq).ToNot(BeNil()) + + _, err := controllerutil.CreateOrPatch( + th.Ctx, th.K8sClient, mq, func() error { + mq.Spec.TLS = rabbitmqclusterv1.TLSSpec{ + CaSecretName: "rootca-internal", + DisableNonTLSListeners: true, + SecretName: "cert-rabbitmq-svc", + } + return nil + }) + g.Expect(err).ShouldNot(HaveOccurred()) + }, th.Timeout, th.Interval).Should(Succeed()) +} + +func GetDefaultRabbitMQClusterSpec(tlsEnabled bool) map[string]interface{} { + spec := make(map[string]interface{}) + spec["delayStartSeconds"] = "30" + spec["image"] = "quay.io/podified-antelope-centos9/openstack-rabbitmq:current-podified" + if tlsEnabled { + spec["tls"] = map[string]interface{}{ + "caSecretName": "rootca-internal", + "disableNonTLSListeners": true, + "secretName": "cert-rabbitmq-svc", + } + } + + return spec +} + +// DeleteRabbitMQCluster deletes a RabbitMQCluster instance from the Kubernetes cluster. +func DeleteRabbitMQCluster(name types.NamespacedName) { + Eventually(func(g Gomega) { + mq := &rabbitmqclusterv1.RabbitmqCluster{} + err := th.K8sClient.Get(th.Ctx, name, mq) + // if it is already gone that is OK + if k8s_errors.IsNotFound(err) { + return + } + g.Expect(err).NotTo(HaveOccurred()) + + g.Expect(th.K8sClient.Delete(th.Ctx, mq)).Should(Succeed()) + + err = th.K8sClient.Get(th.Ctx, name, mq) + g.Expect(k8s_errors.IsNotFound(err)).To(BeTrue()) + }, th.Timeout, th.Interval).Should(Succeed()) +} + +func CreateOrUpdateRabbitMQClusterSecret(name types.NamespacedName, mq *rabbitmqclusterv1.RabbitmqCluster) { + Eventually(func(g Gomega) { + secret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: name.Name, + Namespace: name.Namespace, + }, + } + + // create rabbitmq-secret secret + secretData := map[string][]byte{ + "host": []byte(fmt.Sprintf("host.%s.svc", namespace)), + "password": []byte("12345678"), + "username": []byte("user"), + "port": []byte("5672"), + } + + // if tls is enabled for rabbitmq cluster port will be 5671 + if mq.Spec.TLS.SecretName != "" { + secretData["port"] = []byte("5671") + } + + _, err := controllerutil.CreateOrPatch( + th.Ctx, th.K8sClient, secret, func() error { + secret.Data = secretData + return nil + }) + g.Expect(err).ShouldNot(HaveOccurred()) + }, th.Timeout, th.Interval).Should(Succeed()) +} + +// SimulateRabbitMQClusterReady function updates the RabbitMQCluster object +// status to have AllReplicasReady condition, statusDefaultUser reference +// and creates the secret referenced there containing host, password and user. +// +// Example usage: +// +// SimulateRabbitMQClusterReady(types.NamespacedName{Name: "test-mq", Namespace: "test-namespace"}) +func SimulateRabbitMQClusterReady(name types.NamespacedName) { + Eventually(func(g Gomega) { + secretName := types.NamespacedName{Name: name.Name + "-default-user", Namespace: namespace} + + mq := GetRabbitMQCluster(name) + g.Expect(mq).ToNot(BeNil()) + + // create/update rabbitmq secret + CreateOrUpdateRabbitMQClusterSecret(secretName, mq) + + raw := map[string]interface{}{ + "apiVersion": "rabbitmq.com/v1beta1", + "kind": "RabbitmqCluster", + "metadata": map[string]interface{}{ + "name": name.Name, + "namespace": name.Namespace, + }, + } + + status := make(map[string]interface{}) + + // add AllReplicasReady condition + statusCondition := []map[string]interface{}{ + { + "reason": "AllPodsAreReady", + "status": "True", + "type": "AllReplicasReady", + }, + } + + // add status.defaultUser which is used to get the + // secret holding username/password/host + statusDefaultUser := map[string]interface{}{ + "secretReference": map[string]interface{}{ + "keys": map[string]interface{}{ + "password": "password", + "username": "username", + }, + "name": secretName.Name, + "namespace": name.Namespace, + }, + "serviceReference": map[string]interface{}{ + "name": name.Name, + "namespace": name.Namespace, + }, + } + + status["conditions"] = statusCondition + status["defaultUser"] = statusDefaultUser + raw["status"] = status + + un := &unstructured.Unstructured{Object: raw} + deploymentRes := schema.GroupVersionResource{ + Group: "rabbitmq.com", + Version: "v1beta1", + Resource: "rabbitmqclusters", + } + + // Patch status + result, err := dynClient.Resource(deploymentRes).Namespace(namespace).ApplyStatus( + th.Ctx, name.Name, un, metav1.ApplyOptions{FieldManager: "application/apply-patch"}) + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(result).ToNot(BeNil()) + + mq = GetRabbitMQCluster(name) + g.Expect(mq.Status.Conditions).ToNot(BeNil()) + g.Expect(mq.Status.DefaultUser).ToNot(BeNil()) + + }, th.Timeout, th.Interval).Should(Succeed()) + th.Logger.Info("Simulated RabbitMQCluster ready", "on", name) +} + func GetDNSMasq(name types.NamespacedName) *networkv1.DNSMasq { instance := &networkv1.DNSMasq{} Eventually(func(g Gomega) { @@ -176,6 +370,14 @@ func GetReservation(name types.NamespacedName) *networkv1.Reservation { return instance } +func GetRabbitMQCluster(name types.NamespacedName) *rabbitmqclusterv1.RabbitmqCluster { + mq := &rabbitmqclusterv1.RabbitmqCluster{} + Eventually(func(g Gomega) { + g.Expect(k8sClient.Get(ctx, name, mq)).Should(Succeed()) + }, timeout, interval).Should(Succeed()) + return mq +} + func DNSMasqConditionGetter(name types.NamespacedName) condition.Conditions { instance := GetDNSMasq(name) return instance.Status.Conditions @@ -191,6 +393,11 @@ func IPSetConditionGetter(name types.NamespacedName) condition.Conditions { return instance.Status.Conditions } +func TransportURLConditionGetter(name types.NamespacedName) condition.Conditions { + instance := infra.GetTransportURL(name) + return instance.Status.Conditions +} + func CreateLoadBalancerService(name types.NamespacedName, addDnsAnno bool) *corev1.Service { svc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ diff --git a/tests/functional/suite_test.go b/tests/functional/suite_test.go index 13d39d8f..aba28545 100644 --- a/tests/functional/suite_test.go +++ b/tests/functional/suite_test.go @@ -26,6 +26,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "go.uber.org/zap/zapcore" + "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" @@ -36,8 +37,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + rabbitmqclusterv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" network_ctrl "github.com/openstack-k8s-operators/infra-operator/controllers/network" + rabbitmq_ctrl "github.com/openstack-k8s-operators/infra-operator/controllers/rabbitmq" + + infra_test "github.com/openstack-k8s-operators/infra-operator/apis/test/helpers" + test "github.com/openstack-k8s-operators/lib-common/modules/test" . "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers" //+kubebuilder:scaffold:imports @@ -49,12 +56,14 @@ import ( var ( cfg *rest.Config k8sClient client.Client // You'll be using this client in your tests. + dynClient *dynamic.DynamicClient testEnv *envtest.Environment ctx context.Context cancel context.CancelFunc logger logr.Logger th *TestHelper namespace string + infra *infra_test.TestHelper ) func TestAPIs(t *testing.T) { @@ -70,10 +79,15 @@ var _ = BeforeSuite(func() { ctx, cancel = context.WithCancel(context.TODO()) + rabbitmqv2CRDs, err := test.GetCRDDirFromModule( + "github.com/rabbitmq/cluster-operator", "../../go.mod", "config/crd/bases") + Expect(err).ShouldNot(HaveOccurred()) + By("bootstrapping test environment") testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{ filepath.Join("..", "..", "config", "crd", "bases"), + rabbitmqv2CRDs, }, ErrorIfCRDPathMissing: true, WebhookInstallOptions: envtest.WebhookInstallOptions{ @@ -86,7 +100,6 @@ var _ = BeforeSuite(func() { } // cfg is defined in this file globally. - var err error cfg, err = testEnv.Start() Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) @@ -97,6 +110,10 @@ var _ = BeforeSuite(func() { // in the test env. err = networkv1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) + err = rabbitmqv1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + err = rabbitmqclusterv1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme logger = ctrl.Log.WithName("---Test---") @@ -106,6 +123,8 @@ var _ = BeforeSuite(func() { Expect(k8sClient).NotTo(BeNil()) th = NewTestHelper(ctx, k8sClient, timeout, interval, logger) Expect(th).NotTo(BeNil()) + infra = infra_test.NewTestHelper(ctx, k8sClient, timeout, interval, logger) + Expect(infra).NotTo(BeNil()) // Start the controller-manager if goroutine webhookInstallOptions := &testEnv.WebhookInstallOptions @@ -125,6 +144,10 @@ var _ = BeforeSuite(func() { kclient, err := kubernetes.NewForConfig(cfg) Expect(err).ToNot(HaveOccurred(), "failed to create kclient") + dynClient, err = dynamic.NewForConfig(cfg) + Expect(err).NotTo(HaveOccurred()) + Expect(dynClient).NotTo(BeNil()) + err = (&networkv1.NetConfig{}).SetupWebhookWithManager(k8sManager) Expect(err).NotTo(HaveOccurred()) err = (&networkv1.IPSet{}).SetupWebhookWithManager(k8sManager) @@ -162,6 +185,13 @@ var _ = BeforeSuite(func() { }).SetupWithManager(context.Background(), k8sManager) Expect(err).ToNot(HaveOccurred()) + err = (&rabbitmq_ctrl.TransportURLReconciler{ + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + Kclient: kclient, + }).SetupWithManager(k8sManager) + Expect(err).ToNot(HaveOccurred()) + go func() { defer GinkgoRecover() err = k8sManager.Start(ctx) diff --git a/tests/functional/transporturl_controller_test.go b/tests/functional/transporturl_controller_test.go new file mode 100644 index 00000000..b263f750 --- /dev/null +++ b/tests/functional/transporturl_controller_test.go @@ -0,0 +1,182 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package functional_test + +import ( + "fmt" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + . "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers" + corev1 "k8s.io/api/core/v1" + + rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + + "k8s.io/apimachinery/pkg/types" +) + +var _ = Describe("TransportURL controller", func() { + var transportURLName types.NamespacedName + var rabbitmqClusterName types.NamespacedName + var transportURLSecretName types.NamespacedName + + BeforeEach(func() { + transportURLName = types.NamespacedName{ + Name: "foo", + Namespace: namespace, + } + rabbitmqClusterName = types.NamespacedName{ + Name: "rabbitmq", + Namespace: namespace, + } + transportURLSecretName = types.NamespacedName{ + Name: "rabbitmq-transport-url-" + transportURLName.Name, + Namespace: namespace, + } + }) + + When("a non TLS TransportURL gets created", func() { + BeforeEach(func() { + CreateRabbitMQCluster(rabbitmqClusterName, GetDefaultRabbitMQClusterSpec(false)) + DeferCleanup(DeleteRabbitMQCluster, rabbitmqClusterName) + + spec := map[string]interface{}{ + "rabbitmqClusterName": rabbitmqClusterName.Name, + } + DeferCleanup(th.DeleteInstance, CreateTransportURL(transportURLName, spec)) + }) + + It("should have the Spec fields set", func() { + tr := infra.GetTransportURL(transportURLName) + Expect(tr.Spec.RabbitmqClusterName).Should(Equal("rabbitmq")) + }) + + It("should have not ready Conditions initialized", func() { + th.ExpectCondition( + transportURLName, + ConditionGetterFunc(TransportURLConditionGetter), + condition.ReadyCondition, + corev1.ConditionFalse, + ) + th.ExpectCondition( + transportURLName, + ConditionGetterFunc(TransportURLConditionGetter), + rabbitmqv1.TransportURLReadyCondition, + corev1.ConditionFalse, + ) + }) + + It("should create a secret holding the _NON_ TLS transport url when rabbitmq cluster is ready", func() { + SimulateRabbitMQClusterReady(rabbitmqClusterName) + + Eventually(func(g Gomega) { + s := th.GetSecret(transportURLSecretName) + g.Expect(s.Data).To(HaveLen(1)) + g.Expect(s.Data).To(HaveKeyWithValue("transport_url", []byte(fmt.Sprintf("rabbit://user:12345678@host.%s.svc:5672/?ssl=0", namespace)))) + + }, timeout, interval).Should(Succeed()) + + th.ExpectCondition( + transportURLName, + ConditionGetterFunc(TransportURLConditionGetter), + rabbitmqv1.TransportURLReadyCondition, + corev1.ConditionTrue, + ) + + tr := infra.GetTransportURL(transportURLName) + Expect(tr).ToNot(BeNil()) + Expect(tr.Status.SecretName).To(Equal(transportURLSecretName.Name)) + }) + }) + + When("a TLS TransportURL gets created", func() { + BeforeEach(func() { + CreateRabbitMQCluster(rabbitmqClusterName, GetDefaultRabbitMQClusterSpec(true)) + DeferCleanup(DeleteRabbitMQCluster, rabbitmqClusterName) + + spec := map[string]interface{}{ + "rabbitmqClusterName": rabbitmqClusterName.Name, + } + DeferCleanup(th.DeleteInstance, CreateTransportURL(transportURLName, spec)) + }) + + It("should create a secret holding the TLS transport url when rabbitmq cluster is ready", func() { + SimulateRabbitMQClusterReady(rabbitmqClusterName) + + Eventually(func(g Gomega) { + s := th.GetSecret(transportURLSecretName) + g.Expect(s.Data).To(HaveLen(1)) + g.Expect(s.Data).To(HaveKeyWithValue("transport_url", []byte(fmt.Sprintf("rabbit://user:12345678@host.%s.svc:5671/?ssl=1", namespace)))) + + }, timeout, interval).Should(Succeed()) + + th.ExpectCondition( + transportURLName, + ConditionGetterFunc(TransportURLConditionGetter), + rabbitmqv1.TransportURLReadyCondition, + corev1.ConditionTrue, + ) + + tr := infra.GetTransportURL(transportURLName) + Expect(tr).ToNot(BeNil()) + Expect(tr.Status.SecretName).To(Equal(transportURLSecretName.Name)) + }) + }) + + When("TLS gets enable for RabbitMQ, the TransportURL gets updated", func() { + BeforeEach(func() { + CreateRabbitMQCluster(rabbitmqClusterName, GetDefaultRabbitMQClusterSpec(false)) + DeferCleanup(DeleteRabbitMQCluster, rabbitmqClusterName) + + spec := map[string]interface{}{ + "rabbitmqClusterName": rabbitmqClusterName.Name, + } + DeferCleanup(th.DeleteInstance, CreateTransportURL(transportURLName, spec)) + }) + + It("should update the secret holding the TLS transport url", func() { + SimulateRabbitMQClusterReady(rabbitmqClusterName) + + // validate non tls transport_url + Eventually(func(g Gomega) { + s := th.GetSecret(transportURLSecretName) + g.Expect(s.Data).To(HaveLen(1)) + g.Expect(s.Data).To(HaveKeyWithValue("transport_url", []byte(fmt.Sprintf("rabbit://user:12345678@host.%s.svc:5672/?ssl=0", namespace)))) + + }, timeout, interval).Should(Succeed()) + + // update rabbitmq to be tls + UpdateRabbitMQClusterToTLS(rabbitmqClusterName) + SimulateRabbitMQClusterReady(rabbitmqClusterName) + + Eventually(func(g Gomega) { + s := th.GetSecret(transportURLSecretName) + g.Expect(s.Data).To(HaveLen(1)) + g.Expect(s.Data).To(HaveKeyWithValue("transport_url", []byte(fmt.Sprintf("rabbit://user:12345678@host.%s.svc:5671/?ssl=1", namespace)))) + + }, timeout, interval).Should(Succeed()) + + th.ExpectCondition( + transportURLName, + ConditionGetterFunc(TransportURLConditionGetter), + rabbitmqv1.TransportURLReadyCondition, + corev1.ConditionTrue, + ) + }) + }) +})