Skip to content

Commit

Permalink
kamel stuck when a secret has an illegal name #356
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Jan 23, 2019
1 parent f7714fe commit 08b5904
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
11 changes: 7 additions & 4 deletions pkg/trait/deployment.go
Expand Up @@ -24,6 +24,7 @@ import (
"strings"

"github.com/apache/camel-k/pkg/util/envvar"
"github.com/rs/xid"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -418,7 +419,8 @@ func (t *deploymentTrait) getDeploymentFor(e *Environment) *appsv1.Deployment {
//

VisitConfigurations("configmap", e.Context, e.Integration, func(cmName string) {
refName := "integration-cm-" + strings.ToLower(cmName)
refName := xid.New().String()
fileName := "integration-cm-" + strings.ToLower(cmName)

vols = append(vols, corev1.Volume{
Name: refName,
Expand All @@ -433,7 +435,7 @@ func (t *deploymentTrait) getDeploymentFor(e *Environment) *appsv1.Deployment {

mnts = append(mnts, corev1.VolumeMount{
Name: refName,
MountPath: path.Join("/etc/camel/conf.d", refName),
MountPath: path.Join("/etc/camel/conf.d", fileName),
})
})

Expand All @@ -442,7 +444,8 @@ func (t *deploymentTrait) getDeploymentFor(e *Environment) *appsv1.Deployment {
//

VisitConfigurations("secret", e.Context, e.Integration, func(secretName string) {
refName := "integration-secret-" + strings.ToLower(secretName)
refName := xid.New().String()
fileName := "integration-secret-" + strings.ToLower(secretName)

vols = append(vols, corev1.Volume{
Name: refName,
Expand All @@ -455,7 +458,7 @@ func (t *deploymentTrait) getDeploymentFor(e *Environment) *appsv1.Deployment {

mnts = append(mnts, corev1.VolumeMount{
Name: refName,
MountPath: path.Join("/etc/camel/conf.d", refName),
MountPath: path.Join("/etc/camel/conf.d", fileName),
})
})

Expand Down
79 changes: 40 additions & 39 deletions test/build_manager_integration_test.go
Expand Up @@ -34,6 +34,22 @@ import (
"github.com/stretchr/testify/assert"
)

func handler(in chan builder.Result, out chan builder.Result) {
for {
select {
case res := <-in:
if res.Status == builder.StatusCompleted || res.Status == builder.StatusError {
out <- res
return
}
case <-time.After(5 * time.Minute):
fmt.Println("timeout 1")
close(out)
return
}
}
}

func TestBuildManagerBuild(t *testing.T) {
namespace := getTargetNamespace()
b := builder.New(testContext, testClient, namespace)
Expand All @@ -56,28 +72,20 @@ func TestBuildManagerBuild(t *testing.T) {
Steps: s2i.DefaultSteps,
}

c := make(chan builder.Result)
hc := make(chan builder.Result)
rc := make(chan builder.Result)

b.Submit(r, func(res builder.Result) {
c <- res
})

var result builder.Result

loop:
for {
select {
case res := <-c:
if res.Status == builder.StatusCompleted || res.Status == builder.StatusError {
result = res
break loop
}
case <-time.After(5 * time.Minute):
fmt.Println("timeout 1")
break loop
}
}
go func() {
handler(hc, rc)
}()
go func() {
b.Submit(r, func(res builder.Result) {
hc <- res
})
}()

result, ok := <-rc
assert.True(t, ok)
assert.NotEqual(t, builder.StatusError, result.Status)
assert.Equal(t, builder.StatusCompleted, result.Status)
assert.Regexp(t, ".*/.*/.*:.*", result.Image)
Expand All @@ -104,27 +112,20 @@ func TestBuildManagerFailedBuild(t *testing.T) {
Steps: s2i.DefaultSteps,
}

c := make(chan builder.Result)

b.Submit(r, func(res builder.Result) {
c <- res
})
hc := make(chan builder.Result)
rc := make(chan builder.Result)

var result builder.Result
loop:
for {
select {
case res := <-c:
if res.Status == builder.StatusCompleted || res.Status == builder.StatusError {
result = res
break loop
}
case <-time.After(5 * time.Minute):
fmt.Println("timeout 1")
break loop
}
}
go func() {
handler(hc, rc)
}()
go func() {
b.Submit(r, func(res builder.Result) {
hc <- res
})
}()

result, ok := <-rc
assert.True(t, ok)
assert.Equal(t, builder.StatusError, result.Status)
assert.NotEqual(t, builder.StatusCompleted, result.Status)
}

0 comments on commit 08b5904

Please sign in to comment.