Skip to content

Commit d6efc29

Browse files
authored
Merge pull request #1254 from hzxuzhonghu/master
fix Type transform panic
2 parents 69c89cc + af6a7f6 commit d6efc29

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

core/pkg/ingress/annotations/alias/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ func NewParser() parser.IngressAnnotation {
3838
// used to add an alias to the provided hosts
3939
func (a alias) Parse(ing *extensions.Ingress) (interface{}, error) {
4040
return parser.GetStringAnnotation(annotation, ing)
41-
}
41+
}

core/pkg/ingress/annotations/clientbodybuffersize/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ func NewParser() parser.IngressAnnotation {
3838
// used to add an client-body-buffer-size to the provided locations
3939
func (a clientBodyBufferSize) Parse(ing *extensions.Ingress) (interface{}, error) {
4040
return parser.GetStringAnnotation(annotation, ing)
41-
}
41+
}

core/pkg/ingress/controller/controller.go

+28-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,20 @@ func newIngressController(config *Configuration) *GenericController {
187187
ic.syncQueue.Enqueue(obj)
188188
},
189189
DeleteFunc: func(obj interface{}) {
190-
delIng := obj.(*extensions.Ingress)
190+
delIng, ok := obj.(*extensions.Ingress)
191+
if !ok {
192+
// If we reached here it means the ingress was deleted but its final state is unrecorded.
193+
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
194+
if !ok {
195+
glog.Errorf("couldn't get object from tombstone %#v", obj)
196+
return
197+
}
198+
delIng, ok = tombstone.Obj.(*extensions.Ingress)
199+
if !ok {
200+
glog.Errorf("Tombstone contained object that is not an Ingress: %#v", obj)
201+
return
202+
}
203+
}
191204
if !class.IsValid(delIng, ic.cfg.IngressClass, ic.cfg.DefaultIngressClass) {
192205
glog.Infof("ignoring delete for ingress %v based on annotation %v", delIng.Name, class.IngressKey)
193206
return
@@ -223,7 +236,20 @@ func newIngressController(config *Configuration) *GenericController {
223236
}
224237
},
225238
DeleteFunc: func(obj interface{}) {
226-
sec := obj.(*api.Secret)
239+
sec, ok := obj.(*api.Secret)
240+
if !ok {
241+
// If we reached here it means the secret was deleted but its final state is unrecorded.
242+
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
243+
if !ok {
244+
glog.Errorf("couldn't get object from tombstone %#v", obj)
245+
return
246+
}
247+
sec, ok = tombstone.Obj.(*api.Secret)
248+
if !ok {
249+
glog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
250+
return
251+
}
252+
}
227253
key := fmt.Sprintf("%v/%v", sec.Namespace, sec.Name)
228254
ic.sslCertTracker.DeleteAll(key)
229255
},

0 commit comments

Comments
 (0)