Skip to content

Commit 154646b

Browse files
committed
SQUASH: Store log positions in the logs directory
1 parent 089de7c commit 154646b

File tree

5 files changed

+23
-102
lines changed

5 files changed

+23
-102
lines changed

internal/collector/pgadmin.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,18 @@ func EnablePgAdminLogging(ctx context.Context, configmap *corev1.ConfigMap) erro
1818
return nil
1919
}
2020
otelConfig := NewConfig()
21-
otelConfig.Extensions["file_storage/pgadmin"] = map[string]any{
22-
"directory": "/var/log/pgadmin/receiver",
23-
"create_directory": true,
24-
"fsync": true,
25-
}
26-
otelConfig.Extensions["file_storage/gunicorn"] = map[string]any{
27-
"directory": "/var/log/gunicorn" + "/receiver",
21+
otelConfig.Extensions["file_storage/pgadmin_data_logs"] = map[string]any{
22+
"directory": "/var/lib/pgadmin/logs/receiver",
2823
"create_directory": true,
2924
"fsync": true,
3025
}
3126
otelConfig.Receivers["filelog/pgadmin"] = map[string]any{
3227
"include": []string{"/var/lib/pgadmin/logs/pgadmin.log"},
33-
"storage": "file_storage/pgadmin",
28+
"storage": "file_storage/pgadmin_data_logs",
3429
}
3530
otelConfig.Receivers["filelog/gunicorn"] = map[string]any{
3631
"include": []string{"/var/lib/pgadmin/logs/gunicorn.log"},
37-
"storage": "file_storage/gunicorn",
32+
"storage": "file_storage/pgadmin_data_logs",
3833
}
3934

4035
otelConfig.Processors["resource/pgadmin"] = map[string]any{
@@ -71,7 +66,7 @@ func EnablePgAdminLogging(ctx context.Context, configmap *corev1.ConfigMap) erro
7166
}
7267

7368
otelConfig.Pipelines["logs/pgadmin"] = Pipeline{
74-
Extensions: []ComponentID{"file_storage/pgadmin"},
69+
Extensions: []ComponentID{"file_storage/pgadmin_data_logs"},
7570
Receivers: []ComponentID{"filelog/pgadmin"},
7671
Processors: []ComponentID{
7772
"resource/pgadmin",
@@ -83,7 +78,7 @@ func EnablePgAdminLogging(ctx context.Context, configmap *corev1.ConfigMap) erro
8378
}
8479

8580
otelConfig.Pipelines["logs/gunicorn"] = Pipeline{
86-
Extensions: []ComponentID{"file_storage/gunicorn"},
81+
Extensions: []ComponentID{"file_storage/pgadmin_data_logs"},
8782
Receivers: []ComponentID{"filelog/gunicorn"},
8883
Processors: []ComponentID{
8984
"resource/pgadmin",
@@ -95,9 +90,8 @@ func EnablePgAdminLogging(ctx context.Context, configmap *corev1.ConfigMap) erro
9590
}
9691

9792
otelYAML, err := otelConfig.ToYAML()
98-
if err != nil {
99-
return err
93+
if err == nil {
94+
configmap.Data["collector.yaml"] = otelYAML
10095
}
101-
configmap.Data["collector.yaml"] = otelYAML
102-
return nil
96+
return err
10397
}

internal/collector/pgadmin_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ collector.yaml: |
4141
debug:
4242
verbosity: detailed
4343
extensions:
44-
file_storage/gunicorn:
44+
file_storage/pgadmin_data_logs:
4545
create_directory: true
46-
directory: /var/log/gunicorn/receiver
47-
fsync: true
48-
file_storage/pgadmin:
49-
create_directory: true
50-
directory: /var/log/pgadmin/receiver
46+
directory: /var/lib/pgadmin/logs/receiver
5147
fsync: true
5248
processors:
5349
batch/1s:
@@ -84,15 +80,14 @@ collector.yaml: |
8480
filelog/gunicorn:
8581
include:
8682
- /var/lib/pgadmin/logs/gunicorn.log
87-
storage: file_storage/gunicorn
83+
storage: file_storage/pgadmin_data_logs
8884
filelog/pgadmin:
8985
include:
9086
- /var/lib/pgadmin/logs/pgadmin.log
91-
storage: file_storage/pgadmin
87+
storage: file_storage/pgadmin_data_logs
9288
service:
9389
extensions:
94-
- file_storage/gunicorn
95-
- file_storage/pgadmin
90+
- file_storage/pgadmin_data_logs
9691
pipelines:
9792
logs/gunicorn:
9893
exporters:

internal/controller/standalone_pgadmin/pod.go

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,54 +39,28 @@ func pod(
3939
outPod *corev1.PodSpec,
4040
pgAdminVolume *corev1.PersistentVolumeClaim,
4141
) {
42-
const (
43-
// config and data volume names
44-
configVolumeName = "pgadmin-config"
45-
dataVolumeName = "pgadmin-data"
46-
pgAdminLogVolumeName = "pgadmin-log"
47-
gunicornLogVolumeName = "gunicorn-log"
48-
scriptVolumeName = "pgadmin-config-system"
49-
tempVolumeName = "tmp"
50-
)
51-
5242
// create the projected volume of config maps for use in
5343
// 1. dynamic server discovery
5444
// 2. adding the config variables during pgAdmin startup
55-
configVolume := corev1.Volume{Name: configVolumeName}
45+
configVolume := corev1.Volume{Name: "pgadmin-config"}
5646
configVolume.VolumeSource = corev1.VolumeSource{
5747
Projected: &corev1.ProjectedVolumeSource{
5848
Sources: podConfigFiles(inConfigMap, *inPGAdmin),
5949
},
6050
}
6151

6252
// create the data volume for the persistent database
63-
dataVolume := corev1.Volume{Name: dataVolumeName}
53+
dataVolume := corev1.Volume{Name: "pgadmin-data"}
6454
dataVolume.VolumeSource = corev1.VolumeSource{
6555
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
6656
ClaimName: pgAdminVolume.Name,
6757
ReadOnly: false,
6858
},
6959
}
7060

71-
// create the temp volume for logs
72-
pgAdminLogVolume := corev1.Volume{Name: pgAdminLogVolumeName}
73-
pgAdminLogVolume.VolumeSource = corev1.VolumeSource{
74-
EmptyDir: &corev1.EmptyDirVolumeSource{
75-
Medium: corev1.StorageMediumMemory,
76-
},
77-
}
78-
79-
// create the temp volume for gunicorn logs
80-
gunicornLogVolume := corev1.Volume{Name: gunicornLogVolumeName}
81-
gunicornLogVolume.VolumeSource = corev1.VolumeSource{
82-
EmptyDir: &corev1.EmptyDirVolumeSource{
83-
Medium: corev1.StorageMediumMemory,
84-
},
85-
}
86-
8761
// Volume used to write a custom config_system.py file in the initContainer
8862
// which then loads the configs found in the `configVolume`
89-
scriptVolume := corev1.Volume{Name: scriptVolumeName}
63+
scriptVolume := corev1.Volume{Name: "pgadmin-config-system"}
9064
scriptVolume.VolumeSource = corev1.VolumeSource{
9165
EmptyDir: &corev1.EmptyDirVolumeSource{
9266
Medium: corev1.StorageMediumMemory,
@@ -101,7 +75,7 @@ func pod(
10175

10276
// create a temp volume for restart pid/other/debugging use
10377
// TODO: discuss tmp vol vs. persistent vol
104-
tmpVolume := corev1.Volume{Name: tempVolumeName}
78+
tmpVolume := corev1.Volume{Name: "tmp"}
10579
tmpVolume.VolumeSource = corev1.VolumeSource{
10680
EmptyDir: &corev1.EmptyDirVolumeSource{
10781
Medium: corev1.StorageMediumMemory,
@@ -142,29 +116,21 @@ func pod(
142116
},
143117
VolumeMounts: []corev1.VolumeMount{
144118
{
145-
Name: configVolumeName,
119+
Name: configVolume.Name,
146120
MountPath: configMountPath,
147121
ReadOnly: true,
148122
},
149123
{
150-
Name: dataVolumeName,
124+
Name: dataVolume.Name,
151125
MountPath: "/var/lib/pgadmin",
152126
},
153127
{
154-
Name: gunicornLogVolumeName,
155-
MountPath: "/var/log/gunicorn",
156-
},
157-
{
158-
Name: pgAdminLogVolumeName,
159-
MountPath: "/var/log/pgadmin",
160-
},
161-
{
162-
Name: scriptVolumeName,
128+
Name: scriptVolume.Name,
163129
MountPath: scriptMountPath,
164130
ReadOnly: true,
165131
},
166132
{
167-
Name: tempVolumeName,
133+
Name: tmpVolume.Name,
168134
MountPath: "/tmp",
169135
},
170136
},
@@ -199,7 +165,7 @@ func pod(
199165
VolumeMounts: []corev1.VolumeMount{
200166
// Volume to write a custom `config_system.py` file to.
201167
{
202-
Name: scriptVolumeName,
168+
Name: scriptVolume.Name,
203169
MountPath: scriptMountPath,
204170
ReadOnly: false,
205171
},
@@ -210,8 +176,6 @@ func pod(
210176
outPod.Volumes = []corev1.Volume{
211177
configVolume,
212178
dataVolume,
213-
pgAdminLogVolume,
214-
gunicornLogVolume,
215179
scriptVolume,
216180
tmpVolume,
217181
}

internal/controller/standalone_pgadmin/pod_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ containers:
127127
readOnly: true
128128
- mountPath: /var/lib/pgadmin
129129
name: pgadmin-data
130-
- mountPath: /var/log/gunicorn
131-
name: gunicorn-log
132-
- mountPath: /var/log/pgadmin
133-
name: pgadmin-log
134130
- mountPath: /etc/pgadmin
135131
name: pgadmin-config-system
136132
readOnly: true
@@ -226,12 +222,6 @@ volumes:
226222
- name: pgadmin-data
227223
persistentVolumeClaim:
228224
claimName: ""
229-
- emptyDir:
230-
medium: Memory
231-
name: pgadmin-log
232-
- emptyDir:
233-
medium: Memory
234-
name: gunicorn-log
235225
- emptyDir:
236226
medium: Memory
237227
sizeLimit: 32Ki
@@ -352,10 +342,6 @@ containers:
352342
readOnly: true
353343
- mountPath: /var/lib/pgadmin
354344
name: pgadmin-data
355-
- mountPath: /var/log/gunicorn
356-
name: gunicorn-log
357-
- mountPath: /var/log/pgadmin
358-
name: pgadmin-log
359345
- mountPath: /etc/pgadmin
360346
name: pgadmin-config-system
361347
readOnly: true
@@ -455,12 +441,6 @@ volumes:
455441
- name: pgadmin-data
456442
persistentVolumeClaim:
457443
claimName: ""
458-
- emptyDir:
459-
medium: Memory
460-
name: pgadmin-log
461-
- emptyDir:
462-
medium: Memory
463-
name: gunicorn-log
464444
- emptyDir:
465445
medium: Memory
466446
sizeLimit: 32Ki

internal/controller/standalone_pgadmin/statefulset.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,12 @@ func statefulset(
122122
pod(pgadmin, configmap, &sts.Spec.Template.Spec, dataVolume)
123123

124124
if feature.Enabled(ctx, feature.OpenTelemetryLogs) {
125-
// Mount for file_storage/pgadmin
126-
pgAdminLogVolumeMount := corev1.VolumeMount{
127-
Name: "pgadmin-log",
128-
MountPath: "/var/log/pgadmin",
129-
}
130-
// Mount for file_storage/gunicorn
131-
gunicornLogVolumeMount := corev1.VolumeMount{
132-
Name: "gunicorn-log",
133-
MountPath: "/var/log/gunicorn",
134-
}
135125
// Logs for gunicorn and pgadmin write to /var/lib/pgadmin/logs
136126
dataVolumeMount := corev1.VolumeMount{
137127
Name: "pgadmin-data",
138128
MountPath: "/var/lib/pgadmin",
139129
}
140130
volumeMounts := []corev1.VolumeMount{
141-
pgAdminLogVolumeMount,
142-
gunicornLogVolumeMount,
143131
dataVolumeMount,
144132
}
145133

0 commit comments

Comments
 (0)