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

fix: removed redundant data from service_instance_details table #1109

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

ifindlay-cci
Copy link
Contributor

removed OperationID and OperationType from service_instance_details table.

Storing this data in the service_instance_details table is redundant, since this information is also stored the terraform_deployment table. If these two sources of truth became inconsistent, there is a possiblity that a service details could be deleted incorrectly following a failed deletion. Having a single source of truth prevents this incorrect behaviour.

#TPCF-26508

Checklist:

  • Have you added or updated tests to validate the changed functionality?
  • Have you added Release Notes in the docs repositories?
  • Have you followed the Conventional Commits specification?

…ils table.

Storing this data in the service_instance_details table is redundant, since this information is also stored the terraform_deployment table.
If these two sources of truth became inconsistent, there is a possiblity that a service details could be deleted incorrectly following a failed deletion. Having a single source of truth prevents this incorrect behaviour.

[#TPCF-26508](https://vmw-jira.broadcom.com/browse/TPCF-26508)
Copy link
Member

@blgm blgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. There are a few minor cosmetic improvements, but it's a good improvement that leave the code tidier - and fixes a bad bug.

@@ -94,6 +94,8 @@ func (broker *ServiceBroker) Deprovision(ctx context.Context, instanceID string,
return domain.DeprovisionServiceSpec{}, err
}

fmt.Println("serviceProvider Deprovsion")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

@@ -31,12 +31,11 @@ func (broker *ServiceBroker) LastOperation(ctx context.Context, instanceID strin

_, serviceProvider, err := broker.getDefinitionAndProvider(instance.ServiceGUID)
if err != nil {
broker.Logger.Info("XXXX getDefinitionAndProvider", correlation.ID(ctx), lager.Data{"err": err})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

brokerapi/broker/provision.go Outdated Show resolved Hide resolved
@@ -128,6 +128,14 @@ func RunMigrations(db *gorm.DB) error {
return autoMigrateTables(db, &models.BindRequestDetailsV1{})
}

migrations[16] = func() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doable in a single migration:

migrations[16] = func() error {
  if err := db.Migrator().DropColumn(&models.ServiceInstanceDetailsV3{}, "operation_type"); err != nil {
    return err
  }
  return db.Migrator().DropColumn(&models.ServiceInstanceDetailsV3{}, "operation_id")
}

But I'm not such which approach is best. Given I can't find an argument that a single migration is "better" then maybe leave it as it is.

@@ -12,6 +13,8 @@ import (

// Deprovision performs a terraform destroy on the instance.
func (provider *TerraformProvider) Deprovision(ctx context.Context, instanceGUID string, vc *varcontext.VarContext) (*string, error) {
fmt.Println("XXXXX YO")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

@@ -22,6 +25,7 @@ func (provider *TerraformProvider) Deprovision(ctx context.Context, instanceGUID
return nil, err
}

fmt.Println("provider.destror")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

@ifindlay-cci ifindlay-cci merged commit eabd3d6 into main Oct 3, 2024
8 checks passed
@ifindlay-cci ifindlay-cci deleted the fix_tpcf-26508-missing-instances branch October 3, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants