Skip to content

Commit

Permalink
Merge pull request #117 from dcbw/dhcp-cleanup
Browse files Browse the repository at this point in the history
dhcp plugin testcases and bug fixes
  • Loading branch information
Casey Callendrello authored Feb 9, 2018
2 parents 461d433 + 596480e commit 136399f
Show file tree
Hide file tree
Showing 119 changed files with 13,387 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions plugins/ipam/dhcp/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (d *DHCP) Release(args *skel.CmdArgs, reply *struct{}) error {

if l := d.getLease(args.ContainerID, conf.Name); l != nil {
l.Stop()
d.clearLease(args.ContainerID, conf.Name)
}

return nil
Expand All @@ -118,6 +119,14 @@ func (d *DHCP) setLease(contID, netName string, l *DHCPLease) {
d.leases[contID+netName] = l
}

func (d *DHCP) clearLease(contID, netName string) {
d.mux.Lock()
defer d.mux.Unlock()

// TODO(eyakubovich): hash it to avoid collisions
delete(d.leases, contID+netName)
}

func getListener() (net.Listener, error) {
l, err := activation.Listeners(true)
if err != nil {
Expand Down
27 changes: 27 additions & 0 deletions plugins/ipam/dhcp/dhcp_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2016 CNI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"testing"
)

func TestDHCP(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "DHCP Suite")
}
Loading

0 comments on commit 136399f

Please sign in to comment.