Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Shawn Hurley <[email protected]>
  • Loading branch information
shawn-hurley committed Apr 23, 2024
1 parent 6b3bac8 commit 1d49ab2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/demo-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
build_image yq-external-provider yq-external-provider
build_image generic-external-provider generic-external-provider
popd
build_image . analyzer-lsp
podman build -t quay.io/konveyor/analyzer-lsp:latest -f Dockerfile .
# run the demo in a podman pod
- name: run demo image
Expand Down
31 changes: 27 additions & 4 deletions provider/grpc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"log"
"os/exec"
"time"

"github.com/go-logr/logr"
reflectClient "github.com/jhump/protoreflect/grpcreflect"
Expand Down Expand Up @@ -41,10 +42,11 @@ func NewGRPCClient(config provider.Config, log logr.Logger) (provider.InternalPr
}
refCltCtx, cancel := context.WithCancel(context.Background())
refClt := reflectClient.NewClientAuto(refCltCtx, conn)
defer cancel()

// TODO: reasonable retry here
services, err := refClt.ListServices()
services, err := checkServicesRunning(refClt, log)
if err != nil {
fmt.Printf("%#v", err)
return nil, err
}
foundCodeSnip := false
Expand All @@ -58,8 +60,7 @@ func NewGRPCClient(config provider.Config, log logr.Logger) (provider.InternalPr
foundDepResolve = true
}
}
// Close the reflection service connection
cancel()
fmt.Printf("foundCodeSnip: %#v --- foundDep: %v", foundCodeSnip, foundDepResolve)
// Always need these
provierClient := pb.NewProviderServiceClient(conn)
gp := grpcProvider{
Expand Down Expand Up @@ -132,6 +133,28 @@ func NewGRPCClient(config provider.Config, log logr.Logger) (provider.InternalPr
// }
}

func checkServicesRunning(refClt *reflectClient.Client, log logr.Logger) ([]string, error) {
fmt.Printf("here")
for {
select {
default:
fmt.Printf("here")
services, err := refClt.ListServices()
fmt.Printf("services: %#v -- err: %#v", services, err)
if err == nil && len(services) != 0 {
return services, nil
}
if err != nil {
log.Info("error for list services: ", "error", err)
}
time.Sleep(3 * time.Second)
fmt.Printf("here")
case <-time.After(time.Second * 30):
return nil, fmt.Errorf("no services found")
}
}
}

func (g *grpcProvider) ProviderInit(ctx context.Context) error {
for _, c := range g.config.InitConfig {
s, err := g.Init(ctx, g.log, c)
Expand Down

0 comments on commit 1d49ab2

Please sign in to comment.