Skip to content

Commit

Permalink
thread security group logging through to garden
Browse files Browse the repository at this point in the history
[#86733868]

Signed-off-by: Kris Hicks <krishicks@gmail.com>
  • Loading branch information
vito authored and krishicks committed Jan 23, 2015
1 parent 4ccdfef commit 2ec7cd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions depot/gardenstore/exchanger.go
Expand Up @@ -354,23 +354,23 @@ func (exchanger exchanger) CreateInGarden(logger lager.Logger, gardenClient Gard
var portRange string
if securityRule.PortRange != nil {
portRange = fmt.Sprintf("%d:%d", securityRule.PortRange.Start, securityRule.PortRange.End)
err := gardenContainer.NetOut(dest, 0, portRange, protocol, icmpType, icmpCode, false)
err := gardenContainer.NetOut(dest, 0, portRange, protocol, icmpType, icmpCode, securityRule.Log)
if err != nil {
logger.Error("failed-to-net-out", err, lager.Data{"security_group_rule": securityRule})
exchanger.destroyContainer(logger, gardenClient, gardenContainer)
return executor.Container{}, err
}
} else if securityRule.Ports != nil {
for _, port := range securityRule.Ports {
err := gardenContainer.NetOut(dest, uint32(port), "", protocol, icmpType, icmpCode, false)
err := gardenContainer.NetOut(dest, uint32(port), "", protocol, icmpType, icmpCode, securityRule.Log)
if err != nil {
logger.Error("failed-to-net-out", err, lager.Data{"security_group_rule": securityRule})
exchanger.destroyContainer(logger, gardenClient, gardenContainer)
return executor.Container{}, err
}
}
} else {
err := gardenContainer.NetOut(dest, 0, "", protocol, icmpType, icmpCode, false)
err := gardenContainer.NetOut(dest, 0, "", protocol, icmpType, icmpCode, securityRule.Log)
if err != nil {
logger.Error("failed-to-net-out", err, lager.Data{"security_group_rule": securityRule})
exchanger.destroyContainer(logger, gardenClient, gardenContainer)
Expand Down
12 changes: 7 additions & 5 deletions depot/gardenstore/garden_store_test.go
Expand Up @@ -1051,6 +1051,7 @@ var _ = Describe("GardenContainerStore", func() {
Protocol: "tcp",
Destinations: []string{"1.2.3.4-2.3.4.5"},
Ports: []uint16{80, 443},
Log: true,
},
{
Protocol: "icmp",
Expand All @@ -1060,17 +1061,18 @@ var _ = Describe("GardenContainerStore", func() {
{
Protocol: "all",
Destinations: []string{"9.8.7.6", "8.7.6.5"},
Log: true,
},
}

executorContainer.EgressRules = rules
})

Context("when setting egress rules", func() {

It("creates it with the egress rules", func() {
Ω(createErr).ShouldNot(HaveOccurred())
})

It("updates egress rules on returned container", func() {
Ω(fakeGardenContainer.NetOutCallCount()).Should(Equal(6))

Expand All @@ -1090,7 +1092,7 @@ var _ = Describe("GardenContainerStore", func() {
Ω(icmpCode).Should(Equal(int32(-1)))
Ω(protocol).Should(Equal(garden.ProtocolTCP))
Ω(portRange).Should(BeEmpty())
Ω(netOutLog).Should(BeFalse())
Ω(netOutLog).Should(BeTrue())

network, port, portRange, protocol, icmpType, icmpCode, netOutLog = fakeGardenContainer.NetOutArgsForCall(2)
Ω(network).Should(Equal(rules[1].Destinations[0]))
Expand All @@ -1099,7 +1101,7 @@ var _ = Describe("GardenContainerStore", func() {
Ω(icmpCode).Should(Equal(int32(-1)))
Ω(protocol).Should(Equal(garden.ProtocolTCP))
Ω(portRange).Should(BeEmpty())
Ω(netOutLog).Should(BeFalse())
Ω(netOutLog).Should(BeTrue())

network, port, portRange, protocol, icmpType, icmpCode, netOutLog = fakeGardenContainer.NetOutArgsForCall(3)
Ω(network).Should(Equal(rules[2].Destinations[0]))
Expand All @@ -1117,7 +1119,7 @@ var _ = Describe("GardenContainerStore", func() {
Ω(icmpCode).Should(Equal(int32(-1)))
Ω(protocol).Should(Equal(garden.ProtocolAll))
Ω(portRange).Should(BeEmpty())
Ω(netOutLog).Should(BeFalse())
Ω(netOutLog).Should(BeTrue())

network, port, portRange, protocol, icmpType, icmpCode, netOutLog = fakeGardenContainer.NetOutArgsForCall(5)
Ω(network).Should(Equal(rules[3].Destinations[1]))
Expand All @@ -1126,7 +1128,7 @@ var _ = Describe("GardenContainerStore", func() {
Ω(icmpCode).Should(Equal(int32(-1)))
Ω(protocol).Should(Equal(garden.ProtocolAll))
Ω(portRange).Should(BeEmpty())
Ω(netOutLog).Should(BeFalse())
Ω(netOutLog).Should(BeTrue())
})
})

Expand Down

0 comments on commit 2ec7cd8

Please sign in to comment.