From 981e3cde0e51bb40ad68055c406eccf0a87cb0bd Mon Sep 17 00:00:00 2001 From: George Hicken Date: Wed, 16 Nov 2022 10:38:29 -0800 Subject: [PATCH 1/4] Fix missing timeout arg in helpers and filter in lint --- Makefile | 2 +- infra/scripts/bash-helpers.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e6bbd42b06e..4999ee56399 100644 --- a/Makefile +++ b/Makefile @@ -212,7 +212,7 @@ whitespace: @infra/scripts/whitespace-check.sh # exit 1 if golint complains about anything other than comments -golintf = $(GOLINT) $(1) | sh -c "! grep -v 'lib/apiservers/portlayer/restapi/operations'" | sh -c "! grep -v 'lib/config/dynamic/admiral/client'" | sh -c "! grep -v 'should have comment'" | sh -c "! grep -v 'comment on exported'" | sh -c "! grep -v 'by other packages, and that stutters'" | sh -c "! grep -v 'error strings should not be capitalized'" +golintf = $(GOLINT) $(1) | sh -c "! grep -v 'lib/apiservers/portlayer/restapi/operations'" | sh -c "! grep -v 'lib/apiservers/service/restapi/operations/not_yet_implemented'" | sh -c "! grep -v 'lib/config/dynamic/admiral/client'" | sh -c "! grep -v 'should have comment'" | sh -c "! grep -v 'comment on exported'" | sh -c "! grep -v 'by other packages, and that stutters'" | sh -c "! grep -v 'error strings should not be capitalized'" golint: $(GOLINT) @echo checking go lint... diff --git a/infra/scripts/bash-helpers.sh b/infra/scripts/bash-helpers.sh index c3f86fdf6df..25c629b203d 100644 --- a/infra/scripts/bash-helpers.sh +++ b/infra/scripts/bash-helpers.sh @@ -30,7 +30,7 @@ fi # 1: release numnber, e.g. 1.4.1 or 1.4.1-rc2, or build id, e.g. 19653 vic-set-version () { version="$1" - + if [ "$1" == "" ]; then unset VIC_VERSION return @@ -63,7 +63,7 @@ init-profile () { unset-vic () { unset TARGET_URL MAPPED_NETWORKS NETWORKS IMAGE_STORE DATASTORE COMPUTE VOLUME_STORES IPADDR TLS THUMBPRINT OPS_CREDS VIC_NAME PRESERVE_VOLUMES - unset GOVC_URL GOVC_INSECURE GOVC_DATACENTER GOVC_USERNAME GOVC_PASSWORD GOVC_DATASTORE GOVC_CERTIFICATE + unset GOVC_URL GOVC_INSECURE GOVC_DATACENTER GOVC_USERNAME GOVC_PASSWORD GOVC_DATASTORE GOVC_CERTIFICATE unset vsphere datacenter user password opsuser opspass opsgrant timeout compute datastore dns publicNet publicIP publicGW bridgeNet bridgeRange unset clientNet clientIP clientGW managementNet managementIP managementGW tls volumestores preserveVolumestores containernet @@ -79,7 +79,7 @@ vic-create () { base=$(pwd) ( cd "$(vic-path)"/bin || return - "$(vic-path)/bin/${VIC_VERSION}/vic-machine-$OS" create --target="$TARGET_URL" "${OPS_CREDS[@]}" --image-store="$IMAGE_STORE" --compute-resource="$COMPUTE" "${TLS[@]}" ${TLS_OPTS} --name="${VIC_NAME:-${USER}test}" "${MAPPED_NETWORKS[@]}" "${VOLUME_STORES[@]}" "${NETWORKS[@]}" ${IPADDR} ${TIMEOUT} --thumbprint="$THUMBPRINT" --ai="${VIC_VERSION}/appliance.iso" --bi="${VIC_VERSION}/bootstrap.iso" "$@" + "$(vic-path)/bin/${VIC_VERSION}/vic-machine-$OS" create --target="$TARGET_URL" "${OPS_CREDS[@]}" --image-store="$IMAGE_STORE" --compute-resource="$COMPUTE" "${TLS[@]}" ${TLS_OPTS} --name="${VIC_NAME:-${USER}test}" "${MAPPED_NETWORKS[@]}" "${VOLUME_STORES[@]}" "${NETWORKS[@]}" ${IPADDR} --timeout=${TIMEOUT} --thumbprint="$THUMBPRINT" --ai="${VIC_VERSION}/appliance.iso" --bi="${VIC_VERSION}/bootstrap.iso" "$@" ) vic-select From df1b4602bf51e74fccb4b742d4f2004a7dfbdfdc Mon Sep 17 00:00:00 2001 From: George Hicken Date: Thu, 1 Dec 2022 14:32:37 -0800 Subject: [PATCH 2/4] Expose max concurrent connection config option This adds an option to set the maximum number of concurrent connections to vCenter that will be used by the port layer. This does NOT effect the admin server, and admin server connections do not count towards the maximum for the port layer. This adds a --max-concurrent-connections (--mcc short form) option to create and configure, allowing setting between 2 (because port layer requires 2 minimum to initialize) and 255 (because it's a sane upper limit, given default has been 32 since 2017, but with no reason beyond that). This has NOT made the necessary changes for this option to be available via the VIC LCM API and vCenter UI extension. Testing so far has been via manual use of CLI. --- cmd/vic-machine/common/target.go | 11 +++ cmd/vic-machine/common/target_test.go | 6 +- cmd/vic-machine/configure/configure.go | 6 ++ cmd/vic-machine/create/create.go | 2 + cmd/vic-machine/create/create_test.go | 2 +- lib/config/executor/container_vm.go | 37 +++++++- lib/config/executor/container_vm_test.go | 113 +++++++++++++++++++++++ lib/config/virtual_container_host.go | 25 ++--- lib/constants/constants.go | 9 ++ lib/install/data/data.go | 4 + lib/install/management/appliance.go | 5 + lib/install/validate/config_to_data.go | 11 +++ lib/install/validate/validator.go | 25 ++++- pkg/vsphere/session/session.go | 8 +- 14 files changed, 244 insertions(+), 20 deletions(-) create mode 100644 lib/config/executor/container_vm_test.go diff --git a/cmd/vic-machine/common/target.go b/cmd/vic-machine/common/target.go index e96e5e5fe55..c4cbf5c7173 100644 --- a/cmd/vic-machine/common/target.go +++ b/cmd/vic-machine/common/target.go @@ -33,6 +33,8 @@ type Target struct { Password *string CloneTicket string Thumbprint string `cmd:"thumbprint"` + + MaxConcurrentConnections *int `cmd:"max-concurrent-connections"` } func NewTarget() *Target { @@ -67,11 +69,20 @@ func (t *Target) TargetFlags() []cli.Flag { Usage: "ESX or vCenter host certificate thumbprint", EnvVar: "VIC_MACHINE_THUMBPRINT", }, + cli.GenericFlag{ + Name: "max-concurrent-connections, mcc", + Value: flags.NewOptionalInt(&t.MaxConcurrentConnections), + Usage: "Determines maximum number of connections (not sessions) to vCenter. Integer value, greater than 0", + EnvVar: "VIC_MACHINE_MAX_CONCURRENT_CONNECTIONS", + Hidden: true, + }, } } // HasCredentials check that the credentials have been supplied by any of the permitted mechanisms func (t *Target) HasCredentials(op trace.Operation) error { + defer trace.End(trace.Begin("", op)) + if t.URL == nil { return cli.NewExitError("--target argument must be specified", 1) } diff --git a/cmd/vic-machine/common/target_test.go b/cmd/vic-machine/common/target_test.go index 58f83b6338d..e4fe99b462b 100644 --- a/cmd/vic-machine/common/target_test.go +++ b/cmd/vic-machine/common/target_test.go @@ -29,7 +29,7 @@ func TestFlags(t *testing.T) { target := NewTarget() flags := target.TargetFlags() - if len(flags) != 4 { + if len(flags) != 5 { t.Errorf("Wrong flag numbers") } } @@ -50,6 +50,10 @@ func TestProcess(t *testing.T) { User string Password *string + // MaxConcurrentConnections is not tested here as there's no explicit validation at this stage + // Validation of input type is via flags package, and validation of values is via validator + /// mcc *int + err error result *url.URL }{ diff --git a/cmd/vic-machine/configure/configure.go b/cmd/vic-machine/configure/configure.go index 23f55ada2cb..18b73bc07a9 100644 --- a/cmd/vic-machine/configure/configure.go +++ b/cmd/vic-machine/configure/configure.go @@ -19,6 +19,7 @@ import ( "fmt" "net" "os" + "strconv" "strings" "time" @@ -214,6 +215,11 @@ func (c *Configure) copyChangedConf(o *config.VirtualContainerHostConfigSpec, n updateSessionEnv(portlayerSession, config.PortLayerDCPath, v.Session().Datacenter.Name()) } + // if mcc is explicitly set, apply it + if c.Data.MaxConcurrentConnections != nil { + updateSessionEnv(portlayerSession, config.PortLayerMaxConcurrentConnections, strconv.Itoa(*c.Data.MaxConcurrentConnections)) + } + if c.Debug.Debug != nil { o.SetDebug(n.Diagnostics.DebugLevel) } diff --git a/cmd/vic-machine/create/create.go b/cmd/vic-machine/create/create.go index 03915f49689..df9e986fa70 100644 --- a/cmd/vic-machine/create/create.go +++ b/cmd/vic-machine/create/create.go @@ -719,6 +719,8 @@ func (c *Create) Run(clic *cli.Context) (err error) { vConfig.Timeout = c.Data.Timeout + vConfig.MaxConcurrentConnections = c.MaxConcurrentConnections + // separate initial validation from dispatch of creation task op.Info("") diff --git a/cmd/vic-machine/create/create_test.go b/cmd/vic-machine/create/create_test.go index e257db88ad5..91c93b454a9 100644 --- a/cmd/vic-machine/create/create_test.go +++ b/cmd/vic-machine/create/create_test.go @@ -72,7 +72,7 @@ func TestParseGatewaySpec(t *testing.T) { func TestFlags(t *testing.T) { c := NewCreate() flags := c.Flags() - numberOfFlags := 65 + numberOfFlags := 66 assert.Equal(t, numberOfFlags, len(flags), "Missing flags during Create.") } diff --git a/lib/config/executor/container_vm.go b/lib/config/executor/container_vm.go index b616e08e66c..b9ed6ec6c52 100644 --- a/lib/config/executor/container_vm.go +++ b/lib/config/executor/container_vm.go @@ -119,7 +119,8 @@ type ExitLog struct { // MountSpec details a mount that must be executed within the executor // A mount is a URI -> path mapping with a credential of some kind // In the case of a labeled disk: -// label://