Skip to content

Commit

Permalink
ir: control chain meta by experimental IR configuration value
Browse files Browse the repository at this point in the history
Closes #3090.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Jan 31, 2025
1 parent 75a3586 commit 34d5fdd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/neofs-ir/internal/validate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,8 @@ type validConfig struct {
BasicIncomeRate int64 `mapstructure:"basic_income_rate"`
AuditFee int64 `mapstructure:"audit_fee"`
} `mapstructure:"settlement"`

Experimental struct {
ChainMetaData bool `mapstructure:"chain_meta_data"`
} `mapstructure:"experimental"`
}
2 changes: 2 additions & 0 deletions config/example/ir.env
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ NEOFS_IR_PROMETHEUS_SHUTDOWN_TIMEOUT=30s

NEOFS_IR_SETTLEMENT_BASIC_INCOME_RATE=100
NEOFS_IR_SETTLEMENT_AUDIT_FEE=100

NEOFS_IR_EXPERIMENTAL_CHAIN_META_DATA=false
3 changes: 3 additions & 0 deletions config/example/ir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,6 @@ prometheus:
settlement:
basic_income_rate: 100 # Optional: override basic income rate value from network config; applied only in debug mode
audit_fee: 100 # Optional: override audit fee value from network config; applied only in debug mode

experimental:
chain_meta_data: false # Optional: allows creating containers with meta data handled via FS chain
1 change: 1 addition & 0 deletions pkg/innerring/innerring.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
ContainerClient: cnrClient,
NeoFSIDClient: neofsIDClient,
NetworkState: server.netmapClient,
MetaEnabled: cfg.GetBool("experimental.chain_meta_data"),

Check warning on line 939 in pkg/innerring/innerring.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/innerring.go#L939

Added line #L939 was not covered by tests
})
if err != nil {
return nil, err
Expand Down
10 changes: 9 additions & 1 deletion pkg/innerring/processors/container/process_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ func (cp *Processor) processContainerPut(put putEvent) {
cp.approvePutContainer(ctx)
}

const sysAttrPrefix = "__NEOFS__"
const (
sysAttrPrefix = "__NEOFS__"
sysAttrChainMeta = sysAttrPrefix + "METAINFO_CONSISTENCY"
)

var allowedSystemAttributes = map[string]struct{}{
sysAttrPrefix + "NAME": {},
sysAttrPrefix + "ZONE": {},
sysAttrPrefix + "DISABLE_HOMOMORPHIC_HASHING": {},
sysAttrChainMeta: {},
}

func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
Expand All @@ -80,6 +84,10 @@ func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
if _, ok := allowedSystemAttributes[k]; !ok {
denyErr = fmt.Errorf("system attribute %s is not allowed", k)
}

Check warning on line 86 in pkg/innerring/processors/container/process_container.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/container/process_container.go#L81-L86

Added lines #L81 - L86 were not covered by tests

if k == sysAttrChainMeta && !cp.metaEnabled {
denyErr = fmt.Errorf("chain meta data attribute is not allowed")
}

Check warning on line 90 in pkg/innerring/processors/container/process_container.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/container/process_container.go#L88-L90

Added lines #L88 - L90 were not covered by tests
}
})
if denyErr != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/innerring/processors/container/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type (
cnrClient *container.Client // notary must be enabled
idClient *neofsid.Client
netState NetworkState
metaEnabled bool
}

// Params of the processor constructor.
Expand All @@ -37,6 +38,7 @@ type (
ContainerClient *container.Client
NeoFSIDClient *neofsid.Client
NetworkState NetworkState
MetaEnabled bool
}
)

Expand Down Expand Up @@ -90,6 +92,7 @@ func New(p *Params) (*Processor, error) {
cnrClient: p.ContainerClient,
idClient: p.NeoFSIDClient,
netState: p.NetworkState,
metaEnabled: p.MetaEnabled,

Check warning on line 95 in pkg/innerring/processors/container/processor.go

View check run for this annotation

Codecov / codecov/patch

pkg/innerring/processors/container/processor.go#L95

Added line #L95 was not covered by tests
}, nil
}

Expand Down

0 comments on commit 34d5fdd

Please sign in to comment.