Change mode of shard components #1121

Merged
fyrchik merged 3 commits from achuprov/frostfs-node:feat/change_mode_shard_components into master 2024-06-05 05:55:27 +00:00
Member

Close: #1076
Before:

Shard Mode Metabase Mode Blobstore Mode Writecache Mode Pilorama Mode Blobovnicza Tree Mode FSTree Mode
Read-Only READ_ONLY READ_ONLY READ_ONLY READ_ONLY READ_ONLY READ_ONLY
Read-Write READ_WRITE READ_WRITE READ_WRITE READ_WRITE READ_WRITE READ_WRITE
Degraded-Read-Write DEGRADED_READ_WRITE READ_WRITE DEGRADED_READ_WRITE DEGRADED_READ_WRITE READ_WRITE READ_WRITE
Degraded-Read-Only DEGRADED_READ_ONLY READ_ONLY DEGRADED_READ_ONLY DEGRADED_READ_ONLY READ_ONLY READ_ONLY

After:

Shard Mode Metabase Mode Blobstore Mode Writecache Mode Pilorama Mode Blobovnicza Tree Mode FSTree Mode
Read-Only READ_ONLY READ_ONLY READ_ONLY READ_ONLY READ_ONLY READ_ONLY
Read-Write READ_WRITE READ_WRITE READ_WRITE READ_WRITE READ_WRITE READ_WRITE
Degraded-Read-Write CLOSED READ_WRITE CLOSED CLOSED READ_WRITE READ_WRITE
Degraded-Read-Only CLOSED READ_ONLY CLOSED CLOSED READ_ONLY READ_ONLY
Close: #1076 Before: | Shard Mode | Metabase Mode | Blobstore Mode | Writecache Mode | Pilorama Mode | Blobovnicza Tree Mode | FSTree Mode | |----------------------|----------------------|------------------|----------------------|----------------------|-----------------------|-------------| | `Read-Only` | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | | `Read-Write` | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | |` Degraded-Read-Write ` | DEGRADED_READ_WRITE | READ_WRITE | DEGRADED_READ_WRITE | DEGRADED_READ_WRITE | READ_WRITE | READ_WRITE | | `Degraded-Read-Only ` | DEGRADED_READ_ONLY | READ_ONLY | DEGRADED_READ_ONLY | DEGRADED_READ_ONLY | READ_ONLY | READ_ONLY | After: | Shard Mode | Metabase Mode | Blobstore Mode | Writecache Mode | Pilorama Mode | Blobovnicza Tree Mode | FSTree Mode | |----------------------|---------------|----------------|---------------------|---------------|-----------------------|-------------| | `Read-Only` | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | | `Read-Write` | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | | `Degraded-Read-Write`| CLOSED | READ_WRITE | CLOSED | CLOSED | READ_WRITE | READ_WRITE | | `Degraded-Read-Only` | CLOSED | READ_ONLY | CLOSED | CLOSED | READ_ONLY | READ_ONLY |

@achuprov why shard mode Degraded-Read-Only does match DEGRADED_READ_ONLY for writecache? Also why Degraded-Read-Write for shard does match DEGRADED for writecache?

@achuprov why shard mode `Degraded-Read-Only` does match `DEGRADED_READ_ONLY` for writecache? Also why `Degraded-Read-Write` for shard does match `DEGRADED` for writecache?
achuprov force-pushed feat/change_mode_shard_components from 59a2a606e2 to f4b8d4e7e6 2024-05-07 14:58:23 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from f4b8d4e7e6 to 9984a67c94 2024-05-07 15:02:47 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 9984a67c94 to e5f7261b38 2024-05-07 15:49:13 +00:00 Compare
achuprov changed title from WIP: feat/change_mode_shard_components to feat/change_mode_shard_components 2024-05-07 15:56:59 +00:00
achuprov changed title from feat/change_mode_shard_components to Change mode shard components 2024-05-07 15:57:30 +00:00
achuprov requested review from storage-core-committers 2024-05-07 16:16:34 +00:00
achuprov requested review from storage-core-developers 2024-05-07 16:16:34 +00:00
achuprov changed title from Change mode shard components to Change mode of shard components 2024-05-07 16:24:31 +00:00
fyrchik reviewed 2024-05-08 07:38:05 +00:00
@ -18,0 +22,4 @@
|-----------------------|---------------|----------------|-----------------|---------------|-----------------------|-------------|
| `Read-Only` | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY | READ_ONLY |
| `Read-Write` | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE | READ_WRITE |
| `Degraded-Read-Write` | CLOSED | READ_WRITE | CLOSED | READ_WRITE | READ_WRITE | READ_WRITE |
Owner

Pilorama is also closed in degraded modes.

Pilorama is also closed in degraded modes.
Author
Member

Fixed

Fixed
fyrchik reviewed 2024-05-08 07:38:09 +00:00
dstepanov-yadro reviewed 2024-05-08 08:51:11 +00:00
@ -162,3 +162,3 @@
switch s {
case "read-write", "":
m = mode.ReadWrite
m = mode.Mode(mode.ReadWrite)

Looks complex. I think it is better to use consts. Or something like func ComponentModeFromShardMode().

Looks complex. I think it is better to use consts. Or something like `func ComponentModeFromShardMode()`.
Author
Member

Fixed

Fixed
dstepanov-yadro marked this conversation as resolved
achuprov force-pushed feat/change_mode_shard_components from e5f7261b38 to 0cebe75571 2024-05-13 09:41:40 +00:00 Compare
fyrchik reviewed 2024-05-13 11:09:20 +00:00
@ -117,3 +117,3 @@
require.Equal(t, false, sc.RefillMetabase())
require.Equal(t, mode.ReadOnly, sc.Mode())
require.Equal(t, mode.Mode(mode.ReadOnly), sc.Mode())
Owner

FYI: There is also require.EqualValues which doesn't require explicit type cast.
Don't mind leaving as is.

FYI: There is also `require.EqualValues` which doesn't require explicit type cast. Don't mind leaving as is.
@ -28,0 +27,4 @@
// DegradedReadOnly is a Mode value for shard that is set automatically
// after a certain number of errors is encountered. It is the same as
// `mode.Degraded` but also is read-only.
DegradedReadOnly = Degraded | ReadOnly
Owner

What problem does untyped mode solve?

What problem does untyped mode solve?
Author
Member

We have two types: mode.Mode and mode.ComponentMode. The constants READ, READ_WRITE and CLOSED should be accessible without type casting.

We have two types: `mode.Mode` and `mode.ComponentMode`. The constants `READ`, `READ_WRITE` and `CLOSED` should be accessible without type casting.
Owner

Why don't we introduce a new set of constants?

Why don't we introduce a new set of constants?
Author
Member

Fixed

Fixed
achuprov force-pushed feat/change_mode_shard_components from 0cebe75571 to bb8329e8d7 2024-05-13 20:21:41 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from bb8329e8d7 to cee5e66bb6 2024-05-13 20:39:20 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from cee5e66bb6 to 35df1b665d 2024-05-14 12:23:42 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 35df1b665d to 01c37d8a84 2024-05-14 12:24:34 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 01c37d8a84 to c9cd065b15 2024-05-14 12:50:22 +00:00 Compare
dstepanov-yadro requested changes 2024-05-14 12:55:42 +00:00
@ -123,6 +123,16 @@ func (t *boltForest) Open(_ context.Context, mode mode.Mode) error {
return t.openBolt(mode)
}
func (t *boltForest) getComponentMode(m mode.Mode) mode.ComponentMode {

metabase/mode.go:


func (db *DB) getComponentMode(m mode.Mode) mode.ComponentMode {
	if m.NoMetabase() {
		return mode.ComponentDisabled
	}
	if m.ReadOnly() {
		return mode.ComponentReadOnly
	}
	return mode.ComponentReadWrite
}

writecache/mode.go:


func (c *cache) getComponentMode(m mode.Mode) mode.ComponentMode {
	if m.NoMetabase() {
		return mode.ComponentDisabled
	}
	if m.ReadOnly() {
		return mode.ComponentReadOnly
	}
	return mode.ComponentReadWrite
}

It should all be in one place: pkg/local_object_storage/shard/mode/mode.go

metabase/mode.go: ``` func (db *DB) getComponentMode(m mode.Mode) mode.ComponentMode { if m.NoMetabase() { return mode.ComponentDisabled } if m.ReadOnly() { return mode.ComponentReadOnly } return mode.ComponentReadWrite } ``` writecache/mode.go: ``` func (c *cache) getComponentMode(m mode.Mode) mode.ComponentMode { if m.NoMetabase() { return mode.ComponentDisabled } if m.ReadOnly() { return mode.ComponentReadOnly } return mode.ComponentReadWrite } ``` It should all be in one place: `pkg/local_object_storage/shard/mode/mode.go`
Author
Member

Moved

Moved
Member

Why do we need two different types for shard modes and for component modes? They represent essentially the same concept and just make code harder to read. Can we just add comments to existing mode.Mode constants (maybe rename some of them) to specify their usage with Shard Components?

Also it would be nice to specify somewhere what those Shard Components are.

Why do we need two different types for shard modes and for component modes? They represent essentially the same concept and just make code harder to read. Can we just add comments to existing ```mode.Mode``` constants (maybe rename some of them) to specify their usage with ```Shard Components```? Also it would be nice to specify somewhere what those ```Shard Components``` are.
achuprov force-pushed feat/change_mode_shard_components from c9cd065b15 to b322c32b98 2024-05-16 09:48:46 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from b322c32b98 to 0535ec070f 2024-05-16 09:49:00 +00:00 Compare
fyrchik requested changes 2024-05-16 10:40:38 +00:00
@ -64,0 +99,4 @@
}
// GetComponentMode maps a ShardMode to a ComponentMode.
func GetComponentMode(m Mode) ComponentMode {
Owner

The name is too generic, and the implementation is too narrow:

  1. There is no 1-1 correspondence, this is why this task exists, actually.
  2. This feels like it is for metabase-like components, in this case it should be reflected in the function name.
  3. The disabled case is non-explicit and thus depends on the order of ifs.
The name is too generic, and the implementation is too narrow: 1. There is no 1-1 correspondence, this is why this task exists, actually. 2. This feels like it is for metabase-like components, in this case it should be reflected in the function name. 3. The `disabled` case is non-explicit and thus depends on the order of `if`s.
achuprov force-pushed feat/change_mode_shard_components from 0535ec070f to 4cd16e1e8c 2024-05-16 11:28:21 +00:00 Compare
Author
Member

@elebedeva You are correct, the concepts are similar. However, mode.Mode is responsible for the overall mode of the shard and includes a wider range of modes. Conversely, ComponentsMode can only be in R, RW, or Closed modes. We could use mode.Mode for component modes, but this would create additional requirements when using mode.Mode, which we would like to avoid.

@elebedeva You are correct, the concepts are similar. However, `mode.Mode` is responsible for the overall mode of the shard and includes a wider range of modes. Conversely, `ComponentsMode` can only be in `R`, `RW`, or `Closed` modes. We could use `mode.Mode` for component modes, but this would create additional requirements when using `mode.Mode`, which we would like to avoid.
dstepanov-yadro approved these changes 2024-05-17 07:09:48 +00:00
fyrchik reviewed 2024-05-17 07:29:29 +00:00
fyrchik left a comment
Owner

I don't see any changes for Blobstor.SetMode in this PR -- it is also a component.
My comment for GetComponentMode function have appeared because of this.

I don't see any changes for `Blobstor.SetMode` in this PR -- it is also a component. My comment for `GetComponentMode` function have appeared because of this.
achuprov force-pushed feat/change_mode_shard_components from 4cd16e1e8c to 6cbcfb764f 2024-05-20 13:45:40 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 6cbcfb764f to acded3cea9 2024-05-20 13:47:02 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from acded3cea9 to 074612f5a0 2024-06-03 09:55:10 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 074612f5a0 to 3c95293c8b 2024-06-03 09:59:58 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 3c95293c8b to 0e9226e545 2024-06-03 10:00:50 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 0e9226e545 to 3e3b361f0f 2024-06-03 11:10:58 +00:00 Compare
Author
Member

@fyrchik Fixed

@fyrchik Fixed
fyrchik reviewed 2024-06-04 11:12:26 +00:00
@ -3,13 +3,15 @@ package common
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
Owner

Please, look at the import groups, we use 2 groups, 1 for stdlib, the second for other.
You might want to adjust the setting of your IDE

Please, look at the import groups, we use 2 groups, 1 for stdlib, the second for other. You might want to adjust the setting of your IDE
fyrchik approved these changes 2024-06-04 11:21:02 +00:00
achuprov force-pushed feat/change_mode_shard_components from 3e3b361f0f to 17703f5e16 2024-06-04 13:29:46 +00:00 Compare
achuprov force-pushed feat/change_mode_shard_components from 17703f5e16 to ce7500f003 2024-06-04 13:30:22 +00:00 Compare
fyrchik approved these changes 2024-06-04 14:36:33 +00:00
acid-ant approved these changes 2024-06-04 14:43:42 +00:00
dstepanov-yadro approved these changes 2024-06-04 14:45:24 +00:00
fyrchik merged commit 8fcd0f8f8d into master 2024-06-05 05:55:27 +00:00
fyrchik referenced this pull request from a commit 2024-06-05 05:55:29 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
5 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/frostfs-node#1121
No description provided.