mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
bug(ingress): fix ingress class disallowed to not found issue EE-4311 (#7731)
This commit is contained in:
parent
66fd039933
commit
83a1ce9d2a
3 changed files with 92 additions and 64 deletions
|
@ -14,7 +14,7 @@ import { PageHeader } from '@@/PageHeader';
|
|||
import { Option } from '@@/form-components/Input/Select';
|
||||
import { Button } from '@@/buttons';
|
||||
|
||||
import { Ingress } from '../types';
|
||||
import { Ingress, IngressController } from '../types';
|
||||
import {
|
||||
useCreateIngress,
|
||||
useIngresses,
|
||||
|
@ -66,7 +66,8 @@ export function CreateIngressView() {
|
|||
(servicesResults.isLoading &&
|
||||
configResults.isLoading &&
|
||||
namespacesResults.isLoading &&
|
||||
ingressesResults.isLoading) ||
|
||||
ingressesResults.isLoading &&
|
||||
ingressControllersResults.isLoading) ||
|
||||
(isEdit && !ingressRule.IngressName);
|
||||
|
||||
const [ingressNames, ingresses, ruleCounterByNamespace, hostWithTLS] =
|
||||
|
@ -166,7 +167,12 @@ export function CreateIngressView() {
|
|||
})) || []),
|
||||
];
|
||||
|
||||
if (!existingIngressClass && ingressRule.IngressClassName) {
|
||||
if (
|
||||
(!existingIngressClass ||
|
||||
(existingIngressClass && !existingIngressClass.Availability)) &&
|
||||
ingressRule.IngressClassName &&
|
||||
ingressControllersResults.data
|
||||
) {
|
||||
ingressClassOptions.push({
|
||||
label: !ingressRule.IngressType
|
||||
? `${ingressRule.IngressClassName} - NOT FOUND`
|
||||
|
@ -189,7 +195,12 @@ export function CreateIngressView() {
|
|||
];
|
||||
|
||||
useEffect(() => {
|
||||
if (!!params.name && ingressesResults.data && !ingressRule.IngressName) {
|
||||
if (
|
||||
!!params.name &&
|
||||
ingressesResults.data &&
|
||||
!ingressRule.IngressName &&
|
||||
ingressControllersResults.data
|
||||
) {
|
||||
// if it is an edit screen, prepare the rule from the ingress
|
||||
const ing = ingressesResults.data?.find(
|
||||
(ing) => ing.Name === params.name && ing.Namespace === params.namespace
|
||||
|
@ -199,7 +210,7 @@ export function CreateIngressView() {
|
|||
(c) => c.ClassName === ing.ClassName
|
||||
)?.Type;
|
||||
const r = prepareRuleFromIngress(ing);
|
||||
r.IngressType = type;
|
||||
r.IngressType = type || r.IngressType;
|
||||
setIngressRule(r);
|
||||
}
|
||||
}
|
||||
|
@ -217,9 +228,10 @@ export function CreateIngressView() {
|
|||
ingressRule,
|
||||
ingressNames || [],
|
||||
servicesOptions || [],
|
||||
!!existingIngressClass
|
||||
existingIngressClass
|
||||
);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [
|
||||
ingressRule,
|
||||
namespace,
|
||||
|
@ -289,7 +301,7 @@ export function CreateIngressView() {
|
|||
ingressRule: Rule,
|
||||
ingressNames: string[],
|
||||
serviceOptions: Option<string>[],
|
||||
existingIngressClass: boolean
|
||||
existingIngressClass?: IngressController
|
||||
) {
|
||||
const errors: Record<string, ReactNode> = {};
|
||||
const rule = { ...ingressRule };
|
||||
|
@ -320,7 +332,12 @@ export function CreateIngressView() {
|
|||
'No ingress class is currently set for this ingress - use of the Portainer UI requires one to be set.';
|
||||
}
|
||||
|
||||
if (isEdit && !existingIngressClass && ingressRule.IngressClassName) {
|
||||
if (
|
||||
isEdit &&
|
||||
(!existingIngressClass ||
|
||||
(existingIngressClass && !existingIngressClass.Availability)) &&
|
||||
ingressRule.IngressClassName
|
||||
) {
|
||||
if (!rule.IngressType) {
|
||||
errors.className =
|
||||
'Currently set to an ingress class that cannot be found in the cluster - you must select a valid class.';
|
||||
|
|
|
@ -102,8 +102,9 @@ export function IngressForm({
|
|||
}
|
||||
const hasNoHostRule = rule.Hosts?.some((host) => host.NoHost);
|
||||
const placeholderAnnotation =
|
||||
PlaceholderAnnotations[rule.IngressType || 'other'];
|
||||
const pathTypes = PathTypes[rule.IngressType || 'other'];
|
||||
PlaceholderAnnotations[rule.IngressType || 'other'] ||
|
||||
PlaceholderAnnotations.other;
|
||||
const pathTypes = PathTypes[rule.IngressType || 'other'] || PathTypes.other;
|
||||
|
||||
return (
|
||||
<Widget>
|
||||
|
@ -169,7 +170,7 @@ export function IngressForm({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form-group" key={rule.IngressClassName}>
|
||||
<div className="form-group" key={ingressClassOptions.toString()}>
|
||||
<label
|
||||
className="control-label text-muted col-sm-3 col-lg-2 required"
|
||||
htmlFor="ingress_class"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue