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

[Enterprise Search] disable adding ml pipelines to default ingest pipeline #141169

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 @@ -22,7 +22,7 @@ export const AddMLInferencePipelineButton: React.FC<AddMLInferencePipelineButton
onClick,
}) => {
const { capabilities } = useValues(KibanaLogic);
const { canUseMlInferencePipeline } = useValues(PipelinesLogic);
const { canUseMlInferencePipeline, hasIndexIngestionPipeline } = useValues(PipelinesLogic);
const hasMLPermissions = capabilities?.ml?.canAccessML ?? false;
if (!hasMLPermissions) {
return (
Expand All @@ -36,6 +36,21 @@ export const AddMLInferencePipelineButton: React.FC<AddMLInferencePipelineButton
</EuiToolTip>
);
}
if (!hasIndexIngestionPipeline) {
return (
<EuiToolTip
content={i18n.translate(
'xpack.enterpriseSearch.content.indices.pipelines.mlInference.addButton.defaultIngestPipeline.disabledTooltip',
{
defaultMessage:
'You cannot add machine learning inference pipeline processors to the default ingest pipeline. You must first copy and customize the default ingest pipeline to add machine learning inference pipeline processors.',
}
)}
>
<AddButton disabled />
</EuiToolTip>
);
}
if (!canUseMlInferencePipeline) {
return (
<EuiToolTip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const DEFAULT_VALUES = {
pipelineState: DEFAULT_PIPELINE_VALUES,
showModal: false,
showAddMlInferencePipelineModal: false,
hasIndexIngestionPipeline: false,
};

describe('PipelinesLogic', () => {
Expand Down Expand Up @@ -86,6 +87,7 @@ describe('PipelinesLogic', () => {
expect(PipelinesLogic.values).toEqual({
...DEFAULT_VALUES,
pipelineState: { ...DEFAULT_PIPELINE_VALUES, name: 'new_pipeline_name' },
hasIndexIngestionPipeline: true,
});
});
describe('makeRequest', () => {
Expand Down Expand Up @@ -155,6 +157,7 @@ describe('PipelinesLogic', () => {
connector: { ...connectorIndex.connector, pipeline: newPipeline },
},
pipelineState: newPipeline,
hasIndexIngestionPipeline: true,
});
});
it('should not set configState if modal is open', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ interface PipelinesValues {
canUseMlInferencePipeline: boolean;
defaultPipelineValues: IngestPipelineParams;
defaultPipelineValuesData: IngestPipelineParams | null;
hasIndexIngestionPipeline: boolean;
index: FetchIndexApiResponse;
mlInferencePipelineProcessors: InferencePipeline[];
pipelineState: IngestPipelineParams;
Expand Down Expand Up @@ -289,14 +290,26 @@ export const PipelinesLogic = kea<MakeLogicType<PipelinesValues, PipelinesAction
() => [selectors.index],
(index: ElasticsearchIndexWithIngestion) => !isApiIndex(index),
],
canUseMlInferencePipeline: [
() => [selectors.canSetPipeline, selectors.pipelineState],
(canSetPipeline: boolean, pipelineState: IngestPipelineParams) =>
canSetPipeline && pipelineState.run_ml_inference,
],
defaultPipelineValues: [
() => [selectors.defaultPipelineValuesData],
(pipeline: IngestPipelineParams | null) => pipeline ?? DEFAULT_PIPELINE_VALUES,
],
hasIndexIngestionPipeline: [
() => [selectors.pipelineState, selectors.defaultPipelineValues],
(pipelineState: IngestPipelineParams, defaultPipelineValues: IngestPipelineParams) =>
pipelineState.name !== defaultPipelineValues.name,
],
canUseMlInferencePipeline: [
() => [
selectors.canSetPipeline,
selectors.hasIndexIngestionPipeline,
selectors.pipelineState,
],
(
canSetPipeline: boolean,
hasIndexIngestionPipeline: boolean,
pipelineState: IngestPipelineParams
) => canSetPipeline && hasIndexIngestionPipeline && pipelineState.run_ml_inference,
],
}),
});