Log disk uuid to cloud logging

This commit is contained in:
katexochen 2022-07-26 16:19:53 +02:00 committed by Paul Meyer
parent d6b5e954e7
commit d43ee053ed
2 changed files with 20 additions and 0 deletions

View File

@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Kubernetes version is configured through an entry in `constellation-config.yaml`.
- Kubernetes version 1.24 is now supported.
- Kubernetes version 1.22 is now supported.
- Log the disk UUID to cloud logging for recovery.
### Changed

View File

@ -4,6 +4,7 @@ import (
"net"
"github.com/edgelesssys/constellation/bootstrapper/internal/clean"
"github.com/edgelesssys/constellation/bootstrapper/internal/diskencryption"
"github.com/edgelesssys/constellation/bootstrapper/internal/initserver"
"github.com/edgelesssys/constellation/bootstrapper/internal/joinclient"
"github.com/edgelesssys/constellation/bootstrapper/internal/logging"
@ -28,6 +29,15 @@ func run(issuer quoteIssuer, tpm vtpm.TPMOpenFunc, fileHandler file.Handler,
log.With(zap.String("version", version)).Infof("Starting bootstrapper")
cloudLogger.Disclose("bootstrapper started running...")
uuid, err := getDiskUUID()
if err != nil {
log.With(zap.Error(err)).Errorf("Failed to get disk UUID")
cloudLogger.Disclose("Failed to get disk UUID")
} else {
log.Infof("Disk UUID: %s", uuid)
cloudLogger.Disclose("Disk UUID: " + uuid)
}
nodeBootstrapped, err := vtpm.IsNodeBootstrapped(tpm)
if err != nil {
log.With(zap.Error(err)).Fatalf("Failed to check if node was previously bootstrapped")
@ -60,6 +70,15 @@ func run(issuer quoteIssuer, tpm vtpm.TPMOpenFunc, fileHandler file.Handler,
cloudLogger.Disclose("bootstrapper done")
}
func getDiskUUID() (string, error) {
disk := diskencryption.New()
if err := disk.Open(); err != nil {
return "", err
}
defer disk.Close()
return disk.UUID()
}
type clusterInitJoiner interface {
joinclient.ClusterJoiner
initserver.ClusterInitializer