Skip to content

Commit ef89bac

Browse files
committed
++ add delay to test timeouts
Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
1 parent f2160f8 commit ef89bac

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

  • images
    • dvcr-artifact/cmd/dvcr-cleaner/cmd
    • virtualization-artifact/pkg/controller/dvcr-garbage-collection

images/dvcr-artifact/cmd/dvcr-cleaner/cmd/gc.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ func autoCleanupHandler(cmd *cobra.Command, args []string) error {
146146
errs = multierror.Append(errs, cleanupErr)
147147
}
148148

149+
// Testing: print errors if present and sleep before annotate secret.
150+
err = errs.ErrorOrNil()
151+
if err != nil {
152+
fmt.Printf("Error while performAutoCleanup: %v\n", err)
153+
}
154+
// Big delay to test timeouts.
155+
delayDuration := time.Minute * 10
156+
fmt.Printf("Test: sleep for %s before annotate secret as done ... \n", delayDuration.String())
157+
time.Sleep(delayDuration)
158+
// Testing end.
159+
149160
result := map[string]any{
150161
"result": "success",
151162
"startedAt": started,
@@ -189,14 +200,6 @@ func autoCleanupHandler(cmd *cobra.Command, args []string) error {
189200
errs = multierror.Append(errs, secretErr)
190201
}
191202

192-
// Testing: sleep and print errors if present.
193-
time.Sleep(time.Second * 30)
194-
err = errs.ErrorOrNil()
195-
if err != nil {
196-
fmt.Printf("Error while cleaning up stale images after cleanup: %v\n", err)
197-
}
198-
// Testing end.
199-
200203
// Return previous errors, so Pod will be restarted without waiting.
201204
err = errs.ErrorOrNil()
202205
if err != nil {

images/virtualization-artifact/pkg/controller/dvcr-garbage-collection/internal/life_cycle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ func (h LifeCycleHandler) Handle(ctx context.Context, req reconcile.Request, dep
105105
if h.dvcrService.IsGarbageCollectionStarted(secret) {
106106
hasCreationTimestamp := !secret.GetCreationTimestamp().Time.IsZero()
107107
waitDuration := time.Since(secret.GetCreationTimestamp().Time)
108-
if hasCreationTimestamp && waitDuration > dvcrtypes.WaitProvisionersTimeout {
108+
if hasCreationTimestamp && waitDuration > dvcrtypes.GarbageCollectionTimeout {
109109
if h.dvcrService.IsGarbageCollectionResultPersisted(secret, deploy) {
110110
return reconcile.Result{}, h.dvcrService.DeleteGarbageCollectionSecret(ctx)
111111
}
112112

113113
dvcrcondition.UpdateGarbageCollectionCondition(deploy,
114114
dvcrdeploymentcondition.Error,
115115
"Wait for garbage collection more than %s timeout: %s elapsed, garbage collection canceled",
116-
dvcrtypes.WaitProvisionersTimeout.String(),
116+
dvcrtypes.GarbageCollectionTimeout.String(),
117117
waitDuration.String(),
118118
)
119119
annotations.AddAnnotation(deploy, annotations.AnnDVCRGarbageCollectionResult, "")

images/virtualization-artifact/pkg/controller/dvcr-garbage-collection/types/const.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const (
3030
CronSourceNamespace = "__cron_source__"
3131
CronSourceRunGC = "run-gc"
3232

33-
WaitProvisionersTimeout = time.Hour * 2
33+
WaitProvisionersTimeout = time.Minute * 2
34+
GarbageCollectionTimeout = time.Minute * 2
3435
)
3536

3637
func DVCRDeploymentKey() types.NamespacedName {

0 commit comments

Comments
 (0)