refactor: refactor code and fix ut (#709)

* feat: ut (#707)

* feat: ut (#708)
This commit is contained in:
naison
2025-08-24 16:46:09 +08:00
committed by GitHub
parent 3a4dbe41c7
commit 0548c5a8a0
7 changed files with 86 additions and 52 deletions

View File

@@ -122,6 +122,8 @@ func (d *SyncOptions) DoSync(ctx context.Context, kubeconfigJsonBytes []byte, im
"origin-workload": originName,
}
u.SetLabels(labels.Merge(u.GetLabels(), labelsMap))
// for leave resource and disconnect from cluster
u.SetDeletionGracePeriodSeconds(ptr.To[int64](60))
var path []string
var spec *v1.PodTemplateSpec
spec, path, err = util.GetPodTemplateSpecPath(u)
@@ -489,6 +491,13 @@ func (d *SyncOptions) Cleanup(ctx context.Context, workloads ...string) error {
}
}
}
for _, workload := range d.Workloads {
plog.G(ctx).Infof("Wait workload %s", workload)
err := util.RolloutStatus(ctx, d.factory, d.Namespace, workload, time.Minute*60)
if err != nil {
plog.G(ctx).Warnf("Failed to rollback workload %s: %v", workload, err)
}
}
return nil
}