Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.6.x][BACKPORT] seedimage: clean-up service on image download deadline (#719) #901

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion controllers/seedimage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,20 +868,36 @@ func (r *SeedImageReconciler) createBuildImageService(ctx context.Context, seedI
return err
}

seedImageDeadlinePassed := false
if seedImgCondition := meta.FindStatusCondition(seedImg.Status.Conditions, elementalv1.SeedImageConditionReady); seedImgCondition != nil &&
seedImgCondition.Status == metav1.ConditionTrue &&
seedImgCondition.Reason == elementalv1.SeedImageBuildDeadline {
seedImageDeadlinePassed = true
}

if err == nil {
logger.V(5).Info("Service already there")

// ensure the service was created by us
for _, owner := range foundSvc.GetOwnerReferences() {
if owner.UID == seedImg.UID {
// nothing to do
if seedImageDeadlinePassed {
logger.V(5).Info("Seed image deadline passed, delete associated service", "service", foundSvc.Name)
if err := r.Delete(ctx, foundSvc); err != nil {
return fmt.Errorf("failed to delete service %s: %w", foundSvc.Name, err)
}
}
return nil
}
}

return fmt.Errorf("service already exists and was not created by this controller")
}

if seedImageDeadlinePassed {
return nil
}

logger.V(5).Info("Creating service")

service := fillBuildImageService(seedImg.Name, seedImg.Namespace)
Expand Down
Loading