Skip to content

Commit e0acdd7

Browse files
committed
Merge remote-tracking branch 'origin/expert-mode' into expert-mode
2 parents d982536 + 4c699df commit e0acdd7

File tree

10 files changed

+65
-41
lines changed

10 files changed

+65
-41
lines changed

automation/playbooks/remove_cluster.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
default_postgresql_cluster_name: "{{ 'main' if ansible_os_family == 'Debian' else 'data' }}"
3030
default_postgresql_data_dir: "\
3131
{% if cloud_provider | default('') | length > 0 %}\
32-
{{ pg_data_mount_path | default('/pgdata') }}/{{ default_postgresql_version }}/{{ default_postgresql_cluster_name }}\
32+
{{ postgresql_data_dir_mount_path | default('/pgdata') }}/{{ default_postgresql_version }}/{{ default_postgresql_cluster_name }}\
3333
{% else %}\
3434
{{ default_postgresql_home_dir }}/{{ default_postgresql_version }}/{{ default_postgresql_cluster_name }}\
3535
{% endif %}"

automation/playbooks/remove_node.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
default_postgresql_cluster_name: "{{ 'main' if ansible_os_family == 'Debian' else 'data' }}"
9090
default_postgresql_data_dir: "\
9191
{% if cloud_provider | default('') | length > 0 %}\
92-
{{ pg_data_mount_path | default('/pgdata') }}/{{ default_postgresql_version }}/{{ default_postgresql_cluster_name }}\
92+
{{ postgresql_data_dir_mount_path | default('/pgdata') }}/{{ default_postgresql_version }}/{{ default_postgresql_cluster_name }}\
9393
{% else %}\
9494
{{ default_postgresql_home_dir }}/{{ default_postgresql_version }}/{{ default_postgresql_cluster_name }}\
9595
{% endif %}"

automation/roles/cloud_resources/tasks/aws.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,25 @@
351351
register: ec2_spot_request_result
352352
when: item.instances[0] | default('') | length < 1
353353

354+
- name: "AWS: Wait for EC2 Spot instance to be created"
355+
amazon.aws.ec2_instance:
356+
access_key: "{{ lookup('ansible.builtin.env', 'AWS_ACCESS_KEY_ID') }}"
357+
secret_key: "{{ lookup('ansible.builtin.env', 'AWS_SECRET_ACCESS_KEY') }}"
358+
region: "{{ server_location }}"
359+
filters:
360+
spot-instance-request-id: "{{ item.spot_request.spot_instance_request_id }}"
361+
loop: "{{ ec2_spot_request_result.results }}"
362+
loop_control:
363+
index_var: idx
364+
label: "{{ server_name | lower }}{{ '%02d' % (idx + 1) }}"
365+
register: ec2_spot_instance_wait_result
366+
until:
367+
- ec2_spot_instance_wait_result.instances[0][ip_address_type] is defined
368+
- ec2_spot_instance_wait_result.instances[0][ip_address_type] | length > 0
369+
retries: 12
370+
delay: 10
371+
when: item.spot_request.spot_instance_request_id is defined
372+
354373
- name: "AWS: Rename the EC2 Spot instance"
355374
amazon.aws.ec2_instance:
356375
access_key: "{{ lookup('ansible.builtin.env', 'AWS_ACCESS_KEY_ID') }}"
@@ -364,9 +383,7 @@
364383
index_var: idx
365384
label: "{{ server_name | lower }}{{ '%02d' % (idx + 1) }}"
366385
register: ec2_spot_instance_result
367-
until:
368-
- ec2_spot_instance_result.instances[0][ip_address_type] is defined
369-
- ec2_spot_instance_result.instances[0][ip_address_type] | length > 0
386+
until: ec2_spot_instance_result is success
370387
retries: 3
371388
delay: 10
372389
when: item.spot_request.spot_instance_request_id is defined

automation/roles/common/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ postgresql_home_dir: "{{ '/var/lib/postgresql' if ansible_os_family == 'Debian'
259259
# You can specify custom data dir path. Example: "/pgdata/{{ postgresql_version }}/main"
260260
postgresql_data_dir: "\
261261
{% if cloud_provider | default('') | length > 0 %}\
262-
{{ pg_data_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ postgresql_cluster_name }}\
262+
{{ postgresql_data_dir_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ postgresql_cluster_name }}\
263263
{% else %}\
264264
{{ postgresql_home_dir }}/{{ postgresql_version }}/{{ postgresql_cluster_name }}\
265265
{% endif %}"

automation/roles/mount/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This role configures filesystems and mount points:
1414
| mount[].fstype | "ext4" | Filesystem type (e.q., ext4, xfs). Use "zfs" to create a zpool and mount it. |
1515
| mount[].opts | "defaults,noatime" | Mount options (not applicable to zfs creation). |
1616
| mount[].state | "mounted" | Desired state (mounted, present, absent, etc.). |
17-
| pg_data_mount_path | "/pgdata" | Default path used when auto-provisioning or for the ZFS mountpoint. |
18-
| pg_data_mount_fstype | "ext4" | Filesystem type to create when auto-provisioning the first disk. Set to "zfs" to create a zpool. |
17+
| postgresql_data_dir_mount_path | "/pgdata" | Default path used when auto-provisioning or for the ZFS mountpoint. |
18+
| postgresql_data_dir_mount_fstype | "ext4" | Filesystem type to create when auto-provisioning the first disk. Set to "zfs" to create a zpool. |
1919

2020
Notes:
2121
- The role relies on lsblk and jq for disk detection; ensure jq is available (it is installed by the common role by default).

automation/roles/mount/tasks/main.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
when: lsblk_disk.stdout is defined and lsblk_disk.stdout | length < 1
2727

2828
# Filesystem
29-
- name: Create "{{ pg_data_mount_fstype | default('ext4') }}" filesystem on the disk "/dev/{{ lsblk_disk.stdout | default('') }}"
29+
- name: Create "{{ postgresql_data_dir_mount_fstype | default('ext4') }}" filesystem on the disk "/dev/{{ lsblk_disk.stdout | default('') }}"
3030
community.general.filesystem:
3131
dev: "/dev/{{ lsblk_disk.stdout }}"
32-
fstype: "{{ pg_data_mount_fstype | default('ext4') }}"
32+
fstype: "{{ postgresql_data_dir_mount_fstype | default('ext4') }}"
3333
when:
3434
- (lsblk_disk.stdout is defined and lsblk_disk.stdout | length > 0)
35-
- ((pg_data_mount_fstype is defined and pg_data_mount_fstype != 'zfs') or
36-
(pg_data_mount_fstype is not defined and mount[0].fstype != 'zfs'))
35+
- ((postgresql_data_dir_mount_fstype is defined and postgresql_data_dir_mount_fstype != 'zfs') or
36+
(postgresql_data_dir_mount_fstype is not defined and mount[0].fstype != 'zfs'))
3737

3838
# UUID
3939
- name: Get UUID of the disk "/dev/{{ lsblk_disk.stdout | default('') }}"
@@ -46,30 +46,30 @@
4646
changed_when: false
4747
when:
4848
- (lsblk_disk.stdout is defined and lsblk_disk.stdout | length > 0)
49-
- ((pg_data_mount_fstype is defined and pg_data_mount_fstype != 'zfs') or
50-
(pg_data_mount_fstype is not defined and mount[0].fstype != 'zfs'))
49+
- ((postgresql_data_dir_mount_fstype is defined and postgresql_data_dir_mount_fstype != 'zfs') or
50+
(postgresql_data_dir_mount_fstype is not defined and mount[0].fstype != 'zfs'))
5151

5252
- name: "Set mount variables"
5353
ansible.builtin.set_fact:
5454
mount:
5555
- src: "UUID={{ lsblk_uuid.stdout }}"
56-
path: "{{ pg_data_mount_path | default('/pgdata', true) }}"
57-
fstype: "{{ pg_data_mount_fstype | default('ext4', true) }}"
56+
path: "{{ postgresql_data_dir_mount_path | default('/pgdata', true) }}"
57+
fstype: "{{ postgresql_data_dir_mount_fstype | default('ext4', true) }}"
5858
when: lsblk_uuid.stdout is defined
5959

6060
# Mount
6161
- name: Mount the filesystem
6262
ansible.posix.mount:
6363
path: "{{ item.path }}"
6464
src: "{{ item.src }}"
65-
fstype: "{{ item.fstype | default(pg_data_mount_fstype | default('ext4', true), true) }}"
65+
fstype: "{{ item.fstype | default(postgresql_data_dir_mount_fstype | default('ext4', true), true) }}"
6666
opts: "{{ item.opts | default('defaults,noatime') }}"
6767
state: "{{ item.state | default('mounted') }}"
6868
loop: "{{ mount }}"
6969
when:
7070
- (item.src | length > 0 and item.path | length > 0)
71-
- ((pg_data_mount_fstype is defined and pg_data_mount_fstype != 'zfs') or
72-
(pg_data_mount_fstype is not defined and item.fstype != 'zfs'))
71+
- ((postgresql_data_dir_mount_fstype is defined and postgresql_data_dir_mount_fstype != 'zfs') or
72+
(postgresql_data_dir_mount_fstype is not defined and item.fstype != 'zfs'))
7373

7474
# ZFS Pool (if fstype is 'zfs')
7575
- block:
@@ -150,10 +150,10 @@
150150
-O atime=off
151151
-O recordsize=128k
152152
-O logbias=throughput
153-
-m {{ pg_data_mount_path | default(mount[0].path | default('/pgdata', true), true) }}
153+
-m {{ postgresql_data_dir_mount_path | default(mount[0].path | default('/pgdata', true), true) }}
154154
pgdata {{ mount[0].src | default("/dev/" + lsblk_disk.stdout, true) }}
155155
when:
156156
- (mount[0].src | length > 0 or lsblk_disk.stdout | default('') | length > 0)
157-
- ((pg_data_mount_fstype is defined and pg_data_mount_fstype == 'zfs') or
158-
(pg_data_mount_fstype is not defined and mount[0].fstype == 'zfs'))
157+
- ((postgresql_data_dir_mount_fstype is defined and postgresql_data_dir_mount_fstype == 'zfs') or
158+
(postgresql_data_dir_mount_fstype is not defined and mount[0].fstype == 'zfs'))
159159
tags: mount, zpool

automation/roles/pgbouncer/templates/pgbouncer.ini.j2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
[databases]
22
{% for pool in pgbouncer_pools %}
3-
{{ pool.name }} = host={{ postgresql_unix_socket_dir }} port={{ postgresql_port }} dbname={{ pool.dbname }} {% if pool.pool_parameters is string %}{{ pool.pool_parameters }}{% elif pool.pool_parameters is mapping %}{% for k, v in pool.pool_parameters.items() %}{{ k }}={{ v }} {% endfor %}{% endif %}
3+
{% set params = [] %}
4+
{% if pool.pool_parameters is string %}
5+
{% set _ = params.append(pool.pool_parameters) %}
6+
{% elif pool.pool_parameters is mapping %}
7+
{% for k, v in pool.pool_parameters.items() %}
8+
{% set _ = params.append(k ~ '=' ~ v) %}
9+
{% endfor %}
10+
{% endif %}
11+
{{ pool.name }} = host={{ postgresql_unix_socket_dir }} port={{ postgresql_port }} dbname={{ pool.dbname }} {{ params | join(' ') }}
412
{% endfor %}
513

614
* = host={{ postgresql_unix_socket_dir }} port={{ postgresql_port }}

automation/roles/postgresql_users/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name: "{{ item.name }}"
77
password: "{{ item.password | default(omit) }}"
88
encrypted: true
9-
role_attr_flags: "{{ item.flags }}"
9+
role_attr_flags: "{{ item.flags | default('LOGIN') }}"
1010
login_host: "127.0.0.1"
1111
login_port: "{{ postgresql_port }}"
1212
login_user: "{{ patroni_superuser_username }}"

console/service/internal/controllers/cluster/post_cluster.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -368,24 +368,23 @@ func getIntValFromExtraVars(m map[string]interface{}, key string) int {
368368
if !ok || v == nil {
369369
return 0
370370
}
371-
switch t := v.(type) {
372-
case float64:
373-
return int(t)
374-
case int:
375-
return t
376-
case int32:
377-
return int(t)
378-
case int64:
379-
return int(t)
380-
case string:
381-
n, err := strconv.Atoi(t)
382-
if err != nil {
383-
return 0
384-
}
371+
372+
if num, ok := v.(json.Number); ok {
373+
n, _ := strconv.Atoi(num.String())
385374
return n
386-
default:
387-
return 0
388375
}
376+
377+
if f, ok := v.(float64); ok {
378+
return int(f)
379+
}
380+
381+
s := fmt.Sprintf("%v", v)
382+
383+
if fl, err := strconv.ParseFloat(s, 64); err == nil {
384+
return int(fl)
385+
}
386+
387+
return 0
389388
}
390389

391390
type InventoryJson struct {

console/ui/src/shared/lib/clusterValuesTransformFunctions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const getCloudProviderExtraVars = (values: ClusterFormValues) => ({
7070
...values[CLUSTER_FORM_FIELD_NAMES.REGION_CONFIG].cloud_image.image,
7171
...(IS_EXPERT_MODE
7272
? {
73-
pg_data_mount_fstype: values[STORAGE_BLOCK_FIELDS.FILE_SYSTEM_TYPE],
73+
postgresql_data_dir_mount_fstype: values[STORAGE_BLOCK_FIELDS.FILE_SYSTEM_TYPE],
7474
volume_type: values[STORAGE_BLOCK_FIELDS.VOLUME_TYPE],
7575
database_public_access: !!values?.[ADDITIONAL_SETTINGS_BLOCK_FIELD_NAMES.IS_DB_PUBLIC_ACCESS],
7676
cloud_load_balancer: !!values?.[ADDITIONAL_SETTINGS_BLOCK_FIELD_NAMES.IS_CLOUD_LOAD_BALANCER],

0 commit comments

Comments
 (0)