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

moved DELETE agent_config body to query params #200281

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -66,11 +66,9 @@ async function deleteConfig(config: Config, toasts: NotificationsStart['toasts']
await callApmApi('DELETE /api/apm/settings/agent-configuration 2023-10-31', {
signal: null,
params: {
body: {
service: {
name: config.service.name,
environment: config.service.environment,
},
query: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryce-b this is a public API, I'm not sure if we can just change its signature. I think the APM agents team are the ones using it, have you checked with them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if I create a new API instead? If they do indeed use it, there won't be a clean way to make this change and continue supporting old agents.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest keeping the same API but implementing both query and body parameters. With query params overwriting body. That way, we stay backward compatible and can provide a working API for public (we might document only query parameters for simplicity). What do you think? @bryce-b @cauemarcondes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have found the root cause of this problem. Lets close this PR, please.

serviceName: config.service.name,
serviceEnvironment: config.service.environment,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,22 @@ const deleteAgentConfigurationRoute = createApmServerRoute({
tags: ['access:apm', 'access:apm_settings_write'],
access: 'public',
},
params: t.type({
body: t.type({
service: serviceRt,
}),
params: t.partial({
query: t.intersection([
t.partial({ serviceName: t.string }),
t.partial({ serviceEnvironment: t.string }),
]),
}),
handler: async (resources): Promise<{ result: string }> => {
throwNotFoundIfAgentConfigNotAvailable(resources.featureFlags);

const { params, logger, core, telemetryUsageCounter } = resources;
const { service } = params.body;
const { serviceName, serviceEnvironment } = params.query;
const service = {
name: serviceName ? decodeURIComponent(serviceName) : null,
environment: serviceEnvironment ? decodeURIComponent(serviceEnvironment) : null,
};

const apmIndices = await resources.getApmIndices();
const [internalESClient, apmEventClient] = await Promise.all([
createInternalESClientWithResources(resources),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export default function featureControlsTests({ getService }: FtrProviderContext)
}

function deleteAgent(
body: APIClientRequestParamsOf<'DELETE /api/apm/settings/agent-configuration 2023-10-31'>['params']['body']
query: APIClientRequestParamsOf<'DELETE /api/apm/settings/agent-configuration 2023-10-31'>['params']['query']
) {
return apmApiClient.writeUser({
endpoint: 'DELETE /api/apm/settings/agent-configuration 2023-10-31',
params: {
body,
query,
},
});
}
Expand Down Expand Up @@ -283,7 +283,10 @@ export default function featureControlsTests({ getService }: FtrProviderContext)

after(async () => {
log.info('deleting agent configuration');
await deleteAgent({ service: config.service });
await deleteAgent({
serviceName: config.service.name,
serviceEnvironment: config.service.environment,
});
log.info('Agent configuration deleted');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ export default function ApiTest(ftrProviderContext: FtrProviderContext) {
async function deleteConfiguration(configuration: any) {
return apmApiClient.writeUser({
endpoint: 'DELETE /api/apm/settings/agent-configuration 2023-10-31',
params: { body: { service: configuration.service } },
params: {
query: {
serviceName: configuration.service.name,
serviceEnvironment: configuration.service.environment,
},
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte

return supertestClient({
endpoint: 'DELETE /api/apm/settings/agent-configuration 2023-10-31',
params: { body: { service } },
params: { query: { service } },
});
}

Expand All @@ -96,8 +96,8 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte
endpoint: 'GET /api/apm/settings/agent-configuration/view 2023-10-31',
params: {
query: {
name,
environment,
serviceName: name,
serviceEnvironment: environment,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ export default function ({ getService }: APMFtrContextProvider) {
await apmApiClient.slsUser({
endpoint: 'DELETE /api/apm/settings/agent-configuration 2023-10-31',
params: {
body: {
service: {},
query: {
serviceName: '',
serviceEnvironment: '',
},
},
roleAuthc,
Expand Down