Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-21363

RPM's postin script only starts and enables systemd service if migrated-from-my.cnf-settings.conf does not already exist

Details

    Description

      The postin script used by our RPM packages only starts and enables the systemd service if migrated-from-my.cnf-settings.conf does not exist. See this block of code:

      if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then
        systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
        if [ -x %{_bindir}/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
          # Either fresh install or upgrade non-systemd -> systemd
          mkdir -p /etc/systemd/system/mariadb.service.d
          %{_bindir}/mariadb-service-convert > "${systemd_conf}"
          # Make sure old possibly non-systemd instance is down
          if [ $1 = 2 ]; then
            SYSTEMCTL_SKIP_REDIRECT=1 %{_sysconfdir}/init.d/mysql stop >/dev/null 2>&1 || :
            systemctl start mariadb >/dev/null 2>&1 || :
          fi
          systemctl enable mariadb.service >/dev/null 2>&1 || :
        fi
      fi
      

      https://github.com/MariaDB/server/blob/mariadb-10.1.43/support-files/rpm/server-postin.sh#L1

      I don't think systemctl start mariadb and systemctl enable mariadb should be dependent on whether migrated-from-my.cnf-settings.conf exists or not. I think these commands should be executed on all systemd systems during installations.

      Attachments

        Issue Links

          Activity

            GeoffMontee Geoff Montee (Inactive) created issue -
            GeoffMontee Geoff Montee (Inactive) made changes -
            Field Original Value New Value
            Labels rpm systemd
            serg Sergei Golubchik made changes -
            Description The {{postin}} script used by our RPM packages only starts and enables the systemd service if {{migrated-from-my.cnf-settings.conf}} does not exist. See this block of code:

            {code}
            if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then
              systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
              if [ -x %{_bindir}/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
                # Either fresh install or upgrade non-systemd -> systemd
                mkdir -p /etc/systemd/system/mariadb.service.d
                %{_bindir}/mariadb-service-convert > "${systemd_conf}"
                # Make sure old possibly non-systemd instance is down
                if [ $1 = 2 ]; then
                  SYSTEMCTL_SKIP_REDIRECT=1 %{_sysconfdir}/init.d/mysql stop >/dev/null 2>&1 || :
                  systemctl start mariadb >/dev/null 2>&1 || :
                fi
                systemctl enable mariadb.service >/dev/null 2>&1 || :
              fi
            fi
            {code}

            https://github.com/MariaDB/server/blob/mariadb-10.1.43/support-files/rpm/server-postin.sh#L1

            I don't think {{systemctl start mariadb}} and {{systemctl enable mariadb}} should be dependent on whether {{migrated-from-my.cnf-settings.conf}} exists or not. I think these commands should be executed on all systemd systems during installations.
            The {{postin}} script used by our RPM packages only starts and enables the systemd service if {{migrated-from-my.cnf-settings.conf}} does not exist. See this block of code:

            {code:bash}
            if [ -f /usr/lib/systemd/system/mariadb.service -a -x /usr/bin/systemctl ]; then
              systemd_conf=/etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
              if [ -x %{_bindir}/mariadb-service-convert -a ! -f "${systemd_conf}" ]; then
                # Either fresh install or upgrade non-systemd -> systemd
                mkdir -p /etc/systemd/system/mariadb.service.d
                %{_bindir}/mariadb-service-convert > "${systemd_conf}"
                # Make sure old possibly non-systemd instance is down
                if [ $1 = 2 ]; then
                  SYSTEMCTL_SKIP_REDIRECT=1 %{_sysconfdir}/init.d/mysql stop >/dev/null 2>&1 || :
                  systemctl start mariadb >/dev/null 2>&1 || :
                fi
                systemctl enable mariadb.service >/dev/null 2>&1 || :
              fi
            fi
            {code}

            https://github.com/MariaDB/server/blob/mariadb-10.1.43/support-files/rpm/server-postin.sh#L1

            I don't think {{systemctl start mariadb}} and {{systemctl enable mariadb}} should be dependent on whether {{migrated-from-my.cnf-settings.conf}} exists or not. I think these commands should be executed on all systemd systems during installations.
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Oleksandr Byelkin [ sanja ]
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.1 [ 16100 ]
            abychko Alexey Bychko (Inactive) made changes -
            Assignee Oleksandr Byelkin [ sanja ] Alexey Bychko [ abychko ]
            abychko Alexey Bychko (Inactive) made changes -

            there is a broken logic with restart, yes, but anyway postinstall script must not unconditionally enable systemd unit.
            it's done later using systemctl preset which reads default systemd platform policy and may enable the unit or not accordingly.

            abychko Alexey Bychko (Inactive) added a comment - there is a broken logic with restart, yes, but anyway postinstall script must not unconditionally enable systemd unit. it's done later using systemctl preset which reads default systemd platform policy and may enable the unit or not accordingly.

            GeoffMontee
            upon deeper investigation I've found that this piece of code in description will not be executed anymore.
            this code is only for non-systemd->systemd upgrades, for example for 10.0->10.2.

            systemd has platform policies describing required and optional services. by default all installed systemd unit files should stay in disabled state after installation and must not be started unless unit is listed in platform policy as requred. this is implemented in systemctl preset https://github.com/MariaDB/server/blob/4e99e67c4e8a04bd03cb0e7efc2ce0129af60c34/support-files/rpm/server-postin.sh#L20

            so, everything is fine already and it works as expected. not a bug, because it's admin's work to enable/disable the services on server.

            abychko Alexey Bychko (Inactive) added a comment - GeoffMontee upon deeper investigation I've found that this piece of code in description will not be executed anymore. this code is only for non-systemd->systemd upgrades, for example for 10.0->10.2. systemd has platform policies describing required and optional services. by default all installed systemd unit files should stay in disabled state after installation and must not be started unless unit is listed in platform policy as requred. this is implemented in systemctl preset https://github.com/MariaDB/server/blob/4e99e67c4e8a04bd03cb0e7efc2ce0129af60c34/support-files/rpm/server-postin.sh#L20 so, everything is fine already and it works as expected. not a bug, because it's admin's work to enable/disable the services on server.
            abychko Alexey Bychko (Inactive) made changes -
            Fix Version/s N/A [ 14700 ]
            Fix Version/s 10.2 [ 14601 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Not a Bug [ 6 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 102591 ] MariaDB v4 [ 157131 ]
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 139023

            People

              abychko Alexey Bychko (Inactive)
              GeoffMontee Geoff Montee (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.