mirror of https://github.com/knative/pkg.git
Prevent nil access when resource is nil (#1386)
When an error is returned frequently the resource is nil and results in nil.Name being called for the error.
This commit is contained in:
parent
b7125260dc
commit
2266252575
|
|
@ -463,10 +463,11 @@ func (r *reconcilerImpl) updateFinalizersFiltered(ctx {{.contextContext|raw}}, r
|
|||
{{else}}
|
||||
patcher := r.Client.{{.group}}{{.version}}().{{.type|apiGroup}}(resource.Namespace)
|
||||
{{end}}
|
||||
resource, err = patcher.Patch(resource.Name, {{.typesMergePatchType|raw}}, patch)
|
||||
resourceName := resource.Name
|
||||
resource, err = patcher.Patch(resourceName, {{.typesMergePatchType|raw}}, patch)
|
||||
if err != nil {
|
||||
r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "FinalizerUpdateFailed",
|
||||
"Failed to update finalizers for %q: %v", resource.Name, err)
|
||||
"Failed to update finalizers for %q: %v", resourceName, err)
|
||||
} else {
|
||||
r.Recorder.Eventf(resource, {{.corev1EventTypeNormal|raw}}, "FinalizerUpdate",
|
||||
"Updated %q finalizers", resource.GetName())
|
||||
|
|
|
|||
Loading…
Reference in New Issue