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

rename RiskCalculationStatus to ChangeAnalysisStatus #745

Merged
merged 3 commits into from
Dec 17, 2024
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
6 changes: 5 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- main

jobs:
# this tests the basic commands without checking the output
actions:
runs-on: depot-ubuntu-22.04-4
env:
Expand Down Expand Up @@ -83,6 +84,9 @@ jobs:

echo "E2E Tests Complete"

# this runs 2 commands that require user input,
# the `overmind terraform plan` subcommand has to be run first and succeed before the `overmind terraform apply` subcommand can be run
# the lost pixel tapes have built in sleeps to wait for commands to complete
interactive:
runs-on: depot-ubuntu-22.04-4
env:
Expand Down Expand Up @@ -140,7 +144,7 @@ jobs:
terraform init

cp -a $(which terraform) . # provide a terraform binary to the containers below

# see the workflow file for an explanation of what is happening here
docker run --rm -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION -e AWS_REGION -e AWS_SESSION_TOKEN -e HONEYCOMB_API_KEY -e OVM_API_KEY -e TEABUG -v $PWD:/vhs -v ~/.aws:/root/.aws ghcr.io/charmbracelet/vhs /vhs/.github/e2eplan.tape
docker run --rm -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION -e AWS_REGION -e AWS_SESSION_TOKEN -e HONEYCOMB_API_KEY -e OVM_API_KEY -e TEABUG -v $PWD:/vhs -v ~/.aws:/root/.aws ghcr.io/charmbracelet/vhs /vhs/.github/e2eapply.tape

Expand Down
8 changes: 4 additions & 4 deletions cmd/changes_get_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ fetch:
}
}

if riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetStatus() == sdp.RiskCalculationStatus_STATUS_INPROGRESS {
if riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetStatus() == sdp.ChangeAnalysisStatus_STATUS_INPROGRESS {
// Extract the currently running milestone if you can
milestones := riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetProgressMilestones()
milestones := riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetProgressMilestones()
var currentMilestone string
for _, milestone := range milestones {
if milestone == nil {
continue
}

if milestone.GetStatus() == sdp.RiskCalculationStatus_ProgressMilestone_STATUS_INPROGRESS {
if milestone.GetStatus() == sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_INPROGRESS {
currentMilestone = milestone.GetDescription()
}
}

log.WithContext(ctx).WithFields(log.Fields{
"status": riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetStatus().String(),
"status": riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetStatus().String(),
"milestone": currentMilestone,
}).Info("Waiting for risk calculation")

Expand Down
4 changes: 4 additions & 0 deletions cmd/pterm.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func RunRevlinkWarmup(ctx context.Context, oi sdp.OvermindInstance, postPlanPrin

if spinner != nil {
spinner.Success("Discovered and linked all resources")
} else {
// if we didn't have a spinner, print a success message
// this can happen if the terminal is not available, or if the revlink warmup is very fast
pterm.Success.Println("Discovered and linked all resources")
}

return nil
Expand Down
35 changes: 22 additions & 13 deletions cmd/terraform_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,19 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI

resourceExtractionSpinner.Success()

// wait for the revlink warmup to finish before we update the planned changes
err = revlinkPool.Wait()
if err != nil {
return fmt.Errorf("error waiting for revlink warmup: %w", err)
// wait for the revlink warmup for 15 seconds. if it takes longer, we'll just continue
waitCh := make(chan error, 1)
go func() {
waitCh <- revlinkPool.Wait()
}()

select {
case err = <-waitCh:
if err != nil {
return fmt.Errorf("error waiting for revlink warmup: %w", err)
}
case <-time.After(15 * time.Second):
pterm.Info.Print("Done waiting for revlink warmup")
}

///////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -387,7 +396,7 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI
return nil
}

for i, ms := range riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetProgressMilestones() {
for i, ms := range riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetProgressMilestones() {
if i <= len(milestoneSpinners) {
new := pterm.DefaultSpinner.
WithWriter(multi.NewWriter()).
Expand All @@ -397,31 +406,31 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI
}

switch ms.GetStatus() {
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_PENDING:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_PENDING:
continue
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_INPROGRESS:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_INPROGRESS:
if !milestoneSpinners[i].IsActive {
milestoneSpinners[i], _ = milestoneSpinners[i].Start()
}
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_ERROR:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_ERROR:
milestoneSpinners[i].Fail()
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_DONE:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_DONE:
milestoneSpinners[i].Success()
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_SKIPPED:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_SKIPPED:
milestoneSpinners[i].Warning(fmt.Sprintf("%v: skipped", ms.GetDescription()))
}
}

status := riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetStatus()
if status == sdp.RiskCalculationStatus_STATUS_UNSPECIFIED || status == sdp.RiskCalculationStatus_STATUS_INPROGRESS {
status := riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetStatus()
if status == sdp.ChangeAnalysisStatus_STATUS_UNSPECIFIED || status == sdp.ChangeAnalysisStatus_STATUS_INPROGRESS {
if !riskSpinner.IsActive {
// restart after a Fail()
riskSpinner, _ = riskSpinner.Start("Calculating Risks")
}
// retry
time.Sleep(time.Second)

} else if status == sdp.RiskCalculationStatus_STATUS_ERROR {
} else if status == sdp.ChangeAnalysisStatus_STATUS_ERROR {
riskSpinner.Fail("Calculating Risks: waiting for a retry")
} else {
// it's done
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/overmindtech/discovery v0.33.4
github.com/overmindtech/k8s-source v0.9.1
github.com/overmindtech/pterm v0.0.0-20240919144758-04d94ccb2297
github.com/overmindtech/sdp-go v0.102.4
github.com/overmindtech/sdp-go v0.103.0
github.com/overmindtech/stdlib-source v0.0.0-20241211162909-1bb8eb048964
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/sirupsen/logrus v1.9.3
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ github.com/overmindtech/pterm v0.0.0-20240919144758-04d94ccb2297 h1:ih4bqBMHTCtg
github.com/overmindtech/pterm v0.0.0-20240919144758-04d94ccb2297/go.mod h1:bRQZYnvLrW1S5wYT6tbQnun8NpO5X6zP5cY3VKuDc4U=
github.com/overmindtech/sdp-go v0.102.4 h1:PENbGxfoOvh7L3yCeOH1bWtFNfCGeYg/22iF0JeYPdw=
github.com/overmindtech/sdp-go v0.102.4/go.mod h1:Lx2DtTLaroGuVTq5CL1SBT19zzudhLF6jdRkwXDJXRk=
github.com/overmindtech/sdp-go v0.102.5-0.20241216101827-31ab7b07f9d8 h1:7V7SYUvxFq8IaLXoeX/2j8Q8iwdbCN3dmEwenQlUi7Y=
github.com/overmindtech/sdp-go v0.102.5-0.20241216101827-31ab7b07f9d8/go.mod h1:Lx2DtTLaroGuVTq5CL1SBT19zzudhLF6jdRkwXDJXRk=
github.com/overmindtech/sdp-go v0.102.5-0.20241216105318-a0af4432d4b2 h1:dyCFaDLLf+wOCYgirtOepWHspDDzQyWBCddEUyhAEjg=
github.com/overmindtech/sdp-go v0.102.5-0.20241216105318-a0af4432d4b2/go.mod h1:Lx2DtTLaroGuVTq5CL1SBT19zzudhLF6jdRkwXDJXRk=
github.com/overmindtech/sdp-go v0.103.0 h1:MVOYYrP7kdma8Zd6Ol1jX9KHnpe8ZJGlLqm224+Nt/4=
github.com/overmindtech/sdp-go v0.103.0/go.mod h1:Lx2DtTLaroGuVTq5CL1SBT19zzudhLF6jdRkwXDJXRk=
github.com/overmindtech/sdpcache v1.6.4 h1:MJoYBDqDE3s8FrRzZ0RPgFiH39HWI/Mv2ImH1NdLT8k=
github.com/overmindtech/sdpcache v1.6.4/go.mod h1:/F9XStVdntRJEQjlZ86BPuB1Y7VPo1PFcsCNiU1IoGE=
github.com/overmindtech/stdlib-source v0.0.0-20241211162909-1bb8eb048964 h1:StLQfDPOlAHecZtIItkHiYO3ZArKrP1dv3t2Z/n4N1U=
Expand Down
Loading