app: Refactor the default copies number setting #109

Merged
alexvanin merged 1 commits from ironbee/frostfs-s3-gw:refactor_set-copies-number into master 2023-05-17 12:43:03 +00:00

Signed-off-by: Artem Tataurov a.tataurov@yadro.com

Closes: #101

Signed-off-by: Artem Tataurov <a.tataurov@yadro.com> Closes: #101
ironbee requested review from storage-services-committers 2023-05-16 14:43:28 +00:00
ironbee requested review from storage-services-developers 2023-05-16 14:43:28 +00:00
ironbee self-assigned this 2023-05-16 14:44:17 +00:00
ironbee changed title from [#101] app: Refactor the default copies number setting to app: Refactor the default copies number setting 2023-05-16 14:44:39 +00:00
alexvanin reviewed 2023-05-16 14:50:42 +00:00
@ -155,0 +160,4 @@
parsedValue, err := strconv.ParseUint(unparsed[i], 10, 32)
if err != nil {
l.Error("cannot parse default copies numbers", zap.Error(err))
break

What you think about returning empty slice (i.e. default) in case of an error during parsing? I think this is more appropriate than having half parsed slice.

What you think about returning empty slice (i.e. default) in case of an error during parsing? I think this is more appropriate than having half parsed slice.
alexvanin marked this conversation as resolved
dkirillov reviewed 2023-05-16 14:56:11 +00:00
cmd/s3-gw/app.go Outdated
@ -642,0 +637,4 @@
Policy: a.settings.policies,
DefaultMaxAge: handler.DefaultMaxAge,
NotificatorEnabled: a.cfg.GetBool(cfgEnableNATS),
DefaultCopiesNumbers: []uint32{0},
Collaborator

Let's use []uint32{handler.DefaultCopiesNumber} or drop handler.DefaultCopiesNumber.
Probably we can skip initialization of this field because empty/nil vector leads to default behavior (the same as vectore with one element 0)

Let's use `[]uint32{handler.DefaultCopiesNumber}` or drop `handler.DefaultCopiesNumber`. Probably we can skip initialization of this field because empty/nil vector leads to default behavior (the same as vectore with one element `0`)
dkirillov marked this conversation as resolved
Collaborator

Please, fix linter error:

$ make lint
api/handler/api.go:88:68  godot  Comment should end in a period

Please, fix linter error: ```shell $ make lint api/handler/api.go:88:68 godot Comment should end in a period ```
ironbee force-pushed refactor_set-copies-number from f4f2c716f3 to 744ae8396d 2023-05-16 15:05:23 +00:00 Compare
ironbee force-pushed refactor_set-copies-number from 744ae8396d to a048c3d811 2023-05-16 15:08:39 +00:00 Compare
Collaborator

Since this PR is about refactoring. Can we move this check to line 162? It's minor, but still

Since this PR is about refactoring. Can we move [this check](https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/src/commit/bf47978cfec9eede9322bb7edc0de64d8105c9e6/cmd/s3-gw/app_settings.go#L173-L175) to line 162? It's minor, but still
ironbee force-pushed refactor_set-copies-number from a048c3d811 to e57795bb99 2023-05-16 15:19:59 +00:00 Compare
dkirillov approved these changes 2023-05-16 15:28:50 +00:00
Collaborator

Should we use here this

l.Info("added constraint", zap.String("location", constraint), zap.Uint32s("copies numbers", vector32))

?

Should we use [here](https://git.frostfs.info/ironbee/frostfs-s3-gw/src/commit/e57795bb9991329106e80cfa8c9043a766744119/cmd/s3-gw/app_settings.go#L194) this ``` l.Info("added constraint", zap.String("location", constraint), zap.Uint32s("copies numbers", vector32)) ``` ?
dkirillov reviewed 2023-05-17 06:47:16 +00:00
cmd/s3-gw/app.go Outdated
@ -659,1 +657,4 @@
if val := fetchDefaultCopiesNumbers(a.log, a.cfg); len(val) > 0 {
cfg.DefaultCopiesNumbers = val
}
a.log.Debug("setting default copies numbers", zap.Uint32s("vector", cfg.DefaultCopiesNumbers))
Collaborator

Let's change Debug to Info

Let's change `Debug` to `Info`

Why shouldn't it be the debug?

Why shouldn't it be the `debug`?
Collaborator

Info will be more consistent with other similar cases. And it will be more convenient to see this information about copies number without any changes on cluster (where logging level is info)

`Info` will be more consistent with [other](https://git.frostfs.info/ironbee/frostfs-s3-gw/src/commit/e57795bb9991329106e80cfa8c9043a766744119/cmd/s3-gw/app.go#L239) [similar](https://git.frostfs.info/ironbee/frostfs-s3-gw/src/commit/e57795bb9991329106e80cfa8c9043a766744119/cmd/s3-gw/app.go#L381) [cases](https://git.frostfs.info/ironbee/frostfs-s3-gw/src/commit/e57795bb9991329106e80cfa8c9043a766744119/cmd/s3-gw/app.go#L123). And it will be more convenient to see this information about copies number without any changes on cluster (where logging level is `info`)
Collaborator

The same for #109 (comment)

The same for https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/pulls/109#issuecomment-9639
Collaborator

@ironbee @alexvanin I forgot, should this PR reload frostfs.set_copies_number and placement_policy.copies_numbers by SIGHUP?

@ironbee @alexvanin I forgot, should this PR reload `frostfs.set_copies_number` and `placement_policy.copies_numbers` by SIGHUP?

@ironbee @alexvanin I forgot, should this PR reload frostfs.set_copies_number and placement_policy.copies_numbers by SIGHUP?

No, see #104

> @ironbee @alexvanin I forgot, should this PR reload `frostfs.set_copies_number` and `placement_policy.copies_numbers` by SIGHUP? No, see #104
alexvanin approved these changes 2023-05-17 07:28:58 +00:00
ironbee force-pushed refactor_set-copies-number from e57795bb99 to e24bc3f2ce 2023-05-17 08:36:51 +00:00 Compare

All remaining log issues going to be fixed in #111

All remaining log issues going to be fixed in #111
alexvanin merged commit e24bc3f2ce into master 2023-05-17 12:43:03 +00:00
alexvanin deleted branch refactor_set-copies-number 2023-05-17 12:43:04 +00:00
Sign in to join this conversation.
There is no content yet.