Skip to content

Commit

Permalink
Merge branch 'main' into kbn-test/disable-TLS-for-Kibana
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko authored Nov 23, 2023
2 parents 7227fcd + b2ca784 commit 1d50df5
Show file tree
Hide file tree
Showing 163 changed files with 2,575 additions and 1,216 deletions.
12 changes: 1 addition & 11 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,9 @@ spec:
provider_settings:
trigger_mode: none
teams:
kibana-release-operators:
access_level: MANAGE_BUILD_AND_READ
kibana-operations:
access_level: MANAGE_BUILD_AND_READ
appex-qa:
access_level: BUILD_AND_READ
security-engineering-productivity:
access_level: BUILD_AND_READ
fleet:
access_level: BUILD_AND_READ
kibana-tech-leads:
access_level: BUILD_AND_READ
kibana-core:
kibana-release-operators:
access_level: BUILD_AND_READ
cloud-tooling:
access_level: BUILD_AND_READ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ const getHeaderCss = ({ size }: EuiThemeComputed) => ({
top: 2px;
`,
},
leftHeaderSection: css`
// needed to enable breadcrumbs truncation
min-width: 0;
flex-shrink: 1;
`,
breadcrumbsSectionItem: css`
min-width: 0; // needed to enable breadcrumbs truncation
`,
redirectAppLinksContainer: css`
min-width: 0; // needed to enable breadcrumbs truncation
`,
});

type HeaderCss = ReturnType<typeof getHeaderCss>;
Expand Down Expand Up @@ -181,7 +192,7 @@ export const ProjectHeader = ({
<header data-test-subj="kibanaProjectHeader">
<div id="globalHeaderBars" data-test-subj="headerGlobalNav" className="header__bars">
<EuiHeader position="fixed" className="header__firstBar">
<EuiHeaderSection grow={false}>
<EuiHeaderSection grow={false} css={headerCss.leftHeaderSection}>
<Router history={application.history}>
<ProjectNavigation toggleSideNav={toggleSideNav}>{children}</ProjectNavigation>
</Router>
Expand All @@ -196,8 +207,11 @@ export const ProjectHeader = ({
/>
</EuiHeaderSectionItem>

<EuiHeaderSectionItem>
<RedirectAppLinks coreStart={{ application }}>
<EuiHeaderSectionItem css={headerCss.breadcrumbsSectionItem}>
<RedirectAppLinks
coreStart={{ application }}
css={headerCss.redirectAppLinksContainer}
>
<Breadcrumbs breadcrumbs$={observables.breadcrumbs$} />
</RedirectAppLinks>
</EuiHeaderSectionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const RedirectAppLinks: FC<RedirectAppLinksComponentProps> = ({
children,
navigateToUrl,
currentAppId,
...containerProps
}) => {
const containerRef = useRef<HTMLDivElement>(null);

Expand All @@ -50,6 +51,7 @@ export const RedirectAppLinks: FC<RedirectAppLinksComponentProps> = ({
ref={containerRef}
css={redirectAppLinksStyles}
data-test-subj="kbnRedirectAppLink"
{...containerProps}
>
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React, { FC } from 'react';
import type { RedirectAppLinksComponentProps } from '@kbn/shared-ux-link-redirect-app-types';

import { useServices } from './services';
import { RedirectAppLinks as Component } from './redirect_app_links.component';
Expand All @@ -22,6 +23,11 @@ import { RedirectAppLinks as Component } from './redirect_app_links.component';
* </RedirectAppLinks>
* ```
*/
export const RedirectAppLinks: FC<{}> = ({ children }) => (
<Component {...useServices()}>{children}</Component>
export const RedirectAppLinks: FC<Omit<RedirectAppLinksComponentProps, 'navigateToUrl'>> = ({
children,
...props
}) => (
<Component {...useServices()} {...props}>
{children}
</Component>
);
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ const isKibanaContract = (services: any): services is RedirectAppLinksKibanaDepe
* with which consumers can wrap their components or solutions.
*/
export const RedirectAppLinks: FC<RedirectAppLinksProps> = ({ children, ...props }) => {
const container = <RedirectAppLinksContainer>{children}</RedirectAppLinksContainer>;

if (isKibanaContract(props)) {
const { coreStart } = props;
const { coreStart, ...containerProps } = props;
const container = (
<RedirectAppLinksContainer {...containerProps}>{children}</RedirectAppLinksContainer>
);
return (
<RedirectAppLinksKibanaProvider {...{ coreStart }}>
{container}
</RedirectAppLinksKibanaProvider>
);
}

const { navigateToUrl, currentAppId } = props;
const { navigateToUrl, currentAppId, ...containerProps } = props;
const container = (
<RedirectAppLinksContainer {...containerProps}>{children}</RedirectAppLinksContainer>
);
return (
<RedirectAppLinksProvider {...{ currentAppId, navigateToUrl }}>
{container}
Expand Down
6 changes: 5 additions & 1 deletion packages/shared-ux/link/redirect_app/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export interface RedirectAppLinksKibanaDependencies {
}

/** Props for the `RedirectAppLinks` component. */
export type RedirectAppLinksProps = RedirectAppLinksServices | RedirectAppLinksKibanaDependencies;
export type RedirectAppLinksProps = (
| RedirectAppLinksServices
| RedirectAppLinksKibanaDependencies
) &
DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;

/** Props for the `RedirectAppLinksComponent`. */
export interface RedirectAppLinksComponentProps
Expand Down
55 changes: 55 additions & 0 deletions src/plugins/telemetry/server/fetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,61 @@ describe('FetcherTask', () => {
})
);

test(
'Retries when `getCurrentConfigs` rejects',
fakeSchedulers(async (advance) => {
expect(fetcherTask['isOnline$'].value).toBe(false);
getCurrentConfigs.mockRejectedValueOnce(new Error('SomeError')).mockResolvedValue({
telemetryOptIn: true,
telemetrySendUsageFrom: 'server',
failureCount: 0,
telemetryUrl: 'test-url',
});
fetchMock.mockResolvedValue({});

const subscription = fetcherTask['validateConnectivity']();

// need to advance / await twice for retry
advance(5 * 60 * 1000);
await new Promise((resolve) => process.nextTick(resolve)); // Wait for the initial promise to fulfill
advance(1 * 60 * 1000);
await new Promise((resolve) => process.nextTick(resolve)); // Wait for the retry promise to fulfill

expect(getCurrentConfigs).toHaveBeenCalledTimes(2);
expect(fetchMock).toHaveBeenCalledTimes(1);
expect(updateReportFailure).toHaveBeenCalledTimes(0);
expect(fetcherTask['isOnline$'].value).toBe(true);

subscription.unsubscribe();
})
);

test(
'logs a message when retries are exceeded',
fakeSchedulers(async (advance) => {
expect(fetcherTask['isOnline$'].value).toBe(false);
getCurrentConfigs.mockRejectedValue(new Error('SomeError'));

const subscription = fetcherTask['validateConnectivity']();

const wait = async () => {
advance(5 * 60 * 1000);
await new Promise((resolve) => process.nextTick(resolve)); // Wait for the initial promise to fulfill
};

for (let i = 0; i < 7; i++) {
await wait();
}

expect(fetcherTask['logger'].error).toBeCalledTimes(1);
expect(fetcherTask['logger'].error).toHaveBeenCalledWith(
`Cannot get the current config: SomeError`
);

subscription.unsubscribe();
})
);

test(
'Should not retry if it hit the max number of failures for this version',
fakeSchedulers(async (advance) => {
Expand Down
24 changes: 23 additions & 1 deletion src/plugins/telemetry/server/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import {
Subscription,
takeUntil,
timer,
catchError,
defer,
EMPTY,
retry,
} from 'rxjs';
import fetch from 'node-fetch';
import type { TelemetryCollectionManagerPluginStart } from '@kbn/telemetry-collection-manager-plugin/server';
Expand Down Expand Up @@ -105,7 +109,25 @@ export class FetcherTask {
// Skip any further processing if already online
filter(() => !this.isOnline$.value),
// Fetch current state and configs
exhaustMap(async () => await this.getCurrentConfigs()),
exhaustMap(() => {
return defer(() => {
return this.getCurrentConfigs();
}).pipe(
// exp-backoff retries in case of errors fetching the config
retry({
count: 5,
delay: (error, retryIndex) => {
const retryDelay = 1000 * Math.min(Math.pow(2, retryIndex + 2), 64); // 5 retries -> 8s, 16s, 32s, 64s, 64s
return timer(retryDelay);
},
}),
// shallow errors if all retry failed, next time tick will continue the emission
catchError((err) => {
this.logger.error(`Cannot get the current config: ${err.message}`);
return EMPTY;
})
);
}),
// Skip if opted-out, or should only send from the browser
filter(
({ telemetryOptIn, telemetrySendUsageFrom }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function ChangeDataView({
})}
</EuiContextMenuItem>
) : (
<React.Fragment />
<React.Fragment key="empty" />
),
<EuiHorizontalRule margin="none" key="dataviewActions-divider" />
);
Expand Down Expand Up @@ -336,7 +336,7 @@ export function ChangeDataView({
if (textBasedLanguages?.length) {
panelItems.push(
<EuiHorizontalRule margin="none" key="textbasedLanguages-divider" />,
<EuiPanel color="transparent" paddingSize="none">
<EuiPanel color="transparent" paddingSize="none" key="try-esql">
<EuiButton
color="success"
size="s"
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/actions/server/lib/gen_ai_token_tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const getGenAiTokenTracking = async ({
try {
const { total, prompt, completion } = await getTokenCountFromInvokeStream({
responseStream: result.data.pipe(new PassThrough()),
actionTypeId,
body: (validatedParams as { subActionParams: InvokeBody }).subActionParams,
logger,
});
Expand Down
Loading

0 comments on commit 1d50df5

Please sign in to comment.