mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-17 10:31:19 +02:00
fix: make fingerprint clearly optional in a boot hint
Plus fix the logging on docker/Talos to avoid logs in docker mode going to the host kernel message buffer. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
83bb1afcb6
commit
fc5f53bf51
@ -7,7 +7,6 @@ package v1alpha1
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
@ -23,7 +22,6 @@ import (
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime/logging"
|
||||
"github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/acpi"
|
||||
"github.com/talos-systems/talos/internal/pkg/kmsg"
|
||||
"github.com/talos-systems/talos/pkg/machinery/api/common"
|
||||
"github.com/talos-systems/talos/pkg/machinery/api/machine"
|
||||
"github.com/talos-systems/talos/pkg/machinery/config"
|
||||
@ -328,20 +326,7 @@ func (c *Controller) runTask(progress string, f runtime.TaskSetupFunc, seq runti
|
||||
Action: machine.TaskEvent_STOP,
|
||||
})
|
||||
|
||||
logger := &log.Logger{}
|
||||
|
||||
var machinedLog io.WriteCloser
|
||||
|
||||
machinedLog, err = c.Runtime().Logging().ServiceLog("machined").Writer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer machinedLog.Close() //nolint: errcheck
|
||||
|
||||
if err = kmsg.SetupLogger(logger, fmt.Sprintf("[talos] task %s (%s):", taskName, progress), machinedLog); err != nil {
|
||||
return err
|
||||
}
|
||||
logger := log.New(log.Writer(), fmt.Sprintf("[talos] task %s (%s): ", taskName, progress), log.Flags())
|
||||
|
||||
err = task(context.TODO(), logger, c.r)
|
||||
|
||||
|
@ -75,6 +75,9 @@ func (*Sequencer) Initialize(r runtime.Runtime) []runtime.Phase {
|
||||
switch r.State().Platform().Mode() { //nolint: exhaustive
|
||||
case runtime.ModeContainer:
|
||||
phases = phases.Append(
|
||||
"logger",
|
||||
SetupLogger,
|
||||
).Append(
|
||||
"systemRequirements",
|
||||
WriteRequiredSysctlsForContainer,
|
||||
SetupSystemDirectory,
|
||||
|
@ -66,15 +66,19 @@ import (
|
||||
// SetupLogger represents the SetupLogger task.
|
||||
func SetupLogger(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFunc, string) {
|
||||
return func(ctx context.Context, logger *log.Logger, r runtime.Runtime) (err error) {
|
||||
if r.State().Platform().Mode() == runtime.ModeContainer {
|
||||
return nil
|
||||
}
|
||||
|
||||
machinedLog, err := r.Logging().ServiceLog("machined").Writer()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if r.State().Platform().Mode() == runtime.ModeContainer {
|
||||
// send all the logs to machinedLog as well, but skip /dev/kmsg logging
|
||||
log.SetOutput(io.MultiWriter(log.Writer(), machinedLog))
|
||||
log.SetPrefix("[talos] ")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
if err = kmsg.SetupLogger(nil, "[talos]", machinedLog); err != nil {
|
||||
return fmt.Errorf("failed to setup logging: %w", err)
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func Run(ctx context.Context, logger *log.Logger, r runtime.Runtime) ([]byte, er
|
||||
logger.Println("this machine is reachable at:")
|
||||
|
||||
for _, ip := range ips {
|
||||
logger.Printf("\t%s\n", ip.String())
|
||||
logger.Printf("\t%s", ip.String())
|
||||
}
|
||||
|
||||
firstIP := "<IP>"
|
||||
@ -86,10 +86,13 @@ func Run(ctx context.Context, logger *log.Logger, r runtime.Runtime) ([]byte, er
|
||||
}
|
||||
|
||||
logger.Println("server certificate fingerprint:")
|
||||
logger.Printf("\t%s\n", certFingerprint)
|
||||
logger.Printf("\t%s", certFingerprint)
|
||||
|
||||
logger.Println()
|
||||
logger.Println("upload configuration using talosctl:")
|
||||
logger.Printf("\ttalosctl apply-config --insecure --nodes %s --cert-fingerprint '%s' --file <config.yaml>\n", firstIP, certFingerprint)
|
||||
logger.Printf("\ttalosctl apply-config --insecure --nodes %s --file <config.yaml>", firstIP)
|
||||
logger.Println("optionally with node fingerprint check:")
|
||||
logger.Printf("\ttalosctl apply-config --insecure --nodes %s --cert-fingerprint '%s' --file <config.yaml>", firstIP, certFingerprint)
|
||||
|
||||
select {
|
||||
case cfg := <-cfgCh:
|
||||
|
Loading…
x
Reference in New Issue
Block a user