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

Tink Server rewrite for v1alpha2 #765

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cmd/tink-server/tink-server
cmd/tink-worker/tink-worker
doc/
.idea
.vscode
coverage.txt

# Terraform
Expand Down
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"gopls": {
"build.buildFlags": [
"-tags=e2e,integration,all_providers,docker",
],
"formatting.gofumpt": true,
"formatting.local": "github.com/tinkerbell"
},
}
5 changes: 3 additions & 2 deletions cmd/tink-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"

"github.com/tinkerbell/tink/internal/grpcserver"
"github.com/tinkerbell/tink/internal/httpserver"
"github.com/tinkerbell/tink/internal/server"
"go.uber.org/zap"
"github.com/tinkerbell/tink/internal/obsolete/server"
)

// version is set at build time.
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/go-logr/logr"
"github.com/tinkerbell/tink/internal/agent/event"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
)

// Agent is the core data structure for handling workflow execution on target nodes. It leverages
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/tinkerbell/tink/internal/agent/failure"
"github.com/tinkerbell/tink/internal/agent/runtime"
"github.com/tinkerbell/tink/internal/agent/transport"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/agent/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"time"

"github.com/go-logr/logr"

"github.com/tinkerbell/tink/internal/agent/event"
"github.com/tinkerbell/tink/internal/agent/failure"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
)

// ReasonRuntimeError is the default reason used when no reason is provided by the runtime.
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package agent
import (
"context"

"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
)

// ContainerRuntime is a runtime capable of executing workflow actions.
Expand Down
5 changes: 3 additions & 2 deletions internal/agent/runtime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/client"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/util/rand"

"github.com/tinkerbell/tink/internal/agent"
"github.com/tinkerbell/tink/internal/agent/runtime/internal"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/ptr"
"k8s.io/apimachinery/pkg/util/rand"
"github.com/tinkerbell/tink/internal/workflow"
)

var _ agent.ContainerRuntime = &Docker{}
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/runtime/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/rs/zerolog"
"github.com/tinkerbell/tink/internal/agent/failure"
"github.com/tinkerbell/tink/internal/agent/runtime"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
"go.uber.org/multierr"

"github.com/docker/docker/api/types"
Expand Down
3 changes: 2 additions & 1 deletion internal/agent/runtime/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"context"

"github.com/go-logr/logr"

"github.com/tinkerbell/tink/internal/agent"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
)

var _ agent.ContainerRuntime = Fake{}
Expand Down
3 changes: 2 additions & 1 deletion internal/agent/transport/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"context"

"github.com/go-logr/logr"

"github.com/tinkerbell/tink/internal/agent/event"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
)

func Noop() Fake {
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/transport/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/avast/retry-go"
"github.com/go-logr/logr"
"github.com/tinkerbell/tink/internal/agent/event"
"github.com/tinkerbell/tink/internal/agent/workflow"
workflowproto "github.com/tinkerbell/tink/internal/proto/workflow/v2"
"github.com/tinkerbell/tink/internal/workflow"
)

var _ event.Recorder = &GRPC{}
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/transport/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/rs/zerolog"
"github.com/tinkerbell/tink/internal/agent/event"
"github.com/tinkerbell/tink/internal/agent/transport"
"github.com/tinkerbell/tink/internal/agent/workflow"
workflowproto "github.com/tinkerbell/tink/internal/proto/workflow/v2"
"github.com/tinkerbell/tink/internal/workflow"
"google.golang.org/grpc"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/agent/transport/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/tinkerbell/tink/internal/agent/event"
"github.com/tinkerbell/tink/internal/agent/workflow"
"github.com/tinkerbell/tink/internal/workflow"
)

// WorkflowHandler is responsible for workflow execution.
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/transport/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/controller/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/tinkerbell/tink/api/v1alpha1"
"github.com/tinkerbell/tink/internal/workflow"
"github.com/tinkerbell/tink/internal/obsolete/workflow"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand Down
9 changes: 5 additions & 4 deletions internal/e2e/tink_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import (
"github.com/go-logr/zapr"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tinkerbell/tink/api/v1alpha1"
"github.com/tinkerbell/tink/internal/controller"
"github.com/tinkerbell/tink/internal/grpcserver"
"github.com/tinkerbell/tink/internal/server"
"go.uber.org/zap"
"k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"

"github.com/tinkerbell/tink/api/v1alpha1"
"github.com/tinkerbell/tink/internal/controller"
"github.com/tinkerbell/tink/internal/grpcserver"
"github.com/tinkerbell/tink/internal/obsolete/server"
)

var (
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/pkg/errors"
"github.com/tinkerbell/tink/api/v1alpha1"
"github.com/tinkerbell/tink/internal/obsolete/workflow"
"github.com/tinkerbell/tink/internal/proto"
"github.com/tinkerbell/tink/internal/workflow"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions internal/server/grpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package server

import (
"context"

workflowproto "github.com/tinkerbell/tink/internal/proto/workflow/v2"
)

type GRPCServer struct {
workflowproto.UnimplementedWorkflowServiceServer
}

// GetWorkflows creates a stream that will receive workflows intended for the agent identified
// by the GetWorkflowsRequest.agent_id.
func (s *GRPCServer) GetWorkflows(req *workflowproto.GetWorkflowsRequest, stream workflowproto.WorkflowService_GetWorkflowsServer) error {
return nil
}

// PublishEvent publishes a workflow event.
func (s *GRPCServer) PublishEvent(context.Context, *workflowproto.PublishEventRequest) (*workflowproto.PublishEventResponse, error) {
return nil, nil
}
28 changes: 28 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package server

import "github.com/tinkerbell/tink/internal/workflow"

/*
The server must be notified when an agent connects.
The server must be notified when an agent disconnects.
The server must dispatch workflows to the agent.
The server must be notified of events created by the agent.
The server must ensure a single workflow is dispatched to an agent at a time.
The server must time out workflows.
*/

type Transport interface {
Send(workflow.Workflow) error
}

type Server struct {
agents map[string]Transport
}

func (s *Server) RegisterAgent(agentID string, trnsport Transport) error {
return nil
}

func (s *Server) UnregisterAgent(agentID string) error {
return nil
}
File renamed without changes.