Skip to content

Restore service binding ordering in sys env presenter - #4665

Merged
Samze merged 1 commit into
mainfrom
restore_binding_order
Nov 19, 2025
Merged

Restore service binding ordering in sys env presenter#4665
Samze merged 1 commit into
mainfrom
restore_binding_order

Conversation

@Samze

@Samze Samze commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

The ordering of multiple service bindings for the same service with VCAP service has changed. They are now sorted by service instance guid and not service binding id. This was implicit behaviour.

While clients should be inspecting the binding
object itslef and not relying on the index, unfortunately not all clients do that.

This appears to have been introduced as part of this commit to support binding rotation 79b4da3 and this migration f011651 which contains:

add_index %i[app_guid service_instance_guid], name: :service_bindings_app_guid_service_instance_guid_index

I believe the introduction of the index means that the query to obtain the binding list now uses this index, and it uses the order of that index, which is by service_instance_guid rather than previously which would have been the natural order by id.

This change restores the previous behaviour by explicitly specifying the ordering.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@Samze Samze changed the title Restore service binding ordering Restore service binding ordering in sys env presenter Nov 19, 2025
The ordering of multiple service bindings for the same service with VCAP
service has changed. They are now sorted by service instance guid and
not service binding id. This was implicit behaviour.

While clients should be inspecting the binding
object itslef and not relying on the index, unfortunately not all clients
do that.

This appears to have been introduced as part of this commit to support binding rotation
79b4da3#diff-403a1ff3052c3335b1d4f0db3569c895bf7ba4ca01539c562d009394c907d64bR148  and this migration f011651
and I believe the introduction of the index:
```
add_index %i[app_guid service_instance_guid], name: :service_bindings_app_guid_service_instance_guid_index
```

Means that the query to obtain the binding list now uses this index, and it uses the
natural order of that index, which is by service_instance_guid
rather than previously which would have been the natural order by id.

This change restores the previous behaviour by explicitly specifying the
ordering.
@Samze
Samze force-pushed the restore_binding_order branch from 5326f16 to 78b68cd Compare November 19, 2025 18:59
@Samze
Samze requested review from johha, philippthun and sethboyles and removed request for johha November 19, 2025 20:25

@johha johha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM - Thanks for fixing!

@philippthun philippthun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting finding. It might be a combination of the new index (app_guid + service_instance_guid) and the window function that groups by service_instance_guid - that's what ChatGPT explained to me and it sounds reasonable.

@Samze
Samze merged commit 9cf1846 into main Nov 19, 2025
16 of 17 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Nov 19, 2025
Changes in cloud_controller_ng:

- Restore service binding ordering in sys env presenter
    PR: cloudfoundry/cloud_controller_ng#4665
    Author: Sam Gunaratne <385176+Samze@users.noreply.github.com>
@Samze
Samze deleted the restore_binding_order branch November 19, 2025 22:30
sethboyles pushed a commit to atanas-attodorov-wq/cloud_controller_ng that referenced this pull request Dec 11, 2025
)

The ordering of multiple service bindings for the same service with VCAP
service has changed. They are now sorted by service instance guid and
not service binding id. This was implicit behaviour.

While clients should be inspecting the binding
object itslef and not relying on the index, unfortunately not all clients
do that.

This appears to have been introduced as part of this commit to support binding rotation
cloudfoundry@79b4da3#diff-403a1ff3052c3335b1d4f0db3569c895bf7ba4ca01539c562d009394c907d64bR148  and this migration cloudfoundry@f011651
and I believe the introduction of the index:
```
add_index %i[app_guid service_instance_guid], name: :service_bindings_app_guid_service_instance_guid_index
```

Means that the query to obtain the binding list now uses this index, and it uses the
natural order of that index, which is by service_instance_guid
rather than previously which would have been the natural order by id.

This change restores the previous behaviour by explicitly specifying the
ordering.
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.

5 participants