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

feat(compass-indexes): poll rolling indexes COMPASS-8217 #6290

Closed
wants to merge 9 commits into from

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented Sep 26, 2024

Very much in-progress.

Thinking is to have real/regular indexes, in-progress regular indexes and rolling indexes as three separate lists with no merging happening in the store. Then to do any merging / concatenation that's necessary in the table only.

The problem is that the three things' types are very different. So even then it still leaves the question of whether to map to some common type in the store side or only in the UI. And what to do with all the columns' components: At which point does the component take all three types vs just creating specialised components rather?

@@ -40,7 +47,10 @@ const IndexActions: React.FunctionComponent<IndexActionsProps> = ({
},
];

if (serverSupportsHideIndex(serverVersion)) {
if (
index.compassIndexType === 'regular-index' &&
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 was a bug - we showed the hide button for in-progress indexes.

@@ -58,6 +64,19 @@ const IndexActions: React.FunctionComponent<IndexActionsProps> = ({
);
}

// you can only drop regular indexes or failed inprogress indexes
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 was also a bug - you could drop an in progress index that was really still in progress and that just wouldn't work because the index creation isn't failed and it isn't a real index yet either.


// TODO: this should be its own function, not part of dropIndex
Copy link
Contributor Author

@lerouxb lerouxb Sep 26, 2024

Choose a reason for hiding this comment

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

There was actually momentarily a bug here. Because I'm not merging the in-progress indexes into indexes, the code:

const index = indexes.find((x) => x.name === indexName);

    if (!index) {
      return;
    }

which ran first meant that you could never get to the check to see if the thing is an in-progress index. Which wasn't as obvious to find and I think if the two things weren't both rolled into dropIndex() then it would have been easier to spot, more likely to be tested, etc.

type: React.ReactNode;
size: React.ReactNode;
usage: React.ReactNode;
usageCount: React.ReactNode;
Copy link
Contributor Author

@lerouxb lerouxb Sep 26, 2024

Choose a reason for hiding this comment

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

We were changing usageCount into usage back into usageCount..

// TODO: check that label really is a regular index type
type: (
<TypeField
type={index.indexType.label as RegularIndex['type']}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would be nice if the type could already be narrowed from string to a regular index type somehow.

dbName: string;
indexName: string;
indexProperties: { label: string; properties: Record<string, unknown> }[];
indexType: { label: string };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird that it is { label } and not immediately just the string. Trying to figure out where would be the ideal place to turn that string into an exact index type.

@@ -1,3 +1,14 @@
export type AtlasIndexStats = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry to comment on this, i randomly clicked on the pr and it caught my eye, definitely a nit, and a question also for @gribnoysup.

Isn't this inconsistent with the rest of the design of AtlasService? For the way it is setup for other calls we shouldn't have domain related concepts and types on the atlas service directly, and they should live inside the services that are related to those domains.

It should all still work with the generic, just the definition of the type doesn't seem to fit the rest of the design. Unless something changed recently.

Copy link
Collaborator

@gribnoysup gribnoysup Sep 27, 2024

Choose a reason for hiding this comment

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

Le Roux is just moving types here, so it's coming from my initial implementation of the automation agent request helper, so you can definitely blame me for that 😄

I think it's fair that this is maybe giving this service too much knowledge about the API, but the API is not very consistent and requires to know more about what commands specifically are being executed if we want to have a single way of doing these two-part agent requests. See here for example, certain types of automation agent requests don't return a request id we can wait on, so we need a narrow typing to know what are those cases, the request params and the way response is wrapped in await is also based on the command you're sending, etc.

We can change this to a generic type and move narrower domain specific stuff to rolling indexes, we'd also need to make the assertions we're doing inside the method configurable from outside, or just dismantle this helper in two methods that just know the URL shape for creating these requests and then we re-assemble it into the same logic separately for global writes and rolling indexes. Not very "dry", but it's also just two features we need this for right now, so might be worth it to remove the types from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually have a bunch of scattered TODO comments/reminders to talk about this. This type doesn't map well to our own index type at all and I'm not 100% sure where we should do the mapping/assertions.

Copy link
Collaborator

@mcasimir mcasimir Sep 30, 2024

Choose a reason for hiding this comment

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

Apologies if i'm misunderstanding the code, looking at

// Rolling index creation request doesn't return anything that we can "await"
// on (a successful response is already an acknowledgement that request to
// create an index was registered), so we just end here
if (opType === 'index') {
return undefined as AutomationAgentResponse<OpType>;
}
making this behaviour configurable from outside and externalizing the type seems definitely the right thing to do (assuming that we want to keep AtlasService as a building block for domain specific services).

The fact that you need ifs by "opType" there means that we are mixing up responsibilities already, and is not obvious at all what is happening there. It looks also pretty simple to just split that method in two makeAutomationAgentOpRequest<RT> and makeAutomationAgentOpRequestAndWait<RT> so we don't rely on too many parameters and ifs.

can definitely blame me for that

No blame at all!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, we'll split it into parts

cc @mabaasit just FYI you'd need to account for that for Global Writes implementation

Copy link
Collaborator

Choose a reason for hiding this comment

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

Opened #6305 to make the split

@lerouxb
Copy link
Contributor Author

lerouxb commented Sep 30, 2024

Closing in favour of #6300

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