Skip to content

fix(sysrc-svc): workaround *BSD minion indefinitely hanging on start #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ postgres:
# These pillars are typically never required.
# pkg: 'postgresql'
# pkg_client: 'postgresql-client'
# service: postgresql
# service:
# name: 'postgresql'
# flags: -w -s -m fast
# sysrc: True
pkgs_extra:
- postgresql-contrib
- postgresql-plpython
Expand Down
4 changes: 3 additions & 1 deletion postgres/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ postgres:

config_backup: '.bak'

service: postgresql
service:
name: postgresql
sysrc: False

bake_image: False

Expand Down
18 changes: 14 additions & 4 deletions postgres/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ FreeBSD:
prepare_cluster:
user: *freebsd-user
group: *freebsd-group
service:
flags: -w -s -m fast
sysrc: True

OpenBSD:
conf_dir: /var/postgresql/data
data_dir: /var/postgresql/data
user: _postgresql
service:
flags: -w -s -m fast
sysrc: True

RedHat:
pkg_repo:
Expand All @@ -54,7 +60,8 @@ RedHat:
pkg_dev: postgresql{{ release }}-devel
conf_dir: {{ data_dir }}
data_dir: {{ data_dir }}
service: postgresql-{{ repo.version }}
service:
name: postgresql-{{ repo.version }}

# Alternatives system
linux:
Expand Down Expand Up @@ -132,7 +139,8 @@ Suse:
pkg_libs: postgresql{{ release }}-libs
conf_dir: {{ data_dir }}
data_dir: {{ data_dir }}
service: postgresql-{{ repo.version }}
service:
name: postgresql-{{ repo.version }}

# Alternatives system
linux:
Expand Down Expand Up @@ -175,9 +183,11 @@ Suse:
## jinja check avoids rendering noise/failure on Linux
MacOS:
{%- if repo.use_upstream_repo == 'homebrew' %}
service: homebrew.mxcl.postgresql
service:
name: homebrew.mxcl.postgresql
{%- elif repo.use_upstream_repo == 'postgresapp' %}
service: com.postgresapp.Postgres2
service:
name: com.postgresapp.Postgres2
{%- endif %}
pkg: postgresql
pkg_client:
Expand Down
6 changes: 3 additions & 3 deletions postgres/server/image.sls
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ postgresql-start:
postgresql-enable:
cmd.run:
{%- if salt['file.file_exists']('/bin/systemctl') %}
- name: systemctl enable {{ postgres.service }}
- name: systemctl enable {{ postgres.service.name }}
{%- elif salt['cmd.which']('chkconfig') %}
- name: chkconfig {{ postgres.service }} on
- name: chkconfig {{ postgres.service.name }} on
{%- elif salt['file.file_exists']('/usr/sbin/update-rc.d') %}
- name: update-rc.d {{ service }} defaults
- name: update-rc.d {{ postgres.service.name }} defaults
{%- else %}
# Nothing to do
- name: 'true'
Expand Down
19 changes: 15 additions & 4 deletions postgres/server/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ postgresql-server:
- require_in:
- file: postgresql-server
file.managed:
- name: /Library/LaunchAgents/{{ postgres.service }}.plist
- source: /usr/local/opt/postgres/{{ postgres.service }}.plist
- name: /Library/LaunchAgents/{{ postgres.service.name }}.plist
- source: /usr/local/opt/postgres/{{ postgres.service.name }}.plist
- group: wheel
- require_in:
- service: postgresql-running
Expand Down Expand Up @@ -261,12 +261,23 @@ postgresql-tablespace-dir-{{ name }}-fcontext:

{%- if not postgres.bake_image %}

# Workaround for FreeBSD minion undefinitely hanging on service start
# cf. https://github.com/saltstack/salt/issues/44848
{% if postgres.service.sysrc %}
posgresql-rc-flags:
sysrc.managed:
- name: {{ postgres.service.name }}_flags
- value: "{{ postgres.service.flags }} > /dev/null 2>&1"
- watch_in:
- service: postgresql-running
{% endif %}

# Start PostgreSQL server using OS init
# Note: This is also the target for numerous `watch_in` requisites above, used
# for the necessary service restart after changing the relevant configuration files
postgresql-running:
service.running:
- name: {{ postgres.service }}
- name: {{ postgres.service.name }}
- enable: True

# Reload the service for changes made to `pg_ident.conf`, except for `MacOS`
Expand All @@ -275,7 +286,7 @@ postgresql-running:
postgresql-service-reload:
module.wait:
- name: service.reload
- m_name: {{ postgres.service }}
- m_name: {{ postgres.service.name }}
- require:
- service: postgresql-running
{%- endif %}
Expand Down
4 changes: 2 additions & 2 deletions postgres/server/remove.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

postgresql-dead:
service.dead:
- name: {{ postgres.service }}
- name: {{ postgres.service.name }}
- enable: False

postgresql-repo-removed:
Expand Down Expand Up @@ -81,7 +81,7 @@ postgresql{{ release }}-tablespace-dir-{{ name }}-removed:
file.absent:
- name: {{ tblspace.directory }}
- require:
- file: postgresql{{ release }}-dataconf-removed
- file: postgresql{{ release }}-dataconf-removed
{% endfor %}
{% endif %}

Expand Down