-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Org-wide linter #2943
Org-wide linter #2943
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2943 +/- ##
==========================================
- Coverage 23.49% 23.47% -0.03%
==========================================
Files 776 776
Lines 46594 46550 -44
==========================================
- Hits 10949 10929 -20
+ Misses 34780 34756 -24
Partials 865 865 ☔ View full report in Codecov by Sentry. |
pkg/local_object_storage/blobstor/fstree/fstree_write_generic.go
Outdated
Show resolved
Hide resolved
7468c36
to
b721910
Compare
921ac38
to
6af8199
Compare
@roman-khimov @carpawell I don't know what to do with
For |
There are two protocol changes here:
First of all, let's check if we want a compatibility test (in which case deprecated features are perfectly fine) or something different. |
We still have to support "old" objects with v1 scheme. Deprecations are for client code mostly. All the places with it in the current code are server-side only (and tests). You can just add
I guess it may be the time when we can drop expiration from SG's body completely (when a new SG is created in cli, it should be just an expiration attribute for sure). Not sure if we can say "there will not be old SGs ever" and do not expect expiration in SG at all @roman-khimov. Mb we need to check if there are any old SGs currently on our nodes.
Can you explain, please? |
I say about, for example, this func But here, I can't easily get object that carries SG, so I have to leave it as it is? |
3e7856a
to
7a048fe
Compare
No, this code will stop working properly if we meet a new one SG then. I think you should either extend the interface with expiration epoch ( UPD: reread the code, ReadFromObject looks OK, do we really need to deprecate expiration getters if it is read from object's attributes, @cthulhu-rider? It can be considered as a helper struct that is read from objects only and that includes all the things we need to work with SGs (and any SG still can expire). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job! overall LGTM
i'll leave 2 suggestions here:
- there are a lot of
.Encode -> copy()
changes. For most of them (mb all) we can get rid of the buffer and just useid[:]
. The only risky layer could be BoltDB, be careful there - we now have
cid.Size
,oid.Size
anduser.IDSize
consts. I suggest u to search bysha256.Size
,32
and25
entries across repo, and add commit with const replacement. This ofc can be done in the next PR. P.S. note that somesha256.Size
entries can be unrelated!
ok := len(test.jsonRecord) > 0 | ||
require.Equal(t, ok, err == nil, err) | ||
if ok { | ||
expectedRecord := eacl.NewRecord() | ||
expectedRecord := eacl.ConstructRecord(eacl.ActionUnspecified, eacl.OperationUnspecified, nil, eacl.Filter{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for decoding its enough to have
expectedRecord := eacl.ConstructRecord(eacl.ActionUnspecified, eacl.OperationUnspecified, nil, eacl.Filter{}) | |
var expectedRecord eacl.Record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was in his place, docs say "Record should be created using one of the constructors." so IMO it is either wrong doc or @End-rey was right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not must
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the decoding from json, which contains the correct fields for record, so I agree that declared via var will be enough.
attrs[index].SetValue(expAttrValue) | ||
} | ||
|
||
obj.SetAttributes(attrs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so many lines to set one value. nspcc-dev/neofs-sdk-go#630
7a048fe
to
5f77b92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some places do not need to have a dedicated variable now, quite a valuable change IMO, this is kinda why we did SDK refactoring, but not critical. Waiting for the full test run.
addr.Object().Encode(key[cidSize:]) | ||
cnr := addr.Container() | ||
obj := addr.Object() | ||
copy(key[copy(key, cnr[:]):], obj[:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it is more readable now. moreover copy
is not needed at all, addr
is a copy already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So make for more readability this?
copy(key[copy(key, cnr[:]):], obj[:]) | |
n := copy(key, cnr[:]) | |
copy(key[n:], obj[:]) |
And don't understand about copy
, how to concat 2 slices without copy
and with the same performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is cosmetic. to me something like
key = append(key[:0], cnr[:]...)
key = append(key, obj[:]...)
is more preferable, i am scared of brackets, [:]):]
confuses me. append(append(key[:0], cnr[:]...), cnr[:]...)
in one line if needed
but ok, i benched and now know that your way is faster so ok
And don't understand about copy
i was wrong, i thought that copy
here is for saving the original addr
untouched (cid and oid were not arrays forever, some time ago there were slices in them), but it is not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So make for more readability this?
but stil my answer is yes. 3 closing brackets in 4 symbols is too much for me
cnr, _ := obj.ContainerID() | ||
id, _ := obj.ID() | ||
cnr := obj.GetContainerID() | ||
id := obj.GetID() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed var now
Signed-off-by: Andrey Butusov <[email protected]>
Use: - `eacl.Target.RawSubjects` instead of `eacl.Target.BinaryKeys`. - `eacl.NewTargetByRole` with `eacl.Target.SetRawSubjects` or `eacl.NewTargetByAccounts` with `user.NewFromECDSAPublicKey` for targets with public keys. - `eacl.ConstructTable` instead of `eacl.NewTable`. - `eacl.ConstructRecord` instead of `eacl.NewRecord`. - `*.Get*ID` instead of `*.*ID`. - `ID.IsZero()` to check if ID is set. - comparing with == instead of `ID.Equals`. - `cid.NewFromMarshalledContainer(cnr.Marshal())` instead of. `cid.ID.CalculateID`. - `user.NewFromECDSAPublicKey` instead of `user.ResolveFromECDSAPublicKey`. - direct assign or copy instead of `ID.Encode`. - direct assign instead of `ID.SetSHA256`. - use `rand.Read` from `crypto/rand`. - use expiration epoch of storage group from attribute in header of the object carrying this storage group. - use `oidtest.ID` and `oidtest.IDs` to generate IDs for tests. Signed-off-by: Andrey Butusov <[email protected]>
- `unused` - `errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors` - `variable collides with imported package name` Signed-off-by: Andrey Butusov <[email protected]>
Since we get an expiration option from the object that carries the storage group, and if it's not set we get `object.ErrNoExpiration`, now we print information about it. Signed-off-by: Andrey Butusov <[email protected]>
5f77b92
to
3ebb2d8
Compare
Closes #2940.