Skip to content

Commit 021fe45

Browse files
committed
Only apply PodTemplate and ComputeResources for CI Tests
1 parent b9c1bce commit 021fe45

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

openshift-with-appstudio-test/e2e/util.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,9 +1064,10 @@ func setupMinikube(t *testing.T, namespace string) *testArgs {
10641064
}
10651065
jbsConfig := v1alpha1.JBSConfig{
10661066
ObjectMeta: metav1.ObjectMeta{
1067-
Namespace: ta.ns,
1068-
Name: v1alpha1.JBSConfigName,
1069-
Annotations: map[string]string{jbsconfig.TestRegistry: strconv.FormatBool(insecure)},
1067+
Namespace: ta.ns,
1068+
Name: v1alpha1.JBSConfigName,
1069+
Annotations: map[string]string{jbsconfig.TestRegistry: strconv.FormatBool(insecure),
1070+
jbsconfig.CITests: "true"},
10701071
},
10711072
Spec: v1alpha1.JBSConfigSpec{
10721073
EnableRebuilds: true,

pkg/reconciler/dependencybuild/buildrecipeyaml.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func createDeployPipelineSpec(jbsConfig *v1alpha1.JBSConfig, buildRequestProcess
135135
}
136136
return ps, nil
137137
}
138-
func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfig *v1alpha1.JBSConfig, systemConfig *v1alpha1.SystemConfig, recipe *v1alpha1.BuildRecipe, db *v1alpha1.DependencyBuild, paramValues []tektonpipeline.Param, buildRequestProcessorImage string, buildId string, existingImages map[string]string, orasOptions string) (*tektonpipeline.PipelineSpec, string, error) {
138+
func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfig *v1alpha1.JBSConfig, systemConfig *v1alpha1.SystemConfig, recipe *v1alpha1.BuildRecipe, db *v1alpha1.DependencyBuild, paramValues []tektonpipeline.Param, buildRequestProcessorImage string, buildId string, existingImages map[string]string, insecure bool) (*tektonpipeline.PipelineSpec, string, error) {
139139

140140
// Rather than tagging with hash of json build recipe, buildrequestprocessor image and db.Name as the former two
141141
// could change with new image versions just use db.Name (which is a hash of scm url/tag/path so should be stable)
@@ -147,7 +147,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
147147
fmt.Printf("### Was using preBuildImageArgs %#v and konfluxArgs %#v ", preBuildImageArgs, konfluxArgs)
148148
install := additionalPackages(recipe)
149149
tlsVerify := "true"
150-
if orasOptions != "" {
150+
if insecure {
151151
tlsVerify = "false"
152152
}
153153

@@ -575,7 +575,7 @@ URL=%s
575575
DIGEST=$(tasks.%s.results.IMAGE_DIGEST)
576576
AARCHIVE=$(oras manifest fetch $ORAS_OPTIONS $URL@$DIGEST | jq --raw-output '.layers[0].digest')
577577
echo "URL $URL DIGEST $DIGEST AARCHIVE $AARCHIVE"
578-
use-archive oci:$URL@$AARCHIVE=$(workspaces.source.path)/artifacts`, orasOptions, registryArgsWithDefaults(jbsConfig, ""), BuildTaskName),
578+
use-archive oci:$URL@$AARCHIVE=$(workspaces.source.path)/artifacts`, insecure, registryArgsWithDefaults(jbsConfig, ""), BuildTaskName),
579579
},
580580
{
581581
Name: "verify-and-check-for-contaminates",

pkg/reconciler/dependencybuild/dependencybuild.go

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,9 @@ func (r *ReconcileDependencyBuild) handleStateBuilding(ctx context.Context, db *
597597
{Name: PipelineParamJavaVersion, Value: tektonpipeline.ResultValue{Type: tektonpipeline.ParamTypeString, StringVal: attempt.Recipe.JavaVersion}},
598598
}
599599

600-
orasOptions := ""
600+
insecure := false
601601
if jbsConfig.Annotations != nil && jbsConfig.Annotations[jbsconfig.TestRegistry] == "true" {
602-
orasOptions = "--insecure --plain-http"
602+
insecure = true
603603
}
604604
systemConfig := v1alpha1.SystemConfig{}
605605
err = r.client.Get(ctx, types.NamespacedName{Name: systemconfig.SystemConfigKey}, &systemConfig)
@@ -616,7 +616,7 @@ func (r *ReconcileDependencyBuild) handleStateBuilding(ctx context.Context, db *
616616
Pipeline: &v12.Duration{Duration: time.Hour * v1alpha1.DefaultTimeout},
617617
Tasks: &v12.Duration{Duration: time.Hour * v1alpha1.DefaultTimeout},
618618
}
619-
pr.Spec.PipelineSpec, diagnosticContainerfile, err = createPipelineSpec(log, attempt.Recipe.Tool, db.Status.CommitTime, jbsConfig, &systemConfig, attempt.Recipe, db, paramValues, buildRequestProcessorImage, attempt.BuildId, preBuildImages, orasOptions)
619+
pr.Spec.PipelineSpec, diagnosticContainerfile, err = createPipelineSpec(log, attempt.Recipe.Tool, db.Status.CommitTime, jbsConfig, &systemConfig, attempt.Recipe, db, paramValues, buildRequestProcessorImage, attempt.BuildId, preBuildImages, insecure)
620620
if err != nil {
621621
return reconcile.Result{}, err
622622
}
@@ -636,29 +636,30 @@ func (r *ReconcileDependencyBuild) handleStateBuilding(ctx context.Context, db *
636636
},
637637
}},
638638
}
639-
// TODO: ### Enclose this within an annotation to denote test CI system in use?
640-
pr.Spec.TaskRunTemplate = tektonpipeline.PipelineTaskRunTemplate{
641-
PodTemplate: &pod.Template{
642-
Env: []v1.EnvVar{
643-
{
644-
Name: "ORAS_OPTIONS",
645-
Value: orasOptions,
639+
if insecure {
640+
pr.Spec.TaskRunTemplate = tektonpipeline.PipelineTaskRunTemplate{
641+
PodTemplate: &pod.Template{
642+
Env: []v1.EnvVar{
643+
{
644+
Name: "ORAS_OPTIONS",
645+
Value: "--insecure --plain-http",
646+
},
646647
},
647648
},
648-
},
649+
}
650+
}
651+
if jbsConfig.Annotations != nil && jbsConfig.Annotations[jbsconfig.CITests] == "true" {
652+
podMemR, _ := resource.ParseQuantity("1792Mi")
653+
podMemL, _ := resource.ParseQuantity("3584Mi")
654+
podCPU, _ := resource.ParseQuantity("500m")
655+
pr.Spec.TaskRunSpecs = []tektonpipeline.PipelineTaskRunSpec{{
656+
PipelineTaskName: BuildTaskName,
657+
ComputeResources: &v1.ResourceRequirements{
658+
Requests: v1.ResourceList{"memory": podMemR, "cpu": podCPU},
659+
Limits: v1.ResourceList{"memory": podMemL, "cpu": podCPU},
660+
},
661+
}}
649662
}
650-
// TODO: ### Enclose this within an annotation to denote test CI system in use?
651-
podMemR, _ := resource.ParseQuantity("1792Mi")
652-
podMemL, _ := resource.ParseQuantity("3584Mi")
653-
podCPU, _ := resource.ParseQuantity("500m")
654-
pr.Spec.TaskRunSpecs = []tektonpipeline.PipelineTaskRunSpec{{
655-
PipelineTaskName: BuildTaskName,
656-
ComputeResources: &v1.ResourceRequirements{
657-
Requests: v1.ResourceList{"memory": podMemR, "cpu": podCPU},
658-
Limits: v1.ResourceList{"memory": podMemL, "cpu": podCPU},
659-
},
660-
}}
661-
662663
if !jbsConfig.Spec.CacheSettings.DisableTLS {
663664
pr.Spec.Workspaces = append(pr.Spec.Workspaces, tektonpipeline.WorkspaceBinding{Name: "tls", ConfigMap: &v1.ConfigMapVolumeSource{LocalObjectReference: v1.LocalObjectReference{Name: v1alpha1.TlsConfigMapName}}})
664665
} else {
@@ -1422,10 +1423,6 @@ func (r *ReconcileDependencyBuild) handleStateDeploying(ctx context.Context, db
14221423
{Name: PipelineResultPreBuildImageDigest, Value: tektonpipeline.ResultValue{Type: tektonpipeline.ParamTypeString, StringVal: db.Status.PreBuildImages[len(db.Status.PreBuildImages)-1].BuiltImageDigest}},
14231424
}
14241425

1425-
orasOptions := ""
1426-
if jbsConfig.Annotations != nil && jbsConfig.Annotations[jbsconfig.TestRegistry] == "true" {
1427-
orasOptions = "--insecure --plain-http"
1428-
}
14291426
systemConfig := v1alpha1.SystemConfig{}
14301427
err = r.client.Get(ctx, types.NamespacedName{Name: systemconfig.SystemConfigKey}, &systemConfig)
14311428
if err != nil {
@@ -1450,28 +1447,29 @@ func (r *ReconcileDependencyBuild) handleStateDeploying(ctx context.Context, db
14501447
pr.Spec.Workspaces = append(pr.Spec.Workspaces, tektonpipeline.WorkspaceBinding{Name: "tls", EmptyDir: &v1.EmptyDirVolumeSource{}})
14511448
}
14521449
pr.Spec.Timeouts = &tektonpipeline.TimeoutFields{Pipeline: &v12.Duration{Duration: time.Hour * v1alpha1.DefaultTimeout}}
1453-
// TODO: ### Enclose this within an annotation to denote test CI system in use? Could inline orasOptions then as well?
1454-
pr.Spec.TaskRunTemplate = tektonpipeline.PipelineTaskRunTemplate{
1455-
PodTemplate: &pod.Template{
1456-
Env: []v1.EnvVar{
1457-
{
1458-
Name: "ORAS_OPTIONS",
1459-
Value: orasOptions,
1450+
if jbsConfig.Annotations != nil && jbsConfig.Annotations[jbsconfig.TestRegistry] == "true" {
1451+
pr.Spec.TaskRunTemplate = tektonpipeline.PipelineTaskRunTemplate{
1452+
PodTemplate: &pod.Template{
1453+
Env: []v1.EnvVar{
1454+
{
1455+
Name: "ORAS_OPTIONS",
1456+
Value: "--insecure --plain-http",
1457+
},
14601458
},
14611459
},
1462-
},
1460+
}
1461+
}
1462+
if jbsConfig.Annotations != nil && jbsConfig.Annotations[jbsconfig.CITests] == "true" {
1463+
podMem, _ := resource.ParseQuantity("1024Mi")
1464+
podCPU, _ := resource.ParseQuantity("250m")
1465+
pr.Spec.TaskRunSpecs = []tektonpipeline.PipelineTaskRunSpec{{
1466+
PipelineTaskName: DeployTaskName,
1467+
ComputeResources: &v1.ResourceRequirements{
1468+
Requests: v1.ResourceList{"memory": podMem, "cpu": podCPU},
1469+
Limits: v1.ResourceList{"memory": podMem, "cpu": podCPU},
1470+
},
1471+
}}
14631472
}
1464-
// TODO: ### Enclose this within an annotation to denote test CI system in use?
1465-
podMem, _ := resource.ParseQuantity("1024Mi")
1466-
podCPU, _ := resource.ParseQuantity("250m")
1467-
pr.Spec.TaskRunSpecs = []tektonpipeline.PipelineTaskRunSpec{{
1468-
PipelineTaskName: DeployTaskName,
1469-
ComputeResources: &v1.ResourceRequirements{
1470-
Requests: v1.ResourceList{"memory": podMem, "cpu": podCPU},
1471-
Limits: v1.ResourceList{"memory": podMem, "cpu": podCPU},
1472-
},
1473-
}}
1474-
14751473
if err := controllerutil.SetOwnerReference(db, &pr, r.scheme); err != nil {
14761474
return reconcile.Result{}, err
14771475
}

pkg/reconciler/jbsconfig/jbsconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535

3636
const (
3737
TlsServiceName = v1alpha1.CacheDeploymentName + "-tls"
38+
CITests = "jvmbuildservice.io/ci-tests" // Denote using an insecure registry in GitHub Actions
3839
TestRegistry = "jvmbuildservice.io/test-registry" // Denote using an insecure registry in GitHub Actions
3940
RetryTimeAnnotations = "jvmbuildservice.io/retry-time"
4041
RetryTimestampAnnotations = "jvmbuildservice.io/retry-timestamp"

0 commit comments

Comments
 (0)