-
Notifications
You must be signed in to change notification settings - Fork 4.8k
🎉 Add create & delete workspaces to API #2325
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
Conversation
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.
The change looks great! added a few comments!
final DestinationConnection dci = configRepository.getDestinationConnection(destinationId); | ||
|
||
if (dci.getTombstone()) { | ||
throw new NotFoundException("Could not find destination"); |
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 send a ConfigNotFoundException
instead?
final SourceConnection sourceConnection = configRepository.getSourceConnection(sourceId); | ||
|
||
if (sourceConnection.getTombstone()) { | ||
throw new NotFoundException("Could not find source connection"); |
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.
Same here
final StandardWorkspace workspace = configRepository.getStandardWorkspace(workspaceId); | ||
|
||
if (workspace.getTombstone()) { | ||
throw new NotFoundException("Could not find workspace"); |
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.
Same here. We can add a boolean to getStandardWorkspace
to indicate if you want to include the tombstone ones or not. This way you can let the config repo throw the ConfigNotFoundException
.
WDYT?
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.
The good thing about adding that boolean is that people will have to make the conscious choice of including tombstoned or not. Less risk of forgetting to filter out the tombstoned
|
||
private StandardWorkspace getWorkspaceBySlug(String slug) | ||
throws JsonValidationException, IOException, KnownException { | ||
for (StandardWorkspace workspace : configRepository.listStandardWorkspaces()) { |
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.
Same idea for the prototype.
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.
Instead actually. What about adding a configRepository::getStandardWorkspaceBySlug (with the tombstone boolean as well)
|
||
final WorkspaceRead created = workspacesHandler.createWorkspace(workspaceCreate); | ||
|
||
assertTrue(created.getWorkspaceId() instanceof UUID); |
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.
The test is a bit brittle here. What about: Injecting the uuid generator in a protected constructor and mock it so you can control the value of the uuid and you can just do a assertEqual(expectedWorkspaceRead, created)
Here is an example of how we do it: io/airbyte/server/handlers/DestinationDefinitionsHandler.java:53
@michel-tricot addressed all your comments & added a 0.17.0 migration |
@cgardens is it too late to include this in 0.17.0 release? |
LGTM! You will just need to rename the migrations (we released 0.17.0 in the meantime). |
I'll merge it after that |
f780bd7
to
cc2d75a
Compare
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.
Hi Sam,
First, sorry for the slow follow up on this. There was some confusion about how was going to follow up on your PR. This was my bad.
Second, thanks for contributing this! It looks great. I have have one last round of comments. I'm hoping they are all clear and straight forward. Of course, let me know if you have any questions.
After that, I will merge this PR (for real this time--I know we said this once before already 😉 ). I don't know what your time looks like right now, so if you can't get to these, it not the end of the world. If you just say, "sorry I'm busy right now", I will just merge the PR as is and tweak the things I mentioned in my review. You've done the hard part, there's just a couple tweaks that I'm seeing based on some knowledge of some weird assumptions that we've made.
Let me know! Looking forward to getting this merged.
initialSetupComplete: | ||
type: boolean | ||
displaySetupWizard: | ||
type: 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.
i think instead of exposing these in the API, you can hide them and just set them to false
in the handler. i thin it's reasonable that these 2 fields will always be false when the workspace is created.
@@ -70,7 +70,7 @@ private static void initialize() { | |||
@VisibleForTesting | |||
static TrackingIdentity getTrackingIdentity(ConfigRepository configRepository, String airbyteVersion) { | |||
try { | |||
final StandardWorkspace workspace = configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID); | |||
final StandardWorkspace workspace = configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID, false); |
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.
to give you a little context, the concept of a "workspace" and a "deployment" are conflated in our system right now. that has been okay so far because there is only one workspace. the reason i mention it, is that we still to be able to use the default workspace for deployment info (even if the default workspace has been deleted).
all that being said, i think that just means we want true
here instead of false. if the default workspace is ever deleted we still want this method to be able to access it.
@@ -9,6 +9,7 @@ required: | |||
- name | |||
- slug | |||
- initialSetupComplete | |||
- tombstone |
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.
in the code i think you already check that if tombstone is not set that we treat it as false. i think that means that this field then doesn't need to be required. making it not required should mean that we should be able to not need to do a migration.
Up to you, if you feel like it should be required, then we can keep the migration and just drop the check you're doing in the config repository. LMK if that's not clear.
@@ -157,7 +157,7 @@ private void checkImport(Path tempFolder) throws IOException, JsonValidationExce | |||
|
|||
private Optional<UUID> getCurrentCustomerId() { | |||
try { | |||
return Optional.of(configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID).getCustomerId()); | |||
return Optional.of(configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID, false).getCustomerId()); |
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.
same here. i think we want true. we want the default workspace to be returned even if deleted here.
final StandardWorkspace standardWorkspace = configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID, false); | ||
if (standardWorkspace != null) | ||
writeConfigsToArchive(storageRoot, ConfigSchema.STANDARD_WORKSPACE, List.of(standardWorkspace)); | ||
else |
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.
final StandardWorkspace standardWorkspace = configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID, false); | |
if (standardWorkspace != null) | |
writeConfigsToArchive(storageRoot, ConfigSchema.STANDARD_WORKSPACE, List.of(standardWorkspace)); | |
else | |
writeConfigsToArchive(storageRoot, ConfigSchema.STANDARD_WORKSPACE, configRepository.listStandardWorkspaces(true)); |
I think we can get rid of lines 75-79 and just replace it with this. we just want to do the list of all workspaces (regardless of whether they've been deleted). github didn't let me include line 79 in the suggestion comment, so unfortunately this suggestion can't be purely committed automatically.
@@ -44,7 +44,7 @@ public HealthCheckHandler(ConfigRepository configRepository) { | |||
public HealthCheckRead health() { | |||
boolean databaseHealth = false; | |||
try { | |||
databaseHealth = configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID) != null; | |||
databaseHealth = configRepository.getStandardWorkspace(PersistenceConstants.DEFAULT_WORKSPACE_ID, false) != 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.
true here too. we don't want the healthcheck to fail because the default workspace was deleted.
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.
amazing! thanks for the fast turn around!
What
Closes #1735
Adds
/workspaces/create
and/workspaces/delete
.How
This adds
tombstone
to the workspace.This also adds a check to prevent returning destinations and sources that have been tombstones.
Questions
I see that you are using
TrackingClientSingleton.get().identify();
when updating a workspace. I don't think we need to do that for the new workspaces - but I leave that decision to you.Pre-merge Checklist
Recommended reading order