Skip to content

Commit

Permalink
moar logs
Browse files Browse the repository at this point in the history
Signed-off-by: lsviben <sviben.lovro@gmail.com>
  • Loading branch information
lsviben committed Feb 2, 2024
1 parent 14f055a commit 1f35023
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cmd/crank/beta/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ type Outputs struct {
// TODO(negz): Allow returning desired XR connection details. Maybe as a
// Secret? Should we honor writeConnectionSecretToRef? What if secret stores
// are in use?

// TODO(negz): Allow returning desired XR readiness? Or perhaps just set the
// ready status condition on the XR if all supplied observed resources
// appear ready?
}

// Render the desired XR and composed resources, sorted by resource name, given the supplied inputs.
Expand All @@ -104,7 +100,11 @@ func Render(ctx context.Context, logger logging.Logger, in Inputs) (Outputs, err
if err != nil {
return Outputs{}, errors.Wrapf(err, "cannot start Function %q", fn.GetName())
}
defer rctx.Stop(ctx) //nolint:errcheck // Not sure what to do with this error. Log it to stderr?
defer func() {
if err := rctx.Stop(ctx); err != nil {
logger.Debug("Error stopping function runtime", "function", fn.GetName(), "error", err)
}
}()

conn, err := grpc.DialContext(ctx, rctx.Target,
grpc.WithTransportCredentials(insecure.NewCredentials()),
Expand Down
7 changes: 5 additions & 2 deletions cmd/crank/beta/render/runtime_development.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ type RuntimeDevelopment struct {
// Target is the gRPC target for the running function, for example
// localhost:9443.
Target string
// Function is the name of the function to be run.
Function string
}

// GetRuntimeDevelopment extracts RuntimeDevelopment configuration from the
// supplied Function.
func GetRuntimeDevelopment(fn pkgv1beta1.Function) *RuntimeDevelopment {
r := &RuntimeDevelopment{Target: "localhost:9443"}
r := &RuntimeDevelopment{Target: "localhost:9443", Function: fn.GetName()}
if t := fn.GetAnnotations()[AnnotationKeyRuntimeDevelopmentTarget]; t != "" {
r.Target = t
}
Expand All @@ -52,6 +54,7 @@ func GetRuntimeDevelopment(fn pkgv1beta1.Function) *RuntimeDevelopment {
var _ Runtime = &RuntimeDevelopment{}

// Start does nothing. It returns a Stop function that also does nothing.
func (r *RuntimeDevelopment) Start(_ context.Context, _ logging.Logger) (RuntimeContext, error) {
func (r *RuntimeDevelopment) Start(_ context.Context, logger logging.Logger) (RuntimeContext, error) {
logger.Debug("Starting development runtime. Remember to run the function manually.", "function", r.Function, "target", r.Target)
return RuntimeContext{Target: r.Target, Stop: func(_ context.Context) error { return nil }}, nil
}
1 change: 1 addition & 0 deletions cmd/crank/beta/render/runtime_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ var _ Runtime = &RuntimeDocker{}

// Start a Function as a Docker container.
func (r *RuntimeDocker) Start(ctx context.Context, logger logging.Logger) (RuntimeContext, error) { //nolint:gocyclo // TODO(phisco): Refactor to break this up a bit, not so easy.
logger.Debug("Starting Docker container runtime", "image", r.Image)
c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return RuntimeContext{}, errors.Wrap(err, "cannot create Docker client using environment variables")
Expand Down

0 comments on commit 1f35023

Please sign in to comment.