Skip to content
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 @@ -6,7 +6,12 @@
*/

import { isNotFoundError } from '@kbn/es-errors';
import { IngestStreamLifecycle, Streams, isInheritLifecycle } from '@kbn/streams-schema';
import {
IngestStreamLifecycle,
Streams,
findInheritedLifecycle,
isInheritLifecycle,
} from '@kbn/streams-schema';
import {
getAncestors,
getAncestorsAndSelf,
Expand Down Expand Up @@ -437,6 +442,9 @@ export class WiredStream extends StreamActiveRecord<Streams.WiredStream.Definiti
}

protected async doDetermineCreateActions(): Promise<ElasticsearchAction[]> {
const ancestors = await this.dependencies.streamsClient.getAncestors(this._definition.name);
const lifecycle = findInheritedLifecycle(this._definition, ancestors);

return [
{
type: 'upsert_component_template',
Expand Down Expand Up @@ -474,7 +482,7 @@ export class WiredStream extends StreamActiveRecord<Streams.WiredStream.Definiti
type: 'update_lifecycle',
request: {
name: this._definition.name,
lifecycle: this.getLifecycle(),
lifecycle,
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@ export default function ({ getService }: DeploymentAgnosticFtrProviderContext) {
);
});

it('inherits on creation', async () => {
const rootDefinition = await getStream(apiClient, 'logs');
await putStream(apiClient, 'logs', {
dashboards: [],
queries: [],
stream: {
description: '',
ingest: {
...(rootDefinition as Streams.WiredStream.GetResponse).stream.ingest,
lifecycle: { dsl: { data_retention: '50d' } },
},
},
});
await putStream(apiClient, 'logs.inheritsatcreation', wiredPutBody);

await expectLifecycle(['logs.inheritsatcreation'], {
dsl: { data_retention: '50d' },
from: 'logs',
});
});

it('inherits dsl', async () => {
// create two branches, one that inherits from root and
// another one that overrides the root lifecycle
Expand Down