Skip to content

Commit

Permalink
Remove pkg/controller/ready
Browse files Browse the repository at this point in the history
This package wrote a file to report that the controller was live and
ready, which was unnecessary. Instead, we'll use the /metrics endpoint
to determine liveness and readiness.

This change also removes some unused code in
pkg/controller/controller.go
  • Loading branch information
imjasonh committed Apr 15, 2021
1 parent c186129 commit c3d73a8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 178 deletions.
9 changes: 0 additions & 9 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

buildconfig "github.com/shipwright-io/build/pkg/config"
"github.com/shipwright-io/build/pkg/controller"
"github.com/shipwright-io/build/pkg/controller/ready"
"github.com/shipwright-io/build/pkg/ctxlog"
buildMetrics "github.com/shipwright-io/build/pkg/metrics"
"github.com/shipwright-io/build/version"
Expand Down Expand Up @@ -75,14 +74,6 @@ func main() {
os.Exit(1)
}

r := ready.NewFileReady("/tmp/shipwright-build-ready")
err = r.Set()
if err != nil {
ctxlog.Error(ctx, err, "Checking for /tmp/shipwright-build-ready failed")
os.Exit(1)
}
defer r.Unset()

buildCfg := buildconfig.NewDefaultConfig()
if err := buildCfg.SetConfigFromEnv(); err != nil {
ctxlog.Error(ctx, err, "")
Expand Down
17 changes: 9 additions & 8 deletions deploy/500-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ spec:
fieldPath: metadata.name
- name: CONTROLLER_NAME
value: "shipwright-build"
ports:
- containerPort: 8383
name: metrics-port
livenessProbe:
exec:
command:
- stat
- /tmp/shipwright-build-ready
httpGet:
path: /metrics
port: metrics-port
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
exec:
command:
- stat
- /tmp/shipwright-build-ready
httpGet:
path: /metrics
port: metrics-port
initialDelaySeconds: 5
periodSeconds: 10
19 changes: 1 addition & 18 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ import (
"github.com/shipwright-io/build/pkg/reconciler/clusterbuildstrategy"
)

// AddToManagerFuncs is a list of functions to add all Controllers to the Manager
var AddToManagerFuncs []func(context.Context, *config.Config, manager.Manager) error

// AddToManager adds all Controllers to the Manager
func AddToManager(ctx context.Context, c *config.Config, m manager.Manager) error {
for _, f := range AddToManagerFuncs {
if err := f(ctx, c, m); err != nil {
return err
}
}
return nil
}

// NewManager add all the controllers to the manager and register the required schemes
func NewManager(ctx context.Context, config *config.Config, cfg *rest.Config, options manager.Options) (manager.Manager, error) {
mgr, err := manager.New(cfg, options)
Expand All @@ -59,6 +46,7 @@ func NewManager(ctx context.Context, config *config.Config, cfg *rest.Config, op
return nil, err
}

// Add Reconcilers.
if err := build.Add(ctx, config, mgr); err != nil {
return nil, err
}
Expand All @@ -75,10 +63,5 @@ func NewManager(ctx context.Context, config *config.Config, cfg *rest.Config, op
return nil, err
}

// Setup all Controllers
if err := AddToManager(ctx, config, mgr); err != nil {
return nil, err
}

return mgr, nil
}
52 changes: 0 additions & 52 deletions pkg/controller/ready/ready.go

This file was deleted.

17 changes: 0 additions & 17 deletions pkg/controller/ready/ready_suite_test.go

This file was deleted.

74 changes: 0 additions & 74 deletions pkg/controller/ready/ready_test.go

This file was deleted.

0 comments on commit c3d73a8

Please sign in to comment.