node: add start time field and use it when waiting for log messages

pull/467/head
iwilltry42 4 years ago
parent 58cf15b0e5
commit 746cbcd131
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 8
      pkg/client/node.go
  2. 12
      pkg/runtimes/docker/node.go
  3. 1
      pkg/types/types.go

@ -265,6 +265,14 @@ func NodeStart(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, no
return err
}
if node.State.Started != "" {
ts, err := time.Parse("2006-01-02T15:04:05.999999999Z", node.State.Started)
if err != nil {
log.Debugf("Failed to parse '%s.State.Started' timestamp '%s', falling back to calulated time", node.Name, node.State.Started)
}
startTime = ts
}
if nodeStartOpts.Wait {
if nodeStartOpts.ReadyLogMessage == "" {
nodeStartOpts.ReadyLogMessage = k3d.ReadyLogMessageByRole[node.Role]

@ -127,6 +127,16 @@ func (d Docker) StartNode(ctx context.Context, node *k3d.Node) error {
return err
}
// get container which represents the node
nodeContainerJSON, err := docker.ContainerInspect(ctx, nodeContainer.ID)
if err != nil {
return fmt.Errorf("Failed to inspect container %s for node %s: %+v", node.Name, nodeContainer.ID, err)
}
node.Created = nodeContainerJSON.Created
node.State.Running = nodeContainerJSON.State.Running
node.State.Started = nodeContainerJSON.State.StartedAt
return nil
}
@ -297,7 +307,7 @@ func (d Docker) GetNodeLogs(ctx context.Context, node *k3d.Node, since time.Time
sinceStr := ""
if !since.IsZero() {
sinceStr = since.Format("2006-01-02T15:04:05")
sinceStr = since.Format("2006-01-02T15:04:05.999999999Z")
}
logreader, err := docker.ContainerLogs(ctx, container.ID, types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true, Since: sinceStr})
if err != nil {

@ -358,6 +358,7 @@ func GetDefaultObjectName(name string) string {
type NodeState struct {
Running bool
Status string
Started string
}
/*

Loading…
Cancel
Save