Skip to content

Commit

Permalink
fix: use key instead of object
Browse files Browse the repository at this point in the history
  • Loading branch information
gxthrj committed Mar 8, 2021
1 parent bc20bb2 commit 8fb5f0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
19 changes: 7 additions & 12 deletions pkg/ingress/controller/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,18 @@ func (c *secretController) run(ctx context.Context) {
}

func (c *secretController) sync(ctx context.Context, ev *types.Event) error {
namespace, name, err := cache.SplitMetaNamespaceKey(ev.Key)
key := ev.Object.(string)
namespace, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
log.Errorf("invalid resource key: %s", ev.Key)
log.Errorf("invalid resource key: %s", key)
return err
}
obj := ev.Object.(*corev1.Secret)
sec, err := c.controller.secretLister.Secrets(namespace).Get(name)

secretMapkey := obj.Namespace + "_" + obj.Name
secretMapkey := namespace + "_" + name
if err != nil {
if !k8serrors.IsNotFound(err) {
log.Errorw("failed to get Secret",
zap.String("version", obj.ResourceVersion),
zap.String("key", secretMapkey),
zap.Error(err),
)
Expand All @@ -127,7 +126,6 @@ func (c *secretController) sync(ctx context.Context, ev *types.Event) error {
if ev.Type != types.EventDelete {
log.Warnw("Secret was deleted before it can be delivered",
zap.String("key", secretMapkey),
zap.String("version", obj.ResourceVersion),
)
return nil
}
Expand Down Expand Up @@ -172,9 +170,8 @@ func (c *secretController) onAdd(obj interface{}) {
}

c.workqueue.AddRateLimited(&types.Event{
Key: key,
Type: types.EventAdd,
Object: obj,
Object: key,
})
}

Expand All @@ -194,9 +191,8 @@ func (c *secretController) onUpdate(prev, curr interface{}) {
return
}
c.workqueue.AddRateLimited(&types.Event{
Key: key,
Type: types.EventUpdate,
Object: curr,
Object: key,
})
}

Expand All @@ -223,9 +219,8 @@ func (c *secretController) onDelete(obj interface{}) {
return
}
c.workqueue.AddRateLimited(&types.Event{
Key: key,
Type: types.EventDelete,
Object: sec,
Object: key,
Tombstone: sec,
})
}
1 change: 0 additions & 1 deletion pkg/types/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (ev EventType) String() string {

// Event represents a typed event.
type Event struct {
Key string
// Type is the type of event.
Type EventType
// Object is the event subject.
Expand Down

0 comments on commit 8fb5f0d

Please sign in to comment.