fix: operator propagate correct compression for collection · GoogleCloudPlatform/prometheus-engine@c60d3bb (original) (raw)

`@@ -119,7 +119,7 @@ func (r *rulesReconciler) Reconcile(ctx context.Context, req reconcile.Request)

`

119

119

`return reconcile.Result{}, fmt.Errorf("get operatorconfig for incoming: %q: %w", req.String(), err)

`

120

120

` }

`

121

121

``

122

``

`-

var projectID, location, cluster = resolveLabels(r.opts.ProjectID, r.opts.Location, r.opts.Cluster, config.Rules.ExternalLabels)

`

``

122

`+

projectID, location, cluster := resolveLabels(r.opts.ProjectID, r.opts.Location, r.opts.Cluster, config.Rules.ExternalLabels)

`

123

123

``

124

124

`if err := r.ensureRuleConfigs(ctx, projectID, location, cluster, config.Features.Config.Compression); err != nil {

`

125

125

`return reconcile.Result{}, fmt.Errorf("ensure rule configmaps: %w", err)

`

`@@ -203,13 +203,15 @@ func hasRules(ctx context.Context, c client.Client) (bool, error) {

`

203

203

` }

`

204

204

`return len(rules.Items) > 0, nil

`

205

205

`}

`

``

206

+

206

207

`func hasClusterRules(ctx context.Context, c client.Client) (bool, error) {

`

207

208

`var rules monitoringv1.ClusterRulesList

`

208

209

`if err := c.List(ctx, &rules); err != nil {

`

209

210

`return false, err

`

210

211

` }

`

211

212

`return len(rules.Items) > 0, nil

`

212

213

`}

`

``

214

+

213

215

`func hasGlobalRules(ctx context.Context, c client.Client) (bool, error) {

`

214

216

`var rules monitoringv1.GlobalRulesList

`

215

217

`if err := c.List(ctx, &rules); err != nil {

`

`@@ -219,7 +221,7 @@ func hasGlobalRules(ctx context.Context, c client.Client) (bool, error) {

`

219

221

`}

`

220

222

``

221

223

`// ensureRuleConfigs updates the Prometheus Rules ConfigMap.

`

222

``

`-

func (r *rulesReconciler) ensureRuleConfigs(ctx context.Context, projectID, location, cluster string, compression monitoringv1.CompressionType) error {

`

``

224

`+

func (r *rulesReconciler) ensureRuleConfigs(ctx context.Context, projectID, location, cluster string, configCompression monitoringv1.CompressionType) error {

`

223

225

`logger, _ := logr.FromContext(ctx)

`

224

226

``

225

227

`// Re-generate the configmap that's loaded by the rule-evaluator.

`

`@@ -276,7 +278,7 @@ func (r *rulesReconciler) ensureRuleConfigs(ctx context.Context, projectID, loca

`

276

278

`continue

`

277

279

` }

`

278

280

`filename := fmt.Sprintf("rules__%s__%s.yaml", rs.Namespace, rs.Name)

`

279

``

`-

if err := setConfigMapData(cm, compression, filename, result); err != nil {

`

``

281

`+

if err := setConfigMapData(cm, configCompression, filename, result); err != nil {

`

280

282

`return err

`

281

283

` }

`

282

284

``

`@@ -306,7 +308,7 @@ func (r *rulesReconciler) ensureRuleConfigs(ctx context.Context, projectID, loca

`

306

308

`continue

`

307

309

` }

`

308

310

`filename := fmt.Sprintf("clusterrules__%s.yaml", rs.Name)

`

309

``

`-

if err := setConfigMapData(cm, compression, filename, result); err != nil {

`

``

311

`+

if err := setConfigMapData(cm, configCompression, filename, result); err != nil {

`

310

312

`return err

`

311

313

` }

`

312

314

``

`@@ -336,7 +338,7 @@ func (r *rulesReconciler) ensureRuleConfigs(ctx context.Context, projectID, loca

`

336

338

`continue

`

337

339

` }

`

338

340

`filename := fmt.Sprintf("globalrules__%s.yaml", rs.Name)

`

339

``

`-

if err := setConfigMapData(cm, compression, filename, result); err != nil {

`

``

341

`+

if err := setConfigMapData(cm, configCompression, filename, result); err != nil {

`

340

342

`return err

`

341

343

` }

`

342

344

``