Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Jul 4, 2023
1 parent 8ef0376 commit f75079a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ spec:
divisor: '0'
{{- if .labelSelector }}
- name: CENTRAL_LABEL_SELECTOR
value: "rhacs.redhat.com/reconcile-sha256={{ .labelSelector }}"
value: "rhacs.redhat.com/label-selector={{ .labelSelector }}"
{{- end }}
image: "{{ .repository }}:{{ .tag }}"
imagePullPolicy: IfNotPresent
Expand Down
7 changes: 4 additions & 3 deletions fleetshard/pkg/central/operator/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func parseOperatorImages(images []string) ([]chartutil.Values, error) {
}
if _, used := uniqueImages[repo+tag]; !used {
uniqueImages[repo+tag] = true
img := chartutil.Values{"deploymentName": deploymentName, "repository": repo, "tag": tag, "labelSelector": GetSelectorTag(img)}
img := chartutil.Values{"deploymentName": deploymentName, "repository": repo, "tag": tag, "labelSelector": GetValidSelectorTag(tag)}
operatorImages = append(operatorImages, img)
}
}
Expand Down Expand Up @@ -84,8 +84,9 @@ func init() {
}
}

func GetSelectorTag(image string) string {
return urlRegexExp.ReplaceAllString(image, "")
// GetValidSelectorTag returns a valid selector string which can be used in a kubernetes metadata label.
func GetValidSelectorTag(tag string) string {
return urlRegexExp.ReplaceAllString(tag, "")
}

// InstallOrUpgrade provisions or upgrades an existing ACS Operator from helm chart template
Expand Down
4 changes: 2 additions & 2 deletions fleetshard/pkg/central/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (
BlockedStatus

PauseReconcileAnnotation = "stackrox.io/pause-reconcile"
ReconcileOperatorSelector = "rhacs.redhat.com/reconcile-sha256"
ReconcileOperatorSelector = "rhacs.redhat.com/label-selector"

helmReleaseName = "tenant-resources"

Expand Down Expand Up @@ -256,7 +256,7 @@ func (r *CentralReconciler) getInstanceConfig(remoteCentral *private.ManagedCent
Annotations: map[string]string{
managedServicesAnnotation: "true",
orgNameAnnotationKey: remoteCentral.Spec.Auth.OwnerOrgName,
ReconcileOperatorSelector: imageSHA256,
ReconcileOperatorSelector: operator.GetValidSelectorTag(imageSHA256),
},
},
Spec: v1alpha1.CentralSpec{
Expand Down
18 changes: 5 additions & 13 deletions fleetshard/pkg/fleetshardmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func (m *Metrics) Register(r prometheus.Registerer) {
r.MustRegister(m.centralDBSnapshotsUsed)
r.MustRegister(m.centralDBSnapshotsMax)
r.MustRegister(m.pauseReconcileInstances)
r.MustRegister(m.operatorsHealthStatus)
}

// IncFleetManagerRequests increments the metric counter for fleet-manager requests
Expand Down Expand Up @@ -115,12 +114,12 @@ func (m *Metrics) SetPauseReconcileStatus(instance string, pauseReconcileEnabled

// SetOperatorHealthStatus sets the health status for specific operator image
func (m *Metrics) SetOperatorHealthStatus(image string, healthy bool) {
var healthyVal float64
if healthy {
healthyVal = 1.0
}
//var healthyVal float64
//if healthy {
// healthyVal = 1.0
//}

m.operatorsHealthStatus.With(prometheus.Labels{"image": image}).Set(healthyVal)
//m.operatorsHealthStatus.With(prometheus.Labels{"image": image}).Set(healthyVal)
}

// MetricsInstance return the global Singleton instance for Metrics
Expand Down Expand Up @@ -190,12 +189,5 @@ func newMetrics() *Metrics {
},
[]string{"instance"},
),
operatorsHealthStatus: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: metricsPrefix + "operator_health_status",
Help: "The operator health status reports all healthy operators installed in a data-plane cluster by fleetshard-sync.",
},
[]string{"operator-version"},
),
}
}

0 comments on commit f75079a

Please sign in to comment.