Skip to content

Commit

Permalink
Delay jon when a share is deleted
Browse files Browse the repository at this point in the history
If the share cleanup job is executed right after the share deletion, it
might be possible that the other manila components have not yet been
notified about the event. The result is that the job has no effect.
This patch introduces a parameter for the ManilaJob that is supposed to
delay the command. A constant has been defined to properly indentify the
delay time associated with the service cleanup.

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Oct 4, 2024
1 parent 23b5301 commit 963e223
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions controllers/manila_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ func (r *ManilaReconciler) reconcileInit(
nil,
manila.DBSyncJobName,
manila.DBSyncCommand,
0, // no need to delay dbSync
)
dbSyncjob := job.NewJob(
jobDef,
Expand Down Expand Up @@ -799,6 +800,7 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila
ptr.To(manila.TTL),
fmt.Sprintf("%s-%s", manila.SvcCleanupJobName, hash[:manila.TruncateHash]),
manila.SvcCleanupCommand,
manila.ManilaServiceCleanupDelay,
)
shareCleanupJob := job.NewJob(
jobDef,
Expand Down
2 changes: 2 additions & 0 deletions pkg/manila/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const (
ManilaPublicPort int32 = 8786
// ManilaInternalPort -
ManilaInternalPort int32 = 8786
// ServiceCleanupDelay -
ManilaServiceCleanupDelay int32 = 120

// ManilaExtraVolTypeUndefined can be used to label an extraMount which
// is not associated with a specific backend
Expand Down
4 changes: 3 additions & 1 deletion pkg/manila/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func Job(
ttl *int32,
jobName string,
jobCommand string,
delay int32,
) *batchv1.Job {
var config0644AccessMode int32 = 0644
// Unlike the individual manila services, DbSyncJob or a Job executing a
Expand Down Expand Up @@ -69,7 +70,8 @@ func Job(
},
}

args := []string{"-c", jobCommand}
delayCommand := fmt.Sprintf("sleep %d", delay)
args := []string{"-c", fmt.Sprintf("%s && %s", delayCommand, jobCommand)}

// add CA cert if defined
if instance.Spec.ManilaAPI.TLS.CaBundleSecretName != "" {
Expand Down

0 comments on commit 963e223

Please sign in to comment.