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

Refactor handling of non-managed resources #1360

Merged
merged 6 commits into from
Feb 6, 2025
Merged

Refactor handling of non-managed resources #1360

merged 6 commits into from
Feb 6, 2025

Conversation

csutter
Copy link
Contributor

@csutter csutter commented Feb 6, 2025

We currently need the GCP "name" (actually a path/unique identifier!) for two resources that aren't managed by Search Admin:

  • Controls need the name of our default engine (as they are created as child resources on the engine)
  • Control::BoostActions and Control::FilterActions need the name of our default data store (as that is the data store they are active against).

So far we have been setting separate environment variables for the data store and engine on the app (one of these was missing in a previous PR causing a bug). But both of these share a common parent (the GCP project's default collection), so we only really need to configure that and infer the data store and engine name based on that.

This PR:

  • refactors the current setup to actually model DataStore and Engine as classes, with a single default instance, and uses those in Control and its actions
  • removes superfluous/erroneous configuration
  • generalises naming of all Discovery Engine resources into a DiscoveryNameable mixin
  • Adds the Control's GCP name to the UI to help with future debugging/correlation with the Google Cloud Console

Screenshots

image

These are plain Ruby objects representing the concepts of engine and
data store on Discovery Engine.

Our architecture only has a single one of each, and that is unlikely to
change in the medium term, so these are not persisted in the database
but rather just have a single default instance available as `.default`.
This changes `Control` and its actions to use the new models instead of
getting their engine and data store names straight from the Rails
config.
This removes the unnecessary configuration of a data store, and also
removes the erroneous test environment configuration for engine that was
left in as part of a previous PR.
This refactors the repetitive name generation into a
`DiscoveryEngineNameable` mixin.
This could come in helpful for debugging.
Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

The changes look good, except that I've tripped over the naming again. You can see my full confusion in the inline comments 😅

Anything that removes unnecessary config is a plus 🪇

This is a more sensible name that doesn't cause confusion around
"engines".
# parent resource is not the default collection.
module DiscoveryEngineNameable
# The name (fully qualified path) of this Discovery Engine resource on GCP
def name
[parent_name, resource_path_fragment, discovery_engine_id].join("/")
[parent_name, resource_path_fragment, remote_resource_id].join("/")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a much better name. Thanks for updating! ⭐

@csutter csutter merged commit 6d18db8 into main Feb 6, 2025
10 checks passed
@csutter csutter deleted the fix-engine branch February 6, 2025 16:42
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