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

Improve the logs #513

Merged
merged 1 commit into from
May 16, 2018
Merged
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
2 changes: 1 addition & 1 deletion pkg/skaffold/kubernetes/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (a *LogAggregator) streamLogs(ctx context.Context, client corev1.CoreV1Inte

logrus.Infof("Stream logs from pod: %s container: %s", pod.Name, container.Name)

sinceSeconds := int64(time.Since(a.startTime).Seconds())
sinceSeconds := int64(time.Since(a.startTime).Seconds() + 0.5)
// 0s means all the logs
if sinceSeconds == 0 {
sinceSeconds = 1
Expand Down
21 changes: 17 additions & 4 deletions pkg/skaffold/kubernetes/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,36 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/tools/cache"

"k8s.io/apimachinery/pkg/util/wait"
)

func WaitForPodReady(pods corev1.PodInterface, podName string) error {
logrus.Infof("Waiting for %s to be scheduled", podName)
err := wait.PollImmediate(time.Millisecond*500, time.Second*10, func() (bool, error) {
_, err := pods.Get(podName, meta_v1.GetOptions{
IncludeUninitialized: true,
})
if err != nil {
logrus.Infof("Getting pod %s", err)
return false, nil
}
return true, nil
})
if err != nil {
return err
}

logrus.Infof("Waiting for %s to be ready", podName)
return wait.PollImmediate(time.Millisecond*500, time.Minute*10, func() (bool, error) {
pod, err := pods.Get(podName, meta_v1.GetOptions{
IncludeUninitialized: true,
})
if err != nil {
logrus.Infof("Getting pod %s", err)
return false, nil
return false, fmt.Errorf("not found: %s", podName)
}
switch pod.Status.Phase {
case v1.PodRunning:
Expand Down