Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
remove rest of channel code that block pod build process
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rad committed Feb 10, 2016
1 parent 752f740 commit 0f159d2
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 61 deletions.
7 changes: 4 additions & 3 deletions builder/aci-clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (

func (aci *Aci) Clean() {
logs.WithF(aci.fields).Debug("Cleaning")
checkVersion := make(chan bool, 1)
go aci.checkLatestVersions(&checkVersion)

aci.checkCompatibilityVersions()
aci.checkLatestVersions()

if err := os.RemoveAll(aci.target + "/"); err != nil {
panic("Cannot clean " + aci.manifest.NameAndVersion.String() + err.Error())
}
<-checkVersion
}
2 changes: 1 addition & 1 deletion builder/aci-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (cnt *Aci) prepareTestAci() (*Aci, error) {
Dependencies: []spec.ACFullname{BATS_ACI, cnt.manifest.NameAndVersion},
},
NameAndVersion: *fullname,
}, nil, nil)
})
testAci.FullyResolveDep = false // this is required to run local tests without discovery
testAci.target = cnt.target + PATH_TESTS + PATH_TARGET // this is required when target is deported
testAci.rootfs = testAci.target + PATH_ROOTFS
Expand Down
18 changes: 6 additions & 12 deletions builder/aci.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ type Aci struct {
FullyResolveDep bool
}

func NewAciWithManifest(path string, args BuildArgs, manifest spec.AciManifest, latestChecked *chan bool, compatChecked *chan bool) (*Aci, error) {
func NewAciWithManifest(path string, args BuildArgs, manifest spec.AciManifest) (*Aci, error) {
if manifest.NameAndVersion == "" {
logs.WithField("path", path).Fatal("name is mandatory in manifest")
}
Expand Down Expand Up @@ -179,8 +179,8 @@ func NewAciWithManifest(path string, args BuildArgs, manifest spec.AciManifest,
FullyResolveDep: true,
}

aci.checkCompatibilityVersions(compatChecked)
aci.checkLatestVersions(latestChecked)
aci.checkCompatibilityVersions()
aci.checkLatestVersions()
return aci, nil
}

Expand All @@ -189,7 +189,7 @@ func NewAci(path string, args BuildArgs) (*Aci, error) {
if err != nil {
return nil, errs.WithEF(err, data.WithField("path", path+PATH_CNT_MANIFEST), "Cannot read manifest")
}
return NewAciWithManifest(path, args, *manifest, nil, nil)
return NewAciWithManifest(path, args, *manifest)
}

//////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -222,7 +222,7 @@ func (aci *Aci) tarAci(zip bool) {
os.Chdir(dir)
}

func (aci *Aci) checkCompatibilityVersions(compatChecked *chan bool) {
func (aci *Aci) checkCompatibilityVersions() {
froms, err := aci.manifest.GetFroms()
if err != nil {
logs.WithEF(err, aci.fields).Fatal("Invalid from")
Expand Down Expand Up @@ -285,9 +285,6 @@ func (aci *Aci) checkCompatibilityVersions(compatChecked *chan bool) {
Error("dependency aci was not build with a compatible version of cnt")
}
}
if compatChecked != nil {
*compatChecked <- true
}
}

func loadManifest(content string) schema.ImageManifest {
Expand All @@ -299,7 +296,7 @@ func loadManifest(content string) schema.ImageManifest {
return im
}

func (aci *Aci) checkLatestVersions(latestChecked *chan bool) {
func (aci *Aci) checkLatestVersions() {
froms, err := aci.manifest.GetFroms()
if err != nil {
logs.WithEF(err, aci.fields).Fatal("Invalid from")
Expand All @@ -324,7 +321,4 @@ func (aci *Aci) checkLatestVersions(latestChecked *chan bool) {
logs.WithF(aci.fields.WithField("version", dep.Name()+":"+version)).Warn("Newer 'dependency' version")
}
}
if latestChecked != nil {
*latestChecked <- true
}
}
2 changes: 1 addition & 1 deletion builder/pod-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (p *Pod) buildAci(e spec.RuntimeApp) *Aci {
logs.WithEF(err, p.fields).WithField("path", path).Fatal("Cannot created pod's aci directory")
}
}
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), nil, nil)
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e))
if err != nil {
logs.WithEF(err, p.fields).WithField("aci", path).Fatal("Failed to prepare aci")
}
Expand Down
12 changes: 1 addition & 11 deletions builder/pod-clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,13 @@ func (p *Pod) Clean() {
panic("Cannot clean" + p.manifest.Name.String() + err.Error())
}

checkVersion := make(chan bool, 1)
checkCompat := make(chan bool, 1)

for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion, &checkCompat)
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e))
if err != nil {
logs.WithEF(err, p.fields).WithField("name", e.Name).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Clean()
}

for range p.manifest.Pod.Apps {
<-checkVersion
}
for range p.manifest.Pod.Apps {
<-checkCompat
}

}
12 changes: 1 addition & 11 deletions builder/pod-install.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,13 @@ func (p *Pod) Install() {

p.Build()

checkVersion := make(chan bool, 1)
checkCompat := make(chan bool, 1)

for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion, &checkCompat)
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e))
if err != nil {
logs.WithEF(err, p.fields.WithField("name", e.Name)).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Install()
}

for range p.manifest.Pod.Apps {
<-checkVersion
}
for range p.manifest.Pod.Apps {
<-checkCompat
}

}
12 changes: 1 addition & 11 deletions builder/pod-push.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,15 @@ func (p *Pod) Push() {

p.Build()

checkVersion := make(chan bool, 1)
checkCompat := make(chan bool, 1)

for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion, &checkCompat)
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e))
if err != nil {
logs.WithEF(err, p.fields.WithField("name", e.Name)).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Push()
}

for range p.manifest.Pod.Apps {
<-checkVersion
}
for range p.manifest.Pod.Apps {
<-checkCompat
}

if err := utils.ExecCmd("curl", "-i",
"-F", "r=releases",
"-F", "hasPom=false",
Expand Down
12 changes: 1 addition & 11 deletions builder/pod-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@ import "github.com/n0rad/go-erlog/logs"
func (p *Pod) Test() {
logs.WithF(p.fields).Info("Testing")

checkVersion := make(chan bool, 1)
checkCompat := make(chan bool, 1)

for _, e := range p.manifest.Pod.Apps {
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e), &checkVersion, &checkCompat)
aci, err := NewAciWithManifest(p.path+"/"+e.Name, p.args, p.toAciManifest(e))
if err != nil {
logs.WithEF(err, p.fields).WithField("name", e.Name).Fatal("Cannot prepare aci")
}
aci.podName = &p.manifest.Name
aci.Test()
}

for range p.manifest.Pod.Apps {
<-checkVersion
}
for range p.manifest.Pod.Apps {
<-checkCompat
}

}

0 comments on commit 0f159d2

Please sign in to comment.