Skip to content

Commit

Permalink
Merge pull request #245 from kube-tarian/captenplugin-apis
Browse files Browse the repository at this point in the history
adding capten plugin proto with dummty methods
  • Loading branch information
vramk23 authored Oct 18, 2023
2 parents e482144 + 16eb18d commit c4330aa
Show file tree
Hide file tree
Showing 92 changed files with 9,424 additions and 12,151 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/climon-docker-image-pr.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/climon-docker-image-release.yml

This file was deleted.

86 changes: 0 additions & 86 deletions .github/workflows/climon-docker-image.yml

This file was deleted.

26 changes: 11 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,33 @@ SERVER_APP_NAME := server
AGENT_APP_NAME := agent
DEPLOYMENT_WORKER_APP_NAME := deployment-worker
CONFIG_WORKER_APP_NAME := config-worker
CLIMON_APP_NAME := climon
BUILD := 0.1.1

gen-protoc:
mkdir -p server/pkg/pb/serverpb
mkdir -p capten/agent/pkg/agentpb
mkdir -p capten/agent/pkg/pb/agentpb
mkdir -p server/pkg/pb/agentpb
mkdir -p server/pkg/pb/climonpb
mkdir -p server/pkg/pb/captenpluginspb

cd proto && protoc --go_out=../server/pkg/pb/serverpb/ --go_opt=paths=source_relative \
--go-grpc_out=../server/pkg/pb/serverpb --go-grpc_opt=paths=source_relative \
./server.proto

cd proto && protoc --go_out=../capten/agent/pkg/agentpb/ --go_opt=paths=source_relative \
--go-grpc_out=../capten/agent/pkg/agentpb/ --go-grpc_opt=paths=source_relative \
cd proto && protoc --go_out=../capten/agent/pkg/pb/agentpb/ --go_opt=paths=source_relative \
--go-grpc_out=../capten/agent/pkg/pb/agentpb/ --go-grpc_opt=paths=source_relative \
./agent.proto

cd proto && protoc --go_out=../server/pkg/pb/agentpb --go_opt=paths=source_relative \
--go-grpc_out=../server/pkg/pb/agentpb --go-grpc_opt=paths=source_relative \
./agent.proto

cd proto && protoc --go_out=../capten/capten-sdk/agentpb/ --go_opt=paths=source_relative \
--go-grpc_out=../capten/capten-sdk/agentpb/ --go-grpc_opt=paths=source_relative \
./agent.proto
cd proto && protoc --go_out=../server/pkg/pb/captenpluginspb --go_opt=paths=source_relative \
--go-grpc_out=../server/pkg/pb/captenpluginspb --go-grpc_opt=paths=source_relative \
./capten_plugins.proto

cd proto && protoc --go_out=../server/pkg/pb/climonpb --go_opt=paths=source_relative \
--go-grpc_out=../server/pkg/pb/climonpb --go-grpc_opt=paths=source_relative \
./climon.proto
cd proto && protoc --go_out=../capten/agent/pkg/pb/captenpluginspb --go_opt=paths=source_relative \
--go-grpc_out=../capten/agent/pkg/pb/captenpluginspb --go-grpc_opt=paths=source_relative \
./capten_plugins.proto

docker-build-server:
# The prefix for server to changed either as server or intelops-kad-server
Expand All @@ -47,7 +46,4 @@ docker-build-deployment:
docker-build-config:
docker build -f dockerfiles/config-worker/Dockerfile -t ${PREFIX}-${CONFIG_WORKER_APP_NAME}:${BUILD} .

docker-build-climon:
docker build -f dockerfiles/climon/Dockerfile -t ${PREFIX}-${CLIMON_APP_NAME}:${BUILD} .

docker-build: docker-build-kad docker-build-server docker-build-climon
docker-build: docker-build-kad docker-build-server
1 change: 0 additions & 1 deletion capten/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ build:
go mod download
CGO_ENABLED=0 go build -o build/deployment_worker deployment-worker/main.go
CGO_ENABLED=0 go build -o build/config_worker config-worker/main.go
CGO_ENABLED=0 go build -o build/climon climon/main.go
CGO_ENABLED=0 go build -o build/agent agent/cmd/agent/main.go

clean:
Expand Down
21 changes: 1 addition & 20 deletions capten/Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ make start-kind
# Reference: https://github.com/temporalio/helm-charts
$ cd ~/go/src/github.com/temporalio/helm-charts
$ helm install --set server.replicaCount=1 --set cassandra.config.cluster_size=1 --set prometheus.enabled=false --set grafana.enabled=false --set elasticsearch.enabled=false temporal . --timeout 8m
$ helm install --set server.replicaCount=1 --set cassandra.config.cluster_size=1 --set prometheus.enabled=false --set grafana.enabled=false --set elasticsearch.enabled=false temporal . --timeout 8m
```

## Expose temporal
Expand Down Expand Up @@ -57,8 +57,6 @@ deployment_worker:
repository: kad-deployment-worker
config_worker:
repository: kad-config-worker
climon:
repository: kad-climon
ingressroute:
enabled: false
Expand All @@ -73,9 +71,6 @@ $ helm install kad . -f /tmp/kad-values.yaml
# Install argo-cd using integrator framework helm plugin

```
$ cd integrator
$ curl -X POST http://127.0.0.1:9092/climon -H "content-type: application/json" -d @tests/argocd-helm-plugin.json
# Open temporal web UI (http://127.0.0.1:9082) and check the workflow activity of this action
```

Expand All @@ -97,28 +92,14 @@ $ export PASSWORD=$(kubectl -n default get secret argocd-initial-admin-secret -o
```
# make kind-integration-argocd-test
$ curl -X POST http://127.0.0.1:9092/deployer -H "content-type: application/json" -d @tests/hello-world-argocd-plugin.json
# Open temporal web UI (http://127.0.0.1:9082) and check the workflow activity of this action
```

# Delete hello-world using climon

```
# make kind-integration-argocd-delete-test
$ curl -X DELETE http://127.0.0.1:9092/deployer -H "content-type: application/json" -d @tests/hello-world-argocd-plugin-delete.json
# Open temporal web UI and check the workflow activity of this action
```

# Delete argocd using deployer

```
# make kind-integration-helm-delete-test
$ curl -X POST http://127.0.0.1:9092/climon -H "content-type: application/json" -d @tests/argocd-helm-plugin-delete.json
# Open temporal web UI and check the workflow activity of this action
```

Expand Down
5 changes: 4 additions & 1 deletion capten/agent/cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (

"github.com/intelops/go-common/logging"
"github.com/kube-tarian/kad/capten/agent/pkg/agent"
"github.com/kube-tarian/kad/capten/agent/pkg/agentpb"
"github.com/kube-tarian/kad/capten/agent/pkg/config"
"github.com/kube-tarian/kad/capten/agent/pkg/pb/agentpb"
"github.com/kube-tarian/kad/capten/agent/pkg/pb/captenpluginspb"
"github.com/kube-tarian/kad/capten/agent/pkg/util"
dbinit "github.com/kube-tarian/kad/capten/common-pkg/cassandra/db-init"
dbmigrate "github.com/kube-tarian/kad/capten/common-pkg/cassandra/db-migrate"
Expand Down Expand Up @@ -53,6 +54,8 @@ func main() {
grpcServer = grpc.NewServer()
}
agentpb.RegisterAgentServer(grpcServer, s)
captenpluginspb.RegisterCaptenPluginsServer(grpcServer, s)

log.Infof("Agent listening at %v", listener.Addr())
reflection.Register(grpcServer)

Expand Down
37 changes: 3 additions & 34 deletions capten/agent/pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ package agent

import (
"context"
"fmt"

"github.com/intelops/go-common/logging"
"github.com/kube-tarian/kad/capten/agent/pkg/agentpb"
captenstore "github.com/kube-tarian/kad/capten/agent/pkg/capten-store"
"github.com/kube-tarian/kad/capten/agent/pkg/config"
"github.com/kube-tarian/kad/capten/agent/pkg/pb/agentpb"
"github.com/kube-tarian/kad/capten/agent/pkg/pb/captenpluginspb"
"github.com/kube-tarian/kad/capten/agent/pkg/temporalclient"
"github.com/kube-tarian/kad/capten/agent/pkg/workers"

"go.temporal.io/sdk/client"
)

var _ agentpb.AgentServer = &Agent{}

type Agent struct {
agentpb.UnimplementedAgentServer
captenpluginspb.UnimplementedCaptenPluginsServer
tc *temporalclient.Client
as *captenstore.Store
log logging.Logger
Expand Down Expand Up @@ -51,32 +49,3 @@ func (a *Agent) Ping(ctx context.Context, request *agentpb.PingRequest) (*agentp
a.log.Infof("Ping request received")
return &agentpb.PingResponse{Status: agentpb.StatusCode_OK}, nil
}

func (a *Agent) SubmitJob(ctx context.Context, request *agentpb.JobRequest) (*agentpb.JobResponse, error) {
a.log.Infof("Recieved event %+v", request)
worker, err := a.getWorker(request.Operation)
if err != nil {
return &agentpb.JobResponse{}, err
}

run, err := worker.SendEvent(ctx, request.Payload.GetValue())
if err != nil {
return &agentpb.JobResponse{}, err
}

return prepareJobResponse(run, worker.GetWorkflowName()), err
}

func (a *Agent) getWorker(operatoin string) (workers.Worker, error) {
switch operatoin {
default:
return nil, fmt.Errorf("unsupported operation %s", operatoin)
}
}

func prepareJobResponse(run client.WorkflowRun, name string) *agentpb.JobResponse {
if run != nil {
return &agentpb.JobResponse{Id: run.GetID(), RunID: run.GetRunID(), WorkflowName: name}
}
return &agentpb.JobResponse{}
}
Loading

0 comments on commit c4330aa

Please sign in to comment.