Skip to content

Commit

Permalink
Merge pull request #147 from angelabriel/master
Browse files Browse the repository at this point in the history
fix findings of the last test cycle
  • Loading branch information
angelabriel authored Oct 11, 2024
2 parents 002b3e4 + 9b433da commit 0826ec3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 9 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ func checkSaptuneConfigFile(writer io.Writer, saptuneConf string, lswitch map[st

// set values read from the config file
saptuneVers := sconf.GetString("SAPTUNE_VERSION", "")
if saptuneVers != "1" && saptuneVers != "2" && saptuneVers != "3" {
system.ErrorExit("Wrong saptune version in file '/etc/sysconfig/saptune': %s", SaptuneVersion, 128)
}

// Switch Debug on ("on") or off ("off" - default)
// Switch verbose mode on ("on" - default) or off ("off")
Expand Down
6 changes: 3 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func TestCheckSaptuneConfigFile(t *testing.T) {
tstwriter = &errExitbuffer

// check missing variable
saptuneConf = fmt.Sprintf("%s/saptune_NoVersion", TstFilesInGOPATH)
matchTxt := fmt.Sprintf("Error: File '%s' is broken. Missing variables 'SAPTUNE_VERSION'\n", saptuneConf)
saptuneConf = fmt.Sprintf("%s/saptune_MissingVar", TstFilesInGOPATH)
matchTxt := fmt.Sprintf("Error: File '%s' is broken. Missing variables 'COLOR_SCHEME'\n", saptuneConf)
lSwitch = logSwitch
_ = checkSaptuneConfigFile(&buffer, saptuneConf, lSwitch)

Expand All @@ -168,7 +168,7 @@ func TestCheckSaptuneConfigFile(t *testing.T) {
}
errExOut := errExitbuffer.String()
if errExOut != "" {
t.Errorf("wrong text returned by ErrorExit: '%v' instead of ''\n", errExOut)
t.Errorf("wrong text returned by ErrorExit: '%v' instead of '%v'\n", errExOut, matchTxt)
}

// initialise next test
Expand Down
15 changes: 13 additions & 2 deletions ospackage/man/saptune-note.5
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.\" */
.\"

.TH "saptune-note" "5" "July 2024" "" "saptune note file format description"
.TH "saptune-note" "5" "October 2024" "" "saptune note file format description"
.SH NAME
saptune\-note \- Note definition files for saptune version \fB3\fP
.SH DESCRIPTION
Expand Down Expand Up @@ -124,6 +124,17 @@ Example:
[sysctl:csp=azure]
.RE
.TP
.BI virt= <virtualization type>
to define a special \fIvirtualization\fP type (as reported by \fI/usr/bin/systemd-detect-virt -v|-c|-r\fP)
.br
Valid values for \fBvirt=\fP are \fBvm\fP, \fBchroot\fP and \fBcontainer\fP

.RS 4
Example:
.br
[sysctl:virt=vm]
.RE
.TP
.BI DMI interface tag: <filename>= <file content>
.br
Additional every filename from \fI/sys/class/dmi/id/\fP can be used as a tag.
Expand Down Expand Up @@ -603,7 +614,7 @@ Concerning \fBsysstat.service\fP please be in mind: A running sysstat service ca
.br
See sar(1), sa2(8), sa1(8) for more information

If a service is enabled or disabled by default or admin choice, saptune will NOT disable or enable this service, if only '\fBstart\fP' or '\fBstop\fP' is used. In this case it will only start/stop the service. If such a service is started by systemd during a system reboot \fBafter\fP the start of saptune.service it will be possible that a service is stopped/running even if it was started/stopped by saptune. To change this, the service can be additional enabled or disabled by using '\fBenable\fP' or '\fBdisable\fP' in the Note definition file.
If a service is enabled or disabled by default or admin choice, saptune will NOT disable or enable this service, if only '\fBstart\fP' or '\fBstop\fP' is used. In this case it will only start/stop the service. If such a service is started by systemd during a system reboot \fBafter\fP the start of saptune.service it will be possible that a service is stopped/running even if it was started/stopped by saptune. To change this, the service can be additional enabled or disabled by using '\fBenable\fP' or '\fBdisable\fP' in the Note definition or Override file.
\" section sysctl
.SH "[sysctl]"
The section "[sysctl]" can be used to modify kernel parameters. The parameters available are those listed under /proc/sys/.
Expand Down
4 changes: 3 additions & 1 deletion ospackage/man/saptune.8
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ Success is reported on stdout, errors including systemd error messages are print

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

ATTENTION:
.TP
.B ATTENTION:
.br
saptune is able to start/stop/enable/disable systemd units, but on boot the outcome depends on the order of execution.

If saptune is starting (or stopping) a systemd service ([service] section) it might happen, that the action gets reverted later by systemd because that service is disabled (or enabled) and executed after saptune.service.
Expand Down
4 changes: 2 additions & 2 deletions testdata/saptune_NoVersion → testdata/saptune_MissingVar
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NOTE_APPLY_ORDER="2205917 2684254 1680803"
## Default: "3"
#
# Version of saptune
#SAPTUNE_VERSION="3"
SAPTUNE_VERSION="3"

## Type: boolean
## Default: "false"
Expand All @@ -48,7 +48,7 @@ STAGING="false"
# 'cmpl-blue-zebra', 'full-red-noncmpl', 'red-noncmpl', 'full-yellow-noncmpl'
# 'yellow-noncmpl'
# Refer to the man page for a desciprion of the color schemes.
COLOR_SCHEME=""
#COLOR_SCHEME=""

## Type: string
## Default: "/boot"
Expand Down
2 changes: 1 addition & 1 deletion testdata/saptune_WrongStaging
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NOTE_APPLY_ORDER="2205917 2684254 1680803"
## Default: "3"
#
# Version of saptune
SAPTUNE_VERSION="5"
SAPTUNE_VERSION="3"

## Type: boolean
## Default: "false"
Expand Down
14 changes: 14 additions & 0 deletions txtparser/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func chkSecTags(secFields, blkDev []string) (bool, []string) {
ret = chkArchTags(tagField[1], secFields)
case "csp":
ret = chkCspTags(tagField[1], secFields)
case "virt":
ret = chkVirtTags(tagField[1], secFields)
case "blkvendor", "blkmodel", "blkpat":
ret, blkDev = chkBlkTags(tagField[0], tagField[1], secFields, blkDev)
case "vendor", "model":
Expand Down Expand Up @@ -133,6 +135,18 @@ func chkCspTags(tagField string, secFields []string) bool {
return ret
}

// chkVirtTags checks if the virtualization type section tag is valid or not
func chkVirtTags(tagField string, secFields []string) bool {
ret := true
chkVirt := system.GetVirtStatus()
if tagField != chkVirt {
// virtualization type does not match
system.InfoLog("virtualization type '%s' in section definition '%v' does not match the virtualization type of the running system ('%s'). Skipping whole section with all lines till next valid section definition", tagField, secFields, chkVirt)
ret = false
}
return ret
}

// chkOtherTags checks, if the tag is a valid tag (file exists in
// /sys/class/dmi/id) and the contents matches the tag value
// future use possible by simply look for files in an additional location.
Expand Down

0 comments on commit 0826ec3

Please sign in to comment.