mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
fix: graceful delete runtime dir. (#2393)
* fix: graceful delete runtime dir. Signed-off-by: joyceliu <joyceliu@yunify.com> * fix: graceful delete runtime dir. Signed-off-by: joyceliu <joyceliu@yunify.com> --------- Signed-off-by: joyceliu <joyceliu@yunify.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
7eba91a70e
commit
48831c7121
|
|
@ -60,13 +60,16 @@ func (m *commandManager) Run(ctx context.Context) error {
|
|||
defer func() {
|
||||
fmt.Fprintf(m.logOutput, "%s [Pipeline %s] finish. total: %v,success: %v,ignored: %v,failed: %v\n", time.Now().Format(time.TimeOnly+" MST"), ctrlclient.ObjectKeyFromObject(m.Pipeline),
|
||||
m.Pipeline.Status.TaskResult.Total, m.Pipeline.Status.TaskResult.Success, m.Pipeline.Status.TaskResult.Ignored, m.Pipeline.Status.TaskResult.Failed)
|
||||
if !m.Pipeline.Spec.Debug && m.Pipeline.Status.Phase == kkcorev1.PipelinePhaseSucceed {
|
||||
fmt.Fprintf(m.logOutput, "%s [Pipeline %s] clean runtime directory\n", time.Now().Format(time.TimeOnly+" MST"), ctrlclient.ObjectKeyFromObject(m.Pipeline))
|
||||
// clean runtime directory
|
||||
if err := os.RemoveAll(_const.GetRuntimeDir()); err != nil {
|
||||
klog.ErrorS(err, "clean runtime directory error", "pipeline", ctrlclient.ObjectKeyFromObject(m.Pipeline), "runtime_dir", _const.GetRuntimeDir())
|
||||
go func() {
|
||||
if !m.Pipeline.Spec.Debug && m.Pipeline.Status.Phase == kkcorev1.PipelinePhaseSucceed {
|
||||
<-ctx.Done()
|
||||
fmt.Fprintf(m.logOutput, "%s [Pipeline %s] clean runtime directory\n", time.Now().Format(time.TimeOnly+" MST"), ctrlclient.ObjectKeyFromObject(m.Pipeline))
|
||||
// clean runtime directory
|
||||
if err := os.RemoveAll(_const.GetRuntimeDir()); err != nil {
|
||||
klog.ErrorS(err, "clean runtime directory error", "pipeline", ctrlclient.ObjectKeyFromObject(m.Pipeline), "runtime_dir", _const.GetRuntimeDir())
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
// if pipeline is cornJob. it's always running.
|
||||
if m.Pipeline.Spec.JobSpec.Schedule != "" {
|
||||
m.Pipeline.Status.Phase = kkcorev1.PipelinePhaseRunning
|
||||
|
|
|
|||
Loading…
Reference in New Issue