From 90892ab9f535095ee6c250b331f53bd191dffeca Mon Sep 17 00:00:00 2001 From: AngelaBriel Date: Wed, 1 Nov 2023 11:57:52 +0100 Subject: [PATCH 1/3] fix missing handling for Azure systems regarding parameter 'net.ipv4.tcp_timestamps' --- ospackage/usr/share/saptune/notes/2382421 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ospackage/usr/share/saptune/notes/2382421 b/ospackage/usr/share/saptune/notes/2382421 index 9718810f..c3512b59 100644 --- a/ospackage/usr/share/saptune/notes/2382421 +++ b/ospackage/usr/share/saptune/notes/2382421 @@ -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' From 73fd7cd7d4b205422ade04a51299e4a7b1a0316f Mon Sep 17 00:00:00 2001 From: AngelaBriel Date: Wed, 1 Nov 2023 20:08:50 +0100 Subject: [PATCH 2/3] add parameter IGNORE_RELOAD to /etc/sysconfig/saptune to prevent saptune from stopping and starting the system tuning during package update Related to sapconf bug bsc#1209408 --- actions/serviceacts.go | 43 ++++++++++++++++++++++++++++++++- main.go | 4 +-- ospackage/etc/sysconfig/saptune | 10 ++++++++ ospackage/man/saptune.8 | 15 ++++++++++++ testdata/saptune_NoVersion | 18 ++++++++++++++ testdata/saptune_WrongStaging | 18 ++++++++++++++ 6 files changed, 105 insertions(+), 3 deletions(-) diff --git a/actions/serviceacts.go b/actions/serviceacts.go index 6becebea..8641140f 100644 --- a/actions/serviceacts.go +++ b/actions/serviceacts.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/SUSE/saptune/app" "github.com/SUSE/saptune/system" + "github.com/SUSE/saptune/txtparser" "io" "os" "strings" @@ -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. @@ -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": @@ -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' @@ -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) + } + } +} diff --git a/main.go b/main.go index 910be758..80d62740 100644 --- a/main.go +++ b/main.go @@ -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 { @@ -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) diff --git a/ospackage/etc/sysconfig/saptune b/ospackage/etc/sysconfig/saptune index 66a432c8..af8e93dc 100644 --- a/ospackage/etc/sysconfig/saptune +++ b/ospackage/etc/sysconfig/saptune @@ -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" diff --git a/ospackage/man/saptune.8 b/ospackage/man/saptune.8 index 80903b97..fe4977d9 100644 --- a/ospackage/man/saptune.8 +++ b/ospackage/man/saptune.8 @@ -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. @@ -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. diff --git a/testdata/saptune_NoVersion b/testdata/saptune_NoVersion index 96106cde..94db62b8 100644 --- a/testdata/saptune_NoVersion +++ b/testdata/saptune_NoVersion @@ -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" diff --git a/testdata/saptune_WrongStaging b/testdata/saptune_WrongStaging index 21cec180..b0e789ea 100644 --- a/testdata/saptune_WrongStaging +++ b/testdata/saptune_WrongStaging @@ -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" From a5d47372ad2fb424d3e735eeb0c9b0a52631824f Mon Sep 17 00:00:00 2001 From: AngelaBriel Date: Mon, 6 Nov 2023 20:38:45 +0100 Subject: [PATCH 3/3] fix wrong statement about 'noteId' field in old syntax of version header in man page saptune-note.5 --- ospackage/man/saptune-note.5 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ospackage/man/saptune-note.5 b/ospackage/man/saptune-note.5 index bdd76b99..69e203e0 100644 --- a/ospackage/man/saptune-note.5 +++ b/ospackage/man/saptune-note.5 @@ -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 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 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.