Skip to content

Commit

Permalink
Fix initJob restart condition (#187)
Browse files Browse the repository at this point in the history
* fix issue #94921

* hostNetwork and priorityClassName value from parent for nodeSets

* bump helm chart version

* fix restartPolicy to Never
  • Loading branch information
kobzonega authored Mar 18, 2024
1 parent 1b32748 commit 5bab5dc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
1 change: 0 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
version: v1.48.0
args: --out-format=colored-line-number
code-format-check:
concurrency:
group: lint-autoformat-${{ github.ref }}
Expand Down
4 changes: 2 additions & 2 deletions deploy/ydb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.5.0
version: 0.5.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.5.0"
appVersion: "0.5.1"
9 changes: 8 additions & 1 deletion internal/controllers/storage/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ func (r *Reconciler) initializeStorage(
return r.setInitStorageCompleted(ctx, storage, "Storage initialized successfully")
}

if initJob.Status.Failed > 0 {
var conditionFailed bool
for _, condition := range initJob.Status.Conditions {
if condition.Type == batchv1.JobFailed {
conditionFailed = true
break
}
}
if initJob.Status.Failed == *initJob.Spec.BackoffLimit || conditionFailed {
r.Log.Info("Init Job status failed")
r.Recorder.Event(
storage,
Expand Down
4 changes: 0 additions & 4 deletions internal/resources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ func (b *DatabaseBuilder) recastDatabaseNodeSetSpecInline(nodeSetSpecInline *api
nodeSetSpec.Tolerations = append(nodeSetSpec.Tolerations, nodeSetSpecInline.Tolerations...)
}

if nodeSetSpecInline.PriorityClassName != nodeSetSpec.PriorityClassName {
nodeSetSpec.PriorityClassName = nodeSetSpecInline.PriorityClassName
}

nodeSetSpec.AdditionalLabels = CopyDict(b.Spec.AdditionalLabels)
if nodeSetSpecInline.AdditionalLabels != nil {
for k, v := range nodeSetSpecInline.AdditionalLabels {
Expand Down
8 changes: 0 additions & 8 deletions internal/resources/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@ func (b *StorageClusterBuilder) recastStorageNodeSetSpecInline(nodeSetSpecInline
nodeSetSpec.Resources = nodeSetSpecInline.Resources
}

if nodeSetSpecInline.HostNetwork != nodeSetSpec.HostNetwork {
nodeSetSpec.HostNetwork = nodeSetSpecInline.HostNetwork
}

nodeSetSpec.NodeSelector = CopyDict(b.Spec.NodeSelector)
if nodeSetSpecInline.NodeSelector != nil {
for k, v := range nodeSetSpecInline.NodeSelector {
Expand All @@ -235,10 +231,6 @@ func (b *StorageClusterBuilder) recastStorageNodeSetSpecInline(nodeSetSpecInline
nodeSetSpec.TopologySpreadConstraints = append(nodeSetSpec.TopologySpreadConstraints, nodeSetSpecInline.TopologySpreadConstraints...)
}

if nodeSetSpecInline.PriorityClassName != nodeSetSpec.PriorityClassName {
nodeSetSpec.PriorityClassName = nodeSetSpecInline.PriorityClassName
}

nodeSetSpec.AdditionalLabels = CopyDict(b.Spec.AdditionalLabels)
if nodeSetSpecInline.AdditionalLabels != nil {
for k, v := range nodeSetSpecInline.AdditionalLabels {
Expand Down
4 changes: 2 additions & 2 deletions internal/resources/storage_init_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (b *StorageInitJobBuilder) Build(obj client.Object) error {
Parallelism: ptr.Int32(1),
Completions: ptr.Int32(1),
ActiveDeadlineSeconds: ptr.Int64(300),
BackoffLimit: ptr.Int32(10),
BackoffLimit: ptr.Int32(3),
Template: b.buildInitJobPodTemplateSpec(),
}

Expand Down Expand Up @@ -91,7 +91,7 @@ func (b *StorageInitJobBuilder) buildInitJobPodTemplateSpec() corev1.PodTemplate
Spec: corev1.PodSpec{
Containers: []corev1.Container{b.buildInitJobContainer()},
Volumes: b.buildInitJobVolumes(),
RestartPolicy: corev1.RestartPolicyOnFailure,
RestartPolicy: corev1.RestartPolicyNever,
DNSConfig: &corev1.PodDNSConfig{
Searches: dnsConfigSearches,
},
Expand Down

0 comments on commit 5bab5dc

Please sign in to comment.