You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/04/11 15:30:56 UTC
[camel-k] branch main updated (df638f5ec -> 0aadb7e7f)
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
from df638f5ec chore (docs): add a note about security requirements on macOS
new 9083b9c21 fix(controller): camelcatalog default timeout
new 0aadb7e7f chore(api): make catalog timeout a Duration
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel.apache.org_integrationplatforms.yaml | 8 ++++++
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 7 +++++
.../catalog_builder_test.go | 31 ++++++++++++++++++++++
e2e/support/test_support.go | 10 +++++++
helm/camel-k/crds/crd-integration-platform.yaml | 8 ++++++
pkg/apis/camel/v1/integrationplatform_types.go | 2 ++
.../camel/v1/integrationplatform_types_support.go | 10 ++++++-
pkg/apis/camel/v1/zz_generated.deepcopy.go | 5 ++++
.../camel/v1/integrationplatformbuildspec.go | 27 ++++++++++++-------
pkg/controller/catalog/initialize.go | 26 +++++++++++++++---
pkg/platform/defaults.go | 28 ++++++++++++++++---
11 files changed, 144 insertions(+), 18 deletions(-)
[camel-k] 02/02: chore(api): make catalog timeout a Duration
Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0aadb7e7f562c822d6ae8854c4f58eaa9da3423c
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Tue Apr 11 10:34:07 2023 +0200
chore(api): make catalog timeout a Duration
---
.../camel.apache.org_integrationplatforms.yaml | 4 +--
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 2 +-
.../catalog_builder_test.go | 14 ++++++++--
e2e/support/test_support.go | 6 ++--
helm/camel-k/crds/crd-integration-platform.yaml | 4 +--
pkg/apis/camel/v1/integrationplatform_types.go | 2 +-
.../camel/v1/integrationplatform_types_support.go | 10 ++++++-
pkg/apis/camel/v1/zz_generated.deepcopy.go | 5 ++++
.../camel/v1/integrationplatformbuildspec.go | 4 +--
pkg/controller/catalog/initialize.go | 12 +++++---
pkg/platform/defaults.go | 32 ++++++++++++++++------
11 files changed, 68 insertions(+), 27 deletions(-)
diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
index ff540749e..5589fbc0f 100644
--- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml
+++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
@@ -83,7 +83,7 @@ spec:
buildCatalogToolTimeout:
description: the timeout (in seconds) to use when creating the
build tools container image
- type: integer
+ type: string
buildStrategy:
description: the strategy to adopt for building an Integration
base image
@@ -1633,7 +1633,7 @@ spec:
buildCatalogToolTimeout:
description: the timeout (in seconds) to use when creating the
build tools container image
- type: integer
+ type: string
buildStrategy:
description: the strategy to adopt for building an Integration
base image
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 04c256594..5a093cd9a 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -1878,7 +1878,7 @@ It can be useful if you want to provide some custom base image with further util
the image registry used to push/pull Integration images
|`buildCatalogToolTimeout` +
-int
+*https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#duration-v1-meta[Kubernetes meta/v1.Duration]*
|
diff --git a/e2e/commonwithcustominstall/catalog_builder_test.go b/e2e/commonwithcustominstall/catalog_builder_test.go
index 93abed2f6..9184c1ff7 100644
--- a/e2e/commonwithcustominstall/catalog_builder_test.go
+++ b/e2e/commonwithcustominstall/catalog_builder_test.go
@@ -26,9 +26,11 @@ import (
"fmt"
"strings"
"testing"
+ "time"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
. "github.com/apache/camel-k/v2/e2e/support"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -153,11 +155,17 @@ func TestCamelCatalogBuilder(t *testing.T) {
Eventually(Platform(ns)).ShouldNot(BeNil())
pl := Platform(ns)()
- // set a very short timeout to simulate it
- pl.Spec.Build.BuildCatalogToolTimeout = 1
+ // set a very short timeout to simulate the timeout
+ pl.Spec.Build.BuildCatalogToolTimeout = &metav1.Duration{
+ Duration: 1 * time.Second,
+ }
TestClient().Update(TestContext, pl)
Eventually(Platform(ns)).ShouldNot(BeNil())
- Eventually(PlatformBuildCatalogToolTimeout(ns)).Should(Equal(1))
+ Eventually(PlatformBuildCatalogToolTimeout(ns)).Should(Equal(
+ &metav1.Duration{
+ Duration: 1 * time.Second,
+ },
+ ))
Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index db42596ac..bc058c843 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1779,11 +1779,11 @@ func PlatformProfile(ns string) func() v1.TraitProfile {
}
}
-func PlatformBuildCatalogToolTimeout(ns string) func() int {
- return func() int {
+func PlatformBuildCatalogToolTimeout(ns string) func() *metav1.Duration {
+ return func() *metav1.Duration {
p := Platform(ns)()
if p == nil {
- return 0
+ return &metav1.Duration{}
}
return p.Status.Build.BuildCatalogToolTimeout
}
diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml
index ff540749e..5589fbc0f 100644
--- a/helm/camel-k/crds/crd-integration-platform.yaml
+++ b/helm/camel-k/crds/crd-integration-platform.yaml
@@ -83,7 +83,7 @@ spec:
buildCatalogToolTimeout:
description: the timeout (in seconds) to use when creating the
build tools container image
- type: integer
+ type: string
buildStrategy:
description: the strategy to adopt for building an Integration
base image
@@ -1633,7 +1633,7 @@ spec:
buildCatalogToolTimeout:
description: the timeout (in seconds) to use when creating the
build tools container image
- type: integer
+ type: string
buildStrategy:
description: the strategy to adopt for building an Integration
base image
diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go
index d8b0a3f58..f63163094 100644
--- a/pkg/apis/camel/v1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1/integrationplatform_types.go
@@ -121,7 +121,7 @@ type IntegrationPlatformBuildSpec struct {
// the image registry used to push/pull Integration images
Registry RegistrySpec `json:"registry,omitempty"`
// the timeout (in seconds) to use when creating the build tools container image
- BuildCatalogToolTimeout int `json:"buildCatalogToolTimeout,omitempty"`
+ BuildCatalogToolTimeout *metav1.Duration `json:"buildCatalogToolTimeout,omitempty"`
// how much time to wait before time out the build process
Timeout *metav1.Duration `json:"timeout,omitempty"`
// Maven configuration used to build the Camel/Camel-Quarkus applications
diff --git a/pkg/apis/camel/v1/integrationplatform_types_support.go b/pkg/apis/camel/v1/integrationplatform_types_support.go
index 0d9b0a2e4..599f40ef7 100644
--- a/pkg/apis/camel/v1/integrationplatform_types_support.go
+++ b/pkg/apis/camel/v1/integrationplatform_types_support.go
@@ -186,7 +186,7 @@ func (b IntegrationPlatformBuildSpec) IsOptionEnabled(option string) bool {
return false
}
-// Add a publish strategy option
+// AddOption add a publish strategy option
func (b *IntegrationPlatformBuildSpec) AddOption(option string, value string) {
options := b.PublishStrategyOptions
if options == nil {
@@ -204,6 +204,14 @@ func (b IntegrationPlatformBuildSpec) GetTimeout() metav1.Duration {
return *b.Timeout
}
+// GetBuildCatalogToolTimeout returns the specified duration or a default one
+func (b IntegrationPlatformBuildSpec) GetBuildCatalogToolTimeout() metav1.Duration {
+ if b.BuildCatalogToolTimeout == nil {
+ return metav1.Duration{}
+ }
+ return *b.BuildCatalogToolTimeout
+}
+
var _ ResourceCondition = IntegrationPlatformCondition{}
// GetConditions --
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 1ace84bea..f7b543f17 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -991,6 +991,11 @@ func (in *IntegrationPlatform) DeepCopyObject() runtime.Object {
func (in *IntegrationPlatformBuildSpec) DeepCopyInto(out *IntegrationPlatformBuildSpec) {
*out = *in
out.Registry = in.Registry
+ if in.BuildCatalogToolTimeout != nil {
+ in, out := &in.BuildCatalogToolTimeout, &out.BuildCatalogToolTimeout
+ *out = new(metav1.Duration)
+ **out = **in
+ }
if in.Timeout != nil {
in, out := &in.Timeout, &out.Timeout
*out = new(metav1.Duration)
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go b/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go
index d2806ae60..d884675af 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go
@@ -33,7 +33,7 @@ type IntegrationPlatformBuildSpecApplyConfiguration struct {
RuntimeProvider *v1.RuntimeProvider `json:"runtimeProvider,omitempty"`
BaseImage *string `json:"baseImage,omitempty"`
Registry *RegistrySpecApplyConfiguration `json:"registry,omitempty"`
- BuildCatalogToolTimeout *int `json:"buildCatalogToolTimeout,omitempty"`
+ BuildCatalogToolTimeout *metav1.Duration `json:"buildCatalogToolTimeout,omitempty"`
Timeout *metav1.Duration `json:"timeout,omitempty"`
Maven *MavenSpecApplyConfiguration `json:"maven,omitempty"`
PublishStrategyOptions map[string]string `json:"PublishStrategyOptions,omitempty"`
@@ -96,7 +96,7 @@ func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithRegistry(value *Reg
// WithBuildCatalogToolTimeout sets the BuildCatalogToolTimeout field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the BuildCatalogToolTimeout field is set to the value of the last call.
-func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithBuildCatalogToolTimeout(value int) *IntegrationPlatformBuildSpecApplyConfiguration {
+func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithBuildCatalogToolTimeout(value metav1.Duration) *IntegrationPlatformBuildSpecApplyConfiguration {
b.BuildCatalogToolTimeout = &value
return b
}
diff --git a/pkg/controller/catalog/initialize.go b/pkg/controller/catalog/initialize.go
index 28fe28b73..98d4ddfbe 100644
--- a/pkg/controller/catalog/initialize.go
+++ b/pkg/controller/catalog/initialize.go
@@ -72,14 +72,14 @@ func (action *initializeAction) Handle(ctx context.Context, catalog *v1.CamelCat
return catalog, err
}
- return initialize(options, platform.Status.Build.Registry.Address, platform.Status.Build.BuildCatalogToolTimeout, catalog)
+ return initialize(options, platform, catalog)
}
-func initialize(options spectrum.Options, registryAddress string, buildCatalogTimeout int, catalog *v1.CamelCatalog) (*v1.CamelCatalog, error) {
+func initialize(options spectrum.Options, ip *v1.IntegrationPlatform, catalog *v1.CamelCatalog) (*v1.CamelCatalog, error) {
target := catalog.DeepCopy()
imageName := fmt.Sprintf(
"%s/camel-k-runtime-%s-builder:%s",
- registryAddress,
+ ip.Status.Build.Registry.Address,
catalog.Spec.Runtime.Provider,
strings.ToLower(catalog.Spec.Runtime.Version),
)
@@ -116,7 +116,7 @@ func initialize(options spectrum.Options, registryAddress string, buildCatalogTi
options.Base = catalog.Spec.GetQuarkusToolingImage()
options.Target = imageName
- err := buildRuntimeBuilderWithTimeout(options, time.Duration(buildCatalogTimeout)*time.Second)
+ err := buildRuntimeBuilderWithTimeout(options, ip.Status.Build.GetBuildCatalogToolTimeout().Duration)
if err != nil {
target.Status.Phase = v1.CamelCatalogPhaseError
@@ -161,6 +161,10 @@ func imageSnapshot(options spectrum.Options) bool {
}
func buildRuntimeBuilderWithTimeout(options spectrum.Options, timeout time.Duration) error {
+ // Backward compatibility with IP which had not a timeout field
+ if timeout == 0 {
+ return buildRuntimeBuilderImage(options)
+ }
result := make(chan error, 1)
go func() {
result <- buildRuntimeBuilderImage(options)
diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go
index 981863c72..fa24f4fa9 100644
--- a/pkg/platform/defaults.go
+++ b/pkg/platform/defaults.go
@@ -209,7 +209,12 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error {
p.Status.Build.PublishStrategyOptions[builder.KanikoPVCName] = p.Name
}
- if p.Status.Build.GetTimeout().Duration != 0 {
+ // Build timeout
+ if p.Status.Build.GetTimeout().Duration == 0 {
+ p.Status.Build.Timeout = &metav1.Duration{
+ Duration: 5 * time.Minute,
+ }
+ } else {
d := p.Status.Build.GetTimeout().Duration.Truncate(time.Second)
if verbose && p.Status.Build.GetTimeout().Duration != d {
@@ -221,15 +226,26 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error {
Duration: d,
}
}
- if p.Status.Build.GetTimeout().Duration == 0 {
- p.Status.Build.Timeout = &metav1.Duration{
- Duration: 5 * time.Minute,
+
+ // Catalog tools build timeout
+ if p.Status.Build.GetBuildCatalogToolTimeout().Duration == 0 {
+ log.Debugf("Integration Platform [%s]: setting default build camel catalog tool timeout (1 minute)", p.Namespace)
+ p.Status.Build.BuildCatalogToolTimeout = &metav1.Duration{
+ Duration: 1 * time.Minute,
+ }
+ } else {
+ d := p.Status.Build.GetBuildCatalogToolTimeout().Duration.Truncate(time.Second)
+
+ if verbose && p.Status.Build.GetBuildCatalogToolTimeout().Duration != d {
+ log.Log.Infof("Build catalog tools timeout minimum unit is sec (configured: %s, truncated: %s)", p.Status.Build.GetBuildCatalogToolTimeout().Duration, d)
+ }
+
+ log.Debugf("Integration Platform [%s]: setting build catalog tools timeout", p.Namespace)
+ p.Status.Build.BuildCatalogToolTimeout = &metav1.Duration{
+ Duration: d,
}
}
- if p.Status.Build.BuildCatalogToolTimeout == 0 {
- log.Debugf("Integration Platform [%s]: setting build camel catalog tool timeout", p.Namespace)
- p.Status.Build.BuildCatalogToolTimeout = 60
- }
+
_, cacheEnabled := p.Status.Build.PublishStrategyOptions[builder.KanikoBuildCacheEnabled]
if p.Status.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyKaniko && !cacheEnabled {
// Default to disabling Kaniko cache warmer
[camel-k] 01/02: fix(controller): camelcatalog default timeout
Posted by pc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 9083b9c21e208205048d8f3bfa6d76834d874cc7
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Apr 10 12:10:29 2023 +0200
fix(controller): camelcatalog default timeout
Closes #4226
---
.../camel.apache.org_integrationplatforms.yaml | 8 +++++++
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 7 ++++++
.../catalog_builder_test.go | 23 ++++++++++++++++++
e2e/support/test_support.go | 10 ++++++++
helm/camel-k/crds/crd-integration-platform.yaml | 8 +++++++
pkg/apis/camel/v1/integrationplatform_types.go | 2 ++
.../camel/v1/integrationplatformbuildspec.go | 27 ++++++++++++++--------
pkg/controller/catalog/initialize.go | 20 +++++++++++++---
pkg/platform/defaults.go | 4 ++++
9 files changed, 97 insertions(+), 12 deletions(-)
diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
index 51672f39f..ff540749e 100644
--- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml
+++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
@@ -80,6 +80,10 @@ spec:
images. It can be useful if you want to provide some custom
base image with further utility softwares
type: string
+ buildCatalogToolTimeout:
+ description: the timeout (in seconds) to use when creating the
+ build tools container image
+ type: integer
buildStrategy:
description: the strategy to adopt for building an Integration
base image
@@ -1626,6 +1630,10 @@ spec:
images. It can be useful if you want to provide some custom
base image with further utility softwares
type: string
+ buildCatalogToolTimeout:
+ description: the timeout (in seconds) to use when creating the
+ build tools container image
+ type: integer
buildStrategy:
description: the strategy to adopt for building an Integration
base image
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index a2b565eef..04c256594 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -1877,6 +1877,13 @@ It can be useful if you want to provide some custom base image with further util
the image registry used to push/pull Integration images
+|`buildCatalogToolTimeout` +
+int
+|
+
+
+the timeout (in seconds) to use when creating the build tools container image
+
|`timeout` +
*https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#duration-v1-meta[Kubernetes meta/v1.Duration]*
|
diff --git a/e2e/commonwithcustominstall/catalog_builder_test.go b/e2e/commonwithcustominstall/catalog_builder_test.go
index ee124db65..93abed2f6 100644
--- a/e2e/commonwithcustominstall/catalog_builder_test.go
+++ b/e2e/commonwithcustominstall/catalog_builder_test.go
@@ -36,6 +36,7 @@ import (
)
func TestCamelCatalogBuilder(t *testing.T) {
+
WithNewTestNamespace(t, func(ns string) {
operatorID := fmt.Sprintf("camel-k-%s", ns)
Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
@@ -144,4 +145,26 @@ func TestCamelCatalogBuilder(t *testing.T) {
Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
})
+
+ WithNewTestNamespace(t, func(ns string) {
+ operatorID := fmt.Sprintf("camel-k-%s", ns)
+ Expect(KamelInstallWithID(operatorID, ns).Execute()).To(Succeed())
+ Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+ Eventually(Platform(ns)).ShouldNot(BeNil())
+
+ pl := Platform(ns)()
+ // set a very short timeout to simulate it
+ pl.Spec.Build.BuildCatalogToolTimeout = 1
+ TestClient().Update(TestContext, pl)
+ Eventually(Platform(ns)).ShouldNot(BeNil())
+ Eventually(PlatformBuildCatalogToolTimeout(ns)).Should(Equal(1))
+
+ Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
+ Should(Equal(corev1.ConditionTrue))
+ catalogName := fmt.Sprintf("camel-catalog-%s", strings.ToLower(defaults.DefaultRuntimeVersion))
+
+ Eventually(CamelCatalog(ns, catalogName)).ShouldNot(BeNil())
+ Eventually(CamelCatalogPhase(ns, catalogName)).Should(Equal(v1.CamelCatalogPhaseError))
+ Eventually(CamelCatalogCondition(ns, catalogName, v1.CamelCatalogConditionReady)().Message).Should(ContainSubstring("build timeout"))
+ })
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 877ca7f40..db42596ac 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1779,6 +1779,16 @@ func PlatformProfile(ns string) func() v1.TraitProfile {
}
}
+func PlatformBuildCatalogToolTimeout(ns string) func() int {
+ return func() int {
+ p := Platform(ns)()
+ if p == nil {
+ return 0
+ }
+ return p.Status.Build.BuildCatalogToolTimeout
+ }
+}
+
func AssignPlatformToOperator(ns, operator string) error {
pl := Platform(ns)()
if pl == nil {
diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml
index 51672f39f..ff540749e 100644
--- a/helm/camel-k/crds/crd-integration-platform.yaml
+++ b/helm/camel-k/crds/crd-integration-platform.yaml
@@ -80,6 +80,10 @@ spec:
images. It can be useful if you want to provide some custom
base image with further utility softwares
type: string
+ buildCatalogToolTimeout:
+ description: the timeout (in seconds) to use when creating the
+ build tools container image
+ type: integer
buildStrategy:
description: the strategy to adopt for building an Integration
base image
@@ -1626,6 +1630,10 @@ spec:
images. It can be useful if you want to provide some custom
base image with further utility softwares
type: string
+ buildCatalogToolTimeout:
+ description: the timeout (in seconds) to use when creating the
+ build tools container image
+ type: integer
buildStrategy:
description: the strategy to adopt for building an Integration
base image
diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go
index 0c378f9c7..d8b0a3f58 100644
--- a/pkg/apis/camel/v1/integrationplatform_types.go
+++ b/pkg/apis/camel/v1/integrationplatform_types.go
@@ -120,6 +120,8 @@ type IntegrationPlatformBuildSpec struct {
BaseImage string `json:"baseImage,omitempty"`
// the image registry used to push/pull Integration images
Registry RegistrySpec `json:"registry,omitempty"`
+ // the timeout (in seconds) to use when creating the build tools container image
+ BuildCatalogToolTimeout int `json:"buildCatalogToolTimeout,omitempty"`
// how much time to wait before time out the build process
Timeout *metav1.Duration `json:"timeout,omitempty"`
// Maven configuration used to build the Camel/Camel-Quarkus applications
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go b/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go
index e57151e07..d2806ae60 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go
@@ -27,15 +27,16 @@ import (
// IntegrationPlatformBuildSpecApplyConfiguration represents an declarative configuration of the IntegrationPlatformBuildSpec type for use
// with apply.
type IntegrationPlatformBuildSpecApplyConfiguration struct {
- BuildStrategy *v1.BuildStrategy `json:"buildStrategy,omitempty"`
- PublishStrategy *v1.IntegrationPlatformBuildPublishStrategy `json:"publishStrategy,omitempty"`
- RuntimeVersion *string `json:"runtimeVersion,omitempty"`
- RuntimeProvider *v1.RuntimeProvider `json:"runtimeProvider,omitempty"`
- BaseImage *string `json:"baseImage,omitempty"`
- Registry *RegistrySpecApplyConfiguration `json:"registry,omitempty"`
- Timeout *metav1.Duration `json:"timeout,omitempty"`
- Maven *MavenSpecApplyConfiguration `json:"maven,omitempty"`
- PublishStrategyOptions map[string]string `json:"PublishStrategyOptions,omitempty"`
+ BuildStrategy *v1.BuildStrategy `json:"buildStrategy,omitempty"`
+ PublishStrategy *v1.IntegrationPlatformBuildPublishStrategy `json:"publishStrategy,omitempty"`
+ RuntimeVersion *string `json:"runtimeVersion,omitempty"`
+ RuntimeProvider *v1.RuntimeProvider `json:"runtimeProvider,omitempty"`
+ BaseImage *string `json:"baseImage,omitempty"`
+ Registry *RegistrySpecApplyConfiguration `json:"registry,omitempty"`
+ BuildCatalogToolTimeout *int `json:"buildCatalogToolTimeout,omitempty"`
+ Timeout *metav1.Duration `json:"timeout,omitempty"`
+ Maven *MavenSpecApplyConfiguration `json:"maven,omitempty"`
+ PublishStrategyOptions map[string]string `json:"PublishStrategyOptions,omitempty"`
}
// IntegrationPlatformBuildSpecApplyConfiguration constructs an declarative configuration of the IntegrationPlatformBuildSpec type for use with
@@ -92,6 +93,14 @@ func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithRegistry(value *Reg
return b
}
+// WithBuildCatalogToolTimeout sets the BuildCatalogToolTimeout field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the BuildCatalogToolTimeout field is set to the value of the last call.
+func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithBuildCatalogToolTimeout(value int) *IntegrationPlatformBuildSpecApplyConfiguration {
+ b.BuildCatalogToolTimeout = &value
+ return b
+}
+
// WithTimeout sets the Timeout field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Timeout field is set to the value of the last call.
diff --git a/pkg/controller/catalog/initialize.go b/pkg/controller/catalog/initialize.go
index 11c4d7d33..28fe28b73 100644
--- a/pkg/controller/catalog/initialize.go
+++ b/pkg/controller/catalog/initialize.go
@@ -25,6 +25,7 @@ import (
"os"
"runtime"
"strings"
+ "time"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/builder"
@@ -71,10 +72,10 @@ func (action *initializeAction) Handle(ctx context.Context, catalog *v1.CamelCat
return catalog, err
}
- return initialize(options, platform.Spec.Build.Registry.Address, catalog)
+ return initialize(options, platform.Status.Build.Registry.Address, platform.Status.Build.BuildCatalogToolTimeout, catalog)
}
-func initialize(options spectrum.Options, registryAddress string, catalog *v1.CamelCatalog) (*v1.CamelCatalog, error) {
+func initialize(options spectrum.Options, registryAddress string, buildCatalogTimeout int, catalog *v1.CamelCatalog) (*v1.CamelCatalog, error) {
target := catalog.DeepCopy()
imageName := fmt.Sprintf(
"%s/camel-k-runtime-%s-builder:%s",
@@ -115,7 +116,7 @@ func initialize(options spectrum.Options, registryAddress string, catalog *v1.Ca
options.Base = catalog.Spec.GetQuarkusToolingImage()
options.Target = imageName
- err := buildRuntimeBuilderImage(options)
+ err := buildRuntimeBuilderWithTimeout(options, time.Duration(buildCatalogTimeout)*time.Second)
if err != nil {
target.Status.Phase = v1.CamelCatalogPhaseError
@@ -159,6 +160,19 @@ func imageSnapshot(options spectrum.Options) bool {
return strings.HasSuffix(options.Base, "snapshot")
}
+func buildRuntimeBuilderWithTimeout(options spectrum.Options, timeout time.Duration) error {
+ result := make(chan error, 1)
+ go func() {
+ result <- buildRuntimeBuilderImage(options)
+ }()
+ select {
+ case <-time.After(timeout):
+ return fmt.Errorf("build timeout: %s", timeout.String())
+ case result := <-result:
+ return result
+ }
+}
+
// This func will take care to dynamically build an image that will contain the tools required
// by the catalog build plus kamel binary and a maven wrapper required for the build.
func buildRuntimeBuilderImage(options spectrum.Options) error {
diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go
index d585eb4f6..981863c72 100644
--- a/pkg/platform/defaults.go
+++ b/pkg/platform/defaults.go
@@ -226,6 +226,10 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error {
Duration: 5 * time.Minute,
}
}
+ if p.Status.Build.BuildCatalogToolTimeout == 0 {
+ log.Debugf("Integration Platform [%s]: setting build camel catalog tool timeout", p.Namespace)
+ p.Status.Build.BuildCatalogToolTimeout = 60
+ }
_, cacheEnabled := p.Status.Build.PublishStrategyOptions[builder.KanikoBuildCacheEnabled]
if p.Status.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyKaniko && !cacheEnabled {
// Default to disabling Kaniko cache warmer