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
base: develop
Are you sure you want to change the base?
Conversation
e5cb09d
to
6365a2b
Compare
} | ||
|
||
protected List<String> distinctNamespacesFiles() throws IOException, URISyntaxException { | ||
return storageInterface.list(tenantService.resolveTenant(), new URI("")) |
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.
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 🤔
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)
This change should be made to fix this but we might need to discuss about it
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 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.
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(); | ||
} |
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.
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
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, 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.
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(); | ||
} |
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, 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("")) |
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 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.
6365a2b
to
15c0b98
Compare
15c0b98
to
80c9188
Compare
@Inject NamespaceFileController namespaceFileController; | ||
@Inject FlowController flowController; |
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 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; |
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.
Unused import
return storageInterface.list(tenantService.resolveTenant(), null) | ||
.stream() |
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.
Already said (and explained why) it's a bad idea but I will not block the PR for that if nobody else object.
…oid using controllers
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.
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; |
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 import didn't seems to be used anywhere
It will probably be done in the next release as for now, there is no easy way to list namespaceFiles following the refacto |
2dc2842
to
ab62ba9
Compare
febd835
to
51d21c8
Compare
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