Skip to content

Commit

Permalink
Sync from server repo (edb1d65390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Spilchen committed Oct 5, 2023
1 parent 1f667ff commit ac6b0a4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 50 deletions.
3 changes: 0 additions & 3 deletions vclusterops/create_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ func (opt *VCreateDatabaseOptions) CheckNilPointerParams() error {
if opt.CommunalStorageLocation == nil {
return util.ParamNotSetErrorMsg("communal-storage-location")
}
if opt.CommunalStorageParameters == nil {
return util.ParamNotSetErrorMsg("communal-storage-params")
}
if opt.DepotSize == nil {
return util.ParamNotSetErrorMsg("depot-size")
}
Expand Down
5 changes: 1 addition & 4 deletions vclusterops/nma_bootstrap_catalog_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"

"github.com/vertica/vcluster/vclusterops/util"
"github.com/vertica/vcluster/vclusterops/vlog"
)

Expand Down Expand Up @@ -70,8 +69,6 @@ func makeNMABootstrapCatalogOp(

func (op *NMABootstrapCatalogOp) setupRequestBody(vdb *VCoordinationDatabase, options *VCreateDatabaseOptions) error {
op.hostRequestBodyMap = make(map[string]bootstrapCatalogRequestData)
// Add configuration and communal storage params to bootstrap params
bootstrapParams := util.MapCombine(options.ConfigurationParameters, options.CommunalStorageParameters)

for _, host := range op.hosts {
bootstrapData := bootstrapCatalogRequestData{}
Expand All @@ -88,7 +85,7 @@ func (op *NMABootstrapCatalogOp) setupRequestBody(vdb *VCoordinationDatabase, op

// client port: spread port will be computed based on client port
bootstrapData.PortNumber = vnode.Port
bootstrapData.Parameters = bootstrapParams
bootstrapData.Parameters = options.ConfigurationParameters

// need to read network_profile info in execContext
// see execContext in NMABootstrapCatalogOp:prepare()
Expand Down
8 changes: 0 additions & 8 deletions vclusterops/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,6 @@ func CopyMap[K comparable, V any](original map[K]V) map[K]V {
return copyOfMap
}

// Combine two maps into one map
func MapCombine[M map[K]V, K comparable, V any](m, n M) map[K]V {
for key, value := range n {
m[key] = value
}
return m
}

// ValidateCommunalStorageLocation can identify some invalid communal storage locations
func ValidateCommunalStorageLocation(location string) error {
// reject empty communal storage location
Expand Down
29 changes: 0 additions & 29 deletions vclusterops/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,6 @@ func TestSliceDiff(t *testing.T) {
assert.Equal(t, expected, actual)
}

func TestCombineMap(t *testing.T) {
// Test with keys-values string-string
a := map[string]string{"communal-storage-params": "awsconnecttimeout=123"}
b := map[string]string{"config-param": "InitialDefaultSubclusterName=sc"}
expected := map[string]string{
"communal-storage-params": "awsconnecttimeout=123",
"config-param": "InitialDefaultSubclusterName=sc",
}
actual := MapCombine(a, b)
assert.Equal(t, expected, actual)

// Test with empty keys and values
a = map[string]string{}
b = map[string]string{}
expected = map[string]string{}
actual = MapCombine(a, b)
assert.Equal(t, expected, actual)

// Test with keys-values string-int
map1 := map[string]int{"communal-storage-params": 123}
map2 := map[string]int{"config-param": 456}
expectedMap := map[string]int{
"communal-storage-params": 123,
"config-param": 456,
}
actualMap := MapCombine(map1, map2)
assert.Equal(t, expectedMap, actualMap)
}

func TestMapKeyDiff(t *testing.T) {
a := map[string]bool{"1": true, "2": true}
b := map[string]bool{"1": true, "3": true, "4": false}
Expand Down
17 changes: 11 additions & 6 deletions vclusterops/vlog/vLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,18 @@ func (logger *Vlogger) logMaskedArgParse(inputArgv []string) {
"gcsauth": true,
"azurestoragecredentials": true,
}
const expectedParts = 2
const maskedValue = "******"
const targetMaskedArg = "--communal-storage-params" // target param
const (
expectedParts = 2
maskedValue = "******"
)
// We need to mask any parameters containing sensitive information
targetMaskedArg := map[string]bool{
"--config-param": true,
"--communal-storage-params": true,
}
for i := 0; i < len(inputArgv); i++ {
if inputArgv[i] == targetMaskedArg && i+1 < len(inputArgv) {
if targetMaskedArg[inputArgv[i]] && i+1 < len(inputArgv) {
pairs := strings.Split(inputArgv[i+1], ",")
maskedPairs = append(maskedPairs, targetMaskedArg)
for _, pair := range pairs {
keyValue := strings.Split(pair, "=")
if len(keyValue) == expectedParts {
Expand All @@ -341,7 +346,7 @@ func (logger *Vlogger) logMaskedArgParse(inputArgv []string) {
if sensitiveKeyParams[keyLowerCase] {
value = maskedValue
}
maskedPairs = append(maskedPairs, key+"="+value)
maskedPairs = append(maskedPairs, inputArgv[i], key+"="+value)
} else {
// Handle invalid format
maskedPairs = append(maskedPairs, pair)
Expand Down

0 comments on commit ac6b0a4

Please sign in to comment.