nagaboinaramgopal opened a new pull request, #357:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/357

   ### Description
   
   `virtualRouterElementState` and `internalLbVmElementState` look up the 
service provider element by iterating the list returned by the API, but the 
not-found error was returned inside the loop:
   
       for _, e := range vre.VirtualRouterElements {
           if nsp.Id == e.Nspid {
               vreID = e.Id
               break
           }
           return fmt.Errorf("Service provider element id (nspod) not found: 
%s.", nsp.Id)
       }
   
   So the lookup fails on the first element that does not match instead of 
scanning the rest, and an empty list falls through with an empty id into 
`ConfigureVirtualRouterElement`. Move the error after the loop behind an 
empty-id check, so every element is scanned and a genuinely missing element 
returns a clear error. Same fix for the internal LB element lookup.
   
   ### Testing
   
   `go build ./...`, `go vet ./...` and `go test ./cloudstack/` pass (the 
resource's acceptance test skips without `TF_ACC`).
   
   There is no fails-before/passes-after acceptance test here: in a standard 
zone each provider has a single element, so the early return is not reached and 
the bug does not manifest end to end. The change is a localized control-flow 
correction in the element lookup, verified by the build, vet and the existing 
suite.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to