Skip to content

Conversation

@andrewhsu
Copy link
Contributor

@andrewhsu andrewhsu commented Jun 8, 2018

What this PR does / why we need it:

The ipamclient_test.go was using undefined variables.

$ go test github.com/Azure/azure-container-networking/cns/ipamclient
# github.com/Azure/azure-container-networking/cns/ipamclient
./ipamclient_test.go:30: undefined: getAddressSpacesPath
./ipamclient_test.go:31: undefined: requestPoolPath
./ipamclient_test.go:32: undefined: reserveAddrPath
./ipamclient_test.go:33: undefined: releaseAddrPath
./ipamclient_test.go:34: undefined: getPoolInfoPath
FAIL    github.com/Azure/azure-container-networking/cns/ipamclient [build failed]

This is addressed with the first commit of this PR 8123f3b

Also, ipamclient.go had a nil pointer dereference on non-200 results code responses.

$ go test github.com/Azure/azure-container-networking/cns/ipamclient
2018/06/08 04:21:25 [Listener] Started listening on localhost:42424.
2018/06/08 04:21:25 [Azure CNS] GetAddressSpace Request
2018/06/08 04:21:25 [Azure CNS] GetAddressSpace Request
2018/06/08 04:21:25 [Azure CNS] GetPoolID Request
2018/06/08 04:21:25 [Azure CNS] GetAddressSpace Request
2018/06/08 04:21:25 [Azure CNS] GetPoolID Request
2018/06/08 04:21:25 [Azure CNS] ReserveIpAddress
2018/06/08 04:21:25 [Azure CNS] ReserveIpAddress
2018/06/08 04:21:25 [Azure CNS] GetAddressSpace Request
2018/06/08 04:21:25 [Azure CNS] GetPoolID Request
2018/06/08 04:21:25 [Azure CNS] ReserveIpAddress
2018/06/08 04:21:25 [Azure CNS] ReleaseIpAddress
--- FAIL: TestReleaseIP (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x68389c]

goroutine 19 [running]:
testing.tRunner.func1(0xc42017a0d0)
        /usr/local/go/src/testing/testing.go:622 +0x29d
panic(0x6d0d60, 0x890f80)
        /usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/Azure/azure-container-networking/cns/ipamclient.(*IpamClient).ReleaseIPAddress(0xc420112030, 0xc420112b20, 0xb, 0x7293ad, 0x3, 0x0, 0x0)
        /go/src/github.com/Azure/azure-container-networking/cns/ipamclient/ipamclient.go:210 +0x6bc
github.com/Azure/azure-container-networking/cns/ipamclient.TestReleaseIP(0xc42017a0d0)
        /go/src/github.com/Azure/azure-container-networking/cns/ipamclient/ipamclient_test.go:195 +0x3d1
testing.tRunner(0xc42017a0d0, 0x73c4d0)
        /usr/local/go/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:697 +0x2ca
FAIL    github.com/Azure/azure-container-networking/cns/ipamclient      0.011s

This is addressed with the second commit of this PR c085007

So now the tests pass:

$ go test github.com/Azure/azure-container-networking/cns/ipamclient
ok      github.com/Azure/azure-container-networking/cns/ipamclient      0.010s

Special notes for your reviewer:

🐬

Release note:

Fix nil pointer dereference on non-200 result code responses for ipamclient ReleaseIPAddress

andrewhsu added 2 commits June 8, 2018 04:08
Unable to compile. Variables like getAddressSpacesPath were not declared.

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
@msftclas
Copy link

msftclas commented Jun 8, 2018

CLA assistant check
All CLA requirements met.

@andrewhsu
Copy link
Contributor Author

cc @abhi

Copy link
Member

@tamilmani1989 tamilmani1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR. It looks good. Approving it.

@tamilmani1989 tamilmani1989 merged commit 092b0da into Azure:master Jun 27, 2018
@andrewhsu andrewhsu deleted the ipamclient branch June 27, 2018 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants