Skip to content

Commit

Permalink
Merge pull request moby#4 from tutumcloud/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
bernardopericacho committed May 3, 2014
2 parents f55f4ec + b907699 commit 3a9d782
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 65 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.9.1-tutum6
0.9.1-tutum7
10 changes: 10 additions & 0 deletions archive/archive.go
Expand Up @@ -152,6 +152,16 @@ func addTarFile(path, name string, tw *tar.Writer) error {
return err
}

if hdr.Uid >= 100000 {
utils.Debugf("Translating Uid down by 100000: %i\n", hdr.Uid)
hdr.Uid = hdr.Uid - 100000
}

if hdr.Gid >= 100000 {
utils.Debugf("Translating Gid down by 100000: %i\n", hdr.Gid)
hdr.Gid = hdr.Gid - 100000
}

if fi.IsDir() && !strings.HasSuffix(name, "/") {
name = name + "/"
}
Expand Down
9 changes: 0 additions & 9 deletions container.go
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/dotcloud/docker/engine"
"github.com/dotcloud/docker/execdriver"
"github.com/dotcloud/docker/graphdriver"
"github.com/dotcloud/docker/pkg/iptables"
"github.com/dotcloud/docker/pkg/mount"
"github.com/dotcloud/docker/links"
"github.com/dotcloud/docker/nat"
Expand Down Expand Up @@ -816,19 +815,11 @@ func (container *Container) allocateNetwork() error {
container.NetworkSettings.IPPrefixLen = env.GetInt("IPPrefixLen")
container.NetworkSettings.Gateway = env.Get("Gateway")

if !iptables.ExistsNetworkMetricRule(container.NetworkSettings.IPAddress) {
iptables.CreateNetworkMetricRules(container.NetworkSettings.IPAddress)
}

return nil
}

func (container *Container) releaseNetwork() {

if iptables.ExistsNetworkMetricRule(container.NetworkSettings.IPAddress) {
iptables.DeleteNetworkMetricRules(container.NetworkSettings.IPAddress)
}

if container.Config.NetworkDisabled {
return
}
Expand Down
56 changes: 2 additions & 54 deletions pkg/iptables/iptables.go
Expand Up @@ -84,15 +84,13 @@ func (c *Chain) Forward(action Action, ip net.IP, port int, proto, dest_addr str
"-o", c.Bridge,
"-p", proto,
"-d", dest_addr,
"--dport", strconv.Itoa(dest_port),
"-j", "ACCEPT")) || action != Add ){
"--dport", strconv.Itoa(dest_port))) || action != Add ){
if output, err := Raw(string(fAction), "FORWARD",
"!", "-i", c.Bridge,
"-o", c.Bridge,
"-p", proto,
"-d", dest_addr,
"--dport", strconv.Itoa(dest_port),
"-j", "ACCEPT"); err != nil {
"--dport", strconv.Itoa(dest_port)); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Error iptables forward: %s", output)
Expand Down Expand Up @@ -142,56 +140,6 @@ func (c *Chain) Remove() error {
return nil
}

func CreateNetworkMetricRules(ip string) error {

if ExistsNetworkMetricRule(ip) == true {
return fmt.Errorf("Error when creating metrics rules for %s", ip)
}

if input, err := Raw("-I", "FORWARD", "1", "-o", "docker0", "-d", ip, "!", "-s", InternalNetwork); err != nil {
return err
} else if len(input) != 0 {
return fmt.Errorf("Error when creating metrics input rule: %s", input)
}

if output, err := Raw("-I", "FORWARD", "1", "-i", "docker0", "!", "-o", "docker0", "-s", ip, "!", "-d", InternalNetwork); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Error when creating metrics output rule: %s", output)
}

return nil
}

func DeleteNetworkMetricRules(ip string) error {

if ExistsNetworkMetricRule(ip) == false {
return fmt.Errorf("Error when deleting metrics rules for %s", ip)
}

if input, err := Raw("-D", "FORWARD", "-o", "docker0", "-d", ip, "!", "-s", InternalNetwork); err != nil {
return err
} else if len(input) != 0 {
return fmt.Errorf("Error when deleting metrics input rule: %s", input)
}

if output, err := Raw("-D", "FORWARD", "-i", "docker0", "!", "-o", "docker0", "-s", ip, "!", "-d", InternalNetwork); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Error when deleting metrics output rule: %s", output)
}

return nil
}

func ExistsNetworkMetricRule(ip string) bool {

input := Exists("FORWARD", "-o", "docker0", "-d", ip, "!", "-s", InternalNetwork)
output := Exists("FORWARD", "-i", "docker0", "!", "-o", "docker0", "-s", ip, "!", "-d", InternalNetwork)
fmt.Println("EXISTS:", ((input == output) && (input == true)))
return ((input == output) && (input == true))
}

// Check if an existing rule exists
func Exists(args ...string) bool {
if _, err := Raw(append([]string{"-C"}, args...)...); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion server.go
Expand Up @@ -2333,7 +2333,7 @@ func (srv *Server) HTTPRequestFactory(metaHeaders map[string][]string) *utils.HT
defer srv.Unlock()
v := dockerVersion()
httpVersion := make([]utils.VersionInfo, 0, 4)
httpVersion = append(httpVersion, &simpleVersionInfo{"docker", strings.Split(v.Get("Version"), "-")[0]})
httpVersion = append(httpVersion, &simpleVersionInfo{"docker", v.Get("Version")})
httpVersion = append(httpVersion, &simpleVersionInfo{"go", v.Get("GoVersion")})
httpVersion = append(httpVersion, &simpleVersionInfo{"git-commit", v.Get("GitCommit")})
httpVersion = append(httpVersion, &simpleVersionInfo{"kernel", v.Get("KernelVersion")})
Expand Down

0 comments on commit 3a9d782

Please sign in to comment.