camel-k icon indicating copy to clipboard operation
camel-k copied to clipboard

fix(#5292): Simplify run cmd for archs other than amd64

Open tdiesler opened this issue 1 year ago • 4 comments

This adds -Djib.from.platforms=linux/arm64 when there is no explicit -t builder.platforms trait. Unlike previous attempts, this change should not interfere with the upgrade functionality.

On arm64, try this ...

make images

kamel install
kamel run --dev ./e2e/advanced/files/Java.java

tdiesler avatar Apr 23 '24 12:04 tdiesler

Seems to fail unrelated in TestServiceTrait

tdiesler avatar Apr 23 '24 14:04 tdiesler

The idea is, that (if not explicitly configured otherwise) we build the integration for the arch we run on. Building the integration for multiarch is a different story (and breaking change), which we deferred until the next major version.

A configuration variable which is set at operator install time would likely not add relevant information to what we get from the Go runtime already, or would it?

if runtime.GOARCH == "arm64" is a variation of the switch I had earlier. When more archs become relevant we can expand the mapping. Currently it is ...

switch runtime.GOARCH {
   arm64: linux/arm64
   default: linux/amd64
}

tdiesler avatar Apr 24 '24 05:04 tdiesler

Ready to merge?

tdiesler avatar Apr 25 '24 08:04 tdiesler

I've created the property here and initialized the default here.

Then there is some deep copy magic here which I'm not supposed to edit

On introspection of the CRD, I don't see that property

{"level":"info","ts":"2024-05-03T14:40:20Z","logger":"camel-k","msg":">>> IntegrationPlatform: &{{IntegrationPlatform camel.apache.org/v1} {camel-k  default  49f88784-8ed4-404f-b2f9-eb58859a5c78 14520 1 2024-05-03 14:38:36 +0000 UTC <nil> <nil> map[app:camel-k] map[camel.apache.org/operator.id:camel-k] [] [] [{kamel Update camel.apache.org/v1 2024-05-03 14:38:36 +0000 UTC FieldsV1 {\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:camel.apache.org/operator.id\":{}},\"f:labels\":{\".\":{},\"f:app\":{}}},\"f:spec\":{\".\":{},\"f:build\":{\".\":{},\"f:buildConfiguration\":{},\"f:maven\":{\".\":{},\"f:settings\":{},\"f:settingsSecurity\":{}},\"f:publishStrategy\":{},\"f:registry\":{\".\":{},\"f:address\":{},\"f:insecure\":{}}},\"f:kamelet\":{},\"f:traits\":{}}} } {kamel Update camel.apache.org/v1 2024-05-03 14:38:40 +0000 UTC FieldsV1 {\"f:status\":{\".\":{},\"f:build\":{\".\":{},\"f:baseImage\":{},\"f:buildConfiguration\":{\".\":{},\"f:orderStrategy\":{},\"f:strategy\":{}},\"f:maven\":{\".\":{},\"f:cliOptions\":{},\"f:localRepository\":{}},\"f:maxRunningBuilds\":{},\"f:publishStrategy\":{},\"f:registry\":{\".\":{},\"f:address\":{},\"f:insecure\":{}},\"f:runtimeVersion\":{},\"f:timeout\":{}},\"f:cluster\":{},\"f:conditions\":{},\"f:info\":{\".\":{},\"f:gitCommit\":{},\"f:goOS\":{},\"f:goVersion\":{}},\"f:kamelet\":{\".\":{},\"f:repositories\":{}},\"f:observedGeneration\":{},\"f:phase\":{},\"f:version\":{}}} status}]} {  {{        map[] map[] []} Jib    {true 10.96.98.2   } nil nil { map[] [] {nil nil} {nil nil} [] [] []} map[] 0 } {<nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> map[] <nil> <nil> <nil> <nil> <nil>} [] {[]}} {{Kubernetes  {{  routine sequential     map[] map[] []} Jib 3.8.1  eclipse-temurin:17 {true 10.96.98.2   } nil &Duration{Duration:5m0s,} {/etc/maven/m2 map[] [] {nil nil} {nil nil} [] [] [-V --no-transfer-progress -Dstyle.color=never]} map[] 3 } {<nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> map[] <nil> <nil> <nil> <nil> <nil>} [] {[{none}]}} 1 Ready [{Created True 2024-05-03 14:38:40 +0000 UTC 2024-05-03 14:38:40 +0000 UTC IntegrationPlatformCreated integration platform created} {RegistryAvailable True 2024-05-03 14:38:40 +0000 UTC 2024-05-03 14:38:40 +0000 UTC IntegrationPlatformRegistryAvailable registry available at 10.96.98.2} {CamelCatalogAvailable True 2024-05-03 14:38:40 +0000 UTC 2024-05-03 14:38:40 +0000 UTC IntegrationPlatformCamelCatalogAvailable camel catalog 3.8.1 available}] 2.4.0-SNAPSHOT map[gitCommit:60dcf5302ab354d6e800dcc5a73d69b6c00202ff goOS:linux goVersion:go1.22.1]}}"}
{"level":"info","ts":"2024-05-03T14:40:20Z","logger":"camel-k","msg":">>> ImagePlatform: "}

as a result, the Jib config does not see the imagePlatform default value. Something is missing?

tdiesler avatar May 03 '24 14:05 tdiesler

You don't need to create any new parameter. I think you can use IntegrationPlatform trait [1] setting and just add the default builder trait setting when it's missing. BTW, in order to be fully backward compatible, I think we must leave the setting empty when the default (amd64) is selected. You may need to make generate in order to update the CRDs accordingly.

squakez avatar May 06 '24 07:05 squakez

I now set platform.Status.Build.BuildConfiguration.ImagePlatforms like this on kamel install

	if platform.Status.Build.BuildConfiguration.ImagePlatforms == nil {
		buildConfig := &platform.Status.Build.BuildConfiguration
		if runtime.GOARCH == "arm64" {
			buildConfig.ImagePlatforms = []string{"linux/arm64"}
		}
	}

Later in jib.go, I try to read out that parameter like this

	// If not explicitly configured otherwise, we build the integration for the arch configured in the IntegrationPlatform.
	// Building the integration for multiarch is deferred until the next major version (e.g. 3.x)
	var imagePlatforms []string
	if t.task.Configuration.ImagePlatforms != nil {
		imagePlatforms = t.task.Configuration.ImagePlatforms
	} else {
		if ip, _ := platform.GetForName(ctx, t.c, t.build.Namespace, platform.DefaultPlatformName); ip != nil {
			buildConfig := ip.Status.Build.BuildConfiguration
			imagePlatforms = buildConfig.ImagePlatforms
			log.Infof(">>>")
			log.Infof(">>> IntegrationPlatform: %v", ip)
			log.Infof(">>>")
			log.Infof(">>> BuildConfiguration: %v", buildConfig)
			log.Infof(">>>")
			log.Infof(">>> ImagePlatforms: %v", imagePlatforms)
		}
	}

The expected platform.Status.Build.BuildConfiguration.ImagePlatforms is always empty. I verified that this property is part of deep copy. What else could be missing or needs checking?

tdiesler avatar May 07 '24 10:05 tdiesler

LGTM. I think you can remove the comments in the jib.go which result misleading.

Changed to ...

	// Build the integration for the arch configured in the IntegrationPlatform.
	// This can explicitly be configured with the `-t builder.platforms` trait.
	// Building the integration for multiarch is deferred until the next major version (e.g. 3.x)

tdiesler avatar May 07 '24 11:05 tdiesler

@tdiesler is this one ready to merge?

squakez avatar May 08 '24 09:05 squakez

Yes

tdiesler avatar May 08 '24 14:05 tdiesler