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

Switch Pod and Job await logic to external lib #1856

Merged
merged 3 commits into from
Jan 12, 2022
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD (Unreleased)

- Fix panic for deletions from virtual fields in Helm Release (https://github.com/pulumi/pulumi-kubernetes/pull/1850)
- Switch Pod and Job await logic to external lib (https://github.com/pulumi/pulumi-kubernetes/pull/1856)
- Upgrade kubernetes provider module deps (https://github.com/pulumi/pulumi-kubernetes/pull/1861)

## 3.13.0 (January 7, 2022)
Expand Down
8 changes: 4 additions & 4 deletions provider/pkg/await/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/pkg/errors"
checkerlog "github.com/pulumi/cloud-ready-checks/pkg/checker/logging"
checkpod "github.com/pulumi/cloud-ready-checks/pkg/kubernetes/pod"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/informers"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/states"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/clients"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/kinds"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/metadata"
Expand Down Expand Up @@ -806,14 +806,14 @@ func (dia *deploymentInitAwaiter) aggregatePodErrors() checkerlog.Messages {
}

// Check the pod for errors.
checker := states.NewPodChecker()
checker := checkpod.NewPodChecker()
pod, err := clients.PodFromUnstructured(unstructuredPod)
if err != nil {
logger.V(3).Infof("Failed to unmarshal Pod event: %v", err)
return nil
}
m := checker.Update(pod)
messages = append(messages, m.MessagesWithSeverity(diag.Warning, diag.Error)...)
_, results := checker.ReadyDetails(pod)
messages = append(messages, results.Messages().MessagesWithSeverity(diag.Warning, diag.Error)...)
}

return messages
Expand Down
16 changes: 10 additions & 6 deletions provider/pkg/await/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"time"

"github.com/pkg/errors"
"github.com/pulumi/cloud-ready-checks/pkg/checker"
checkerlog "github.com/pulumi/cloud-ready-checks/pkg/checker/logging"
"github.com/pulumi/cloud-ready-checks/pkg/kubernetes/job"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/informers"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/states"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/clients"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/kinds"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/logging"
Expand Down Expand Up @@ -82,16 +83,17 @@ const (
type jobInitAwaiter struct {
job *unstructured.Unstructured
config createAwaitConfig
state *states.StateChecker
checker *checker.StateChecker
errors logging.TimeOrderedLogSet
resource ResourceID
ready bool
}

func makeJobInitAwaiter(c createAwaitConfig) *jobInitAwaiter {
return &jobInitAwaiter{
config: c,
job: c.currentOutputs,
state: states.NewJobChecker(),
checker: job.NewJobChecker(),
resource: ResourceIDFromUnstructured(c.currentOutputs),
}
}
Expand Down Expand Up @@ -124,7 +126,7 @@ func (jia *jobInitAwaiter) Await() error {

timeout := metadata.TimeoutDuration(jia.config.timeout, jia.config.currentInputs, DefaultJobTimeoutMins*60)
for {
if jia.state.Ready() {
if jia.ready {
return nil
}

Expand Down Expand Up @@ -176,7 +178,7 @@ func (jia *jobInitAwaiter) Read() error {
_ = jia.processJobEvent(watchAddedEvent(job))

// Check whether we've succeeded.
if jia.state.Ready() {
if jia.ready {
return nil
}

Expand Down Expand Up @@ -215,7 +217,9 @@ func (jia *jobInitAwaiter) processJobEvent(event watch.Event) error {
return nil
}

messages := jia.state.Update(job)
var results checker.Results
jia.ready, results = jia.checker.ReadyDetails(job)
messages := results.Messages()
for _, message := range messages.MessagesWithSeverity(diag.Warning, diag.Error) {
jia.errors.Add(message)
}
Expand Down
20 changes: 12 additions & 8 deletions provider/pkg/await/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"time"

"github.com/pkg/errors"
"github.com/pulumi/cloud-ready-checks/pkg/checker"
"github.com/pulumi/cloud-ready-checks/pkg/checker/logging"
"github.com/pulumi/cloud-ready-checks/pkg/kubernetes/pod"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/informers"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/await/states"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/clients"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/kinds"
"github.com/pulumi/pulumi-kubernetes/provider/v3/pkg/metadata"
Expand Down Expand Up @@ -107,15 +108,16 @@ const (
type podInitAwaiter struct {
pod *unstructured.Unstructured
config createAwaitConfig
state *states.StateChecker
checker *checker.StateChecker
ready bool
messages logging.Messages
}

func makePodInitAwaiter(c createAwaitConfig) *podInitAwaiter {
return &podInitAwaiter{
config: c,
pod: c.currentOutputs,
state: states.NewPodChecker(),
config: c,
pod: c.currentOutputs,
checker: pod.NewPodChecker(),
}
}

Expand Down Expand Up @@ -160,7 +162,7 @@ func (pia *podInitAwaiter) Await() error {

timeout := metadata.TimeoutDuration(pia.config.timeout, pia.config.currentInputs, DefaultPodTimeoutMins*60)
for {
if pia.state.Ready() {
if pia.ready {
return nil
}

Expand Down Expand Up @@ -202,7 +204,7 @@ func (pia *podInitAwaiter) Read() error {
pia.processPodEvent(watchAddedEvent(pod))

// Check whether we've succeeded.
if pia.state.Ready() {
if pia.ready {
return nil
}

Expand All @@ -228,7 +230,9 @@ func (pia *podInitAwaiter) processPodEvent(event watch.Event) {
return
}

pia.messages = pia.state.Update(pod)
var results checker.Results
pia.ready, results = pia.checker.ReadyDetails(pod)
pia.messages = results.Messages()
for _, message := range pia.messages {
pia.config.logMessage(message)
}
Expand Down
8 changes: 0 additions & 8 deletions provider/pkg/await/recordings/README.md

This file was deleted.

79 changes: 0 additions & 79 deletions provider/pkg/await/recordings/load.go

This file was deleted.

75 changes: 0 additions & 75 deletions provider/pkg/await/recordings/states/job/backoffLimit.json

This file was deleted.

75 changes: 0 additions & 75 deletions provider/pkg/await/recordings/states/job/deadlineExceeded.json

This file was deleted.

Loading