Add registry import command line tool #160

Merged
fyrchik merged 1 commit from elebedeva/xk6-frostfs:feat/registry-importer into master 2024-08-23 10:47:04 +00:00
Member

Close #154

Currently, objects created in preset are never deleted. k6 deletes only objects from registry, if registry file is not provided k6 delete load fails.

Added command line tool to import objects created in preset into registry so k6 can delete them normally.

Signed-off-by: Ekaterina Lebedeva ekaterina.lebedeva@yadro.com

Close #154 Currently, objects created in preset are never deleted. k6 deletes only objects from registry, if registry file is not provided k6 delete load fails. Added command line tool to import objects created in preset into registry so k6 can delete them normally. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva added 1 commit 2024-08-09 09:02:24 +00:00
[#154] Add registry import cli utility
All checks were successful
DCO action / DCO (pull_request) Successful in 46s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m46s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m50s
Tests and linters / Tests with -race (pull_request) Successful in 1m56s
Tests and linters / Lint (pull_request) Successful in 3m2s
fa240302de
* Currently, objects created in preset are never deleted.
  k6 deletes only objects from registry, if registry file
  is not provided k6 delete load fails.
* Added cli utility to import objects created in preset
  into registry so k6 can delete them normally.

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
elebedeva requested review from storage-core-committers 2024-08-09 09:03:50 +00:00
elebedeva requested review from storage-core-developers 2024-08-09 09:03:50 +00:00
fyrchik requested changes 2024-08-09 10:11:04 +00:00
@ -0,0 +19,4 @@
func runCmd(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return fmt.Errorf("expected at least two non-flag argumets: paths to the registry and to the pregenerated file, got: %s", args)
Owner
https://git.frostfs.info/TrueCloudLab/frostfs-node/src/commit/68029d756e59d036b11b95153d70e64588ee720e/cmd/frostfs-cli/modules/acl/basic/print.go#L21
Owner

Please, see the validation above, it can be done simpler.

Please, see the validation above, it can be done simpler.
Author
Member

Fixed!

Fixed!
fyrchik marked this conversation as resolved
@ -0,0 +20,4 @@
}
func init() {
cobra.AddTemplateFunc("runtimeVersion", runtime.Version)
Owner

Will it look xk6-registry runtimeVersion in CLI?

Will it look `xk6-registry runtimeVersion` in CLI?
Author
Member

It's used in the template of --version.
Looks like this:

❯ ./bin/frostfs-xk6-registry -v
FrostFS xk6-registry
Version: fa240302
GoVersion: go1.22.5
It's used in the template of `--version`. Looks like this: ``` ❯ ./bin/frostfs-xk6-registry -v FrostFS xk6-registry Version: fa240302 GoVersion: go1.22.5 ```
fyrchik marked this conversation as resolved
acid-ant reviewed 2024-08-09 10:22:18 +00:00
@ -0,0 +1,32 @@
package importer
Member

Why have you put it in cmd/xk6-registry/importer/ but not in cmd/xk6-registry-importer/ as it is done for xk6-registry-exporter?
How to build it with make bin/*?

Why have you put it in `cmd/xk6-registry/importer/` but not in `cmd/xk6-registry-importer/` as it is done for `xk6-registry-exporter`? How to build it with `make bin/*`?
Author
Member

import is a subcommand of xk6-registry commandline tool. Later we can move xk6-registry-exporter functionality to the subcommand export of xk6-registry so that we have one tool to work with registry instead of many.

`import` is a subcommand of `xk6-registry` commandline tool. Later we can move `xk6-registry-exporter` functionality to the subcommand `export` of `xk6-registry` so that we have one tool to work with registry instead of many.
acid-ant marked this conversation as resolved
elebedeva force-pushed feat/registry-importer from fa240302de to 64df65a2e4 2024-08-09 14:31:33 +00:00 Compare
fyrchik requested changes 2024-08-09 17:21:51 +00:00
@ -23,1 +20,3 @@
OID string `json:"oid"`
Bucket string `json:"bucket"`
Object string `json:"object"`
Container string `json:"container"`
Owner

This struct should not have been touched in this PR.
If we need to unmarshal registry, let's do it with a separate struct.

Also, preset should be handled in the cmd itself, not internal/registry package.

This struct should not have been touched in this PR. If we need to unmarshal registry, let's do it with a separate struct. Also, preset should be handled in the cmd itself, not `internal/registry` package.
fyrchik marked this conversation as resolved
elebedeva force-pushed feat/registry-importer from 64df65a2e4 to 4cd50c8c03 2024-08-20 11:38:42 +00:00 Compare
fyrchik approved these changes 2024-08-20 12:20:51 +00:00
@ -0,0 +34,4 @@
for _, obj := range pregenInfo.Objects {
if obj.Bucket != "" {
err = o.AddObject("", "", obj.Bucket, obj.Object, "")
Owner

Please, check if AddObject uses DB.Batch(). In this case we are effectively limited by MaxBatchDelay (10ms or 20ms).
Not important for preset (100 containers * 10 objects each = 1 second to process), but worth a comment somewhere.

Please, check if `AddObject` uses `DB.Batch()`. In this case we are effectively limited by `MaxBatchDelay` (10ms or 20ms). Not important for preset (100 containers * 10 objects each = 1 second to process), but worth a comment somewhere.
Author
Member

AddObject uses DB.Batch()

It does.

worth a comment somewhere

Do you mean the comment in the code?

> `AddObject` uses `DB.Batch()` It does. > worth a comment somewhere Do you mean the comment in the code?
Owner

Yes, near the loop -- it is the first thing we will try if we need to speed up things.

Yes, near the loop -- it is the first thing we will try if we need to speed up things.
fyrchik marked this conversation as resolved
@ -0,0 +38,4 @@
} else {
err = o.AddObject(obj.Container, obj.Object, "", "", "")
}
if err != nil {
Owner

Is this command idempotent. I.e. if we fail (no space on disk) on the object A, it would be both in preset and registry.
What will happen if we run this command again?

Is this command idempotent. I.e. if we fail (no space on disk) on the object A, it would be both in preset and registry. What will happen if we run this command again?
Author
Member

The command is not idempotent. If we run it again after the object was put in registry, the registry will have two entities representing this object.

The command is not idempotent. If we run it again after the object was put in registry, the registry will have two entities representing this object.
fyrchik marked this conversation as resolved
elebedeva force-pushed feat/registry-importer from 4cd50c8c03 to 6d3ecb6528 2024-08-23 10:42:47 +00:00 Compare
fyrchik merged commit 6d3ecb6528 into master 2024-08-23 10:47:04 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/xk6-frostfs#160
No description provided.