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(webserver): improve namespace list in files editor #2457

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Skraye
Copy link
Member

@Skraye Skraye commented Nov 6, 2023

Now include namespace that have files & namespace that have flows (or both!)

I've started a flowUtils for test to avoid duplicated utils methods in every controller, but will do another PR as its unrelated to this one.
edit:
close #2452

@Skraye Skraye self-assigned this Nov 6, 2023
@Skraye Skraye force-pushed the feat/improve-files-editor-select branch from e5cb09d to 6365a2b Compare November 7, 2023 08:08
}

protected List<String> distinctNamespacesFiles() throws IOException, URISyntaxException {
return storageInterface.list(tenantService.resolveTenant(), new URI(""))
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't work with S3, idk for GCS, idk if that's the case for localstorage but for eg. in S3 you can't list "" & "/", not sure if it's an implementation issue or a SDK limitation, that's an issue we should adress quickly 🤔
image
image

Btw I think we have an issue as the extension is creating namespace file without a leading '/' and it seems to have an impact on some storage (s3 does, idk for gcs). We might need to discuss whether it is a problem and if we should keep the forward '/' also for namespace files (currently it is only the case for every other files)
image
This change should be made to fix this but we might need to discuss about it
image

Copy link
Member

Choose a reason for hiding this comment

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

We should never list all the internal storage like that.
What you want if I understood, is to list all namespaces that have files. But this is not what you did here as namespaces can have execution data but not files, and in this case, you will still include it in the list.

Moreover, listing like this will bypass security checks on EE so it's really not a good idea.

Comment on lines 122 to 176
public List<String> distinctNamespaces() throws IOException, URISyntaxException {
List<String> storageNamespaces = distinctNamespacesFiles();
List<String> flowNamespaces = flowRepository.findDistinctNamespace(tenantService.resolveTenant());

return Stream.concat(storageNamespaces.stream(), flowNamespaces.stream()).distinct().toList();
}
Copy link
Member

Choose a reason for hiding this comment

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

as in the comment of the issue, I'm not sure the merge should be done at the backend level as it might be interesting for admin purpose to be able to list exclusively namespaces with files

Copy link
Member

Choose a reason for hiding this comment

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

Yes, those are two very different things: flows and namespace files, and we want to display both of them in the editor. So it's the responsibility of the editor to merge them.

Comment on lines 122 to 176
public List<String> distinctNamespaces() throws IOException, URISyntaxException {
List<String> storageNamespaces = distinctNamespacesFiles();
List<String> flowNamespaces = flowRepository.findDistinctNamespace(tenantService.resolveTenant());

return Stream.concat(storageNamespaces.stream(), flowNamespaces.stream()).distinct().toList();
}
Copy link
Member

Choose a reason for hiding this comment

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

Yes, those are two very different things: flows and namespace files, and we want to display both of them in the editor. So it's the responsibility of the editor to merge them.

}

protected List<String> distinctNamespacesFiles() throws IOException, URISyntaxException {
return storageInterface.list(tenantService.resolveTenant(), new URI(""))
Copy link
Member

Choose a reason for hiding this comment

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

We should never list all the internal storage like that.
What you want if I understood, is to list all namespaces that have files. But this is not what you did here as namespaces can have execution data but not files, and in this case, you will still include it in the list.

Moreover, listing like this will bypass security checks on EE so it's really not a good idea.

@Skraye Skraye force-pushed the feat/improve-files-editor-select branch from 15c0b98 to 80c9188 Compare November 10, 2023 09:56
Comment on lines 22 to 23
@Inject NamespaceFileController namespaceFileController;
@Inject FlowController flowController;
Copy link
Member

Choose a reason for hiding this comment

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

I would not use controller inside of controllers, this is kind of strange and breaks some clean architecture rules.
Controllers are here to deals with the HTTP layer, by directly calling it's method out of an HTTP context you may breaks things.

Better to use the repository here.

@@ -2,6 +2,7 @@

import io.kestra.core.storages.FileAttributes;
import io.kestra.core.storages.StorageInterface;
import io.kestra.core.utils.IdUtils;
Copy link
Member

Choose a reason for hiding this comment

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

Unused import

Comment on lines 165 to 166
return storageInterface.list(tenantService.resolveTenant(), null)
.stream()
Copy link
Member

Choose a reason for hiding this comment

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

Already said (and explained why) it's a bad idea but I will not block the PR for that if nobody else object.

Copy link
Member

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

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

Still think it's not a good idea to list all internal storage root directories like that but I will not argue anymore about it.

@@ -20,12 +21,15 @@
import lombok.extern.slf4j.Slf4j;

import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.ByteArrayInputStream;
Copy link
Member

Choose a reason for hiding this comment

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

This import didn't seems to be used anywhere

@Skraye
Copy link
Member Author

Skraye commented Nov 15, 2023

It will probably be done in the next release as for now, there is no easy way to list namespaceFiles following the refacto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants