Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.4] Bug 1809182: fixes issue with prefetching of container ports for image #4592

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
import * as React from 'react';
import * as _ from 'lodash';
import { TextInputTypes } from '@patternfly/react-core';
import { InputField } from '@console/shared';
import { useFormikContext, FormikValues } from 'formik';
import { InputField, DropdownField } from '@console/shared';
import FormSection from '../section/FormSection';
import { RouteData } from '../import-types';
import { makePortName } from '../../../utils/imagestream-utils';

export interface ServerlessRouteSectionProps {
route: RouteData;
}

const ServerlessRouteSection: React.FC<ServerlessRouteSectionProps> = ({ route }) => {
const {
values: {
image: { ports },
route: { defaultUnknownPort, targetPort },
},
} = useFormikContext<FormikValues>();
const portOptions = ports.reduce((acc, port) => {
const name = makePortName(port);
acc[name] = <>{port.containerPort}</>;
return acc;
}, {});
return (
<FormSection title="Routing">
{route.create && (
<InputField
type={TextInputTypes.text}
name="route.unknownTargetPort"
label="Target Port"
placeholder="8080"
helpText="Target port for traffic."
/>
<>
{_.isEmpty(ports) ? (
<InputField
type={TextInputTypes.text}
name="route.unknownTargetPort"
label="Target Port"
placeholder={defaultUnknownPort}
helpText="Target port for traffic."
/>
) : (
<DropdownField
name="route.targetPort"
label="Target Port"
items={portOptions}
title={portOptions[targetPort] || 'Select target port'}
helpText="Target port for traffic."
fullWidth
/>
)}
</>
)}
</FormSection>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ export const getKnativeServiceDepResource = (
project: { name: namespace },
serverless: { scaling },
limits,
route: { unknownTargetPort, create },
route: { unknownTargetPort, create, targetPort },
labels,
image: { tag: imageTag },
} = formData;
const contTargetPort: number = parseInt(unknownTargetPort, 10);
const contTargetPort = targetPort
? parseInt(targetPort.split('-')[0], 10)
: parseInt(unknownTargetPort, 10);
const { concurrencylimit, concurrencytarget, minpods, maxpods } = scaling;
const {
cpu: {
Expand Down