Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add src and image to envs #1050

Merged
merged 34 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
aee5edd
Added to environment confir image and dockerfilename
satr Jan 25, 2024
1e67ba5
Build images individually for each env
satr Jan 26, 2024
0d7bf36
Added build job go routine
satr Jan 26, 2024
57b3beb
Build each env and component in own job, when build-kit used
satr Jan 26, 2024
c4fd6ca
Corrected log messages
satr Jan 26, 2024
7a4556d
Added env to build job component annotation
satr Jan 29, 2024
1c3cedb
Fixing unit-tests
satr Jan 29, 2024
90ea54a
Fixing unit-tests
satr Jan 30, 2024
e4a36b5
Fixing unit-tests
satr Jan 30, 2024
f06a6aa
Extending unit-tests
satr Jan 31, 2024
bbd8765
Extending unit-tests
satr Jan 31, 2024
6dc89fb
Extending unit-tests
satr Jan 31, 2024
d1b6695
Extending unit-tests
satr Jan 31, 2024
b6655e2
Merge remote-tracking branch 'origin/master' into add-src-and-image-t…
satr Feb 1, 2024
a390034
Show component names in pipeline steps
satr Feb 1, 2024
75e166d
Limited container and image name for environments
satr Feb 2, 2024
e7392e5
Merge remote-tracking branch 'origin/master' into add-src-and-image-t…
satr Feb 2, 2024
21b7db9
Corrected log text for failed pipeline job
satr Feb 2, 2024
9fb06e7
Added buildContext to the pipeline job result configMap
satr Feb 5, 2024
3ee1f7a
Added buildContext to the pipeline job result configMap
satr Feb 5, 2024
33f867d
Removed buildContext from the pipeline job result configMap
satr Feb 5, 2024
59af3d8
Fixed commit-id logic
satr Feb 6, 2024
1db428c
Repaired componentsToDeploy condition
satr Feb 6, 2024
4911624
Corrected componentsToDeploy condition
satr Feb 7, 2024
ca41998
Corrected componentsToDeploy condition
satr Feb 7, 2024
1bc3420
Corrected reported lint issues
satr Feb 8, 2024
9a10e02
Merge branch 'master' into add-src-and-image-to-envs
satr Feb 19, 2024
c17af96
Merge branch 'master' into add-src-and-image-to-envs
satr Feb 23, 2024
6d247df
Merge branch 'master' into add-src-and-image-to-envs
satr Feb 29, 2024
1483e98
Added error for getComponentSources, renamed methods
satr Mar 1, 2024
1b73bae
Corrected getComponentSources
satr Mar 1, 2024
651a2dc
Corrected getComponentSources
satr Mar 1, 2024
2ac1ef8
Merge remote-tracking branch 'origin/master' into add-src-and-image-t…
satr Mar 4, 2024
f2b27b7
Set new version
satr Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions charts/radix-operator/templates/radixapplication.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ spec:
type: boolean
type: object
type: object
dockerfileName:
description: 'Name of the Dockerfile that builds the component.
More info: https://www.radix.equinor.com/references/reference-radix-config/#dockerfilename'
type: string
enabled:
description: 'Controls if the component shall be deployed
to this environment. More info: https://www.radix.equinor.com/references/reference-radix-config/#enabled'
Expand Down Expand Up @@ -442,6 +446,10 @@ spec:
- clientId
type: object
type: object
image:
description: 'Name of an existing container image to use
when running the component. More info: https://www.radix.equinor.com/references/reference-radix-config/#image'
type: string
imageTagName:
description: 'The imageTagName allows for flexible configuration
of fixed images, built outside of Radix, to be configured
Expand Down Expand Up @@ -595,6 +603,10 @@ spec:
type: object
type: array
type: object
src:
description: 'Path to the Dockerfile that builds the component.
More info: https://www.radix.equinor.com/references/reference-radix-config/#src'
type: string
variables:
additionalProperties:
type: string
Expand Down Expand Up @@ -1322,6 +1334,10 @@ spec:
format: int32
minimum: 0
type: integer
dockerfileName:
description: 'Name of the Dockerfile that builds the component.
More info: https://www.radix.equinor.com/references/reference-radix-config/#dockerfilename'
type: string
enabled:
description: Controls if the job shall be deployed to
this environment.
Expand Down Expand Up @@ -1349,6 +1365,10 @@ spec:
- clientId
type: object
type: object
image:
description: 'Name of an existing container image to use
when running the job. More info: https://www.radix.equinor.com/references/reference-radix-config/#image-2'
type: string
imageTagName:
description: 'The imageTagName allows for flexible configuration
of fixed images, built outside of Radix, to be configured
Expand Down Expand Up @@ -1510,6 +1530,10 @@ spec:
type: object
type: array
type: object
src:
description: 'Path to the Dockerfile that builds the component.
More info: https://www.radix.equinor.com/references/reference-radix-config/#src'
type: string
timeLimitSeconds:
description: 'Environment specific value for the maximum
number of seconds the job can run. More info: https://www.radix.equinor.com/references/reference-radix-config/#timelimitseconds-2'
Expand Down
24 changes: 24 additions & 0 deletions json-schema/radixapplication.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@
},
"type": "object"
},
"dockerfileName": {
"description": "Name of the Dockerfile that builds the component. More info: https://www.radix.equinor.com/references/reference-radix-config/#dockerfilename",
"type": "string"
},
"enabled": {
"description": "Controls if the component shall be deployed to this environment. More info: https://www.radix.equinor.com/references/reference-radix-config/#enabled",
"type": "boolean"
Expand Down Expand Up @@ -440,6 +444,10 @@
},
"type": "object"
},
"image": {
"description": "Name of an existing container image to use when running the component. More info: https://www.radix.equinor.com/references/reference-radix-config/#image",
"type": "string"
},
"imageTagName": {
"description": "The imageTagName allows for flexible configuration of fixed images, built outside of Radix, to be configured with separate tag for each environment. More info: https://www.radix.equinor.com/references/reference-radix-config/#imagetagname",
"type": "string"
Expand Down Expand Up @@ -591,6 +599,10 @@
},
"type": "object"
},
"src": {
"description": "Path to the Dockerfile that builds the component. More info: https://www.radix.equinor.com/references/reference-radix-config/#src",
"type": "string"
},
"variables": {
"additionalProperties": {
"type": "string"
Expand Down Expand Up @@ -1369,6 +1381,10 @@
"minimum": 0,
"type": "integer"
},
"dockerfileName": {
"description": "Name of the Dockerfile that builds the component. More info: https://www.radix.equinor.com/references/reference-radix-config/#dockerfilename",
"type": "string"
},
"enabled": {
"description": "Controls if the job shall be deployed to this environment.",
"type": "boolean"
Expand Down Expand Up @@ -1399,6 +1415,10 @@
},
"type": "object"
},
"image": {
"description": "Name of an existing container image to use when running the job. More info: https://www.radix.equinor.com/references/reference-radix-config/#image-2",
"type": "string"
},
"imageTagName": {
"description": "The imageTagName allows for flexible configuration of fixed images, built outside of Radix, to be configured with separate tag for each environment. More info: https://www.radix.equinor.com/references/reference-radix-config/#imagetagname-2",
"type": "string"
Expand Down Expand Up @@ -1557,6 +1577,10 @@
},
"type": "object"
},
"src": {
"description": "Path to the Dockerfile that builds the component. More info: https://www.radix.equinor.com/references/reference-radix-config/#src",
"type": "string"
},
"timeLimitSeconds": {
"description": "Environment specific value for the maximum number of seconds the job can run. More info: https://www.radix.equinor.com/references/reference-radix-config/#timelimitseconds-2",
"format": "int64",
Expand Down
6 changes: 3 additions & 3 deletions pipeline-runner/internal/tekton/tekton.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const (
// CreateActionPipelineJob Create action pipeline job
func CreateActionPipelineJob(containerName string, action string, pipelineInfo *model.PipelineInfo, appName string, initContainers []corev1.Container, envVars *[]corev1.EnvVar) *batchv1.Job {
imageTag := pipelineInfo.PipelineArguments.ImageTag
jobName := pipelineInfo.PipelineArguments.JobName
pipelineJobName := pipelineInfo.PipelineArguments.JobName
timestamp := time.Now().Format("20060102150405")
hash := strings.ToLower(utils.RandStringStrSeed(5, pipelineInfo.PipelineArguments.JobName))
backOffLimit := int32(0)
job := batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("radix-%s-pipelines-%s-%s-%s", action, timestamp, imageTag, hash),
Labels: map[string]string{
kube.RadixJobNameLabel: jobName,
kube.RadixJobNameLabel: pipelineJobName,
kube.RadixAppLabel: appName,
kube.RadixImageTagLabel: imageTag,
kube.RadixJobTypeLabel: getActionPipelineJobTypeLabelByPipelinesAction(action),
Expand All @@ -44,7 +44,7 @@ func CreateActionPipelineJob(containerName string, action string, pipelineInfo *
BackoffLimit: &backOffLimit,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: radixlabels.ForPipelineJobName(jobName),
Labels: radixlabels.ForPipelineJobName(pipelineJobName),
Annotations: annotations.ForClusterAutoscalerSafeToEvict(false),
},
Spec: corev1.PodSpec{
Expand Down
18 changes: 17 additions & 1 deletion pipeline-runner/internal/wait/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package wait
import (
"errors"
"fmt"
"strings"

"github.com/equinor/radix-operator/pkg/apis/kube"
logger "github.com/sirupsen/logrus"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -51,7 +53,7 @@ func waitForCompletionOf(kubeClient kubernetes.Interface, job *batchv1.Job) erro
case currJob.Status.Succeeded == 1:
errChan <- nil
case currJob.Status.Failed == 1:
errChan <- fmt.Errorf("job failed. See log for more details")
errChan <- fmt.Errorf("job failed. See more details in the log of the job %s", getJobDescription(currJob))
}
}
},
Expand Down Expand Up @@ -106,6 +108,20 @@ func waitForCompletionOf(kubeClient kubernetes.Interface, job *batchv1.Job) erro
return err
}

func getJobDescription(job *batchv1.Job) string {
var lines []string
if jobType, ok := job.GetLabels()[kube.RadixJobTypeLabel]; ok {
lines = append(lines, jobType)
}
if componentName, ok := job.GetLabels()[kube.RadixComponentLabel]; ok {
lines = append(lines, fmt.Sprintf("for the component %s", componentName))
}
if envName, ok := job.GetLabels()[kube.RadixEnvLabel]; ok {
lines = append(lines, fmt.Sprintf("for the environment %s", envName))
}
return strings.Join(lines, " ")
}

func checkPodIsTerminatedOrFailed(containerStatuses *[]corev1.ContainerStatus) error {
for _, containerStatus := range *containerStatuses {
if containerStatus.State.Terminated != nil {
Expand Down
4 changes: 2 additions & 2 deletions pipeline-runner/model/pipelineInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type PipelineInfo struct {
GitCommitHash string
GitTags string

// Holds information about components to be built
BuildComponentImages pipeline.BuildComponentImages
// Holds information about components to be built for each environment
BuildComponentImages pipeline.EnvironmentBuildComponentImages

// Hold information about components to be deployed
DeployEnvironmentComponentImages pipeline.DeployEnvironmentComponentImages
Expand Down
7 changes: 4 additions & 3 deletions pipeline-runner/pipelines/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ func (cli *PipelineRunner) CreateResultConfigMap() error {
if err != nil {
return err
}
jobName := cli.pipelineInfo.PipelineArguments.JobName
pipelineJobName := cli.pipelineInfo.PipelineArguments.JobName

configMap := corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: jobName,
Name: pipelineJobName,
Labels: map[string]string{
kube.RadixJobNameLabel: jobName,
kube.RadixJobNameLabel: pipelineJobName,
kube.RadixConfigMapTypeLabel: string(kube.RadixPipelineResultConfigMap),
},
},
Expand Down
Loading
Loading