Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions internal/controller/appserver/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,23 @@ func GenerateOLSConfigMap(r reconciler.Reconciler, ctx context.Context, cr *olsv
}

func generateExporterConfigMap(r reconciler.Reconciler, cr *olsv1alpha1.OLSConfig) (*corev1.ConfigMap, error) {
serviceID := utils.ServiceIDOLS
if cr.Labels != nil {
if _, hasRHOSLightspeedLabel := cr.Labels[utils.RHOSOLightspeedOwnerIDLabel]; hasRHOSLightspeedLabel {
serviceID = utils.ServiceIDRHOSO
}
}

// Collection interval is set to 300 seconds in production (5 minutes)
exporterConfigContent := `service_id: "ols"
exporterConfigContent := fmt.Sprintf(`service_id: "%s"
ingress_server_url: "https://console.redhat.com/api/ingress/v1/upload"
allowed_subdirs:
- feedback
- transcripts
# Collection settings
collection_interval: 300
cleanup_after_send: true
ingress_connection_timeout: 30`
ingress_connection_timeout: 30`, serviceID)

cm := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
22 changes: 22 additions & 0 deletions internal/controller/appserver/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,28 @@ var _ = Describe("App server assets", func() {
}))
})

It("should generate exporter configmap with service_id 'ols' by default", func() {
cm, err := generateExporterConfigMap(testReconcilerInstance, cr)
Expect(err).NotTo(HaveOccurred())
Expect(cm.Name).To(Equal(utils.ExporterConfigCmName))
Expect(cm.Namespace).To(Equal(utils.OLSNamespaceDefault))
Expect(cm.Data[utils.ExporterConfigFilename]).To(ContainSubstring(`service_id: "` + utils.ServiceIDOLS + `"`))
})

It("should generate exporter configmap with service_id 'rhos-lightspeed' when label is present", func() {
if cr.Labels == nil {
cr.Labels = make(map[string]string)
}

cr.Labels[utils.RHOSOLightspeedOwnerIDLabel] = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"

cm, err := generateExporterConfigMap(testReconcilerInstance, cr)
Expect(err).NotTo(HaveOccurred())
Expect(cm.Name).To(Equal(utils.ExporterConfigCmName))
Expect(cm.Namespace).To(Equal(utils.OLSNamespaceDefault))
Expect(cm.Data[utils.ExporterConfigFilename]).To(ContainSubstring(`service_id: "` + utils.ServiceIDRHOSO + `"`))
})

})

Context("empty custom resource", func() {
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ ssl_ca_file = '/etc/certs/cm-olspostgresca/service-ca.crt'
ExporterConfigFilename = "config.yaml"
// OLSUserDataMountPath is the path where user data is mounted in the app server container
OLSUserDataMountPath = "/app-root/ols-user-data"
// ServiceIDOLS is the service ID used by the data exporter
ServiceIDOLS = "ols"
// RHOSOLightspeedOwnerIDLabel is the label used to identify RHOSO Lightspeed deployment
RHOSOLightspeedOwnerIDLabel = "openstack.org/lightspeed-owner-id"
// ServiceIDRHOSO is the service ID used by the data exporter when RHOSO Lightspeed is deployed
ServiceIDRHOSO = "rhos-lightspeed"

/*** Container Names (used for testing) ***/
// OLSAppServerContainerName is the name of the OLS application server container
Expand Down