Skip to content

daemon: split image search to a separate service#44032

Draft
thaJeztah wants to merge 5 commits intomoby:masterfrom
thaJeztah:search_split_search_service
Draft

daemon: split image search to a separate service#44032
thaJeztah wants to merge 5 commits intomoby:masterfrom
thaJeztah:search_split_search_service

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

This extracts the image search to its own service, as searching a registry for images does not depend on functionality of the image service.

See individual commits for details.

@thaJeztah thaJeztah added area/api API area/distribution Image Distribution status/2-code-review area/images Image Distribution kind/refactor PR's that refactor, or clean-up code containerd-integration Issues and PRs related to containerd integration labels Aug 25, 2022
@thaJeztah thaJeztah added this to the v-next milestone Aug 25, 2022
@thaJeztah thaJeztah force-pushed the search_split_search_service branch 2 times, most recently from 57aacfc to 74ae853 Compare August 25, 2022 13:06
Comment on lines +20 to +24
func NewRouter(backend Backend, referenceBackend reference.Store, imageStore image.Store, layerStore layer.Store) router.Router {
func NewRouter(backend Backend, searchBackend SearchBackend, referenceBackend reference.Store, imageStore image.Store, layerStore layer.Store) router.Router {
ir := &imageRouter{
backend: backend,
searchBackend: searchBackend,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FWIW; perhaps this should be a separate router, but we can do so in a follow-up. I kept it here, as the endpoint is still /images/search, so it felt like for the "router" it still made sense to have it here

@thaJeztah thaJeztah marked this pull request as ready for review August 25, 2022 13:14
@thaJeztah
Copy link
Copy Markdown
Member Author

Ah, dang; forgot to GoDoc this one

api/server/router/image/backend.go:43:6: exported: exported type SearchBackend should have comment or be unexported (revive)
type SearchBackend interface {
     ^

@thaJeztah thaJeztah force-pushed the search_split_search_service branch from 74ae853 to 9192fdb Compare August 25, 2022 14:06
@thaJeztah thaJeztah requested review from corhere, rumpl and tianon August 25, 2022 16:30
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.

The registry config is reloadable so any config updates need to also be propagated into SearchService. (And despite being synchronized with a mutex, the config reload is not atomic! 🤦) Perhaps introduce a "registry config store" which holds the config and is passed into both registry services? E.g.:

package registry

type ConfigStore struct {
        v atomic.Value // or go1.19 atomic.Pointer[serviceConfig]
}

func (s ConfigStore) get() *serviceConfig {
        p := s.v.Load()
        if p == nil {
                return emptyServiceConfig
        }
        return p.(*serviceConfig)
}

func (s ConfigStore) Set(opts ServiceOptions) error {
        cfg, err := newServiceConfig(opts)
        if err != nil {
                return err
        }
        s.v.Store(cfg)
        return nil
}

@thaJeztah
Copy link
Copy Markdown
Member Author

Ah, good one; I didn't think of reloading "insecure registries" (does it use mirrors?) for this one. 🤔

@thaJeztah thaJeztah force-pushed the search_split_search_service branch from 9192fdb to 7689955 Compare January 3, 2023 15:44
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.

See my earlier review.

Moves the TestPingRegistryEndpoint and TestEndpoint tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Also touching-up some comments.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This extracts the image search to its own service, as searching a registry
for images does not depend on functionality of the image service.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
There's only a single implementation, so no need to return an
interface.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the search_split_search_service branch from 7689955 to 22e3724 Compare January 10, 2023 16:06
@thaJeztah
Copy link
Copy Markdown
Member Author

See my earlier review.

Oh, sorry, yes, I only did a rebase to prevent it fully bit-rotting; need to reserve some time to find the best approach for the config reloading part. Ignore for now, I'll give a ping when I found time for that 😅

@thaJeztah thaJeztah marked this pull request as draft January 10, 2023 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/distribution Image Distribution area/images Image Distribution kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants