Couldn't create container/bucket via s3 #899

Closed
opened 2024-01-10 14:26:21 +00:00 by dkirillov · 1 comment
Member

Couldn't create container with session token

Expected Behavior

Can create bucket/container

Current Behavior

See error from node code = 1024 message = invalid context *session.ContainerSessionContext"

2024-01-10T17:05:23.907+0300    error   handler/util.go:46      request failed  {"status": 500, "request_id": "152ed869-2f29-4ec4-8378-859719ae3945", "method": "CreateBucket", "bucket": "dkirillov-test4", "object": "", "description": "could not create bucket", "error": "create container: save container via connection pool: put container via client 's01.frostfs.devenv:8080': container put on client: status: code = 1024 message = invalid context *session.ContainerSessionContext"}

Steps to Reproduce (for bugs)

This test should pass (sdk version git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20231122162120-56debcfa569e)

import (
	"context"
	"fmt"
	"testing"

	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
	frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session"
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
	"github.com/google/uuid"
	"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
	"github.com/stretchr/testify/require"
)


func TestCreateContainer(t *testing.T) {
	ctx := context.Background()

	key, err := keys.NewPrivateKeyFromWIF("KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr") // devenv key
	require.NoError(t, err)

	anonKey, err := keys.NewPrivateKey()
	require.NoError(t, err)

	tok := new(session.Container)
	tok.ForVerb(session.VerbContainerPut)

	tok.SetID(uuid.New())
	tok.SetAuthKey((*frostfsecdsa.PublicKey)(&anonKey.PrivateKey.PublicKey))

	tok.SetIat(100)
	tok.SetNbf(100)
	tok.SetExp(100500)

	err = tok.Sign(key.PrivateKey)
	require.NoError(t, err)

	var prm pool.InitParameters
	prm.SetKey(&anonKey.PrivateKey)
	prm.AddNode(pool.NewNodeParam(1, "s01.frostfs.devenv:8080", 1))

	p, err := pool.NewPool(prm)
	require.NoError(t, err)
	err = p.Dial(ctx)
	require.NoError(t, err)

	var pp netmap.PlacementPolicy
	err = pp.DecodeString("REP 1")
	require.NoError(t, err)

	var ownerID user.ID
	user.IDFromKey(&ownerID, key.PrivateKey.PublicKey)

	var cnr container.Container
	cnr.Init()
	cnr.SetPlacementPolicy(pp)
	cnr.SetOwner(ownerID)
	cnr.SetBasicACL(acl.PublicRWExtended)

	err = pool.SyncContainerWithNetwork(ctx, &cnr, p)
	require.NoError(t, err)

	prmPut := pool.PrmContainerPut{
		ClientParams: client.PrmContainerPut{
			Container: &cnr,
			Session:   tok,
		},
	}

	idCnr, err := p.PutContainer(ctx, prmPut)
	require.NoError(t, err)

	fmt.Println(idCnr)
}

Regression

Yes. It seems this commit broke something

Your Environment

Checked on devenv

  • Version used:
FrostFS Storage node
Version: v0.37.0-rc.1-188-gd5d3d8ba 
GoVersion: go1.20.1

Couldn't create container with session token ## Expected Behavior Can create bucket/container ## Current Behavior See error from node `code = 1024 message = invalid context *session.ContainerSessionContext"` ``` 2024-01-10T17:05:23.907+0300 error handler/util.go:46 request failed {"status": 500, "request_id": "152ed869-2f29-4ec4-8378-859719ae3945", "method": "CreateBucket", "bucket": "dkirillov-test4", "object": "", "description": "could not create bucket", "error": "create container: save container via connection pool: put container via client 's01.frostfs.devenv:8080': container put on client: status: code = 1024 message = invalid context *session.ContainerSessionContext"} ``` ## Steps to Reproduce (for bugs) This test should pass (sdk version `git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20231122162120-56debcfa569e`) ```golang import ( "context" "fmt" "testing" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl" frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" "github.com/google/uuid" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/stretchr/testify/require" ) func TestCreateContainer(t *testing.T) { ctx := context.Background() key, err := keys.NewPrivateKeyFromWIF("KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr") // devenv key require.NoError(t, err) anonKey, err := keys.NewPrivateKey() require.NoError(t, err) tok := new(session.Container) tok.ForVerb(session.VerbContainerPut) tok.SetID(uuid.New()) tok.SetAuthKey((*frostfsecdsa.PublicKey)(&anonKey.PrivateKey.PublicKey)) tok.SetIat(100) tok.SetNbf(100) tok.SetExp(100500) err = tok.Sign(key.PrivateKey) require.NoError(t, err) var prm pool.InitParameters prm.SetKey(&anonKey.PrivateKey) prm.AddNode(pool.NewNodeParam(1, "s01.frostfs.devenv:8080", 1)) p, err := pool.NewPool(prm) require.NoError(t, err) err = p.Dial(ctx) require.NoError(t, err) var pp netmap.PlacementPolicy err = pp.DecodeString("REP 1") require.NoError(t, err) var ownerID user.ID user.IDFromKey(&ownerID, key.PrivateKey.PublicKey) var cnr container.Container cnr.Init() cnr.SetPlacementPolicy(pp) cnr.SetOwner(ownerID) cnr.SetBasicACL(acl.PublicRWExtended) err = pool.SyncContainerWithNetwork(ctx, &cnr, p) require.NoError(t, err) prmPut := pool.PrmContainerPut{ ClientParams: client.PrmContainerPut{ Container: &cnr, Session: tok, }, } idCnr, err := p.PutContainer(ctx, prmPut) require.NoError(t, err) fmt.Println(idCnr) } ``` ## Regression Yes. It seems this [commit](https://git.frostfs.info/TrueCloudLab/frostfs-node/commit/764f70634d24868eddf247cd4fec10341d16967f) broke something ## Your Environment Checked on devenv * Version used: ``` FrostFS Storage node Version: v0.37.0-rc.1-188-gd5d3d8ba GoVersion: go1.20.1 ```
dkirillov added the
bug
triage
labels 2024-01-10 14:26:21 +00:00
dstepanov-yadro self-assigned this 2024-01-10 14:46:54 +00:00
fyrchik added
frostfs-node
and removed
triage
labels 2024-01-10 15:27:09 +00:00

Fixed: was used wrong session context type.

Fixed: was used wrong session context type.
fyrchik added this to the v0.38.0 milestone 2024-01-11 09:42:46 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 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#899
No description provided.