Skip to content

Commit

Permalink
Checking for type assertion success (kedacore#181)
Browse files Browse the repository at this point in the history
Fixes kedacore#174

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

Co-authored-by: Tom Kerkhove <kerkhove.tom@gmail.com>
  • Loading branch information
arschles and tomkerkhove committed Aug 18, 2021
1 parent fc9c699 commit 0e7413c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 3 additions & 7 deletions interceptor/forward_wait_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ func newDeployReplicasForwardWaitFunc(
for {
select {
case event := <-eventCh:
deployment := event.Object.(*appsv1.Deployment)
if err != nil {
log.Printf(
"Error getting deployment %s after change was triggered (%s)",
deployName,
err,
)
deployment, ok := event.Object.(*appsv1.Deployment)
if !ok {
log.Println("Didn't get a deployment back in event")
}
if moreThanPtr(deployment.Spec.Replicas, 0) {
return nil
Expand Down
7 changes: 6 additions & 1 deletion pkg/k8s/deployment_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ func NewK8sDeploymentCache(
evt := <-ch
ret.broadcaster.Action(evt.Type, evt.Object)
ret.rwm.Lock()
depl := evt.Object.(*appsv1.Deployment)
depl, ok := evt.Object.(*appsv1.Deployment)
// if we didn't get back a deployment in the event,
// something is wrong that we can't fix, so just continue
if !ok {
continue
}
ret.latestEvts[depl.GetObjectMeta().GetName()] = evt
ret.rwm.Unlock()
}
Expand Down

0 comments on commit 0e7413c

Please sign in to comment.