@@ -126,6 +126,7 @@ func AutoDetectTenantSecrets(
126
126
127
127
// Filter secrets for configured tenants.
128
128
configuredTenants := strings .Split (managedTenants , "," )
129
+ missingSecretTenants := strings .Split (managedTenants , "," )
129
130
for i := range secret .Items {
130
131
lbls := secret .Items [i ].Labels
131
132
@@ -136,6 +137,9 @@ func AutoDetectTenantSecrets(
136
137
// If tenant is not configured, skip.
137
138
if ! slices .Contains (configuredTenants , lbls ["tenant" ]) {
138
139
continue
140
+ } else {
141
+ s , _ := slices .BinarySearch (missingSecretTenants , lbls ["tenant" ])
142
+ missingSecretTenants = slices .Delete (missingSecretTenants , s , s + 1 )
139
143
}
140
144
141
145
if secret .Items [i ].Data == nil {
@@ -171,6 +175,10 @@ func AutoDetectTenantSecrets(
171
175
tenantSecret [lbls ["tenant" ]] = tOIDC
172
176
}
173
177
178
+ if len (missingSecretTenants ) != 0 {
179
+ return tenantSecret , errors .Newf ("missing secrets for tenants: %v" , missingSecretTenants )
180
+ }
181
+
174
182
return tenantSecret , nil
175
183
}
176
184
@@ -201,7 +209,9 @@ func (o *ObsctlRulesSyncer) InitOrReloadObsctlConfig() error {
201
209
tenantSecrets , err := o .autoDetectSecretsFn (o .ctx , o .k8s , o .namespace , o .audience , o .issuerURL , o .managedTenants )
202
210
if err != nil {
203
211
level .Error (o .logger ).Log ("msg" , "auto detecting tenant secrets" , "error" , err )
204
- return errors .Wrap (err , "auto detecting tenant secrets" )
212
+ if len (tenantSecrets ) == 0 {
213
+ return errors .Wrap (err , "no tenant secrets auto-detected" )
214
+ }
205
215
}
206
216
207
217
// Add all managed tenants under the API.
0 commit comments