github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/feat/feat.go (about) 1 // Package feat: global runtime-configurable feature flags 2 /* 3 * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package feat 6 7 import ( 8 "errors" 9 "strconv" 10 11 "github.com/NVIDIA/aistore/cmn/cos" 12 ) 13 14 type Flags cos.BitFlags 15 16 // NOTE: 17 // - `Bucket` features(*) are a strict subset of all `Cluster` features, and can be changed 18 // for individual buckets 19 // - when making any changes, make sure to update `Cluster` and maybe the `Bucket` enum as well (NOTE) 20 21 const ( 22 PropName = "features" 23 ) 24 25 const ( 26 EnforceIntraClusterAccess = Flags(1 << iota) 27 SkipVC // (*) skip loading existing object's metadata, Version and Checksum (VC) in particular 28 DontAutoDetectFshare // do not auto-detect file share (NFS, SMB) when _promoting_ shared files to AIS 29 S3APIviaRoot // handle s3 requests via `aistore-hostname/` (default: `aistore-hostname/s3`) 30 FsyncPUT // (*) when finalizing PUT(object): fflush prior to (close, rename) sequence 31 LZ4Block1MB // .tar.lz4 format, lz4 compression: max uncompressed block size=1MB (default: 256K) 32 LZ4FrameChecksum // checksum lz4 frames (default: don't) 33 DontAllowPassingFQNtoETL // do not allow passing fully-qualified name of a locally stored object to (local) ETL containers 34 IgnoreLimitedCoexistence // run in presence of "limited coexistence" type conflicts (same as e.g. CopyBckMsg.Force but globally) 35 S3PresignedRequest // (*) pass-through client-signed (presigned) S3 requests for subsequent authentication by S3 36 DontOptimizeVirtualDir // when prefix doesn't end with '/' and is a subdirectory: don't assume there are no _prefixed_ obj names 37 DisableColdGET // disable cold-GET (from remote bucket) 38 StreamingColdGET // write and transmit cold-GET content back to user in parallel, without _finalizing_ in-cluster object 39 S3ReverseProxy // use reverse proxy calls instead of HTTP-redirect for S3 API 40 S3UsePathStyle // use older path-style addressing (as opposed to virtual-hosted style), e.g., https://s3.amazonaws.com/BUCKET/KEY 41 ) 42 43 var Cluster = []string{ 44 "Enforce-IntraCluster-Access", 45 "Skip-Loading-VersionChecksum-MD", 46 "Do-not-Auto-Detect-FileShare", 47 "S3-API-via-Root", 48 "Fsync-PUT", 49 "LZ4-Block-1MB", 50 "LZ4-Frame-Checksum", 51 "Dont-Allow-Passing-FQN-to-ETL", 52 "Ignore-LimitedCoexistence-Conflicts", 53 "S3-Presigned-Request", 54 "Dont-Optimize-Listing-Virtual-Dirs", 55 "Disable-Cold-GET", 56 "Streaming-Cold-GET", 57 "S3-Reverse-Proxy", 58 "S3-Use-Path-Style", // https://aws.amazon.com/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story 59 // "none" ==================== 60 } 61 62 var Bucket = []string{ 63 "Skip-Loading-VersionChecksum-MD", 64 "Fsync-PUT", 65 "S3-Presigned-Request", 66 "Disable-Cold-GET", 67 "Streaming-Cold-GET", 68 "S3-Use-Path-Style", // https://aws.amazon.com/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story 69 // "none" ==================== 70 } 71 72 func (f Flags) IsSet(flag Flags) bool { return cos.BitFlags(f).IsSet(cos.BitFlags(flag)) } 73 func (f Flags) Set(flags Flags) Flags { return Flags(cos.BitFlags(f).Set(cos.BitFlags(flags))) } 74 func (f Flags) String() string { return strconv.FormatUint(uint64(f), 10) } 75 76 func IsBucketScope(name string) bool { return cos.StringInSlice(name, Bucket) } 77 78 func CSV2Feat(s string) (Flags, error) { 79 if s == "" || s == "none" { 80 return 0, nil 81 } 82 for i, name := range Cluster { 83 if s == name { 84 return 1 << i, nil 85 } 86 } 87 return 0, errors.New("unknown feature flag '" + s + "'") 88 } 89 90 func (f Flags) Names() (names []string) { 91 if f == 0 { 92 return names 93 } 94 for i, name := range Cluster { 95 if f&(1<<i) != 0 { 96 names = append(names, name) 97 } 98 } 99 return names 100 } 101 102 func (f Flags) ClearName(n string) Flags { 103 for i, name := range Cluster { 104 if name == n { 105 of := Flags(1 << i) 106 return f &^ of 107 } 108 } 109 return f 110 }