Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions internal/controller/cachegroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (r *CacheGroupReconciler) sync(ctx context.Context, cg *juicefsiov1.CacheGr
}
groupBackUp := r.shouldAddGroupBackupOrNot(cg, actualState, expectState)
podBuilder := builder.NewPodBuilder(cg, secret, node, expectState, groupBackUp)
expectWorker := podBuilder.NewCacheGroupWorker(ctx)
expectWorker := podBuilder.NewCacheGroupWorker(ctx, false)

if actualState != nil && actualState.DeletionTimestamp != nil {
log.Info("actual worker is being deleted, skip updating worker, waiting for next reconciler", "worker", expectWorker.Name)
Expand Down Expand Up @@ -315,7 +315,7 @@ func (r *CacheGroupReconciler) parseExpectStateByScheduler(ctx context.Context,
for _, node := range nodes {
state := expectStates[node.Name]
podBuilder := builder.NewPodBuilder(cg, &corev1.Secret{}, node.Name, state, false)
pod := podBuilder.NewCacheGroupWorker(ctx)
pod := podBuilder.NewCacheGroupWorker(ctx, true)
if ok, err := sim.CanSchedulePodOnNode(ctx, pod, &node); err != nil {
return nil, err
} else {
Expand Down Expand Up @@ -684,7 +684,7 @@ func (r *CacheGroupReconciler) HandleFinalizer(ctx context.Context, cg *juicefsi
}
for node, expectState := range expectStates {
podBuilder := builder.NewPodBuilder(cg, secret, node, expectState, false)
expectWorker := podBuilder.NewCacheGroupWorker(ctx)
expectWorker := podBuilder.NewCacheGroupWorker(ctx, false)
if err := r.cleanWorkerCache(ctx, cg, *expectWorker); err != nil {
log.Error(err, "failed to clean worker cache", "worker", expectWorker.Name)
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/builder/cache_group_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (p *PodBuilder) genInitConfigVolumes() {
})
}

func (p *PodBuilder) NewCacheGroupWorker(ctx context.Context) *corev1.Pod {
func (p *PodBuilder) NewCacheGroupWorker(ctx context.Context, dryrun bool) *corev1.Pod {
worker := newBasicPod(p.cg, p.node)
p.genInitConfigVolumes()
p.genCacheDirs()
Expand All @@ -398,7 +398,12 @@ func (p *PodBuilder) NewCacheGroupWorker(ctx context.Context) *corev1.Pod {
if spec.Affinity == nil {
spec.Affinity = &corev1.Affinity{}
}
worker.Spec.Affinity = utils.AddNodeNameNodeAffinity(spec.Affinity.DeepCopy(), p.node)
// dryrun means just generate the pod spec without binding to a specific node
if !dryrun {
worker.Spec.Affinity = utils.AddNodeNameNodeAffinity(spec.Affinity.DeepCopy(), p.node)
} else {
worker.Spec.Affinity = spec.Affinity.DeepCopy()
}
}
}
maps.Copy(worker.Labels, spec.Labels)
Expand Down
6 changes: 3 additions & 3 deletions pkg/builder/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (j *JobBuilder) NewWarmUpJob() *batchv1.Job {
Name: common.WarmUpContainerName,
Image: image,
ImagePullPolicy: j.worker.Spec.Containers[0].ImagePullPolicy,
Command: j.getWarmUpCommand(),
Command: j.getWarmUpCommand(image),
Env: j.worker.Spec.Containers[0].Env,
SecurityContext: &corev1.SecurityContext{
Privileged: utils.ToPtr(true),
Expand Down Expand Up @@ -156,7 +156,7 @@ var (
ignoreMountOpts = []string{"foreground", "cache-size", "free-space-ratio", "group-weight", "cache-dir", "group-backup"}
)

func (j *JobBuilder) getWarmUpCommand() []string {
func (j *JobBuilder) getWarmUpCommand(image string) []string {
workerCommad := strings.Split(j.worker.Spec.Containers[0].Command[2], "\n")
authCmd := workerCommad[0]
volName, opts := utils.MustParseWorkerMountCmds(workerCommad[1])
Expand Down Expand Up @@ -241,7 +241,7 @@ func (j *JobBuilder) getWarmUpCommand() []string {
cmds = append(cmds, fmt.Sprintf("--%s", opt))
}
// enable debug mode to get warmup stats log
if utils.WarmupSupportStats(j.wu.Spec.Image) && !hasDebug {
if utils.WarmupSupportStats(image) && !hasDebug {
cmds = append(cmds, "--debug")
}
return []string{
Expand Down