Skip to content

Commit

Permalink
fix: ignore no init containers update (#276)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan authored Jan 14, 2024
1 parent bcaad13 commit b70d401
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/jobs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func WithJobTimeout(timeout time.Duration) JobOption {
}
}

func WithNodeConfiguration(nodeConfig bool) JobOption {
return func(j *JobBuilder) {
j.nodeConfig = nodeConfig
}
}

func GetJob(opts ...JobOption) (*batchv1.Job, error) {
jb := &JobBuilder{}
for _, opt := range opts {
Expand All @@ -135,6 +141,7 @@ type JobBuilder struct {
imagePullSecrets []corev1.LocalObjectReference
resourceRequirements *corev1.ResourceRequirements
timeout time.Duration
nodeConfig bool
}

func (b *JobBuilder) build() (*batchv1.Job, error) {
Expand All @@ -152,7 +159,7 @@ func (b *JobBuilder) build() (*batchv1.Job, error) {
if len(b.imageRef) > 0 {
job.Spec.Template.Spec.Containers[0].Image = b.imageRef
}
if len(b.nodeSelector) > 0 {
if len(b.nodeSelector) > 0 && b.nodeConfig {
job.Spec.Template.Spec.Containers[0].Args = append(job.Spec.Template.Spec.Containers[0].Args, "--node", b.nodeSelector)
}
if b.nodeSelector != "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/jobs/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func (jb *jobCollector) ApplyAndCollect(ctx context.Context, nodeName string) (s
WithPodVolumes(jb.volumes),
WithImagePullSecrets(jb.imagePullSecrets),
WithContainerVolumeMounts(jb.volumeMounts),
WithNodeConfiguration(jb.nodeConfig),
WithPriorityClassName(jb.priorityClassName),
WithResourceRequirements(jb.resourceRequirements),
WithJobName(fmt.Sprintf("%s-%s", jb.templateName, ComputeHash(
Expand Down

0 comments on commit b70d401

Please sign in to comment.