-
Notifications
You must be signed in to change notification settings - Fork 188
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(global-writes): add unsharded state COMPASS-8276 #6289
Conversation
createShardkey: { | ||
isLoading: boolean; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not part of the tech doc, but while working on this, I realzied we need to disable the create-shard-button and added this. as an alternative, we can also await on the dispatch action on the react side and while its waiting we disable the button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify why is this not just part of sharding status? I'm maybe missing the purpose, but this seems like just part of the status transition for creation flow, so why are we moving this state into its own field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a state between UNSHARDED
and SHARDING
, time duration for which user clicks the create shard key and server acknowledges the change - keeps the button disabled, and for error shows the toast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this loading state is mutually exclusive with all the other states, is that correct? If yes, in that case we should just add it as another state in list of available state transitions for the component, using multiple states to declare mutually exclusive, state-machine-like, states of the application can lead to potentially weird cases and hard to reason about logic as it basically allows application to be in multiple states at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's correct. It does make sense to add these to the state as well, its just that I think the list will grow a little and in such case, i find it a bit hard to maintain the transitions.
But I will try to do that. Thanks for the suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in 23c1361
}); | ||
return; | ||
} | ||
// TODO (COMPASS-8277): Now fetch the sharding key and possible process error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here in the follow up tickets, we want to fetch the shard keys and also the agent process errors and based on that information, transition to other states. Currently this leaves user in a loading state, but i think that's fine with the current state of the project.
openToast('global-writes-fetch-shard-info-error', { | ||
title: `Failed to fetch sharding information: ${ | ||
(error as Error).message | ||
}`, | ||
dismissible: true, | ||
timeout: 5000, | ||
variant: 'important', | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also want to have another state like ERROR
or something, where user does not see loading and can see the error and possibly an action to refetch.
import type { AtlasService } from '@mongodb-js/atlas-service/provider'; | ||
import type { CreateShardKeyData } from '../store/reducer'; | ||
|
||
type ZoneMapping = unknown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaving it unknow for now, will implement it when needed
case ShardingStatuses.NOT_READY: | ||
return ( | ||
<div className={centeredContent}> | ||
<SpinLoaderWithLabel progressText="Loading ..." /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<SpinLoaderWithLabel progressText="Loading ..." /> | |
<SpinLoaderWithLabel progressText="Loading …" /> |
return ( | ||
<div className={containerStyles}> | ||
<Banner variant={BannerVariant.Info}> | ||
<strong>Sharding your collection ...</strong> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<strong>Sharding your collection ...</strong> | |
<strong>Sharding your collection …</strong> |
(or I guess you can … like the ' below – but just fyi, ' is just a literal '
that you don't really need to escape here anyway. And even more pedantically, you'd want to use ‘ ’
instead of '
😄)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in 3b384fc
'AtlasFetchError', | ||
'Error creating cluster shard key', | ||
{ | ||
error: error as Error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can log literal Error
objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed to log the message only
>; | ||
|
||
enum GlobalWritesActionTypes { | ||
SetIsManagedNamespace = 'global-writes/SetIsManagedNamespace', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid setter actions. What is the actual event that happens in the app here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in a0eb2be.
this action is dispatched after we call the api to check if the namespace is managed or not, in fetchClusterShardingData
action.
function getStateViewBasedOnShardingStatus(shardingStatus: ShardingStatus) { | ||
switch (shardingStatus) { | ||
case ShardingStatuses.NOT_READY: | ||
return ( | ||
<div className={centeredContent}> | ||
<SpinLoaderWithLabel progressText="Loading …" /> | ||
</div> | ||
); | ||
case ShardingStatuses.UNSHARDED: | ||
return <UnshardedState />; | ||
case ShardingStatuses.SHARDING: | ||
return <ShardingState />; | ||
default: | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this is just a React component that is written like a plain function, I'd suggest we don't do that because you loose some React functionality that might come in handy like memoing the component or the ability to safely use hooks inside this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 5f03a49
createShardkey: { | ||
isLoading: boolean; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify why is this not just part of sharding status? I'm maybe missing the purpose, but this seems like just part of the status transition for creation flow, so why are we moving this state into its own field?
I added some spacing to avoid this in eca4068 (but only for the radio options and aligned checkbox accordingly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This PR includes:
Preview
Tab Warning
Unsharded State
Sharding State (more work in next ticket)
Description
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes