Skip to content

Commit

Permalink
move s3 obj deletion to end and unblock
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Landgraf committed Jan 12, 2021
1 parent 5c5fe8a commit 2244a08
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions backend/objstore/health_objstore.go
Expand Up @@ -69,22 +69,6 @@ func (h *HealthCheck) HealthCheck(ctx context.Context) servicehealthcheck.Health
}
defer obj.Close()

// in case the bucket is versioned, delete versions to not leak versions
if info.VersionID != "" {
err = h.Client.RemoveObject(
ctx,
cfg.HealthCheckBucketName,
cfg.HealthCheckObjectName,
minio.RemoveObjectOptions{
GovernanceBypass: true, // there is no reason to store health checks
VersionID: info.VersionID,
})
if err != nil {
log.Ctx(ctx).Err(err).Msgf("failed to delete version %q of %q in bucket %q",
info.VersionID, cfg.HealthCheckObjectName, cfg.HealthCheckBucketName)
}
}

// Assert expectations
buf, err := ioutil.ReadAll(obj)
if err != nil {
Expand All @@ -101,6 +85,24 @@ func (h *HealthCheck) HealthCheck(ctx context.Context) servicehealthcheck.Health
return h.state.GetState()
}

// in case the bucket is versioned, delete versions to not leak versions
if info.VersionID != "" {
go func() {
err = h.Client.RemoveObject(
ctx,
cfg.HealthCheckBucketName,
cfg.HealthCheckObjectName,
minio.RemoveObjectOptions{
GovernanceBypass: true, // there is no reason to store health checks
VersionID: info.VersionID,
})
if err != nil {
log.Ctx(ctx).Err(err).Msgf("failed to delete version %q of %q in bucket %q",
info.VersionID, cfg.HealthCheckObjectName, cfg.HealthCheckBucketName)
}
}()
}

healthy:
// If uploading and downloading worked set the Health Check to healthy
h.state.SetHealthy()
Expand Down

0 comments on commit 2244a08

Please sign in to comment.