mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[8.12][Fleet] removed restriction to use remote es as integration data (#17… (#173522)
Backport https://github.com/elastic/kibana/pull/173353 to 8.12
This commit is contained in:
parent
0ead2df977
commit
d6e2907755
6 changed files with 31 additions and 52 deletions
|
@ -28,9 +28,9 @@ export function getAllowedOutputTypeForPolicy(agentPolicy: AgentPolicy) {
|
|||
agentPolicy.package_policies &&
|
||||
agentPolicy.package_policies.some(
|
||||
(p) =>
|
||||
p.package?.name === FLEET_APM_PACKAGE ||
|
||||
p.package?.name === FLEET_SERVER_PACKAGE ||
|
||||
p.package?.name === FLEET_SYNTHETICS_PACKAGE
|
||||
p.package?.name === FLEET_SYNTHETICS_PACKAGE ||
|
||||
p.package?.name === FLEET_APM_PACKAGE
|
||||
);
|
||||
|
||||
if (isRestrictedToSameClusterES) {
|
||||
|
|
|
@ -533,7 +533,7 @@ describe('useOutputOptions', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
it('should only enable remote es output for monitoring output', async () => {
|
||||
it('should enable remote es output for data and monitoring output', async () => {
|
||||
const testRenderer = createFleetTestRendererMock();
|
||||
mockedUseLicence.mockReturnValue({
|
||||
hasAtLeast: () => true,
|
||||
|
@ -545,7 +545,8 @@ describe('useOutputOptions', () => {
|
|||
expect(result.current.isLoading).toBeTruthy();
|
||||
|
||||
await waitForNextUpdate();
|
||||
expect(result.current.dataOutputOptions.length).toEqual(1);
|
||||
expect(result.current.dataOutputOptions.length).toEqual(2);
|
||||
expect(result.current.dataOutputOptions[1].value).toEqual('remote1');
|
||||
expect(result.current.monitoringOutputOptions.length).toEqual(2);
|
||||
expect(result.current.monitoringOutputOptions[1].value).toEqual('remote1');
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
useGetDownloadSources,
|
||||
useGetFleetServerHosts,
|
||||
} from '../../../../hooks';
|
||||
import { LICENCE_FOR_PER_POLICY_OUTPUT, outputType } from '../../../../../../../common/constants';
|
||||
import { LICENCE_FOR_PER_POLICY_OUTPUT } from '../../../../../../../common/constants';
|
||||
import {
|
||||
getAllowedOutputTypeForPolicy,
|
||||
policyHasFleetServer,
|
||||
|
@ -99,28 +99,26 @@ export function useOutputOptions(agentPolicy: Partial<NewAgentPolicy | AgentPoli
|
|||
|
||||
return [
|
||||
getDefaultOutput(defaultOutputName, defaultOutputDisabled, defaultOutputDisabledMessage),
|
||||
...outputsRequest.data.items
|
||||
.filter((item) => item.type !== outputType.RemoteElasticsearch)
|
||||
.map((item) => {
|
||||
const isOutputTypeUnsupported = !allowedOutputTypes.includes(item.type);
|
||||
...outputsRequest.data.items.map((item) => {
|
||||
const isOutputTypeUnsupported = !allowedOutputTypes.includes(item.type);
|
||||
|
||||
return {
|
||||
value: item.id,
|
||||
inputDisplay: getOutputLabel(
|
||||
item.name,
|
||||
isOutputTypeUnsupported ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
|
||||
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
|
||||
values={{
|
||||
outputType: item.type,
|
||||
}}
|
||||
/>
|
||||
) : undefined
|
||||
),
|
||||
disabled: !isPolicyPerOutputAllowed || isOutputTypeUnsupported,
|
||||
};
|
||||
}),
|
||||
return {
|
||||
value: item.id,
|
||||
inputDisplay: getOutputLabel(
|
||||
item.name,
|
||||
isOutputTypeUnsupported ? (
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
|
||||
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
|
||||
values={{
|
||||
outputType: item.type,
|
||||
}}
|
||||
/>
|
||||
) : undefined
|
||||
),
|
||||
disabled: !isPolicyPerOutputAllowed || isOutputTypeUnsupported,
|
||||
};
|
||||
}),
|
||||
];
|
||||
}, [outputsRequest, isPolicyPerOutputAllowed, allowedOutputTypes]);
|
||||
|
||||
|
|
|
@ -542,7 +542,6 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
|
|||
}}
|
||||
/>
|
||||
}
|
||||
disabled={isRemoteESOutput}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiFormRow fullWidth {...inputs.defaultMonitoringOutputInput.formRowProps}>
|
||||
|
|
|
@ -705,12 +705,12 @@ describe('Output Service', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should throw when a remote es output is attempted to be created as default data output', async () => {
|
||||
it('should not throw when a remote es output is attempted to be created as default data output', async () => {
|
||||
const soClient = getMockedSoClient({
|
||||
defaultOutputId: 'output-test',
|
||||
});
|
||||
|
||||
await expect(
|
||||
expect(
|
||||
outputService.create(
|
||||
soClient,
|
||||
esClientMock,
|
||||
|
@ -722,9 +722,7 @@ describe('Output Service', () => {
|
|||
},
|
||||
{ id: 'output-1' }
|
||||
)
|
||||
).rejects.toThrow(
|
||||
`Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.`
|
||||
);
|
||||
).resolves.not.toThrow();
|
||||
});
|
||||
|
||||
it('should set preset: balanced by default when creating a new ES output', async () => {
|
||||
|
@ -1644,21 +1642,19 @@ describe('Output Service', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should throw when a remote es output is attempted to be updated as default data output', async () => {
|
||||
it('should not throw when a remote es output is attempted to be updated as default data output', async () => {
|
||||
const soClient = getMockedSoClient({
|
||||
defaultOutputId: 'output-test',
|
||||
});
|
||||
|
||||
await expect(
|
||||
expect(
|
||||
outputService.update(soClient, esClientMock, 'output-test', {
|
||||
is_default: true,
|
||||
is_default_monitoring: false,
|
||||
name: 'Test',
|
||||
type: 'remote_elasticsearch',
|
||||
})
|
||||
).rejects.toThrow(
|
||||
`Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.`
|
||||
);
|
||||
).resolves.not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -437,13 +437,6 @@ class OutputService {
|
|||
}
|
||||
): Promise<Output> {
|
||||
const data: OutputSOAttributes = { ...omit(output, ['ssl', 'secrets']) };
|
||||
if (output.type === outputType.RemoteElasticsearch) {
|
||||
if (data.is_default) {
|
||||
throw new OutputInvalidError(
|
||||
'Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (outputTypeSupportPresets(data.type)) {
|
||||
if (
|
||||
|
@ -757,14 +750,6 @@ class OutputService {
|
|||
fromPreconfiguration: false,
|
||||
}
|
||||
) {
|
||||
if (data.type === outputType.RemoteElasticsearch) {
|
||||
if (data.is_default) {
|
||||
throw new OutputInvalidError(
|
||||
'Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let secretsToDelete: PolicySecretReference[] = [];
|
||||
const originalOutput = await this.get(soClient, id);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue