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

Fix VM Execution Comparison #216

Merged
merged 3 commits into from
Jan 23, 2025
Merged
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
33 changes: 5 additions & 28 deletions v3/services/terraformsvc/internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,6 @@ func (v *VMController) handleProvision(vm *vmpb.VM) (error, bool) {
return nil, false

} else if vm.Status.Status == string(hfv1.VmStatusProvisioned) {
// let's check the status of our tf provision
/*tfState, err := t.tfsLister.States(util.GetReleaseNamespace()).Get(vm.Status.TFState)
if err != nil {
if apierrors.IsNotFound(err) {
return fmt.Errorf("execution not found")
}
return nil
} */
// TEMPORARY WORKAROUND UNTIL WE FIGURE OUT A BETTER WAY TO DO THIS

if vm.GetStatus().GetTfstate() == "" {
return fmt.Errorf("tf state was blank in object"), true
}
Expand All @@ -395,34 +385,21 @@ func (v *VMController) handleProvision(vm *vmpb.VM) (error, bool) {

tfExecs := tfExecsList.GetExecutions()

var newestTimestamp int32
var tfExec *terraformpb.Execution
if len(tfExecs) == 0 {
return fmt.Errorf("no executions found for terraform state"), true
}

newestTimestamp = tfExecs[0].GetCreationTimestamp().GetNanos()
hasValidExec := false
tfExec = tfExecs[0]
for _, e := range tfExecs {
if newestTimestamp < e.GetCreationTimestamp().GetNanos() {
newestTimestamp = e.GetCreationTimestamp().GetNanos()
if e.GetStatus().GetOutputs() != "" {
tfExec = e
hasValidExec = true
}
}
// END TEMPORARY WORKAROUND

//executionName := tfState.Status.ExecutionName
/*
tfExec, err := t.tfeLister.Executions(util.GetReleaseNamespace()).Get(executionName)
if err != nil {
//glog.Error(err)
if apierrors.IsNotFound(err) {
return fmt.Errorf("execution not found")
}
return nil
}
*/
if tfExec.GetStatus().GetOutputs() == "" {

if !hasValidExec {
return nil, true
}

Expand Down
Loading