Skip to content

Commit

Permalink
Merge pull request #19 from mercedes-benz/decouple_image_to_pool_depe…
Browse files Browse the repository at this point in the history
…ndency

feat: allow image deletion for deleted pools
  • Loading branch information
rafalgalaw authored Oct 24, 2023
2 parents cf3cea0 + acd5461 commit 4a27765
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions api/v1alpha1/image_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ func (i *Image) attachedPools(ctx context.Context) ([]Pool, error) {
}

for _, pool := range pools.Items {
if pool.Spec.ImageName == i.Name {
result = append(result, pool)
// we do not care about pools that are already deleted
if pool.GetDeletionTimestamp() == nil {
if pool.Spec.ImageName == i.Name {
result = append(result, pool)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/pool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (r *Pool) ValidateCreate() (admission.Warnings, error) {
if len(poolList.Items) > 0 {
existing := poolList.Items[0]
return nil, apierrors.NewBadRequest(
fmt.Sprintf("can not create pool, pool=%s with same image=%s , flavor=%s and provider=%s already exists for specified GitHubScope=%s", existing.Name, existing.Spec.ImageName, existing.Spec.Flavor, existing.Spec.ProviderName, existing.Spec.GitHubScopeRef.Name))
fmt.Sprintf("can not create pool, pool=%s with same image=%s, flavor=%s and provider=%s already exists for specified GitHubScope=%s", existing.Name, existing.Spec.ImageName, existing.Spec.Flavor, existing.Spec.ProviderName, existing.Spec.GitHubScopeRef.Name))
}

return nil, nil
Expand Down

0 comments on commit 4a27765

Please sign in to comment.