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
12 changes: 12 additions & 0 deletions locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@
"DEPLOYMENT_ACTION_CONTAINER_NO_CONFIG": "None",
"DEPLOYMENT_ACTION_CONTAINER_SINGLE_AUTO_SELECTED": "Single container automatically selected",
"DEPLOYMENT_ACTION_CONTAINER_MUST_SELECT_ONE": "You must select exactly one container to instrument",
"DEPLOYMENT_ACTION_WIZARD_STEP_AGENT_CONFIG": "Agent Configuration",
"DEPLOYMENT_ACTION_WIZARD_STEP_AGENT_CONFIG_DESC": "Configure Agent settings",
"DEPLOYMENT_ACTION_JAVA_OPTS_VAR_LABEL": "Java Options Environment Variable:",
"DEPLOYMENT_ACTION_JAVA_OPTS_VAR_HELPER": "The environment variable name used to pass Java options to the JVM (default: JAVA_TOOL_OPTIONS)",
"DEPLOYMENT_ACTION_CALLBACK_PORT_LABEL": "Callback Port:",
"DEPLOYMENT_ACTION_CALLBACK_PORT_HELPER": "HTTP port for the Cryostat Agent (leave empty for Operator default)",
"DEPLOYMENT_ACTION_CALLBACK_PORT_PLACEHOLDER": "<Default>",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_LABEL": "Harvester Template:",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_NONE": "None",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_CONTINUOUS": "Continuous",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_PROFILING": "Profiling",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_NONE_DESC": "No automatic JFR harvesting",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_CONTINUOUS_DESC": "Continuous JFR recording with periodic harvesting",
"DEPLOYMENT_ACTION_HARVESTER_TEMPLATE_PROFILING_DESC": "Profiling template for performance analysis",
"DEPLOYMENT_ACTION_HARVESTER_PERIOD_LABEL": "Harvester Period:",
"DEPLOYMENT_ACTION_HARVESTER_PERIOD_HELPER": "How often to push JFR data to Cryostat (default: 15 minutes)",
"DEPLOYMENT_ACTION_HARVESTER_MAX_FILES_LABEL": "Harvester Max Files:",
"DEPLOYMENT_ACTION_HARVESTER_MAX_FILES_HELPER": "Maximum number of JFR files to retain locally (default: 4 files)",
"DEPLOYMENT_ACTION_HARVESTER_EXIT_MAX_AGE_LABEL": "Harvester Exit Max Age:",
"DEPLOYMENT_ACTION_HARVESTER_EXIT_MAX_AGE_HELPER": "Maximum age of data retained in the local recording file before it is pushed to Cryostat on shutdown (default: 5 minutes)",
"DEPLOYMENT_ACTION_HARVESTER_EXIT_MAX_SIZE_LABEL": "Harvester Exit Max Size:",
Expand All @@ -69,7 +78,10 @@
"DEPLOYMENT_ACTION_REVIEW_INSTANCE": "Cryostat Instance",
"DEPLOYMENT_ACTION_REVIEW_CONTAINER": "Selected Container",
"DEPLOYMENT_ACTION_REVIEW_JAVA_OPTS_VAR": "Java Options Variable",
"DEPLOYMENT_ACTION_REVIEW_CALLBACK_PORT": "Callback Port",
"DEPLOYMENT_ACTION_REVIEW_HARVESTER": "Harvester Template",
"DEPLOYMENT_ACTION_REVIEW_HARVESTER_PERIOD": "Harvester Period",
"DEPLOYMENT_ACTION_REVIEW_HARVESTER_MAX_FILES": "Harvester Max Files",
"DEPLOYMENT_ACTION_REVIEW_HARVESTER_EXIT_MAX_AGE": "Harvester Exit Max Age",
"DEPLOYMENT_ACTION_REVIEW_HARVESTER_EXIT_MAX_SIZE": "Harvester Exit Max Size",
"DEPLOYMENT_ACTION_REVIEW_LOG_LEVEL": "Log Level",
Expand Down
104 changes: 104 additions & 0 deletions src/openshift/actions/DeploymentLabelAction/AgentConfigStep.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright The Cryostat Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useCryostatTranslation } from '@i18n/i18nextUtil';
import {
Form,
FormGroup,
TextInput,
NumberInput,
FormHelperText,
HelperText,
HelperTextItem,
} from '@patternfly/react-core';
import * as React from 'react';

interface AgentConfigStepProps {
javaOptsVar: string;
callbackPort?: number;
onJavaOptsVarChange: (value: string) => void;
onCallbackPortChange: (value: number | undefined) => void;
}

export const AgentConfigStep: React.FC<AgentConfigStepProps> = ({
javaOptsVar,
callbackPort,
onJavaOptsVarChange,
onCallbackPortChange,
}) => {
const { t } = useCryostatTranslation();

const handleCallbackPortChange = (event: React.FormEvent<HTMLInputElement>) => {
const value = (event.target as HTMLInputElement).value;
if (value === '') {
onCallbackPortChange(undefined);
} else {
const numValue = Number(value);
if (!isNaN(numValue) && numValue > 0) {
onCallbackPortChange(numValue);
}
}
};

const handleCallbackPortMinus = () => {
if (callbackPort !== undefined && callbackPort > 1) {
onCallbackPortChange(callbackPort - 1);
}
};

const handleCallbackPortPlus = () => {
if (callbackPort !== undefined) {
onCallbackPortChange(callbackPort + 1);
} else {
onCallbackPortChange(1);
}
};

return (
<Form>
<FormGroup label={t('DEPLOYMENT_ACTION_JAVA_OPTS_VAR_LABEL')} fieldId="java-opts-var">
<TextInput
id="java-opts-var"
name="java-opts-var"
value={javaOptsVar}
onChange={(_event, value) => onJavaOptsVarChange(value)}
placeholder="JAVA_TOOL_OPTIONS"
/>
<FormHelperText>
<HelperText>
<HelperTextItem>{t('DEPLOYMENT_ACTION_JAVA_OPTS_VAR_HELPER')}</HelperTextItem>
</HelperText>
</FormHelperText>
</FormGroup>
<FormGroup label={t('DEPLOYMENT_ACTION_CALLBACK_PORT_LABEL')} fieldId="callback-port">
<NumberInput
id="callback-port"
value={callbackPort ?? ''}
onMinus={handleCallbackPortMinus}
onPlus={handleCallbackPortPlus}
onChange={handleCallbackPortChange}
min={1}
widthChars={10}
placeholder={t('DEPLOYMENT_ACTION_CALLBACK_PORT_PLACEHOLDER')}
/>
<FormHelperText>
<HelperText>
<HelperTextItem>{t('DEPLOYMENT_ACTION_CALLBACK_PORT_HELPER')}</HelperTextItem>
</HelperText>
</FormHelperText>
</FormGroup>
</Form>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
DescriptionListDescription,
} from '@patternfly/react-core';
import * as React from 'react';
import { Container, getAgentConfig, formatAgentConfig, LogLevel } from './envVarUtils';
import { Container, getAgentConfig, formatAgentConfig, LogLevel } from './utils';

interface ContainerSelectionStepProps {
containers: Container[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CryostatIcon from '@console-plugin/assets/CryostatIcon';
import { k8sGet, K8sResourceKind, useK8sModel, useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
import { Node } from '@patternfly/react-topology';
import * as React from 'react';
import { AGENT_LABEL_KEYS } from './utils';

type DeploymentDecoratorProps = {
element: Node;
Expand Down Expand Up @@ -50,7 +51,7 @@ export const DeploymentDecorator: React.FC<DeploymentDecoratorProps> = ({ elemen
React.useEffect(() => {
if (deploymentLoaded && cryostatsLoaded) {
const deploymentLabels = deployment.spec?.template.metadata.labels;
if (deploymentLabels && deploymentLabels['cryostat.io/name'] && deploymentLabels['cryostat.io/namespace']) {
if (deploymentLabels && deploymentLabels[AGENT_LABEL_KEYS.NAME] && deploymentLabels[AGENT_LABEL_KEYS.NAMESPACE]) {
setIsRegistered(true);
} else {
setIsRegistered(false);
Expand All @@ -61,16 +62,16 @@ export const DeploymentDecorator: React.FC<DeploymentDecoratorProps> = ({ elemen
React.useEffect(() => {
if (deploymentLoaded && cryostatsLoaded && isRegistered) {
const labels = deployment.spec?.template.metadata.labels;
if (labels && labels['cryostat.io/name'] && labels['cryostat.io/namespace']) {
if (labels && labels[AGENT_LABEL_KEYS.NAME] && labels[AGENT_LABEL_KEYS.NAMESPACE]) {
cryostats.forEach((cryostat) => {
if (
cryostat.metadata?.name === labels['cryostat.io/name'] &&
cryostat.metadata?.namespace === labels['cryostat.io/namespace']
cryostat.metadata?.name === labels[AGENT_LABEL_KEYS.NAME] &&
cryostat.metadata?.namespace === labels[AGENT_LABEL_KEYS.NAMESPACE]
) {
k8sGet({
model: routeModel,
name: labels['cryostat.io/name'],
ns: labels['cryostat.io/namespace'],
name: labels[AGENT_LABEL_KEYS.NAME],
ns: labels[AGENT_LABEL_KEYS.NAMESPACE],
})
.catch(() => '')
.then(
Expand Down
Loading
Loading