Skip to content

api/search: Reset is_automated to false#47465

Merged
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:v26-remove-deprecated
Mar 4, 2024
Merged

api/search: Reset is_automated to false#47465
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:v26-remove-deprecated

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Feb 28, 2024

The field will still be present in the response, but will always be false.
Searching for is-automated=true will yield no results, while is-automated=false will effectively be a no-op.

Signed-off-by: Paweł Gronowski [email protected]

- How to verify it
CI

- Description for the changelog

The `is_automated` field in the `POST /images/search` endpoint results is always `false` now. Consequently, searching for `is-automated=true` will yield no results, while `is-automated=false` will be a no-op.

- A picture of a cute animal (not mandatory but encouraged)

Comment thread api/server/router/image/image_routes.go Outdated
Comment on lines +492 to +500
// "is-automated" is deprecated and was removed in 1.45.
// If the client is older than 1.45, remove the filter to avoid erroring out
// on older clients.
if versions.LessThan(httputils.VersionFromContext(ctx), "1.45") {
for _, v := range searchFilters.Get("is-automated") {
searchFilters.Del("is-automated", v)
}
}

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.

Following our discussion on Slack; I think the plan was to keep the filter, but it would not produce results; from the original PR;

Consequently, searching for is-automated=true will yield no results.

And the change to have IsAutomated always being false would be unversioned;

The deprecation is not versioned, and applies to all API versions.

Motivation there was that the deprecation correlates with the upstream (docker hub) service being in process of deprecating it; IIRC, the field is already out of date with reality, so results are not correct in many cases, thus always setting it to false makes sure that we don't return "bogus" results here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah so with this PR the IsAutomated response will always be false (regardless of API version), but the is-automated filter will always produce an error on API >= 1.45 (it no longer makes sense, so we don't want newer clients to be using it while still keeping old clients working).

Comment thread api/swagger.yaml
@vvoland vvoland force-pushed the v26-remove-deprecated branch 2 times, most recently from b7c982f to 8c1eb86 Compare February 28, 2024 14:48
Copy link
Copy Markdown
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

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

If we're going to make is-automated=false an invalid filter on v1.45+ we should be upfront about that.

Comment thread docs/api/version-history.md Outdated
Comment thread registry/search.go Outdated
Comment on lines +65 to +79
// "is-automated" is deprecated and will always be false
result.IsAutomated = false //nolint:staticcheck // ignore SA1019 (field is deprecated)
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.

If it's deprecated and always false in Hub results, why do we need to explicitly set it to false ourselves?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IIUC, on Hub side this is not always false (yet), it's just deprecated.

But @thaJeztah might have more context here

Comment thread registry/search_test.go
@thaJeztah
Copy link
Copy Markdown
Member

I don't think we need to remove the filter, and just silently ignoring would be fine.

The reason I'd want the field to be reset is that it's very much broken. The v1 search is a bit of a legacy service, and this field is known to be broken. In all honesty, it was announced internally to deprecated that field (as repairing would not be possible), but that task has been kicked around to different teams, so I have no clue when that work continues, other than knowing it's broken, and that it won't be fixed.

@vvoland
Copy link
Copy Markdown
Contributor Author

vvoland commented Feb 28, 2024

I don't think we need to remove the filter, and just silently ignoring would be fine.

What's the point of having that filter on >= 1.45 though? If it's going to be a no-op anyway, we should just get rid of it any only ignore it for older APIs.

@vvoland vvoland force-pushed the v26-remove-deprecated branch from 8c1eb86 to b1039b5 Compare February 28, 2024 16:19
@corhere
Copy link
Copy Markdown
Contributor

corhere commented Feb 28, 2024

What's the point of having that filter on >= 1.45 though?

To not break users' existing workflows.

@vvoland
Copy link
Copy Markdown
Contributor Author

vvoland commented Feb 28, 2024

And it won't break if they pin to an API version before 1.45, where it will just be silently ignored:

// "is-automated" is deprecated and was removed in 1.45.
// If the client is older than 1.45, remove the filter to avoid erroring out
// on older clients.
if versions.LessThan(httputils.VersionFromContext(ctx), "1.45") {
for _, v := range searchFilters.Get("is-automated") {
searchFilters.Del("is-automated", v)
}
}

@vvoland vvoland force-pushed the v26-remove-deprecated branch from b1039b5 to 0e814c8 Compare March 1, 2024 12:22
@vvoland vvoland changed the title api/search: remove is-automated filter api/search: Reset is_automated to false Mar 1, 2024
@vvoland
Copy link
Copy Markdown
Contributor Author

vvoland commented Mar 1, 2024

As discussed in the maintainers call, updated the PR to not remove the filter completely.

@vvoland vvoland force-pushed the v26-remove-deprecated branch 2 times, most recently from 007ae32 to 0f97a09 Compare March 1, 2024 13:50
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread docs/api/version-history.md Outdated
Comment thread registry/search.go Outdated
The field will still be present in the response, but will always be
`false`.
Searching for `is-automated=true` will yield no results, while
`is-automated=false` will effectively be a no-op.

Signed-off-by: Paweł Gronowski <[email protected]>
@vvoland vvoland force-pushed the v26-remove-deprecated branch from 0f97a09 to b292150 Compare March 4, 2024 09:16
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

still LGTM, thanks!

@thaJeztah thaJeztah merged commit 04c9d7f into moby:master Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants