Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into auto-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
topliceanurazvan committed Jul 7, 2023
2 parents 1bad654 + 0e94c3d commit e77d051
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 111 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.3.1](https://github.com/kubeshop/monokle/compare/v2.3.1-nightly-2023-07-07.0...v2.3.1) (2023-07-07)


### Features

* setting: kubectl proxy --append-server-path ([afda309](https://github.com/kubeshop/monokle/commit/afda309edb42392aef9fa6c507d73e2ddc97271f))


### Bug Fixes

* kubelet version telemetry ([542d862](https://github.com/kubeshop/monokle/commit/542d862782ced02ace937ccbca1997826ee411ae))
* skip noisy errors from sentry ([7ee5e98](https://github.com/kubeshop/monokle/commit/7ee5e98f652047adb0aaa69aee03544d27160451))

## [2.3.0](https://github.com/kubeshop/monokle/compare/v2.3.1-nightly-2023-07-06.0...v2.3.0) (2023-07-06)


Expand Down
9 changes: 0 additions & 9 deletions electron/app/ipc/ipcListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
saveFileDialog,
selectFileDialog,
} from '../commands';
import {killKubectlProxyProcess, startKubectlProxyProcess} from '../kubectl';
import {ProjectNameChange, StorePropagation} from '../models';
import '../services/cluster/ipc';
import {downloadPlugin, updatePlugin} from '../services/pluginService';
Expand Down Expand Up @@ -276,14 +275,6 @@ ipcMain.on('run-command', (event, args: CommandOptions) => {
runCommand(args, event);
});

ipcMain.on('kubectl-proxy-open', event => {
startKubectlProxyProcess(event);
});

ipcMain.on('kubectl-proxy-close', () => {
killKubectlProxyProcess();
});

ipcMain.on('app-version', event => {
event.sender.send('app-version', {version: app.getVersion()});
});
Expand Down
55 changes: 0 additions & 55 deletions electron/app/kubectl.ts

This file was deleted.

7 changes: 7 additions & 0 deletions electron/kubernetes/ProxyInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import log from 'electron-log';
import {ChildProcessWithoutNullStreams, spawn} from 'child_process';

import type {ProxyLog} from '@shared/ipc';
import electronStore from '@shared/utils/electronStore';

import {Signal} from './signal';

Expand Down Expand Up @@ -56,6 +57,12 @@ export class ProxyInstance {

const proxyOptions = [`--port=${this.port}`];

const shouldAppendServerPath = electronStore.get('kubeConfig.proxyOptions.appendServerPath');
if (shouldAppendServerPath === undefined || shouldAppendServerPath === true) {
log.info('[kubectl-proxy]: Append Server Path enabled.');
proxyOptions.push('--append-server-path=true');
}

const proxySignal = new Signal();
this._cmd = ['kubectl', ...globalOptions, 'proxy', ...proxyOptions].join(' ');
this._process = spawn('kubectl', [...globalOptions, 'proxy', ...proxyOptions], {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monokle",
"version": "2.3.0",
"version": "2.3.1",
"author": "Kubeshop",
"description": "UI for managing k8s manifests",
"homepage": "./",
Expand Down Expand Up @@ -100,7 +100,7 @@
"@dnd-kit/core": "6.0.8",
"@dnd-kit/sortable": "7.0.2",
"@kubernetes/client-node": "0.18.1",
"@monokle/components": "^1.6.1",
"@monokle/components": "^1.6.6",
"@monokle/validation": "0.23.3",
"@open-policy-agent/opa-wasm": "1.8.0",
"@reduxjs/toolkit": "1.9.5",
Expand Down
11 changes: 9 additions & 2 deletions src/components/organisms/ProblemPane/ProblemPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {useMeasure} from 'react-use';

import {DEFAULT_PANE_TITLE_HEIGHT} from '@constants/constants';

import {useAppSelector} from '@redux/hooks';
import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {setLeftMenuSelection} from '@redux/reducers/ui';

import {SelectItemImage} from '@atoms';

Expand All @@ -17,6 +18,7 @@ import {openUrlInExternalBrowser} from '@shared/utils';
import * as S from './ProblemPane.styled';

const ProblemPane: React.FC = () => {
const dispatch = useAppDispatch();
const lastResponse = useAppSelector(state => state.validation.lastResponse);
const selectedProblem = useAppSelector(state => state.validation.validationOverview.selectedProblem?.problem ?? null);

Expand Down Expand Up @@ -56,7 +58,12 @@ const ProblemPane: React.FC = () => {

{selectedProblem && (
<div ref={problemInfoRef}>
<ProblemInfo problem={selectedProblem} rule={rule} onHelpURLClick={url => openUrlInExternalBrowser(url)} />
<ProblemInfo
problem={selectedProblem}
rule={rule}
onHelpURLClick={url => openUrlInExternalBrowser(url)}
onSettingsClick={() => dispatch(setLeftMenuSelection('settings'))}
/>
</div>
)}
</S.ProblemPaneContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useEffect, useState} from 'react';
import {useCallback, useEffect, useState} from 'react';
import {useDebounce} from 'react-use';

import {Button, Checkbox, Form, Input, Select, Tooltip} from 'antd';
Expand All @@ -23,6 +23,7 @@ import {FileExplorer} from '@components/atoms';

import {useFileExplorer} from '@hooks/useFileExplorer';

import electronStore from '@shared/utils/electronStore';
import {openUrlInExternalBrowser} from '@shared/utils/shell';

import * as S from './GlobalSettings.styled';
Expand All @@ -35,6 +36,18 @@ export const GlobalSettings = () => {
const loadLastProjectOnStartup = useAppSelector(state => state.config.loadLastProjectOnStartup);
const projectsRootPath = useAppSelector(state => state.config.projectsRootPath);

const [shouldAppendServerPath, _setShouldAppendServerPath] = useState<boolean>(
electronStore.get('kubeConfig.proxyOptions.appendServerPath') ?? true
);

const setShouldAppendServerPath = useCallback(
(value: boolean) => {
_setShouldAppendServerPath(value);
electronStore.set('kubeConfig.proxyOptions.appendServerPath', value);
},
[_setShouldAppendServerPath]
);

const [currentProjectsRootPath, setCurrentProjectsRootPath] = useState(projectsRootPath);

const [settingsForm] = useForm();
Expand Down Expand Up @@ -131,12 +144,21 @@ export const GlobalSettings = () => {
</Select>
</S.Div>

<S.Span>On Startup</S.Span>
<Tooltip mouseEnterDelay={TOOLTIP_DELAY} title={AutoLoadLastProjectTooltip}>
<Checkbox checked={loadLastProjectOnStartup} onChange={handleChangeLoadLastFolderOnStartup}>
Automatically load last project
<S.Div>
<S.Span>On Startup</S.Span>
<Tooltip mouseEnterDelay={TOOLTIP_DELAY} title={AutoLoadLastProjectTooltip}>
<Checkbox checked={loadLastProjectOnStartup} onChange={handleChangeLoadLastFolderOnStartup}>
Automatically load last project
</Checkbox>
</Tooltip>
</S.Div>

<S.Div>
<S.Span>Cluster</S.Span>
<Checkbox checked={shouldAppendServerPath} onChange={e => setShouldAppendServerPath(e.target.checked)}>
Append Server Path to Kubectl Proxy
</Checkbox>
</Tooltip>
</S.Div>
</div>

<div style={{width: '45%'}}>
Expand Down
12 changes: 0 additions & 12 deletions src/components/organisms/SettingsPane/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,6 @@ export const Settings = ({
}}
/>
</S.Div>
{/* <S.Div>
<S.Span>Resource links processing</S.Span> */}

{/*
// TODO: revisit this after @monokle/validation is integrated
<Checkbox
checked={resourceRefsProcessingOptions.shouldIgnoreOptionalUnsatisfiedRefs}
onChange={setShouldIgnoreOptionalUnsatisfiedRefs}
>
Ignore optional unsatisfied links
</Checkbox> */}
{/* </S.Div> */}
<S.Div>
<S.Span>Form Editor</S.Span>
<S.Div>
Expand Down
6 changes: 3 additions & 3 deletions src/redux/appConfig/appConfig.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {CONFIG_PATH, keysToDelete, keysToUpdateStateBulk, writeProjectConfigFile
import {setRootFolder} from '@redux/thunks/setRootFolder';

import {init as sentryInit} from '@sentry/electron/renderer';
import {SKIPPED_ERRORS} from '@shared/constants/sentry';
import {ClusterColors} from '@shared/models/cluster';
import {
ApiKeyVendor,
Expand Down Expand Up @@ -370,9 +371,8 @@ export const configSlice = createSlice({
dsn: action.payload.SENTRY_DSN,
tracesSampleRate: 0.6,
beforeSend: event => {
// TODO: Skip errors related to model.getModeId for now, should fix in 2.0
// also why is it model.getModeId and not model.getModelId? is it a typo?
if (event.exception?.values?.some(v => v.value?.includes('model.getModeId'))) {
// skipping noisy errors from sentry
if (event.exception?.values?.some(v => SKIPPED_ERRORS.some(err => v.value?.includes(err)))) {
return null;
}
// we have to get this from electron store to get the most updated value
Expand Down
9 changes: 7 additions & 2 deletions src/redux/services/clusterDashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {isDefined} from '@shared/utils/filter';
import {trackEvent} from '@shared/utils/telemetry';

let lastContext: string | undefined;
let lastKubeletVersion: string | undefined;

export const getClusterUtilization = async (kubeconfig: string, context: string): Promise<NodeMetric[]> => {
const kc = await createKubeClientWithSetup({context, kubeconfig, skipHealthCheck: true});
Expand All @@ -20,9 +21,10 @@ export const getClusterUtilization = async (kubeconfig: string, context: string)

const nodeMetrics: k8s.NodeMetric[] = (await metricClient.getNodeMetrics()).items;
const nodes = await k8s.topNodes(k8sApiClient);
let kubeletVersion: string | undefined;

if (lastContext !== context) {
lastContext = context;
let kubeletVersion: string | undefined;
const providers = uniq(
nodes
.map(node => {
Expand All @@ -40,7 +42,10 @@ export const getClusterUtilization = async (kubeconfig: string, context: string)
})
.filter(isDefined)
);
trackEvent('cluster/info', {providers, kubeletVersion});
if (lastKubeletVersion !== kubeletVersion) {
lastKubeletVersion = kubeletVersion;
trackEvent('cluster/info', {providers, kubeletVersion});
}
}

return nodeMetrics.map(m => ({
Expand Down
2 changes: 0 additions & 2 deletions src/redux/thunks/cluster/stopClusterConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import {disconnectFromCluster} from '@redux/services/clusterResourceWatcher';

import {AppDispatch} from '@shared/models/appDispatch';
import {RootState} from '@shared/models/rootState';
import {closeKubectlProxy} from '@shared/utils/commands/kubectl';

export const stopClusterConnection = createAsyncThunk<void, undefined, {dispatch: AppDispatch; state: RootState}>(
'main/stopClusterConnection',
async (payload, {dispatch}) => {
// Close connection
dispatch(setClusterProxyPort(undefined));
disconnectFromCluster();
closeKubectlProxy();
}
);
9 changes: 9 additions & 0 deletions src/shared/constants/electronStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ export const electronStoreSchema = {
type: 'string',
},
},
proxyOptions: {
type: 'object',
properties: {
appendServerPath: {
type: 'boolean',
default: true,
},
},
},
},
},
terminal: {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/constants/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const SKIPPED_ERRORS = [
'model.getModeId',
'ResizeObserver loop limit exceeded',
"Failed to execute 'importScripts' on 'WorkerGlobalScope'",
];
12 changes: 0 additions & 12 deletions src/shared/utils/commands/kubectl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {ipcRenderer} from 'electron';

import {v4 as uuid} from 'uuid';

import {CommandOptions, KubectlApplyArgs, KubectlEnv} from '@shared/models/commands';
Expand All @@ -22,13 +20,3 @@ export function createKubectlApplyCommand(
env,
};
}

export function openKubectlProxy(listener: (...args: any[]) => void) {
ipcRenderer.removeAllListeners('kubectl-proxy-event');
ipcRenderer.on('kubectl-proxy-event', (event, args) => listener(args));
ipcRenderer.send('kubectl-proxy-open');
}

export function closeKubectlProxy() {
ipcRenderer.send('kubectl-proxy-close');
}

0 comments on commit e77d051

Please sign in to comment.