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

feat: STREAMP-8526, STREAMP-10704: Support zone and infrastructure deletion #356

Conversation

rahul-9337
Copy link
Contributor

stream-registry PR

<High level description of the PR>

Added

  • <detail item of what was added>
  • <describe functionality added>

Changed

  • <detail item of what was changed>
  • _<describe functionality that was changed>
  • _<in particular, describe BACKWARD INCOMPATIBLE changes>

Deleted

  • <detail item of what was removed>

PR Checklist Forms

  • CHANGELOG.md updated
  • Reviewer assigned
  • PR assigned (presumably to submitter)
  • Labels added (enhancement, bug, documentation)

@rahul-9337 rahul-9337 marked this pull request as draft April 25, 2024 07:24
.findAll(pb -> pb.getKey().getInfrastructureName().equals(infrastructure.getKey().getName()))
.findAny()
.ifPresent(pb -> { throw new IllegalStateException("Infrastructure is used in producer binding: " + pb.getKey()); });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no reference of infrastructure in process binding.
Do we need to check using zone?

processBindingView
      .findAll(pb -> pb.getKey().getInfrastructureZone().equals(infrastructure.getKey().getZone()))
      .findAny()
      .ifPresent(pb -> { throw new IllegalStateException("Infrastructure is used in process binding: " + pb.getKey()); });

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, the ProcessBinding -> Infrastructure reference is indirect via the StreamBinding on inputs and outputs.

I feel like we should be as defensive as possible and still do the check on those inputs/outputs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally look here. It's currently possible to delete a StreamBinding when there is a reference it from a ProcessBinding. This could lead to dodgy data and orphaned entities.

@rahul-9337 rahul-9337 marked this pull request as ready for review April 25, 2024 11:10
@jamespfaulkner
Copy link
Contributor

We need to update InfrastructureTestStage and ZoneTestStage

@@ -97,6 +99,12 @@ public void upsert() {
@Override
public void delete() {
//not implemented for infrastructure
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs removing 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now removed 👍


private boolean isZoneUsedInProcessBindingOutput(Zone zone, ProcessBinding processBinding) {
return processBinding.getOutputs().stream().map(o -> o.getStreamBindingKey().getInfrastructureZone()).toList()
.contains(zone.getKey().getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any need for the toList.contains()? I think we can use anyMatch()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's not required to convert to list unnecessarily. I'll replace it with anyMatch()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

throw new UnsupportedOperationException("Infrastructure deletion not currently supported.");
handlerService.handleDelete(infrastructure);
streamBindingView
.findAll(sb -> sb.getKey().getInfrastructureName().equals(infrastructure.getKey().getName()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Third time looking at this PR and just noticed, shouldn't this be comparing on the InfrastructureKey, not the Infrastructure name?

Suggested change
.findAll(sb -> sb.getKey().getInfrastructureName().equals(infrastructure.getKey().getName()))
.findAll(sb -> sb.getKey().getInfrastructureKey().equals(infrastructure.getKey()))

Copy link
Contributor

Choose a reason for hiding this comment

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

The name and the zone together identify an Infra

@jamespfaulkner jamespfaulkner merged commit cd57681 into ExpediaGroup:master May 7, 2024
1 check passed
@rahul-9337 rahul-9337 deleted the feat/support-zone-and-infra-deletion branch May 7, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants