Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for type assertion success #181

Merged
merged 2 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions interceptor/forward_wait_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,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