Skip to content
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

fix: fix e2e test with extensions and SELinux #9803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 13 additions & 5 deletions internal/integration/api/selinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/siderolabs/talos/pkg/machinery/client"
"github.com/siderolabs/talos/pkg/machinery/config/machine"
"github.com/siderolabs/talos/pkg/machinery/constants"
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

// SELinuxSuite ...
Expand Down Expand Up @@ -152,6 +153,13 @@ func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[st
suite.T().Skip("skipping SELinux test since SELinux is disabled")
}

// TODO: do not skip the test if system extensions are enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably easier to check if either extensions.qemu or extensions.nvidia is set

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what if we just run locally? Well, for CI that'd suffice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, those tests gets enabled only if the flag is passed

extensionsResult, err := suite.Client.COSI.List(nodeCtx, runtimeres.NewExtensionStatus(runtimeres.NamespaceName, "1").Metadata())
suite.Require().NoError(err)
if len(extensionsResult.Items) > 0 {
suite.T().Skip("skipping SELinux test since system extensions are enabled")
}

// We should check both folders and their contents for proper labels
for _, dir := range []bool{true, false} {
for path, label := range expectedLabels {
Expand All @@ -173,30 +181,30 @@ func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[st
return nil
}

suite.Require().NotNil(info.Xattrs)
suite.Require().NotNil(info.Xattrs, "no xattrs for %s", info.Name)

found := false

for _, l := range info.Xattrs {
if l.Name == "security.selinux" {
got := string(bytes.Trim(l.Data, "\x00\n"))
suite.Require().Contains(got, label, "expected %s to have label %s, got %s", path, label, got)
suite.Require().Contains(got, label, "expected %s to have label %s, got %s", info.Name, label, got)

found = true

break
}
}

suite.Require().True(found)
suite.Require().True(found, "could not find security.selinux xattr for %s", info.Name)

return nil
})

if allowMissing {
if err != nil {
suite.Require().Contains(err.Error(), "lstat")
suite.Require().Contains(err.Error(), "no such file or directory")
suite.Require().Contains(err.Error(), "lstat", "expected error to be due to missing file %s", path)
suite.Require().Contains(err.Error(), "no such file or directory", "expected error to be due to missing file %s", path)
}
} else {
suite.Require().NoError(err)
Expand Down
Loading