-
Notifications
You must be signed in to change notification settings - Fork 82
Do not delete constraint if it is attached #3801
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment - can we just remove the DB cascade and make sure that the DB is guarding us as a list mile?
return errors.Wrapf(err, "while listing Formation Template Constraint References for Constraint with ID %s", id) | ||
} | ||
|
||
formationTemplateIDs := make([]string, 0, len(formationTemplateConstraintReferences)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need this, can we just check the other slice's len?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formationTemplateConstraintReferences is used for the error check and the formationTemplateIDs is used in the error message.
The gathering of the template IDs can be moved inside if len(formationTemplateConstraintReferences) > 0 {
but it wont make any performance difference
@@ -150,6 +151,20 @@ func (s *service) ListByFormationTemplateIDs(ctx context.Context, formationTempl | |||
|
|||
// Delete deletes formation constraint by id | |||
func (s *service) Delete(ctx context.Context, id string) error { | |||
formationTemplateConstraintReferences, err := s.formationTemplateConstraintReferenceRepo.ListByConstraintID(ctx, id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just use exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use Exist - but then we wouldnt know which are the Formation Templates from which the constraint has to be potentialy detached
… dont-delete-attached-constraints
components/director/internal/domain/formationtemplateconstraintreferences/repository.go
Outdated
Show resolved
Hide resolved
...chema-migrator/migrations/director/20240410172316_remove_constrain_cascade_deletion.down.sql
Outdated
Show resolved
Hide resolved
.../schema-migrator/migrations/director/20240410172316_remove_constrain_cascade_deletion.up.sql
Outdated
Show resolved
Hide resolved
tests/director/tests/notifications/application_subscription_notifications_test.go
Outdated
Show resolved
Hide resolved
@StanislavStefanov: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
… dont-delete-attached-constraints
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: la4ezar The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Currently a Formation Constraint can be deleted even if it is attached to a Formation Template. Deleting attached constraint can cause isses with the existing formations or newly created formations from the attached Formation Type.
Changes proposed in this pull request:
Related issue(s)
Pull Request status
chart/compass/values.yaml
is updated