app: Reload copies numbers on SIGHUP #112
No reviewers
TrueCloudLab/storage-services-developers
Labels
No labels
P0
P1
P2
P3
good first issue
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-s3-gw#112
Loading…
Reference in a new issue
No description provided.
Delete branch "ironbee/frostfs-s3-gw:update-copies-numbers-on-SIGHUP"
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?
Signed-off-by: Artem Tataurov a.tataurov@yadro.com
Closes: #104
@ -310,0 +338,4 @@
p.mu.RLock()
copiesNumbers := p.defaultCopiesNumbers
p.mu.RUnlock()
return copiesNumbers
Cosmetic: function above adds empty line before return state and this isn't.
Maybe we can write:
The same way as in
p.Default()
?@ -472,0 +530,4 @@
a.log.Info("setting location constraint", zap.String("constraint", k), zap.Uint32s("vector", v))
}
} else {
a.log.Warn("location constraints won't be updated")
Location constraints are optional in the config. So it is a valid case to remove all constraints and call SIGHUP (just to use default for all cases, for example).
Maybe we need to clear a map and refill it with new values there? The same way it is done in
policies.update
.I suggest change signature of
fetchCopiesNumbers
and make it return(map[string][]uint32, error)
. So if error is notnil
we can log that this value won't be updated.@ -160,2 +162,4 @@
}
var defaultCopiesNumbers []uint32
defaultCopiesNumbers = []uint32{handler.DefaultCopiesNumber}
Let's write:
@ -162,0 +167,4 @@
defaultCopiesNumbers = val
}
policies.updateDefaultCopiesNumbers(defaultCopiesNumbers)
log.logger.Info("setting default copies numbers", zap.Uint32s("vector", policies.GetDefaultCopiesNumbers()))
We can write:
Why shouldn't we refer to the actual content when logging this?
@ -162,0 +175,4 @@
log.logger.Info("settings location constraint", zap.String("location", k), zap.Uint32s("vector", v))
}
} else {
log.logger.Warn("location constraints are not set")
Actually, something like
copies number
be more accurate rather thanlocation constraints
@ -472,0 +523,4 @@
a.log.Warn("default copies numbers won't be updated")
}
copiesNumbers := fetchCopiesNumbers(a.log, a.cfg)
Can we move both this updating to new method
a.settings.policies.updateCopiesNumbers(...)
similar toa.settings.policies.udpate(...)
?@ -45,2 +43,4 @@
Default() netmap.PlacementPolicy
Get(string) (netmap.PlacementPolicy, bool)
GetCopiesNumbers(string) ([]uint32, bool)
GetDefaultCopiesNumbers() []uint32
Let's rename methods of this interface to:
?
Why should we call methods with nouns without verbs?
It's like a getter I suppose https://go.dev/doc/effective_go#Getters
If we rename
Get
toPolicy
then this line https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/src/branch/master/api/handler/put.go#L754 will look likeh.cfg.Policy.Policy(...)
which I don't feel well about.We can use
DefaultPlacementPolicy
andPlacementPolicy
methods names then.@alexvanin What do you think about renaming methods in general?
app: Reload copies numbers on SIGHUPto WIP: app: Reload copies numbers on SIGHUP9096110388
to046c30ba73
Overall LGTM.
@ -345,0 +390,4 @@
p.mu.Unlock()
l.Info("default copies numbers", zap.Uint32s("vector", p.defaultCopiesNumbers))
return
} else {
I don't think you need
else
block, because you have early return above.@ -345,0 +393,4 @@
} else {
l.Error("cannot parse default copies numbers", zap.Error(err))
if initialUpdate {
I think you can avoid this flag if you set
p.defaultCopiesNumbers
innewPlacementPolicy
function upfront.Then you call
updateDefaultCopiesNumbers
and return error.In
newPlacementPolicy
you get an error and log:default copies numbers
.In
update you get an error and log:
default copies numbers won't be updated`.046c30ba73
to926aea7054
926aea7054
to96ec14c4b6
96ec14c4b6
to48bb410275
WIP: app: Reload copies numbers on SIGHUPto app: Reload copies numbers on SIGHUP48bb410275
to9f186d9aba