Skip to content

Commit 8449f55

Browse files
committed
feat(observability): update retention management for tenants
resolves: #MAOBS-147 Signed-off-by: David Arsène <[email protected]>
1 parent 067e159 commit 8449f55

File tree

52 files changed

+1988
-858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1988
-858
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
22
"mandatory":"obligatoire",
3-
"service":"Service <strong>{{serviceName}}</strong>"
3+
"service":"Service <strong>{{serviceName}}</strong>",
4+
"form":{
5+
"bounds": {
6+
"helper": "Le minimum est de {{min}} et le maximum est de {{max}}."
7+
}
8+
}
49
}

packages/manager/apps/observability/public/translations/tenants/Messages_fr_FR.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,31 @@
1515
},
1616
"delete": {
1717
"delete_tenant_title": "Supprimer le Tenant",
18-
"delete_tenant_description": "Êtes-vous sûr de vouloir supprimer le tenant \"{{tenantName}}\""
18+
"delete_tenant_description": "Êtes-vous sûr de vouloir supprimer le tenant \"{{tenantName}}\"",
19+
"success": "Le tenant a été supprimé avec succès"
1920
},
2021
"onboarding": {
2122
"description": "Créez votre nouveau tenant pour continuer à explorer tout le potentiel des métriques d'observabilité. Vous pourrez envoyer des données, créer des tableaux de bord et configurer des alertes adaptées à vos besoins spécifiques.",
2223
"orderButtonLabel": "Créez votre tenant"
2324
},
2425
"creation": {
2526
"title": "Créer un tenant",
27+
"success": "Le tenant a été créé avec succès",
2628
"tenantInformation": "Saisir les informations du tenant",
2729
"namePlaceholder": "Nom du tenant",
2830
"description":"Description (optionnelle)",
2931
"descriptionPlaceholder": "Ajoutez une description des metrics que vous allez écrire dans ce tenant"
3032
},
3133
"edition": {
3234
"title": "Modifier le tenant",
33-
"subtitle": "Vous créez un tenant dans votre service d'observabilité \"{{tenantName}}\""
35+
"subtitle": "Vous créez un tenant dans votre service d'observabilité \"{{tenantName}}\"",
36+
"success": "Le tenant a été modifié avec succès"
3437
},
3538
"configuration": {
3639
"title": "Configurez votre tenant",
37-
"retention": "Rétention",
38-
"retentionPlaceholder": "Sélectionnez la rétention des données",
40+
"retention":{
41+
"title": "Rétention"
42+
},
3943
"limit": {
4044
"title": "Limite d'ingestion (métriques actives)",
4145
"description": "Définissez la limite maximale du nombre de métriques actives pour ce tenant."

packages/manager/apps/observability/src/__mocks__/infrastructures/infrastructures.mock.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
import { InfrastructuresParams, RetentionParams } from '@/data/api/infrastructures.props';
22
import { Infrastructure, Retention } from '@/types/infrastructures.type';
33

4+
const defaultExtraSettings = {
5+
mimir: {
6+
configurable: {
7+
compactor_blocks_retention_period: {
8+
default: '30d',
9+
min: '7d',
10+
max: '400d',
11+
type: 'DURATION' as const,
12+
},
13+
max_global_series_per_user: {
14+
default: 1000000,
15+
min: 100000,
16+
max: 10000000,
17+
type: 'NUMERIC' as const,
18+
},
19+
},
20+
},
21+
};
22+
423
const infrastructures: Infrastructure[] = [
524
{
625
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
@@ -9,6 +28,7 @@ const infrastructures: Infrastructure[] = [
928
type: 'SHARED',
1029
usage: 'METRICS',
1130
entryPoint: 'eee.metrics.ovh.com',
31+
extraSettings: defaultExtraSettings,
1232
},
1333
},
1434
{
@@ -18,6 +38,7 @@ const infrastructures: Infrastructure[] = [
1838
type: 'SHARED',
1939
usage: 'METRICS',
2040
entryPoint: 'aaa.metrics.ovh.com',
41+
extraSettings: defaultExtraSettings,
2142
},
2243
},
2344
{
@@ -27,6 +48,7 @@ const infrastructures: Infrastructure[] = [
2748
type: 'SHARED',
2849
usage: 'METRICS',
2950
entryPoint: 'bbb.metrics.ovh.com',
51+
extraSettings: defaultExtraSettings,
3052
},
3153
},
3254
{
@@ -36,6 +58,7 @@ const infrastructures: Infrastructure[] = [
3658
type: 'SHARED',
3759
usage: 'METRICS',
3860
entryPoint: 'ccc.metrics.ovh.com',
61+
extraSettings: defaultExtraSettings,
3962
},
4063
},
4164
{
@@ -45,6 +68,7 @@ const infrastructures: Infrastructure[] = [
4568
type: 'SHARED',
4669
usage: 'METRICS',
4770
entryPoint: 'ddd.metrics.ovh.com',
71+
extraSettings: defaultExtraSettings,
4872
},
4973
},
5074
];

packages/manager/apps/observability/src/__mocks__/mock.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export type ApiConfigMode = 'mock' | 'api';
22
export type ApiEndpoint = 'tenant' | 'service' | 'infrastructure' | 'grafana' | 'log' | 'metric';
33

44
export const apiConfig: Record<ApiEndpoint, ApiConfigMode> = {
5-
tenant: 'mock',
5+
tenant: 'api',
66
service: 'api',
7-
infrastructure: 'mock', // FIXME : fix retentions first before unmocking
7+
infrastructure: 'api',
88
grafana: 'mock',
99
log: 'mock',
1010
metric: 'mock',

packages/manager/apps/observability/src/__mocks__/tenants/tenant.mock.ts

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,16 @@ const tenantsDataset: Tenant[] = [
3131
title: 'Tenant 1',
3232
description: 'Tenant 1 description',
3333
limits: {
34-
numberOfSeries: {
35-
current: 222,
36-
maximum: 300,
37-
},
38-
retention: {
39-
id: '1',
40-
duration: 'P1M',
41-
link: 'retention_link_1',
34+
mimir: {
35+
compactor_blocks_retention_period: '30d',
36+
max_global_series_per_user: 300,
4237
},
4338
},
4439
infrastructure: {
4540
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
46-
currentState: {
47-
location: 'eu-west-sbg',
48-
entryPoint: 'sbg1.metrics.ovh.com',
49-
type: 'SHARED',
50-
usage: 'METRICS',
51-
},
41+
location: 'eu-west-sbg',
42+
entryPoint: 'sbg1.metrics.ovh.com',
43+
type: 'SHARED',
5244
},
5345
},
5446
},
@@ -67,24 +59,16 @@ const tenantsDataset: Tenant[] = [
6759
title: 'Tenant 2',
6860
description: 'Tenant 2 description',
6961
limits: {
70-
numberOfSeries: {
71-
current: 36,
72-
maximum: 50,
73-
},
74-
retention: {
75-
id: '2',
76-
duration: 'P3M',
77-
link: 'retention_link_2',
62+
mimir: {
63+
compactor_blocks_retention_period: '90d',
64+
max_global_series_per_user: 50,
7865
},
7966
},
8067
infrastructure: {
8168
id: '6ee8fb35-2621-4530-a288-84fc0e85dac1',
82-
currentState: {
83-
entryPoint: 'gra1.metrics.ovh.com',
84-
location: 'eu-west-gra',
85-
type: 'SHARED',
86-
usage: 'METRICS',
87-
},
69+
entryPoint: 'gra1.metrics.ovh.com',
70+
location: 'eu-west-gra',
71+
type: 'SHARED',
8872
},
8973
},
9074
},

packages/manager/apps/observability/src/__tests__/components/dashboard/ConfigurationTile.component.spec.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { vi } from 'vitest';
33

44
import { ConfigurationTile } from '@/components/dashboard/ConfigurationTile.component';
55

6-
const { mockFormatDuration } = vi.hoisted(() => ({
7-
mockFormatDuration: vi.fn(),
6+
const { mockFormatObservabilityDuration } = vi.hoisted(() => ({
7+
mockFormatObservabilityDuration: vi.fn(),
88
}));
99

1010
vi.mock('react-i18next', () => ({
@@ -43,7 +43,7 @@ vi.mock('@ovhcloud/ods-react', () => ({
4343
}));
4444

4545
vi.mock('@/utils/duration.utils', () => ({
46-
formatDuration: mockFormatDuration,
46+
formatObservabilityDuration: mockFormatObservabilityDuration,
4747
}));
4848

4949
describe('ConfigurationTile.component', () => {
@@ -55,7 +55,7 @@ describe('ConfigurationTile.component', () => {
5555

5656
beforeEach(() => {
5757
vi.clearAllMocks();
58-
mockFormatDuration.mockReturnValue('10 days');
58+
mockFormatObservabilityDuration.mockReturnValue('10 days');
5959
});
6060

6161
it('renders skeletons while data is loading', () => {
@@ -67,7 +67,10 @@ describe('ConfigurationTile.component', () => {
6767
it('renders formatted retention and metric limits when available', () => {
6868
render(<ConfigurationTile {...baseProps} isLoading={false} />);
6969

70-
expect(mockFormatDuration).toHaveBeenCalledWith(baseProps.retention, 'test-locale');
70+
expect(mockFormatObservabilityDuration).toHaveBeenCalledWith(
71+
baseProps.retention,
72+
'test-locale',
73+
);
7174
expect(screen.getByText('10 days')).toBeInTheDocument();
7275
expect(screen.getByText(String(baseProps.numberOfSeriesCurrent))).toBeInTheDocument();
7376
expect(screen.getByText(String(baseProps.numberOfSeriesMaximum))).toBeInTheDocument();
@@ -83,6 +86,6 @@ describe('ConfigurationTile.component', () => {
8386
/>,
8487
);
8588

86-
expect(mockFormatDuration).not.toHaveBeenCalled();
89+
expect(mockFormatObservabilityDuration).not.toHaveBeenCalled();
8790
});
8891
});

packages/manager/apps/observability/src/__tests__/components/dashboard/drawer/EditTenantDrawer.component.spec.tsx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
44
import { vi } from 'vitest';
55

66
import EditTenantDrawer from '@/components/drawer/EditTenantDrawer.component';
7-
import { INGESTION_BOUNDS } from '@/utils/tenants.constants';
87

98
const { mockNavigate, mockUseTenant, mockUseEditTenant, mockUseTenantsFormSchema } = vi.hoisted(
109
() => ({
@@ -82,6 +81,10 @@ vi.mock('@ovh-ux/muk', () => ({
8281
</footer>
8382
),
8483
},
84+
useNotifications: () => ({
85+
addSuccess: vi.fn(),
86+
addError: vi.fn(),
87+
}),
8588
}));
8689

8790
vi.mock('@ovhcloud/ods-react', () => ({
@@ -136,12 +139,9 @@ describe('EditTenantDrawer.component', () => {
136139
id: 'infra-1',
137140
},
138141
limits: {
139-
retention: {
140-
id: 'ret-30',
141-
},
142-
numberOfSeries: {
143-
maximum: 1500,
144-
current: 900,
142+
mimir: {
143+
compactor_blocks_retention_period: '30d',
144+
max_global_series_per_user: 1500,
145145
},
146146
},
147147
},
@@ -188,11 +188,10 @@ describe('EditTenantDrawer.component', () => {
188188
title: tenant.currentState.title,
189189
description: tenant.currentState.description,
190190
infrastructureId: tenant.currentState.infrastructure?.id ?? '',
191-
retentionId: tenant.currentState.limits?.retention?.id ?? '',
192-
maxSeries:
193-
tenant.currentState.limits?.numberOfSeries?.maximum ??
194-
tenant.currentState.limits?.numberOfSeries?.current ??
195-
INGESTION_BOUNDS.DEFAULT,
191+
retentionDuration:
192+
tenant.currentState.limits?.mimir?.compactor_blocks_retention_period ?? '',
193+
retentionUnit: '',
194+
maxSeries: tenant.currentState.limits?.mimir?.max_global_series_per_user ?? null,
196195
});
197196
});
198197
});
@@ -202,7 +201,8 @@ describe('EditTenantDrawer.component', () => {
202201
title: 'Updated tenant',
203202
description: 'Updated description',
204203
infrastructureId: 'infra-42',
205-
retentionId: 'ret-60',
204+
retentionDuration: '30',
205+
retentionUnit: 'd',
206206
maxSeries: 5000,
207207
};
208208
mockForm.handleSubmit.mockImplementation(
@@ -220,15 +220,10 @@ describe('EditTenantDrawer.component', () => {
220220
targetSpec: {
221221
title: formValues.title,
222222
description: formValues.description,
223-
infrastructure: {
224-
id: formValues.infrastructureId,
225-
},
226223
limits: {
227-
numberOfSeries: {
228-
maximum: formValues.maxSeries ?? INGESTION_BOUNDS.DEFAULT,
229-
},
230-
retention: {
231-
id: formValues.retentionId,
224+
mimir: {
225+
compactor_blocks_retention_period: '30d',
226+
max_global_series_per_user: formValues.maxSeries,
232227
},
233228
},
234229
},

0 commit comments

Comments
 (0)