TiDB 6.4后通过S3访问阿里云OSS失败,同样配置在6.1, 5.1都可上传成功

	// s3manager.GetBucketRegionWithClient will set credential anonymous, which works with s3.
	// we need reassign credential to be compatible with minio authentication.
	confCred := ses.Config.Credentials
	setCredOpt := func(req *request.Request) {
		if confCred != nil {
			req.Config.Credentials = confCred
		}
	}
	region, err := s3manager.GetBucketRegionWithClient(context.Background(), c, qs.Bucket, setCredOpt)
	if err != nil {
		return nil, errors.Annotatef(err, "failed to get region of bucket %s", qs.Bucket)
	}

看起来 s3manager.GetBucketRegionWithClient will set credential anonymous这个是关键,看了下6.1的版本没有使用s3manger获取region的逻辑。

1 个赞