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

api: set last index and request time on alloc stop #16319

Merged
merged 5 commits into from
Mar 3, 2023

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented Mar 3, 2023

Some of the methods in Allocations() incorrectly use the putQuery in API calls where put is more appropriate since they are not reading information back. These methods are also not returning request metadata such as LastIndex back to callers, which can be useful to have in some scenarios.

They also provide poor developer experience as they take an *api.Allocation struct when only the allocation ID is necessary. This can lead consumers to make unnecessary API calls to fetch the full allocation.

Fixing these problems require updating the methods' signatures so they take *WriteOptions instead of *QueryOptions and return *WriteMeta, but this is a breaking change that requires advanced notice to consumers.

This commit adds a future breaking change notice and also fixes the Stop method so it properly returns request metadata in a backwards compatible way.

Some of the methods in `Allocations()` incorrectly use the `putQuery`
in API calls where `put` is more appropriate since they are not reading
information back. These methods are also not returning request metadata
such as `LastIndex` back to callers, which can be useful to have in some
scenarios.

They also provide poor developer experience as they take an
`*api.Allocation` struct when only the allocation ID is necessary. This
can lead consumers to make unnecessary API calls to fetch the full
allocation.

Fixing these problems require updating the methods' signatures so they
take `*WriteOptions` instead of `*QueryOptions` and return `*WriteMeta`,
but this is a breaking change that requires advanced notice to consumers.

This commit adds a future breaking change notice and also fixes the
`Stop` method so it properly returns request metadata in a backwards
compatible way.
@@ -0,0 +1,3 @@
```release-note:bug
api: Fix `Allocations().Stop()` method to properly set the request `LastIndex` and `RequestTime` in the response
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 the only user facing change, but should I note the future breaking changes somehow?

Copy link
Member

Choose a reason for hiding this comment

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

make cl has a deprecation option, so I think we can add the release-note:deprecation to this file for those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice. I added the deprecation notes and I also remembered that I added RestartAllTasks() method to prevent a breaking change. Since we're breaking things already we may as well clean that up.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

I've left an item to fix but once that's accepted LGTM!

@@ -0,0 +1,3 @@
```release-note:bug
api: Fix `Allocations().Stop()` method to properly set the request `LastIndex` and `RequestTime` in the response
Copy link
Member

Choose a reason for hiding this comment

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

make cl has a deprecation option, so I think we can add the release-note:deprecation to this file for those.

api/allocations.go Outdated Show resolved Hide resolved
@lgfa29 lgfa29 merged commit b24dddc into main Mar 3, 2023
@lgfa29 lgfa29 deleted the api-fix-alloc-stop-index branch March 3, 2023 20:52
@lgfa29 lgfa29 added the backport/1.5.x backport to 1.5.x release line label Mar 3, 2023
philrenaud pushed a commit that referenced this pull request Mar 14, 2023
Some of the methods in `Allocations()` incorrectly use the `putQuery`
in API calls where `put` is more appropriate since they are not reading
information back. These methods are also not returning request metadata
such as `LastIndex` back to callers, which can be useful to have in some
scenarios.

They also provide poor developer experience as they take an
`*api.Allocation` struct when only the allocation ID is necessary. This
can lead consumers to make unnecessary API calls to fetch the full
allocation.

Fixing these problems require updating the methods' signatures so they
take `*WriteOptions` instead of `*QueryOptions` and return `*WriteMeta`,
but this is a breaking change that requires advanced notice to consumers.

This commit adds a future breaking change notice and also fixes the
`Stop` method so it properly returns request metadata in a backwards
compatible way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.5.x backport to 1.5.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants