diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 35e2d0b7..5ffcb52c 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -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: @@ -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: @@ -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 diff --git a/cmd/changes_get_change.go b/cmd/changes_get_change.go index 6b48ab44..13e392a2 100644 --- a/cmd/changes_get_change.go +++ b/cmd/changes_get_change.go @@ -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") diff --git a/cmd/pterm.go b/cmd/pterm.go index e04867c3..38e78dbe 100644 --- a/cmd/pterm.go +++ b/cmd/pterm.go @@ -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 diff --git a/cmd/terraform_plan.go b/cmd/terraform_plan.go index 2869d576..7db3c8a2 100644 --- a/cmd/terraform_plan.go +++ b/cmd/terraform_plan.go @@ -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") } /////////////////////////////////////////////////////////////////// @@ -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()). @@ -397,23 +406,23 @@ 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") @@ -421,7 +430,7 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI // 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 diff --git a/go.mod b/go.mod index 7e5c9fd9..1775a875 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index beebda43..2750bb66 100644 --- a/go.sum +++ b/go.sum @@ -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=