Skip to content

Commit

Permalink
OCPBUGS-44849: Skip manifest metadata operations if xattr support not…
Browse files Browse the repository at this point in the history
… present.

Some customers are expereincing breaking issues when their OS does not support xattr, most notably NFS + Xattr
This causes installations not to proceed and needs to be addressed urgently.

As an intermim measure, it has been decided that we will skip manifest metadata operations and warn the user if we find that xattr is unsupported for the file path.
  • Loading branch information
paul-maidment committed Nov 26, 2024
1 parent 8dc67a1 commit a8f70cc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/s3wrapper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ObjectInfo struct {
//go:generate mockgen --build_flags=--mod=mod -package=s3wrapper -destination=mock_s3wrapper.go . API
//go:generate mockgen --build_flags=--mod=mod -package s3wrapper -destination mock_s3iface.go github.com/aws/aws-sdk-go/service/s3/s3iface S3API
//go:generate mockgen --build_flags=--mod=mod -package s3wrapper -destination mock_s3manageriface.go github.com/aws/aws-sdk-go/service/s3/s3manager/s3manageriface UploaderAPI
//go:generate mockgen --build_flags=--mod=mod -package s3wrapper -destination mock_s3iface.go github.com/aws/aws-sdk-go/service/s3/s3iface S3API
type API interface {
IsAwsS3() bool
CreateBucket() error
Expand Down
44 changes: 43 additions & 1 deletion pkg/s3wrapper/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,64 @@ func (f *FSClient) CreateBucket() error {

const xattrUserAttributePrefix = "user."

func isUnsupportedXattrError(err error) bool {
xattr_error, ok := err.(*xattr.Error)
if !ok {
return true
}
errno, ok := xattr_error.Err.(syscall.Errno)
if !ok {
return true
}
if errno == syscall.Errno(syscall.ENOTSUP) || errno == syscall.Errno(syscall.EOPNOTSUPP) {
return true
}
return false
}



func (f *FSClient) writeFileMetadata(filePath string, metadata map[string]string) error {
if xattr.XATTR_SUPPORTED == false {
f.log.Warn("Xattr is not supported for your platform - consider upgrading to one that supports xattr")
return nil
}
for attributeName, attributeValue := range metadata {
err := xattr.Set(filePath, strings.ToLower(fmt.Sprintf("%s%s", xattrUserAttributePrefix, attributeName)), []byte(attributeValue))
if err != nil {
if err != nil && !isUnsupportedXattrError(err) {
return errors.Wrapf(err, "unable to store metadata key %s = %s", attributeName, attributeValue)
}
// Warn that Xattr is unsupported in the filesystem for the path - then ignore the error
f.log.Warnf(
"Error while setting xattr %s=%s for path %s, the filesystem does not support extended attributes (xattr) - consider upgrading the operation system to one that supports xattr",
fmt.Sprintf("%s%s", xattrUserAttributePrefix, attributeName),
attributeValue,
filePath,
)
}
return nil
}

func (f *FSClient) getFileMetadata(filePath string) (map[string]string, error) {
attributes := make(map[string]string)
if xattr.XATTR_SUPPORTED == false {
f.log.Warn("Xattr is not supported for your platform - consider upgrading to one that supports xattr")
return attributes, nil
}
attributeNames, err := xattr.List(filePath)
isUnsupportedXattrError := isUnsupportedXattrError(err)
if err != nil {
if isUnsupportedXattrError {
// Warn that Xattr is unsupported in the filesystem for the path - then ignore the error
f.log.Warnf(
"Error while listing metadata in path %s, the filesystem does not support extended attributes (xattr) - consider upgrading the operation system to one that supports xattr",
filePath,
)
return attributes, nil
}
return nil, errors.Wrap(err, "Unable to obtain extended file attributes while retrieving file metadata")
}

for _, attributeName := range attributeNames {
if !strings.HasPrefix(attributeName, xattrUserAttributePrefix) {
continue
Expand Down

0 comments on commit a8f70cc

Please sign in to comment.