[#5] Add container zone names support #6
No reviewers
Labels
No labels
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/rclone#6
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "KurlesHS/rclone:feature/add-container-zones-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Added the ability to explicitly specify the container zone in its name. For this, the syntax "
<cnr-name>.<zone-name>
" is used, where<cnr-name>
is the name of a container and<zone-name>
is the name of the zone. If no zone is explicitly specified, the default zone will be used.A new parameter has been added for the frostfs backend: "
default_container_zone
", which is responsible for the zone where new containers are created and existing containers are resolved if no zone is specified in the container's name.close #5
It's possible that I'm wrong, but I've seen/heard in demos the opposite naming convention:
<cnr-name>.<zone-name>
. I think we should stick to one approach everywhere.787f164997
to0889e3075f
Yes, you're not the only one who noticed this. I changed the format of the zone assignment to the expected one.
@ -818,3 +828,3 @@
container.SetCreationTime(&cnr, time.Now())
container.SetName(&cnr, containerName)
container.SetName(&cnr, containerStr)
Probably we can set to this just name rather than name+zone
For the internal logic of the application, it does not matter what value is in this property. But if we suddenly have to look at containers not using
rclone
, but usingfrostfs-cli
, it seems to me that it is better to store in this property the value that the user explicitly entered when specifying the name of the root directory. Besides, in most cases there will be a name without a zone anyway.@ -946,3 +958,2 @@
func getContainerIDByName(dirEntry fs.DirEntry, containerName string) (ok bool, cnrID cid.ID, err error) {
if dirEntry.Remote() != containerName {
func getContainerIDByZoneAndName(dirEntry fs.DirEntry, cnrZone, cnrName, defaultZone string) (ok bool, cnrID cid.ID, err error) {
Maybe it's matter of taste, but It's more common to see
ok bool
after value (cnrID cid.ID
)@ -957,3 +970,3 @@
}
func resolveContainerIDWithNNS(resolver *resolver.NNS, containerName string) (cid.ID, error) {
func resolveContainerIDWithNNS(resolver *resolver.NNS, cnrZone, cnrName, containerStr string) (cid.ID, error) {
I'm not sure if we need
containerStr string
parameter here@ -968,2 +982,2 @@
func (f *Fs) resolveContainerIDHelper(ctx context.Context, containerName string) (cid.ID, error) {
cnrIDStr, ok := f.containerIDCache[containerName]
func (f *Fs) resolveContainerIDHelper(ctx context.Context, containerStr string) (cid.ID, error) {
cnrIDStr, ok := f.containerIDCache[containerStr]
Shouldn't we protect
f.containerIDCache
more granular? Now we hold lock when create/delete container. I'm not sure if it's necessaryDue to the fact that
PUT
operations are performed in parallel in separate goroutines, if a requested container is missing, and we do not use a global lock, all these goroutines will attempt to create their own containers, which could lead to conflicts.Well, let's add comment about this then.
By the way I'm a little confused by not seeing using mutex in function where we work with resource that should be protected by it (
f.containerIDCache
). Maybe we should not extractresolveContainerIDHelper
into separate function but make a little duplication inresolveContaienrID
andresolveOrCreateContainer
?@alexvanin
#9
@ -976,2 +994,2 @@
if cnrID, err = resolveContainerIDWithNNS(f.resolver, containerName); err == nil {
f.containerIDCache[containerName] = cnrID.String()
if cnrID, err = resolveContainerIDWithNNS(f.resolver, cnrZone, cnrName, containerStr); err == nil {
f.containerIDCache[containerStr] = cnrID.String()
Why don't we update cache inside
resolveContainerIDWithNNS
?Then we can simplify code here to
Or we can rewrite
resolveContainerIDHelper
so it looks like:@ -302,3 +302,3 @@
if domain := container.ReadDomain(cnr); domain.Name() != "" {
remote = domain.Name()
if defaultZone != domain.Zone() {
Why do we need such difference?
Without this, the root directories in the default zone will be resolved as
"<cnr-name>.<default-zone>"
, and many integration tests will fail. If we leave only the container name as "Remote", then when listing all container files, the root directories "root-dir.z1" and "root-dir.z2" will have the same name "root-dir", which will lead to ambiguity.@ -310,2 +314,4 @@
return dir
}
func getZoneAndContainerNames(containerStr, defaultZone string) (cnrZone string, cnrName string) {
Can we return values in opposite order (name, zone)?
@ -312,0 +317,4 @@
func getZoneAndContainerNames(containerStr, defaultZone string) (cnrZone string, cnrName string) {
defer func() {
if len(cnrZone) == 0 {
cnrZone = "container"
I woudn't allow empty
cnrZone
. By the way why we use here"container"
rather thandefaultZone
?Here I mean the following logic: if the user enters the name of the root directory as
"<cnr-name>"
, the zone name will be resolved to the one specified in the restic configuration in the "default_container_zone
" parameter. And if the name of root directory is specified in"<cnr-name>."
format (with a dot at the end), then zone will resolve to standard one for FrostFS, which is "container
".Maybe it's better, if user want to enter name of root directory that isn't in default zone make he enter full name (with zone) even if it's
container
?0889e3075f
to5ad64af106
@ -997,0 +1005,4 @@
return parseContainerID(cnrIDStr)
}
cnrID, err := f.resolveCIDByRootDirName(ctx, rootDirName)
if err == nil {
Can we use opposite condition
if err != nil
? It's more common@ -997,0 +1008,4 @@
if err == nil {
f.containerIDCache[rootDirName] = cnrID.String()
}
return cnrID, err
If we know that value doesn't matter because of
err != nil
, let's writeto highlight the fact that we aren't interested in value
@ -1005,2 +1021,4 @@
func (f *Fs) parseContainer(ctx context.Context, rootDirName string) (cid.ID, error) {
cnrID, err := parseContainerID(rootDirName)
if err == nil {
return cnrID, err
Matter of taste but can we write
return <val>, nil
in such cases rather thanreturn <val>, err
?5ad64af106
to12b572e62a
Looks good to me