mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.7`: - [[Fleet] always create agent upload write indices (#155729)](https://github.com/elastic/kibana/pull/155729) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Bardi","email":"90178898+juliaElastic@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-04-26T08:44:42Z","message":"[Fleet] always create agent upload write indices (#155729)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/155483\r\n\r\nAlways create file upload write indices for elastic_agent package, so\r\nthat Request diagnostics of a managed Fleet Server works before\r\ninstalling Elastic Agent package.\r\n\r\nTo verify:\r\n- Go to a fresh cloud deployment without Elastic Agent installed\r\n- Go to the managed Fleet Server and click Request Diagnostics on Agent\r\nDetails\r\n- Expect the action to work\r\n- Check in Stack Management that the `.fleet-files-agent-000001` index\r\nis created.\r\n\r\nVerified on pr link that the agent write index is created before Elastic\r\nAgent package is installed:\r\n\r\n\r\nhttps://kibana-pr-155729.kb.us-west2.gcp.elastic-cloud.com:9243/app/management/data/index_management/indices?includeHiddenIndices=true\r\n\r\n<img width=\"777\" alt=\"image\"\r\nsrc=\"https://user-images.githubusercontent.com/90178898/234502605-cd91bbc2-0938-41ef-8455-1700f139a3ee.png\">\r\n<img width=\"1538\" alt=\"image\"\r\nsrc=\"https://user-images.githubusercontent.com/90178898/234502727-74e84a2a-3126-4346-8328-cdb10ed26b8f.png\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"636674c2137bc38017f7a085f70b87d6a362308e","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","ci:cloud-deploy","v8.8.0","v8.7.2"],"number":155729,"url":"https://github.com/elastic/kibana/pull/155729","mergeCommit":{"message":"[Fleet] always create agent upload write indices (#155729)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/155483\r\n\r\nAlways create file upload write indices for elastic_agent package, so\r\nthat Request diagnostics of a managed Fleet Server works before\r\ninstalling Elastic Agent package.\r\n\r\nTo verify:\r\n- Go to a fresh cloud deployment without Elastic Agent installed\r\n- Go to the managed Fleet Server and click Request Diagnostics on Agent\r\nDetails\r\n- Expect the action to work\r\n- Check in Stack Management that the `.fleet-files-agent-000001` index\r\nis created.\r\n\r\nVerified on pr link that the agent write index is created before Elastic\r\nAgent package is installed:\r\n\r\n\r\nhttps://kibana-pr-155729.kb.us-west2.gcp.elastic-cloud.com:9243/app/management/data/index_management/indices?includeHiddenIndices=true\r\n\r\n<img width=\"777\" alt=\"image\"\r\nsrc=\"https://user-images.githubusercontent.com/90178898/234502605-cd91bbc2-0938-41ef-8455-1700f139a3ee.png\">\r\n<img width=\"1538\" alt=\"image\"\r\nsrc=\"https://user-images.githubusercontent.com/90178898/234502727-74e84a2a-3126-4346-8328-cdb10ed26b8f.png\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"636674c2137bc38017f7a085f70b87d6a362308e"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/155729","number":155729,"mergeCommit":{"message":"[Fleet] always create agent upload write indices (#155729)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/155483\r\n\r\nAlways create file upload write indices for elastic_agent package, so\r\nthat Request diagnostics of a managed Fleet Server works before\r\ninstalling Elastic Agent package.\r\n\r\nTo verify:\r\n- Go to a fresh cloud deployment without Elastic Agent installed\r\n- Go to the managed Fleet Server and click Request Diagnostics on Agent\r\nDetails\r\n- Expect the action to work\r\n- Check in Stack Management that the `.fleet-files-agent-000001` index\r\nis created.\r\n\r\nVerified on pr link that the agent write index is created before Elastic\r\nAgent package is installed:\r\n\r\n\r\nhttps://kibana-pr-155729.kb.us-west2.gcp.elastic-cloud.com:9243/app/management/data/index_management/indices?includeHiddenIndices=true\r\n\r\n<img width=\"777\" alt=\"image\"\r\nsrc=\"https://user-images.githubusercontent.com/90178898/234502605-cd91bbc2-0938-41ef-8455-1700f139a3ee.png\">\r\n<img width=\"1538\" alt=\"image\"\r\nsrc=\"https://user-images.githubusercontent.com/90178898/234502727-74e84a2a-3126-4346-8328-cdb10ed26b8f.png\">\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"636674c2137bc38017f7a085f70b87d6a362308e"}},{"branch":"8.7","label":"v8.7.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
This commit is contained in:
parent
ce77b30cbc
commit
1dce8b278a
3 changed files with 28 additions and 4 deletions
|
@ -62,7 +62,7 @@ export const createAppContextStartContractMock = (
|
|||
securitySetup: securityMock.createSetup(),
|
||||
securityStart: securityMock.createStart(),
|
||||
logger: loggingSystemMock.create().get(),
|
||||
experimentalFeatures: {} as ExperimentalFeatures,
|
||||
experimentalFeatures: { diagnosticFileUploadEnabled: true } as ExperimentalFeatures,
|
||||
isProductionMode: true,
|
||||
configInitialValue: {
|
||||
agents: { enabled: true, elasticsearch: {} },
|
||||
|
|
|
@ -15,7 +15,9 @@ import { ensurePreconfiguredPackagesAndPolicies } from '.';
|
|||
import { appContextService } from './app_context';
|
||||
import { getInstallations } from './epm/packages';
|
||||
import { upgradeManagedPackagePolicies } from './managed_package_policies';
|
||||
import { setupFleet } from './setup';
|
||||
import { setupFleet, ensureFleetFileUploadIndices } from './setup';
|
||||
|
||||
import { ensureFileUploadWriteIndices } from './epm/elasticsearch/template/install';
|
||||
|
||||
jest.mock('./preconfiguration');
|
||||
jest.mock('./preconfiguration/outputs');
|
||||
|
@ -26,6 +28,12 @@ jest.mock('./download_source');
|
|||
jest.mock('./epm/packages');
|
||||
jest.mock('./managed_package_policies');
|
||||
jest.mock('./setup/upgrade_package_install_version');
|
||||
jest.mock('./epm/elasticsearch/template/install', () => {
|
||||
return {
|
||||
...jest.requireActual('./epm/elasticsearch/template/install'),
|
||||
ensureFileUploadWriteIndices: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
const mockedMethodThrowsError = (mockFn: jest.Mock) =>
|
||||
mockFn.mockImplementation(() => {
|
||||
|
@ -62,6 +70,8 @@ describe('setupFleet', () => {
|
|||
|
||||
soClient.find.mockResolvedValue({ saved_objects: [] } as any);
|
||||
soClient.bulkGet.mockResolvedValue({ saved_objects: [] } as any);
|
||||
|
||||
(ensureFileUploadWriteIndices as jest.Mock).mockResolvedValue({});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
@ -128,4 +138,12 @@ describe('setupFleet', () => {
|
|||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should create agent file upload write indices', async () => {
|
||||
await ensureFleetFileUploadIndices(soClient, esClient);
|
||||
|
||||
expect((ensureFileUploadWriteIndices as jest.Mock).mock.calls[0][0].integrationNames).toEqual([
|
||||
'elastic_agent',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,11 @@ import pMap from 'p-map';
|
|||
import type { ElasticsearchClient, SavedObjectsClientContract } from '@kbn/core/server';
|
||||
import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common/constants';
|
||||
|
||||
import { AUTO_UPDATE_PACKAGES, FILE_STORAGE_INTEGRATION_NAMES } from '../../common/constants';
|
||||
import {
|
||||
AUTO_UPDATE_PACKAGES,
|
||||
FILE_STORAGE_INTEGRATION_NAMES,
|
||||
FLEET_ELASTIC_AGENT_PACKAGE,
|
||||
} from '../../common/constants';
|
||||
import type { PreconfigurationError } from '../../common/constants';
|
||||
import type {
|
||||
DefaultPackagesInstallationError,
|
||||
|
@ -199,8 +203,10 @@ export async function ensureFleetFileUploadIndices(
|
|||
pkgNames: [...FILE_STORAGE_INTEGRATION_NAMES],
|
||||
});
|
||||
|
||||
if (!installedFileUploadIntegrations.length) return [];
|
||||
const integrationNames = installedFileUploadIntegrations.map(({ name }) => name);
|
||||
if (!integrationNames.includes(FLEET_ELASTIC_AGENT_PACKAGE)) {
|
||||
integrationNames.push(FLEET_ELASTIC_AGENT_PACKAGE);
|
||||
}
|
||||
logger.debug(`Ensuring file upload write indices for ${integrationNames}`);
|
||||
return ensureFileUploadWriteIndices({
|
||||
esClient,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue