Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2bfd2a1

Browse files
committed
Merge branch 'nix-portpool-upper-boundary-inclusive' into 'master'
Make upper boundary in portPool inclusive See merge request postgres-ai/database-lab!785
2 parents 0ebf7ae + 5e5a9ac commit 2bfd2a1

12 files changed

+23
-19
lines changed

‎engine/configs/config.example.logical_generic.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ databaseConfigs: &db_configs
130130
provision:
131131
<<: *db_container
132132
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
133-
# starting from the lowest value. The "from" value must be less than "to".
133+
# starting from the lowest value. The "from" value must be less than or equal to "to".
134134
portPool:
135135
from: 6000
136-
to: 6100
136+
to: 6099
137137

138138
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
139139
# outside a container. Keep it "false" (default) when running in a container.

‎engine/configs/config.example.logical_rds_iam.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ databaseConfigs: &db_configs
129129
provision:
130130
<<: *db_container
131131
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
132-
# starting from the lowest value. The "from" value must be less than "to".
132+
# starting from the lowest value. The "from" value must be less than or equal to "to".
133133
portPool:
134134
from: 6000
135-
to: 6100
135+
to: 6099
136136

137137
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
138138
# outside a container. Keep it "false" (default) when running in a container.

‎engine/configs/config.example.physical_generic.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ databaseConfigs: &db_configs
127127
provision:
128128
<<: *db_container
129129
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
130-
# starting from the lowest value. The "from" value must be less than "to".
130+
# starting from the lowest value. The "from" value must be less than or equal to "to".
131131
portPool:
132132
from: 6000
133-
to: 6100
133+
to: 6099
134134

135135
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
136136
# outside a container. Keep it "false" (default) when running in a container.

‎engine/configs/config.example.physical_pgbackrest.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ databaseConfigs: &db_configs
127127
provision:
128128
<<: *db_container
129129
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
130-
# starting from the lowest value. The "from" value must be less than "to".
130+
# starting from the lowest value. The "from" value must be less than or equal to "to".
131131
portPool:
132132
from: 6000
133-
to: 6100
133+
to: 6099
134134

135135
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
136136
# outside a container. Keep it "false" (default) when running in a container.

‎engine/configs/config.example.physical_walg.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ databaseConfigs: &db_configs
127127
provision:
128128
<<: *db_container
129129
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
130-
# starting from the lowest value. The "from" value must be less than "to".
130+
# starting from the lowest value. The "from" value must be less than or equal to "to".
131131
portPool:
132132
from: 6000
133-
to: 6100
133+
to: 6099
134134

135135
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
136136
# outside a container. Keep it "false" (default) when running in a container.

‎engine/internal/provision/mode_local.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func New(ctx context.Context, cfg *Config, dbCfg *resources.DB, docker *client.C
9292
pm: pm,
9393
networkID: networkID,
9494
instanceID: instanceID,
95-
ports: make([]bool, cfg.PortPool.To-cfg.PortPool.From),
95+
ports: make([]bool, cfg.PortPool.To-cfg.PortPool.From+1),
9696
}
9797

9898
return p, nil
@@ -114,7 +114,7 @@ func isValidConfigModeLocal(config Config) error {
114114
return errors.New(`"portPool.to" must be defined and be greater than 0`)
115115
}
116116

117-
if portPool.To <= portPool.From {
117+
if portPool.To < portPool.From {
118118
return errors.New(`"portPool" must include at least one port`)
119119
}
120120

@@ -444,7 +444,7 @@ func (p *Provisioner) RevisePortPool() error {
444444

445445
availablePorts := 0
446446

447-
for port := p.config.PortPool.From; port < p.config.PortPool.To; port++ {
447+
for port := p.config.PortPool.From; port <= p.config.PortPool.To; port++ {
448448
if err := p.portChecker.checkPortAvailability(host, port); err != nil {
449449
log.Msg(fmt.Sprintf("port %d is not available, marking as busy", port))
450450

@@ -533,7 +533,7 @@ func (p *Provisioner) FreePort(port uint) error {
533533
func (p *Provisioner) setPortStatus(port uint, bind bool) error {
534534
portOpts := p.config.PortPool
535535

536-
if port < portOpts.From || port >= portOpts.To {
536+
if port < portOpts.From || port > portOpts.To {
537537
return errors.Errorf("port %d is out of bounds of the port pool", port)
538538
}
539539

‎engine/internal/provision/mode_local_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func TestPortAllocation(t *testing.T) {
4040
_, err = p.allocatePort()
4141
require.NoError(t, err)
4242

43+
// Allocate one more port.
44+
_, err = p.allocatePort()
45+
require.NoError(t, err)
46+
4347
// Impossible allocate a new port.
4448
_, err = p.allocatePort()
4549
assert.IsType(t, errors.Cause(err), &NoRoomError{})

‎engine/test/1.synthetic.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DLE_SERVER_NAME="dblab_server_test"
99
export POSTGRES_VERSION="${POSTGRES_VERSION:-13}"
1010
export DLE_SERVER_PORT=${DLE_SERVER_PORT:-12345}
1111
export DLE_PORT_POOL_FROM=${DLE_PORT_POOL_FROM:-9000}
12-
export DLE_PORT_POOL_TO=${DLE_PORT_POOL_TO:-9100}
12+
export DLE_PORT_POOL_TO=${DLE_PORT_POOL_TO:-9099}
1313
export DLE_TEST_MOUNT_DIR="/var/lib/test/dblab_mount"
1414
export DLE_TEST_POOL_NAME="test_dblab_pool"
1515

‎engine/test/2.logical_generic.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export DLE_TEST_MOUNT_DIR="/var/lib/test/dblab_mount"
1616
export DLE_TEST_POOL_NAME="test_dblab_pool"
1717
export DLE_SERVER_PORT=${DLE_SERVER_PORT:-12345}
1818
export DLE_PORT_POOL_FROM=${DLE_PORT_POOL_FROM:-9000}
19-
export DLE_PORT_POOL_TO=${DLE_PORT_POOL_TO:-9100}
19+
export DLE_PORT_POOL_TO=${DLE_PORT_POOL_TO:-9099}
2020

2121
DIR=${0%/*}
2222

‎engine/test/3.physical_walg.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export DLE_TEST_MOUNT_DIR="/var/lib/test/dblab_mount"
1212
export DLE_TEST_POOL_NAME="test_dblab_pool"
1313
export DLE_SERVER_PORT=${DLE_SERVER_PORT:-12345}
1414
export DLE_PORT_POOL_FROM=${DLE_PORT_POOL_FROM:-9000}
15-
export DLE_PORT_POOL_TO=${DLE_PORT_POOL_TO:-9100}
15+
export DLE_PORT_POOL_TO=${DLE_PORT_POOL_TO:-9099}
1616
## AWS
1717
set +euxo pipefail # ---- do not display secrets
1818
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-""}"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /