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.13][Fleet] Backport output health fix (using output id instead of "default" for non-elasticsearch outputs) #179406

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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 @@ -93,6 +93,15 @@ jest.mock('../output', () => {
type: 'elasticsearch',
hosts: ['http://127.0.0.1:9201'],
},
'test-remote-id': {
id: 'test-remote-id',
is_default: true,
is_default_monitoring: true,
name: 'default',
// @ts-ignore
type: 'remote_elasticsearch',
hosts: ['http://127.0.0.1:9201'],
},
};
return {
outputService: {
Expand Down Expand Up @@ -375,6 +384,23 @@ describe('getFullAgentPolicy', () => {
expect(agentPolicy?.outputs.default).toBeDefined();
});

it('should use output id as the default policy id when remote elasticsearch', async () => {
mockAgentPolicy({
id: 'policy',
status: 'active',
package_policies: [],
is_managed: false,
namespace: 'default',
revision: 1,
data_output_id: 'test-remote-id',
monitoring_output_id: 'test-remote-id',
});

const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy');

expect(agentPolicy?.outputs['test-remote-id']).toBeDefined();
});

it('should return the sourceURI from the agent policy', async () => {
mockAgentPolicy({
namespace: 'default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ import type {
PackageInfo,
} from '../../../common/types';
import { agentPolicyService } from '../agent_policy';
import { dataTypes, kafkaCompressionType, outputType } from '../../../common/constants';
import { DEFAULT_OUTPUT } from '../../constants';
import {
dataTypes,
DEFAULT_OUTPUT,
kafkaCompressionType,
outputType,
} from '../../../common/constants';

import { getPackageInfo } from '../epm/packages';
import { pkgToPkgKey, splitPkgKey } from '../epm/registry';
Expand Down Expand Up @@ -494,10 +498,9 @@ export function transformOutputToFullPolicyOutput(
* we use "default" for the default policy to avoid breaking changes
*/
function getOutputIdForAgentPolicy(output: Output) {
if (output.is_default) {
if (output.is_default && output.type === outputType.Elasticsearch) {
return DEFAULT_OUTPUT.name;
}

return output.id;
}

Expand Down
Loading