Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.11] [Synthetics] Refactor supress API Key error (#171114) #171766

Merged
merged 1 commit into from
Nov 22, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -423,49 +423,48 @@ export class SyntheticsService {
};

for await (const result of finder.find()) {
if (result.saved_objects.length === 0) {
return;
}
try {
if (!output) {
output = await this.getOutput();
if (result.saved_objects.length > 0) {
try {
if (!output) {
sendErrorTelemetryEvents(service.logger, service.server.telemetry, {
reason: 'API key is not valid.',
message: 'Failed to push configs. API key is not valid.',
type: 'invalidApiKey',
stackVersion: service.server.stackVersion,
});
return;
output = await this.getOutput();
if (!output) {
sendErrorTelemetryEvents(service.logger, service.server.telemetry, {
reason: 'API key is not valid.',
message: 'Failed to push configs. API key is not valid.',
type: 'invalidApiKey',
stackVersion: service.server.stackVersion,
});
return;
}
}
}

const monitors = result.saved_objects.filter(({ error }) => !error);
const formattedConfigs = this.normalizeConfigs(monitors, paramsBySpace);
const monitors = result.saved_objects.filter(({ error }) => !error);
const formattedConfigs = this.normalizeConfigs(monitors, paramsBySpace);

this.logger.debug(
`${formattedConfigs.length} monitors will be pushed to synthetics service.`
);
this.logger.debug(
`${formattedConfigs.length} monitors will be pushed to synthetics service.`
);

formattedConfigs.forEach((monitor) => {
monitor.locations.forEach((location) => {
if (location.isServiceManaged) {
bucketsByLocation[location.id]?.push(monitor);
}
formattedConfigs.forEach((monitor) => {
monitor.locations.forEach((location) => {
if (location.isServiceManaged) {
bucketsByLocation[location.id]?.push(monitor);
}
});
});
});

await syncAllLocations(PER_PAGE);
} catch (e) {
sendErrorTelemetryEvents(service.logger, service.server.telemetry, {
reason: 'Failed to push configs to service',
message: e?.message,
type: 'pushConfigsError',
code: e?.code,
status: e.status,
stackVersion: service.server.stackVersion,
});
this.logger.error(e);
await syncAllLocations(PER_PAGE);
} catch (e) {
sendErrorTelemetryEvents(service.logger, service.server.telemetry, {
reason: 'Failed to push configs to service',
message: e?.message,
type: 'pushConfigsError',
code: e?.code,
status: e.status,
stackVersion: service.server.stackVersion,
});
this.logger.error(e);
}
}
}

Expand Down
Loading