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

Allow simultaneous creation of Component and ImageRepository #137

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions controllers/imagerepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,12 @@ func (r *ImageRepositoryReconciler) ProvisionImageRepository(ctx context.Context
componentKey := types.NamespacedName{Namespace: imageRepository.Namespace, Name: componentName}
if err := r.Client.Get(ctx, componentKey, component); err != nil {
if errors.IsNotFound(err) {
imageRepository.Status.State = imagerepositoryv1alpha1.ImageRepositoryStateFailed
imageRepository.Status.Message = fmt.Sprintf("Component '%s' does not exist", componentName)
if err := r.Client.Status().Update(ctx, imageRepository); err != nil {
log.Error(err, "failed to update imageRepository status", l.Action, l.ActionUpdate)
return err
}
log.Info("attempt to create image repository related to non existing component", "Component", componentName)
return nil
}
log.Error(err, "failed to get component", "ComponentName", componentName, l.Action, l.ActionView)
return err
Expand Down
4 changes: 2 additions & 2 deletions controllers/imagerepository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,10 +1175,10 @@ var _ = Describe("Image repository controller", func() {
})
defer deleteImageRepository(resourceKey)

errorMessage := fmt.Sprintf("Component '%s' does not exist", defaultComponentName)
Eventually(func() bool {
imageRepository := getImageRepository(resourceKey)
return imageRepository.Status.State == imagerepositoryv1alpha1.ImageRepositoryStateFailed &&
imageRepository.Status.Message != ""
return imageRepository.Status.Message == errorMessage
}, timeout, interval).Should(BeTrue())
})

Expand Down
Loading