Skip to content

Commit

Permalink
Fix checkMinIO for pathStyle not supported cloudProvider (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: haorenfsa <[email protected]>
  • Loading branch information
haorenfsa authored Sep 13, 2024
1 parent de93c17 commit af463b9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/status_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (r *MilvusStatusSyncer) GetMinioCondition(
UseIAM: GetMinioUseIAM(mc.Spec.Conf.Data),
IAMEndpoint: GetMinioIAMEndpoint(mc.Spec.Conf.Data),
StorageAccount: GetAzureStorageAccount(mc.Spec.Conf.Data),
UseVirtualHost: GetVirtualHostCondition(mc.Spec.Conf.Data),
UseVirtualHost: ShouldUseVirtualHost(mc.Spec.Conf.Data),
}
getter := wrapMinioConditionGetter(ctx, r.logger, r.Client, info)
return GetCondition(getter, []string{mc.Spec.Dep.Storage.Endpoint}), nil
Expand Down
11 changes: 9 additions & 2 deletions pkg/controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,20 @@ func GetMinioSecure(conf map[string]interface{}) bool {
return false
}

func GetVirtualHostCondition(conf map[string]interface{}) bool {
func ShouldUseVirtualHost(conf map[string]interface{}) bool {
fields := []string{"minio", "useVirtualHost"}
useVirtualHost, exist := util.GetBoolValue(conf, fields...)
if exist {
return useVirtualHost
if useVirtualHost {
return true
}
}

fields = []string{"minio", "cloudProvider"}
cloudProvider, exists := util.GetStringValue(conf, fields...)
if exists && cloudProvider != "aws" {
return true
}
return false
}

Expand Down
41 changes: 41 additions & 0 deletions pkg/controllers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,44 @@ func Test_int64Ptr(t *testing.T) {
func Test_boolPtr(t *testing.T) {
assert.True(t, *boolPtr(true))
}

func TestShouldUseVirtualHost(t *testing.T) {
config := map[string]interface{}{
"minio": map[string]interface{}{
"useVirtualHost": true,
},
}
assert.True(t, ShouldUseVirtualHost(config))

config = map[string]interface{}{
"minio": map[string]interface{}{
"useVirtualHost": false,
"cloudProvider": "gcp",
},
}
assert.True(t, ShouldUseVirtualHost(config))

config = map[string]interface{}{
"minio": map[string]interface{}{
"useVirtualHost": false,
"cloudProvider": "aliyun",
},
}
assert.True(t, ShouldUseVirtualHost(config))

config = map[string]interface{}{
"minio": map[string]interface{}{
"useVirtualHost": false,
"cloudProvider": "aws",
},
}
assert.False(t, ShouldUseVirtualHost(config))

config = map[string]interface{}{
"minio": map[string]interface{}{
"useVirtualHost": true,
"cloudProvider": "aws",
},
}
assert.True(t, ShouldUseVirtualHost(config))
}

0 comments on commit af463b9

Please sign in to comment.