diff --git a/config/custom-environment-variables.json b/config/custom-environment-variables.json index 67aa92f..b53d147 100644 --- a/config/custom-environment-variables.json +++ b/config/custom-environment-variables.json @@ -14,14 +14,11 @@ }, "opentelemetryOptions": { "enabled": { - "__name": "TELEMETRY_LOGGER_OTEL_ENABLED", + "__name": "OPENTELEMETRY_LOGGING_ENABLED", "__format": "boolean" }, - "url": "TELEMETRY_LOGGER_OTEL_URL", - "resourceAttributes": { - "__name": "TELEMETRY_LOGGER_OTEL_RESOURCE_ATTRIBUTES", - "__format": "json" - } + "url": "OTLP_LOGGER_ENDPOINT_URL", + "resourceAttributes": "OTEL_RESOURCE_ATTRIBUTES" } } }, diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 1169686..778663b 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -96,23 +96,35 @@ Returns the cloud provider image pull secret name from global if exists or from {{- end -}} {{/* -Returns the tracing url from global if exists or from the chart's values +Returns the tracing url from global if set, otherwise from the chart's values */}} {{- define "cleaner.tracingUrl" -}} -{{- if .Values.global.tracing.url }} - {{- .Values.global.tracing.url -}} -{{- else if .Values.cloudProvider -}} - {{- .Values.env.tracing.url -}} +{{- if .Values.global.telemetry.tracing.url }} + {{- .Values.global.telemetry.tracing.url -}} +{{- else if .Values.telemetry.tracing.url -}} + {{- .Values.telemetry.tracing.url -}} {{- end -}} {{- end -}} {{/* -Returns the metrics url from global if exists or from the chart's values +Returns the opentelemetry logging url from global if set, otherwise from the chart's values */}} -{{- define "cleaner.metricsUrl" -}} -{{- if .Values.global.metrics.url }} - {{- .Values.global.metrics.url -}} -{{- else -}} - {{- .Values.env.metrics.url | default "" -}} +{{- define "cleaner.opentelemetryLoggingUrl" -}} +{{- if .Values.global.telemetry.logger.opentelemetryOptions.url }} + {{- .Values.global.telemetry.logger.opentelemetryOptions.url -}} +{{- else if .Values.telemetry.logger.opentelemetryOptions.url -}} + {{- .Values.telemetry.logger.opentelemetryOptions.url -}} {{- end -}} {{- end -}} + +{{/* +Renders a map of resource attributes as key=value,key=value for OTEL_RESOURCE_ATTRIBUTES. +Usage: {{ include "cleaner.otelResourceAttributes" .resourceAttributes }} +*/}} +{{- define "cleaner.otelResourceAttributes" -}} +{{- $attributes := list }} +{{- range $key, $value := . }} +{{- $attributes = append $attributes (printf "%s=%s" $key (toString $value)) }} +{{- end }} +{{- join "," $attributes }} +{{- end -}} diff --git a/helm/templates/_tplValues.tpl b/helm/templates/_tplValues.tpl index 55da75a..6b8e843 100644 --- a/helm/templates/_tplValues.tpl +++ b/helm/templates/_tplValues.tpl @@ -56,7 +56,3 @@ Custom definitions {{- define "common.storage.merged" -}} {{- include "common.tplvalues.merge" ( dict "values" ( list .Values.storage .Values.global.storage ) "context" . ) }} {{- end -}} - -{{- define "common.ca.merged" -}} -{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.ca .Values.global.ca ) "context" . ) }} -{{- end -}} diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 95bc4c1..c8ade63 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -1,4 +1,6 @@ +{{- $telemetry := .Values.telemetry -}} {{- $tracingUrl := include "cleaner.tracingUrl" . -}} +{{- $opentelemetryLoggingUrl := include "cleaner.opentelemetryLoggingUrl" . -}} {{- $serviceUrls := fromYaml (include "common.serviceUrls.merged" .) -}} {{- $storage := fromYaml (include "common.storage.merged" .) -}} {{- $s3 := ($storage.s3) | default dict -}} @@ -11,18 +13,22 @@ kind: ConfigMap metadata: name: {{ printf "%s-configmap" (include "cleaner.fullname" .) }} data: - LOG_LEVEL: {{ .Values.env.logLevel | quote }} - LOG_PRETTY_PRINT_ENABLED: {{ .Values.env.prettyPrintEnabled | quote }} - {{- with .Values.env.openTelemetryOptions }} - TELEMETRY_LOGGER_OTEL_ENABLED: {{ .enabled | default false | quote }} + {{- with $telemetry }} + LOG_LEVEL: {{ .logger.level | quote }} + LOG_PRETTY_PRINT_ENABLED: {{ .logger.prettyPrint | quote }} + {{- with .logger.opentelemetryOptions }} + OPENTELEMETRY_LOGGING_ENABLED: {{ .enabled | quote }} {{- if .enabled }} - TELEMETRY_LOGGER_OTEL_URL: {{ .url | default "" | quote }} - TELEMETRY_LOGGER_OTEL_RESOURCE_ATTRIBUTES: {{ .resourceAttributes | default dict | toJson | quote }} - {{- end}} + OTLP_LOGGER_ENDPOINT_URL: {{ $opentelemetryLoggingUrl | quote }} + {{- if .resourceAttributes }} + OTEL_RESOURCE_ATTRIBUTES: {{ include "cleaner.otelResourceAttributes" .resourceAttributes | quote }} + {{- end }} + {{- end }} + {{- end }} + TELEMETRY_TRACING_ENABLED: {{ .tracing.enabled | quote }} + {{- if .tracing.enabled }} + TELEMETRY_TRACING_URL: {{ $tracingUrl | quote }} {{- end }} - {{- if .Values.env.tracing.enabled }} - TELEMETRY_TRACING_ENABLED: 'true' - TELEMETRY_TRACING_URL: {{ $tracingUrl }} {{- end }} npm_config_cache: /tmp/ {{- with .Values.configManagement }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 0b8be5f..9e4563c 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -4,7 +4,7 @@ {{- $cloudProviderDockerRegistryUrl := include "cleaner.cloudProviderDockerRegistryUrl" . -}} {{- $cloudProviderImagePullSecretName := include "cleaner.cloudProviderImagePullSecretName" . -}} {{- $imageTag := include "cleaner.tag" . -}} -{{- $ca := fromYaml (include "common.ca.merged" .) -}} +{{- $server := .Values.server -}} {{- $storage := fromYaml (include "common.storage.merged" .) -}} {{- $s3 := ($storage.s3) | default dict -}} {{- $internalPvc := (($storage.fs).internalPvc) | default dict -}} @@ -62,10 +62,10 @@ spec: {{- end }} {{- end }} volumeMounts: - {{- if $ca.secretName }} - - mountPath: {{ printf "%s/%s" $ca.path $ca.key | quote }} + {{- if .Values.global.ca.secretName }} + - mountPath: {{ printf "%s/%s" .Values.global.ca.path .Values.global.ca.key | quote }} name: root-ca - subPath: {{ quote $ca.key }} + subPath: {{ quote .Values.global.ca.key }} {{- end }} {{- if .Values.extraVolumeMounts -}} {{ toYaml .Values.extraVolumeMounts | nindent 12 }} @@ -80,12 +80,12 @@ spec: fieldRef: fieldPath: metadata.uid - name: SERVER_PORT - value: {{ .Values.env.targetPort | quote }} - {{- if $ca.secretName }} + value: {{ $server.targetPort | quote }} + {{- if .Values.global.ca.secretName }} - name: REQUESTS_CA_BUNDLE - value: {{ printf "%s/%s" $ca.path $ca.key | quote }} + value: {{ printf "%s/%s" .Values.global.ca.path .Values.global.ca.key | quote }} - name: NODE_EXTRA_CA_CERTS - value: {{ printf "%s/%s" $ca.path $ca.key | quote }} + value: {{ printf "%s/%s" .Values.global.ca.path .Values.global.ca.key | quote }} {{- end }} {{- if $s3.secretName }} - name: S3_ACCESS_KEY_ID @@ -112,7 +112,7 @@ spec: failureThreshold: {{ .Values.livenessProbe.failureThreshold }} httpGet: path: {{ .Values.livenessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ $server.targetPort }} {{- end }} {{- if .Values.readinessProbe.enabled }} readinessProbe: @@ -121,7 +121,7 @@ spec: failureThreshold: {{ .Values.readinessProbe.failureThreshold }} httpGet: path: {{ .Values.readinessProbe.path }} - port: {{ .Values.env.targetPort }} + port: {{ $server.targetPort }} {{- end }} {{- if .Values.resources.enabled }} resources: @@ -131,10 +131,10 @@ spec: {{ tpl (toYaml .Values.sidecars) . | nindent 8 }} {{- end }} volumes: - {{- if $ca.secretName }} + {{- if .Values.global.ca.secretName }} - name: root-ca secret: - secretName: {{ $ca.secretName }} + secretName: {{ .Values.global.ca.secretName }} {{- end }} {{- if .Values.extraVolumes -}} {{ tpl (toYaml .Values.extraVolumes) . | nindent 8 }} diff --git a/helm/values.yaml b/helm/values.yaml index 70f01e9..9bd6e92 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -1,11 +1,16 @@ global: cloudProvider: {} - tracing: {} - metrics: {} + telemetry: + tracing: {} + logger: + opentelemetryOptions: {} jobDefinitions: {} storage: {} serviceUrls: {} - ca: {} + ca: + secretName: '' + path: '/usr/local/share/ca-certificates' + key: 'ca.crt' serviceUrls: jobManager: "" @@ -13,7 +18,7 @@ serviceUrls: jobTracker: "" storage: - cleanupStorageProviders: {} + cleanupStorageProviders: [] # e.g. [S3, FS] s3: delete: batchSize: 1000 @@ -49,10 +54,10 @@ nameOverride: "" fullnameOverride: "" configManagement: - offlineMode: false + offlineMode: true name: 'cleaner' - version: '' - serverUrl: '' + version: 'latest' + serverUrl: 'http://localhost:8080/api' jobDefinitions: {} @@ -90,37 +95,44 @@ cloudProvider: imagePullSecretName: '' flavor: openshift -ca: - secretName: '' - path: '/usr/local/share/ca-certificates' - key: 'ca.crt' - image: repository: cleaner # If commented, appVersion will be taken. See: _helpers.tpl # tag: 'latest' pullPolicy: IfNotPresent -env: +server: port: 8080 - logLevel: info - prettyPrintEnabled: false - openTelemetryOptions: - enabled: false - url: "" - resourceAttributes: {} + targetPort: 8080 + +telemetry: + logger: + level: info + prettyPrint: false + opentelemetryOptions: + enabled: true + url: http://localhost:4317 + # resourceAttributes: + # service.namespace: namespace + # deployment.environment: dev tracing: - enabled: false - url: "" + enabled: true + # url can be overridden from global.telemetry.tracing.url + url: http://localhost:4318/v1/traces + +env: queue: heartbeatIntervalMs: 1000 dequeueIntervalMs: 3000 + jobnik: + worker: + concurrency: 1 worker: capabilities: pairs: - job: "Ingestion_Update" task: "tiles-deletion" - - job: "Ingestion_Swap_Update" + - job: "Delete_Layer" task: "tiles-deletion" httpRetry: attempts: 3 diff --git a/src/containerConfig.ts b/src/containerConfig.ts index f7826d3..c2b1c04 100644 --- a/src/containerConfig.ts +++ b/src/containerConfig.ts @@ -29,7 +29,7 @@ export const registerExternalValues = async (options?: RegisterOptions): Promise const loggerConfig = configInstance.get('telemetry.logger'); - const logger = await jsLogger({ ...loggerConfig, prettyPrint: loggerConfig.prettyPrint, mixin: getOtelMixin() }); + const logger = await jsLogger({ ...loggerConfig, mixin: getOtelMixin() }); const tracer = trace.getTracer(SERVICE_NAME); const metricsRegistry = new Registry();