Change mode of shard components #1121

Open
achuprov wants to merge 3 commits from achuprov/frostfs-node:feat/change_mode_shard_components into master
Collaborator

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 added 2 commits 2024-05-06 22:38:34 +00:00
f8770f2236 [#1121] metrics: Change mode of shard components
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
DCO action / DCO (pull_request) Successful in 3m15s Details
Vulncheck / Vulncheck (pull_request) Successful in 3m44s Details
Build / Build Components (1.21) (pull_request) Successful in 4m37s Details
Build / Build Components (1.22) (pull_request) Successful in 4m34s Details
Tests and linters / gopls check (pull_request) Successful in 5m19s Details
Tests and linters / Staticcheck (pull_request) Successful in 6m7s Details
Tests and linters / Lint (pull_request) Successful in 6m51s Details
Tests and linters / Tests with -race (pull_request) Successful in 9m27s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 9m45s Details
Tests and linters / Tests (1.22) (pull_request) Successful in 9m50s Details
59a2a606e2
[#1121] docs: Change mode of shard components
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>

@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 |

Pilorama is also closed in degraded modes.

Pilorama is also closed in degraded modes.
Poster
Collaborator

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()`.
Poster
Collaborator

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())

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

What problem does untyped mode solve?

What problem does untyped mode solve?
Poster
Collaborator

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.

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

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

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`
Poster
Collaborator

Moved

Moved
Collaborator

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 {

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
Poster
Collaborator

@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
All checks were successful
Build / Build Components (1.22) (pull_request) Successful in 11m48s
DCO action / DCO (pull_request) Successful in 19m6s
Tests and linters / gopls check (pull_request) Successful in 20m25s
Vulncheck / Vulncheck (pull_request) Successful in 21m11s
Build / Build Components (1.21) (pull_request) Successful in 23m17s
Tests and linters / Lint (pull_request) Successful in 24m50s
Tests and linters / Staticcheck (pull_request) Successful in 25m0s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m22s
Tests and linters / Tests (1.21) (pull_request) Successful in 4m51s
Tests and linters / Tests (1.22) (pull_request) Successful in 5m0s
Tests and linters / Tests with -race (pull_request) Successful in 5m23s
This Pull Request doesn't have enough approvals yet. 0 of 2 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No Milestone
No Assignees
4 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
There is no content yet.