Skip to content

Commit

Permalink
Merge pull request #118 from angelabriel/master
Browse files Browse the repository at this point in the history
bsc#1209408 - add parameter IGNORE_RELOAD to saptune too
  • Loading branch information
angelabriel authored Nov 10, 2023
2 parents 0eeee4c + a5d4737 commit 920a0ca
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 4 deletions.
43 changes: 42 additions & 1 deletion actions/serviceacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/SUSE/saptune/app"
"github.com/SUSE/saptune/system"
"github.com/SUSE/saptune/txtparser"
"io"
"os"
"strings"
Expand All @@ -16,6 +17,7 @@ var ignoreFlag = "/run/.saptune.ignore"
// ServiceAction handles service actions like start, stop, status, enable, disable
// it controls the systemd saptune.service
func ServiceAction(writer io.Writer, actionName, saptuneVersion string, tApp *app.App) {
preventReload()
switch actionName {
case "apply":
// This action name is only used by saptune service, hence it is not advertised to end user.
Expand All @@ -37,7 +39,11 @@ func ServiceAction(writer io.Writer, actionName, saptuneVersion string, tApp *ap
ServiceActionRevert(tApp)
case "reload":
// This action name is only used by saptune service, hence it is not advertised to end user.
system.NoticeLog("saptune is now restartig the service...")
system.NoticeLog("saptune is now restarting the service...")
if ignoreServiceReload() {
system.NoticeLog("'IGNORE_RELOAD' is set in saptune configuration file, so no permission to reload")
system.ErrorExit("", 0)
}
ServiceActionRevert(tApp)
ServiceActionApply(tApp)
case "start":
Expand Down Expand Up @@ -279,6 +285,10 @@ func ServiceActionStop(disableService bool) {
func ServiceActionRestart(tuneApp *app.App) {
var err error
system.NoticeLog("Restarting 'saptune.service', this may take some time...")
if ignoreServiceReload() {
system.NoticeLog("'IGNORE_RELOAD' is set in saptune configuration file, so no permission to restart")
system.ErrorExit("", 0)
}
// release Lock, to prevent deadlock with systemd service 'saptune.service'
system.ReleaseSaptuneLock()
// restart 'saptune.service'
Expand Down Expand Up @@ -786,3 +796,34 @@ func DaemonAction(writer io.Writer, actionName, saptuneVersion string, tuneApp *
PrintHelpAndExit(writer, 1)
}
}

// ignoreServiceReload returns true, if 'IGNORE_RELOAD' is set to 'yes' in
// the saptune configuration file. Otherwise it returns false
func ignoreServiceReload() bool {
ret := false
sconf, err := txtparser.ParseSysconfigFile(saptuneSysconfig, true)
if err != nil {
system.ErrorExit("Unable to read file '/etc/sysconfig/saptune': '%v'\n", err, 2)
}
if sconf.GetString("IGNORE_RELOAD", "no") == "yes" {
ret = true
}
return ret
}

// preventReload implements a workaround to prevent service reload/restart
// during preun/postun from a previous saptune package, which gets triggered
// during package update of saptune
// if triggered by other package updates (like uuidd because of the dependencies
// in the systemd service file) can not be identified at the moment.
// see related sapconf bug bsc#1207899
func preventReload() {
_, err := os.Stat("/run/saptune_during_pkg_inst")
if err == nil {
system.NoticeLog("we are called during a package update of saptune")
if ignoreServiceReload() {
system.NoticeLog("And 'IGNORE_RELOAD' is set in saptune configuration file, so nothing to do")
system.ErrorExit("", 0)
}
}
}
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,12 @@ func checkWorkingArea() {
// returns the saptune version and changes some log switches
func checkSaptuneConfigFile(writer io.Writer, saptuneConf string, lswitch map[string]string) string {
missingKey := []string{}
keyList := []string{app.TuneForSolutionsKey, app.TuneForNotesKey, app.NoteApplyOrderKey, "SAPTUNE_VERSION", "STAGING", "COLOR_SCHEME"}
keyList := []string{app.TuneForSolutionsKey, app.TuneForNotesKey, app.NoteApplyOrderKey, "SAPTUNE_VERSION", "STAGING", "COLOR_SCHEME", "SKIP_SYSCTL_FILES", "IGNORE_RELOAD"}
sconf, err := txtparser.ParseSysconfigFile(saptuneConf, false)
if err != nil {
fmt.Fprintf(writer, "Error: Unable to read file '%s': %v\n", saptuneConf, err)
system.ErrorExit("", 128)
}
txtparser.GetSysctlExcludes(sconf.GetString("SKIP_SYSCTL_FILES", ""))
// check, if all needed variables are available in the saptune
// config file
for _, key := range keyList {
Expand All @@ -234,6 +233,7 @@ func checkSaptuneConfigFile(writer io.Writer, saptuneConf string, lswitch map[st
fmt.Fprintf(writer, "Error: File '%s' is broken. Missing variables '%s'\n", saptuneConf, strings.Join(missingKey, ", "))
system.ErrorExit("", 128)
}
txtparser.GetSysctlExcludes(sconf.GetString("SKIP_SYSCTL_FILES", ""))
stageVal := sconf.GetString("STAGING", "")
if stageVal != "true" && stageVal != "false" {
fmt.Fprintf(writer, "Error: Variable 'STAGING' from file '%s' contains a wrong value '%s'. Needs to be 'true' or 'false'\n", saptuneConf, stageVal)
Expand Down
10 changes: 10 additions & 0 deletions ospackage/etc/sysconfig/saptune
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ COLOR_SCHEME=""
# comma separated list of sysctl.conf files or directories containing sysctl
# files, which should be excluded from the 'additional defined' WARNING
SKIP_SYSCTL_FILES="/boot"

## Type: string
## Default: "no"
#
# IGNORE_RELOAD is used to control the 'systemctl reload saptune.service'
# and the 'systemctl try-restart saptune.service' during package installation
# behavior.
# Default is 'no'. If set to 'yes' a 'systemctl reload' will do nothing.
# same reason as for sapconf bsc#1209408
IGNORE_RELOAD="no"
4 changes: 3 additions & 1 deletion ospackage/man/saptune-note.5
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ Example:

All fields are separated by spaces. But please do not use spaces around the equal operator (=) of the fields. And please do not change the order of the fields.

The <noteId> must be a text string without spaces, which will be used as the unique identifier of this Note definition. It will be displayed during the action 'saptune note list' and used for all other actions, where the NoteID is needed as parameter.
The <noteId> must be a text string without spaces. It was planned for future use, but this field was never used.

The internal used NoteID - the unique identifier of a Note definition - was always taken from the filename of the Note definition file without extention '.conf'. It will be displayed during the action 'saptune note list' and used for all other actions, where the NoteID is needed as parameter.

The CATEGORY is for future use. So we do not have defined CATEGORIES at the moment. It must be a text string without spaces.

Expand Down
15 changes: 15 additions & 0 deletions ospackage/man/saptune.8
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ It redirects to '\fIsystemctl restart saptune.service\fP'
Success is reported on stdout, errors including systemd error messages are printed on stderr. The action gets logged.

If the action was successfully the exit code is 0, otherwise 1.

If '\fIIGNORE_RELOAD\fP' is set to '\fByes\fP' in the saptune configuration file the action '\fIrestart\fP' will do \fBnothing\fP. The reason will be logged.
See the 'NOTE' section at the end of the man page for more information.
.TP
.B enable
Enables the saptune service. To activate the tuning, the saptune service needs to be started. But as the service is now enabled, the tuning will automatically activated upon system boot.
Expand Down Expand Up @@ -894,6 +897,18 @@ Please do not change or remove files in this directory. The knowledge about the
Using saptune within a pipe, the color information will be removed from the output.
.SH NOTE
When the values from the saptune Note definitions are applied to the system, no further monitoring of the system parameters are done. So changes of saptune relevant parameters by using the 'sysctl' command or by editing configuration files will not be observed. If the values set by saptune should be reverted, these unrecognized changed settings will be overwritten by the previous saved system settings from saptune.
.SH NOTE
To prevent unintended reload/restart of saptune during package installation/update of saptune or normal work, which will result in a short time period, where the system is not tuned for SAP workloads, it's possible to set the parameter \fBIGNORE_RELOAD\fP in the central saptune configuration file \fI/etc/sysconfig/saptune\fP.
.br
\fBIGNORE_RELOAD\fP is used to control the '\fBsystemctl reload saptune.service\fP' behavior.
.br
Default is \fBIGNORE_RELOAD="no"\fP, which means that the 'reload' is working as expected.
.br
If set to '\fByes\fP' a '\fBsystemctl reload saptune.service\fP' and a '\fBsaptune service restart\fP' will do \fBnothing\fP. The reason will be logged.
.br
Additional this parameter setting will prevent '\fBsystemctl restart saptune.service\fP' (which is a 'ExecStop' followed by 'ExecStart') called from macros used during the package installation/update of the saptune package from restarting the tuning.
.br
ATTENTION: Outside the saptune package installation '\fBsystemctl restart saptune.service\fP' can \fBnot\fP be blocked.

.SH ATTENTION
Higher or lower system values set by the system, the SAP installer or by the administrator using sysctl command or sysctl configuration files will be now \fBoverwritten\fP by saptune, if they are part of the applied Note definitions.
Expand Down
11 changes: 11 additions & 0 deletions ospackage/usr/share/saptune/notes/2382421
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ net.ipv4.tcp_tw_recycle =
#net.ipv4.tcp_tw_recycle
net.ipv4.tcp_tw_recycle =

# net.ipv4.tcp_timestamps for Azure
# This setting adds the timestamp field to the TCP header.
# It should already be active on most systems and is a prerequisite for
# net.ipv4.tcp_tw_reuse and net.ipv4.tcp_tw_recycle.
# If you are running on Microsoft Azure depending on your scenario the setting
# of this OS parameter might not be supported. Please refer to the documentation
# provided by Microsoft for details. In this case please adjust the OS
# parameters as recommended by Microsoft.
[sysctl:csp=azure]
net.ipv4.tcp_timestamps =

[reminder]
# SAP HANA Parameters - all '.ini' file changes - not handled by saptune
# WARNING - on systems with iSCSI devices the setting of 'net.ipv4.tcp_syn_retries = 8'
Expand Down
18 changes: 18 additions & 0 deletions testdata/saptune_NoVersion
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,21 @@ STAGING="false"
# 'yellow-noncmpl'
# Refer to the man page for a desciprion of the color schemes.
COLOR_SCHEME=""

## Type: string
## Default: "/boot"
#
# exclude list for the sysctl config warnings
# comma separated list of sysctl.conf files or directories containing sysctl
# files, which should be excluded from the 'additional defined' WARNING
SKIP_SYSCTL_FILES="/boot"

## Type: string
## Default: "no"
#
# IGNORE_RELOAD is used to control the 'systemctl reload saptune.service'
# and the 'systemctl try-restart saptune.service' during package installation
# behavior.
# Default is 'no'. If set to 'yes' a 'systemctl reload' will do nothing.
# same reason as for sapconf bsc#1209408
IGNORE_RELOAD="no"
18 changes: 18 additions & 0 deletions testdata/saptune_WrongStaging
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,21 @@ STAGING="hugo"
# 'yellow-noncmpl'
# Refer to the man page for a desciprion of the color schemes.
COLOR_SCHEME=""

## Type: string
## Default: "/boot"
#
# exclude list for the sysctl config warnings
# comma separated list of sysctl.conf files or directories containing sysctl
# files, which should be excluded from the 'additional defined' WARNING
SKIP_SYSCTL_FILES="/boot"

## Type: string
## Default: "no"
#
# IGNORE_RELOAD is used to control the 'systemctl reload saptune.service'
# and the 'systemctl try-restart saptune.service' during package installation
# behavior.
# Default is 'no'. If set to 'yes' a 'systemctl reload' will do nothing.
# same reason as for sapconf bsc#1209408
IGNORE_RELOAD="no"

0 comments on commit 920a0ca

Please sign in to comment.