Skip to content

Commit

Permalink
libnet: don't check if ctrler store is nil
Browse files Browse the repository at this point in the history
Since commit befff0e, `(*Controller).getStore()` never returns nil
except if `c.store` isn't initialized yet. This can't happen unless
`New()` returned an error and it wasn't proper caught.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
  • Loading branch information
akerouanton committed May 8, 2024
1 parent 4d525c9 commit 7216541
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 18 deletions.
6 changes: 0 additions & 6 deletions libnetwork/endpoint_cnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ func (ec *endpointCnt) EndpointCnt() uint64 {

func (ec *endpointCnt) updateStore() error {
store := ec.n.getController().getStore()
if store == nil {
return fmt.Errorf("store not found on endpoint count update")
}
// make a copy of count and n to avoid being overwritten by store.GetObject
count := ec.EndpointCnt()
n := ec.n
Expand All @@ -135,9 +132,6 @@ func (ec *endpointCnt) setCnt(cnt uint64) error {

func (ec *endpointCnt) atomicIncDecEpCnt(inc bool) error {
store := ec.n.getController().getStore()
if store == nil {
return fmt.Errorf("store not found on endpoint count atomic inc/dec")
}

tmp := &endpointCnt{n: ec.n}
if err := store.GetObject(tmp); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions libnetwork/sandbox_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ func (sb *Sandbox) storeDelete() error {

func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) error {
store := c.getStore()
if store == nil {
return fmt.Errorf("could not find local scope store")
}

sandboxStates, err := store.List(&sbState{c: c})
if err != nil {
Expand Down
9 changes: 0 additions & 9 deletions libnetwork/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ func (c *Controller) getNetworks() ([]*Network, error) {
var nl []*Network

store := c.getStore()
if store == nil {
return nil, nil
}

kvol, err := store.List(&Network{ctrlr: c})
if err != nil && err != datastore.ErrKeyNotFound {
Expand Down Expand Up @@ -147,9 +144,6 @@ func (n *Network) getEndpointsFromStore() ([]*Endpoint, error) {

func (c *Controller) updateToStore(kvObject datastore.KVObject) error {
cs := c.getStore()
if cs == nil {
return fmt.Errorf("datastore is not initialized")
}

if err := cs.PutObjectAtomic(kvObject); err != nil {
if err == datastore.ErrKeyModified {
Expand All @@ -163,9 +157,6 @@ func (c *Controller) updateToStore(kvObject datastore.KVObject) error {

func (c *Controller) deleteFromStore(kvObject datastore.KVObject) error {
cs := c.getStore()
if cs == nil {
return fmt.Errorf("datastore is not initialized")
}

retry:
if err := cs.DeleteObjectAtomic(kvObject); err != nil {
Expand Down

0 comments on commit 7216541

Please sign in to comment.