mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 18:28:13 +00:00 
			
		
		
		
	Merge pull request #100505 from lauchokyip/fixDescribe
Fixed kubectl describe ingress causing SEGFAULT if API Group is not specified
This commit is contained in:
		| @@ -2556,7 +2556,11 @@ func (i *IngressDescriber) describeBackendV1(ns string, backend *networkingv1.In | |||||||
| 	} | 	} | ||||||
| 	if backend.Resource != nil { | 	if backend.Resource != nil { | ||||||
| 		ic := backend.Resource | 		ic := backend.Resource | ||||||
| 		return fmt.Sprintf("APIGroup: %v, Kind: %v, Name: %v", *ic.APIGroup, ic.Kind, ic.Name) | 		apiGroup := "<none>" | ||||||
|  | 		if ic.APIGroup != nil { | ||||||
|  | 			apiGroup = fmt.Sprintf("%v", *ic.APIGroup) | ||||||
|  | 		} | ||||||
|  | 		return fmt.Sprintf("APIGroup: %v, Kind: %v, Name: %v", apiGroup, ic.Kind, ic.Name) | ||||||
| 	} | 	} | ||||||
| 	return "" | 	return "" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2213,6 +2213,12 @@ func TestDescribeIngress(t *testing.T) { | |||||||
| 			Name:     "bar", | 			Name:     "bar", | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|  | 	backendResourceNoAPIGroup := networkingv1.IngressBackend{ | ||||||
|  | 		Resource: &corev1.TypedLocalObjectReference{ | ||||||
|  | 			Kind: "foo", | ||||||
|  | 			Name: "bar", | ||||||
|  | 		}, | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	tests := map[string]struct { | 	tests := map[string]struct { | ||||||
| 		input  *fake.Clientset | 		input  *fake.Clientset | ||||||
| @@ -2280,6 +2286,42 @@ Rules: | |||||||
|   foo.bar.com   |   foo.bar.com   | ||||||
|                /foo   APIGroup: example.com, Kind: foo, Name: bar |                /foo   APIGroup: example.com, Kind: foo, Name: bar | ||||||
| Annotations:   <none> | Annotations:   <none> | ||||||
|  | Events:        <none>` + "\n", | ||||||
|  | 		}, | ||||||
|  | 		"IngressRule.HTTP.Paths.Backend.Resource v1 Without APIGroup": { | ||||||
|  | 			input: fake.NewSimpleClientset(&networkingv1.Ingress{ | ||||||
|  | 				ObjectMeta: metav1.ObjectMeta{ | ||||||
|  | 					Name:      "bar", | ||||||
|  | 					Namespace: "foo", | ||||||
|  | 				}, | ||||||
|  | 				Spec: networkingv1.IngressSpec{ | ||||||
|  | 					Rules: []networkingv1.IngressRule{ | ||||||
|  | 						{ | ||||||
|  | 							Host: "foo.bar.com", | ||||||
|  | 							IngressRuleValue: networkingv1.IngressRuleValue{ | ||||||
|  | 								HTTP: &networkingv1.HTTPIngressRuleValue{ | ||||||
|  | 									Paths: []networkingv1.HTTPIngressPath{ | ||||||
|  | 										{ | ||||||
|  | 											Path:    "/foo", | ||||||
|  | 											Backend: backendResourceNoAPIGroup, | ||||||
|  | 										}, | ||||||
|  | 									}, | ||||||
|  | 								}, | ||||||
|  | 							}, | ||||||
|  | 						}, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}), | ||||||
|  | 			output: `Name:             bar | ||||||
|  | Namespace:        foo | ||||||
|  | Address:           | ||||||
|  | Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>) | ||||||
|  | Rules: | ||||||
|  |   Host         Path  Backends | ||||||
|  |   ----         ----  -------- | ||||||
|  |   foo.bar.com   | ||||||
|  |                /foo   APIGroup: <none>, Kind: foo, Name: bar | ||||||
|  | Annotations:   <none> | ||||||
| Events:        <none>` + "\n", | Events:        <none>` + "\n", | ||||||
| 		}, | 		}, | ||||||
| 		"Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": { | 		"Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot