node: add start time field and use it when waiting for log messages
This commit is contained in:
parent
58cf15b0e5
commit
746cbcd131
@ -265,6 +265,14 @@ func NodeStart(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, no
|
|||||||
return err
|
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.Wait {
|
||||||
if nodeStartOpts.ReadyLogMessage == "" {
|
if nodeStartOpts.ReadyLogMessage == "" {
|
||||||
nodeStartOpts.ReadyLogMessage = k3d.ReadyLogMessageByRole[node.Role]
|
nodeStartOpts.ReadyLogMessage = k3d.ReadyLogMessageByRole[node.Role]
|
||||||
|
@ -127,6 +127,16 @@ func (d Docker) StartNode(ctx context.Context, node *k3d.Node) error {
|
|||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +307,7 @@ func (d Docker) GetNodeLogs(ctx context.Context, node *k3d.Node, since time.Time
|
|||||||
|
|
||||||
sinceStr := ""
|
sinceStr := ""
|
||||||
if !since.IsZero() {
|
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})
|
logreader, err := docker.ContainerLogs(ctx, container.ID, types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true, Since: sinceStr})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -358,6 +358,7 @@ func GetDefaultObjectName(name string) string {
|
|||||||
type NodeState struct {
|
type NodeState struct {
|
||||||
Running bool
|
Running bool
|
||||||
Status string
|
Status string
|
||||||
|
Started string
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user