Skip to content

Commit

Permalink
Merge pull request #1216 from equinor/master
Browse files Browse the repository at this point in the history
Release: Batch Job Status, Always create Ingresses, Remove ActiveClusterName
  • Loading branch information
Richard87 authored Oct 28, 2024
2 parents 3f84f9d + 3591531 commit e35e5fd
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 105 deletions.
3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"--RADIX_RESERVED_DNS_ALIASES=grafana,prometheus,www"
]
},
{
{
"name": "Launch-deploy-pipeline",
"type": "go",
"request": "launch",
Expand Down Expand Up @@ -116,7 +116,6 @@
"RADIXOPERATOR_APP_ROLLING_UPDATE_MAX_SURGE": "25%",
"RADIXOPERATOR_APP_READINESS_PROBE_INITIAL_DELAY_SECONDS": "5",
"RADIXOPERATOR_APP_READINESS_PROBE_PERIOD_SECONDS": "10",
"RADIX_ACTIVE_CLUSTERNAME": "weekly-35",
"RADIX_IMAGE_BUILDER": "radix-image-builder:master-latest",
"RADIX_TEKTON_IMAGE": "radix-tekton:main-latest",
"RADIXOPERATOR_JOB_SCHEDULER": "radix-job-scheduler:main-latest",
Expand Down
4 changes: 2 additions & 2 deletions charts/radix-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: radix-operator
version: 1.43.1
appVersion: 1.63.1
version: 1.44.0
appVersion: 1.64.0
kubeVersion: ">=1.24.0"
description: Radix Operator
keywords:
Expand Down
11 changes: 4 additions & 7 deletions charts/radix-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ spec:
value: {{ .Values.app.rollingUpdate.maxUnavailable | quote }}
- name: RADIXOPERATOR_APP_ROLLING_UPDATE_MAX_SURGE
value: {{ .Values.app.rollingUpdate.maxSurge | quote }}
# Active cluster name
- name: RADIX_ACTIVE_CLUSTERNAME
value: {{ .Values.activeClusterName }}
# Maximum custom resources
- name: RADIX_DEPLOYMENTS_PER_ENVIRONMENT_HISTORY_LIMIT
value: {{ .Values.deploymentsPerEnvironmentHistoryLimit | quote }}
Expand Down Expand Up @@ -174,9 +171,9 @@ spec:
- name: RADIXOPERATOR_CERTIFICATE_AUTOMATION_DURATION
value: {{ .Values.ingress.certificate.automation.duration }}
- name: RADIXOPERATOR_CERTIFICATE_AUTOMATION_RENEW_BEFORE
value: {{ .Values.ingress.certificate.automation.renewBefore }}
value: {{ .Values.ingress.certificate.automation.renewBefore }}
- name: RADIX_EXTERNAL_REGISTRY_DEFAULT_AUTH_SECRET
value: {{ .Values.externalRegistryDefaultAuthSecret }}
value: {{ .Values.externalRegistryDefaultAuthSecret }}
- name: RADIXOPERATOR_ORPHANED_ENVIRONMENTS_RETENTION_PERIOD
value: {{ .Values.task.orphanedEnvironmentsRetentionPeriod }}
- name: RADIXOPERATOR_ORPHANED_ENVIRONMENTS_CLEANUP_CRON
Expand All @@ -198,7 +195,7 @@ spec:
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -214,4 +211,4 @@ spec:
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
1 change: 0 additions & 1 deletion charts/radix-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
nameOverride: ""
fullnameOverride: ""
clusterName: xx
activeClusterName: xx
clusterActiveEgressIps: xx

registrationControllerThreads: 1
Expand Down
29 changes: 17 additions & 12 deletions pkg/apis/batch/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,31 @@ func (s *syncer) buildJobStatuses(ctx context.Context) ([]radixv1.RadixBatchJobS
}

func (s *syncer) buildBatchJobStatus(ctx context.Context, batchJob *radixv1.RadixBatchJob, allJobs []*batchv1.Job) radixv1.RadixBatchJobStatus {
currentStatus := slice.FindAll(s.radixBatch.Status.JobStatuses, func(jobStatus radixv1.RadixBatchJobStatus) bool {
currentStatus, hasCurrentStatus := slice.FindFirst(s.radixBatch.Status.JobStatuses, func(jobStatus radixv1.RadixBatchJobStatus) bool {
return jobStatus.Name == batchJob.Name
})
if len(currentStatus) > 0 && isJobStatusDone(currentStatus[0]) {
return currentStatus[0]
if hasCurrentStatus && isJobStatusDone(currentStatus) {
return currentStatus
}

status := radixv1.RadixBatchJobStatus{
Name: batchJob.Name,
Phase: radixv1.BatchJobPhaseWaiting,
}
if len(currentStatus) > 0 {
status.Restart = currentStatus[0].Restart
if hasCurrentStatus {
status.Restart = currentStatus.Restart
status.Phase = currentStatus.Phase
}

if isBatchJobStopRequested(batchJob) {
status.Phase = radixv1.BatchJobPhaseStopped
now := metav1.Now()
status.EndTime = &now
if len(currentStatus) > 0 {
status.CreationTime = currentStatus[0].CreationTime
status.StartTime = currentStatus[0].StartTime
status.Message = currentStatus[0].Message
status.Reason = currentStatus[0].Reason
if hasCurrentStatus {
status.CreationTime = currentStatus.CreationTime
status.StartTime = currentStatus.StartTime
status.Message = currentStatus.Message
status.Reason = currentStatus.Reason
}
s.updateJobAndPodStatuses(ctx, batchJob.Name, &status)
return status
Expand All @@ -158,12 +159,16 @@ func (s *syncer) buildBatchJobStatus(ctx context.Context, batchJob *radixv1.Radi
status.CreationTime = &job.CreationTimestamp
status.Failed = job.Status.Failed

var uncountedSucceeded, uncountedFailed int
if uncounted := job.Status.UncountedTerminatedPods; uncounted != nil {
uncountedSucceeded, uncountedFailed = len(uncounted.Succeeded), len(uncounted.Failed)
}
jobConditionsSortedDesc := getJobConditionsSortedDesc(job)
if job.Status.Succeeded > 0 &&
if (job.Status.Succeeded+int32(uncountedSucceeded)) > 0 &&
s.setJobStatus(ctx, batchJob, &status, job, jobConditionsSortedDesc, radixv1.BatchJobPhaseSucceeded, batchv1.JobComplete) {
return status
}
if job.Status.Failed == jobBackoffLimit+1 &&
if (job.Status.Failed+int32(uncountedFailed)) == jobBackoffLimit+1 &&
s.setJobStatus(ctx, batchJob, &status, job, jobConditionsSortedDesc, radixv1.BatchJobPhaseFailed, batchv1.JobFailed) {
return status
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/defaults/environment_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ const (
// RadixClusterTypeEnvironmentVariable The type of cluster dev|playground|prod. Will be equal to OperatorClusterTypeEnvironmentVariable
RadixClusterTypeEnvironmentVariable = "RADIX_CLUSTER_TYPE"

// ActiveClusternameEnvironmentVariable The name of the active cluster. If ActiveClusternameEnvironmentVariable == ClusternameEnvironmentVariable, this is the active cluster
ActiveClusternameEnvironmentVariable = "RADIX_ACTIVE_CLUSTERNAME"

// RadixCommitHashEnvironmentVariable Contains the commit id of the build
RadixCommitHashEnvironmentVariable = "RADIX_GIT_COMMIT_HASH"

Expand Down
Loading

0 comments on commit e35e5fd

Please sign in to comment.