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

chore: enable TPM2 by default in CI #9783

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion hack/test/e2e-image-factory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ case "${FACTORY_BOOT_METHOD:-iso}" in
QEMU_FLAGS+=("--ipxe-boot-script=${FACTORY_SCHEME}://${PXE_FACTORY_HOSTNAME}/pxe/${FACTORY_SCHEMATIC}/${FACTORY_VERSION}/metal-amd64")
;;
secureboot-iso)
QEMU_FLAGS+=("--iso-path=${FACTORY_SCHEME}://${FACTORY_HOSTNAME}/image/${FACTORY_SCHEMATIC}/${FACTORY_VERSION}/metal-amd64-secureboot.iso" "--with-tpm2" "--encrypt-ephemeral" "--encrypt-state" "--disk-encryption-key-types=tpm")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why it got removed here

Copy link
Member Author

Choose a reason for hiding this comment

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

If we run all tests with TPM2 we don't need it here. However we shouldn't do it for all

Copy link
Member

Choose a reason for hiding this comment

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

ah, I see it now

Copy link
Member

Choose a reason for hiding this comment

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

we have at least in the misc section the test with UEFI disabled (BIOS mode), this could be a good place with disabled tpm2

QEMU_FLAGS+=("--iso-path=${FACTORY_SCHEME}://${FACTORY_HOSTNAME}/image/${FACTORY_SCHEMATIC}/${FACTORY_VERSION}/metal-amd64-secureboot.iso" "--encrypt-ephemeral" "--encrypt-state" "--disk-encryption-key-types=tpm")
INSTALLER_IMAGE_NAME=installer-secureboot
;;
esac
Expand Down Expand Up @@ -59,6 +59,7 @@ function create_cluster {
--with-apply-config \
--talos-version="${FACTORY_VERSION}" \
--install-image="${FACTORY_HOSTNAME}/${INSTALLER_IMAGE_NAME}/${FACTORY_SCHEMATIC}:${FACTORY_VERSION}" \
--with-tpm2 \
"${REGISTRY_MIRROR_FLAGS[@]}" \
"${QEMU_FLAGS[@]}"

Expand Down
1 change: 1 addition & 0 deletions hack/test/e2e-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function create_cluster {
--with-apply-config \
--install-image=${REGISTRY:-ghcr.io}/siderolabs/installer:${TAG} \
--cni-bundle-url=${ARTIFACTS}/talosctl-cni-bundle-'${ARCH}'.tar.gz \
--with-tpm2 \
"${REGISTRY_MIRROR_FLAGS[@]}"

"${TALOSCTL}" config node "${NODE}"
Expand Down
3 changes: 2 additions & 1 deletion hack/test/e2e-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ case "${WITH_TRUSTED_BOOT_ISO:-false}" in
;;
*)
INSTALLER_IMAGE=${INSTALLER_IMAGE}-amd64-secureboot
QEMU_FLAGS+=("--iso-path=_out/metal-amd64-secureboot.iso" "--with-tpm2" "--encrypt-ephemeral" "--encrypt-state" "--disk-encryption-key-types=tpm")
QEMU_FLAGS+=("--iso-path=_out/metal-amd64-secureboot.iso" "--encrypt-ephemeral" "--encrypt-state" "--disk-encryption-key-types=tpm")
;;
esac

Expand Down Expand Up @@ -225,6 +225,7 @@ function create_cluster {
--with-init-node=false \
--cni-bundle-url="${ARTIFACTS}/talosctl-cni-bundle-\${ARCH}.tar.gz" \
--crashdump \
--with-tpm2 \
"${REGISTRY_MIRROR_FLAGS[@]}" \
"${QEMU_FLAGS[@]}"

Expand Down
40 changes: 13 additions & 27 deletions internal/integration/api/selinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func (suite *SELinuxSuite) TestFileMountLabels() {
// Mounts and runtime-generated files
constants.SystemEtcPath: constants.EtcSelinuxLabel,
"/etc": constants.EtcSelinuxLabel,
// Devices labeled by subsystems, labeled by udev
"/dev/rtc0": "system_u:object_r:rtc_device_t:s0",
"/dev/tpm0": "system_u:object_r:tpm_device_t:s0",
"/dev/tpmrm0": "system_u:object_r:tpm_device_t:s0",
"/dev/watchdog": "system_u:object_r:wdt_device_t:s0",
"/dev/watchdog0": "system_u:object_r:wdt_device_t:s0",
"/dev/null": "system_u:object_r:null_device_t:s0",
"/dev/zero": "system_u:object_r:null_device_t:s0",
}

// Only running on controlplane
Expand All @@ -119,25 +127,12 @@ func (suite *SELinuxSuite) TestFileMountLabels() {
}
maps.Copy(expectedLabelsControlPlane, expectedLabelsWorker)

// Devices labeled by subsystems, labeled by udev
expectedLabelsDevices := map[string]string{
"/dev/rtc0": "system_u:object_r:rtc_device_t:s0",
"/dev/tpm0": "system_u:object_r:tpm_device_t:s0",
"/dev/tpmrm0": "system_u:object_r:tpm_device_t:s0",
"/dev/watchdog": "system_u:object_r:wdt_device_t:s0",
"/dev/watchdog0": "system_u:object_r:wdt_device_t:s0",
"/dev/null": "system_u:object_r:null_device_t:s0",
"/dev/zero": "system_u:object_r:null_device_t:s0",
}

suite.checkFileLabels(workers, expectedLabelsWorker, false)
suite.checkFileLabels(controlplanes, expectedLabelsControlPlane, false)
suite.checkFileLabels(workers, expectedLabelsDevices, true)
suite.checkFileLabels(controlplanes, expectedLabelsDevices, true)
suite.checkFileLabels(workers, expectedLabelsWorker)
suite.checkFileLabels(controlplanes, expectedLabelsControlPlane)
}

//nolint:gocyclo
func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[string]string, allowMissing bool) {
func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[string]string) {
paths := make([]string, 0, len(expectedLabels))
for k := range expectedLabels {
paths = append(paths, k)
Expand Down Expand Up @@ -167,7 +162,7 @@ func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[st

suite.Require().NoError(err)

err = helpers.ReadGRPCStream(stream, func(info *machineapi.FileInfo, node string, multipleNodes bool) error {
suite.Require().NoError(helpers.ReadGRPCStream(stream, func(info *machineapi.FileInfo, node string, multipleNodes bool) error {
// E.g. /var/lib should inherit /var label, while /var/run is a new mountpoint
if slices.Contains(paths, info.Name) && info.Name != path {
return nil
Expand All @@ -191,16 +186,7 @@ func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[st
suite.Require().True(found)

return nil
})

if allowMissing {
if err != nil {
suite.Require().Contains(err.Error(), "lstat")
suite.Require().Contains(err.Error(), "no such file or directory")
}
} else {
suite.Require().NoError(err)
}
}))
}
}
}
Expand Down
Loading