Skip to content
Merged
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
3 changes: 3 additions & 0 deletions cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ func (i info) Human(w io.Writer) error {
fmt.Fprintf(w, " %v\n", route)
}

fmt.Fprintln(w, "Function is ready:")
fmt.Fprintf(w, " %v\n", i.Ready)
fmt.Fprintln(w, "Deployer:")
fmt.Fprintf(w, " %v\n", i.Deployer)

Expand Down Expand Up @@ -180,6 +182,7 @@ func (i info) Plain(w io.Writer) error {
fmt.Fprintf(w, "Route %v\n", route)
}

fmt.Fprintf(w, "Ready %v\n", i.Ready)
fmt.Fprintf(w, "Deployer %v\n", i.Deployer)

if len(i.Subscriptions) > 0 {
Expand Down
1 change: 1 addition & 0 deletions pkg/functions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ type Instance struct {
Labels map[string]string `json:"labels" yaml:"labels" xml:"-"`
Middleware Middleware `json:"middleware,omitempty" yaml:"middleware,omitempty"`
Generation int64 `json:"generation,omitempty" yaml:"generation,omitempty"`
Ready string `json:"ready,omitempty" yaml:"ready,omitempty"`
}

// Subscriptions currently active to event sources
Expand Down
12 changes: 12 additions & 0 deletions pkg/k8s/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package k8s
import (
"context"
"fmt"
"strings"

v1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fn "knative.dev/func/pkg/functions"
Expand Down Expand Up @@ -55,6 +58,14 @@ func (d *Describer) Describe(ctx context.Context, name, namespace string) (fn.In
return fn.Instance{}, fmt.Errorf("unable to get deployment %q: %v", name, err)
}

ready := corev1.ConditionUnknown
for _, con := range deployment.Status.Conditions {
if con.Type == v1.DeploymentAvailable {
ready = con.Status
break
}
}

primaryRouteURL := fmt.Sprintf("http://%s.%s.svc", name, namespace) // TODO: get correct scheme?

// get image
Expand Down Expand Up @@ -86,6 +97,7 @@ func (d *Describer) Describe(ctx context.Context, name, namespace string) (fn.In
Version: middlewareVersion,
},
Generation: deployment.Generation,
Ready: strings.ToLower(string(ready)),
}

return description, nil
Expand Down
12 changes: 12 additions & 0 deletions pkg/keda/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ package keda
import (
"context"
"fmt"
"strings"

"github.com/kedacore/http-add-on/operator/apis/http/v1alpha1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
Expand Down Expand Up @@ -60,6 +64,13 @@ func (d *Describer) Describe(ctx context.Context, name, namespace string) (fn.In
return fn.Instance{}, fmt.Errorf("unable to get HTTPScaledObject: %w", err)
}

ready := v1.ConditionUnknown
if meta.IsStatusConditionTrue(httpScaledObject.Status.Conditions, v1alpha1.ConditionTypeReady) {
ready = v1.ConditionTrue
} else if meta.IsStatusConditionFalse(httpScaledObject.Status.Conditions, v1alpha1.ConditionTypeReady) {
ready = v1.ConditionFalse
}

if len(httpScaledObject.Spec.Hosts) == 0 {
return fn.Instance{}, fmt.Errorf("HTTPScaledObject %q does not have any hosts", name)
}
Expand Down Expand Up @@ -105,6 +116,7 @@ func (d *Describer) Describe(ctx context.Context, name, namespace string) (fn.In
Version: middlewareVersion,
},
Generation: deployment.Generation,
Ready: strings.ToLower(string(ready)),
}

return description, nil
Expand Down
12 changes: 12 additions & 0 deletions pkg/knative/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package knative
import (
"context"
"fmt"
"strings"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientservingv1 "knative.dev/client/pkg/serving/v1"
eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
"knative.dev/pkg/apis"
)

type Describer struct {
Expand Down Expand Up @@ -66,6 +69,14 @@ func (d *Describer) Describe(ctx context.Context, name, namespace string) (fn.In

// We're responsible, for this function --> proceed...

ready := corev1.ConditionUnknown
for _, con := range service.Status.Conditions {
if con.Type == apis.ConditionReady {
ready = con.Status
break
}
}

routes, err := servingClient.ListRoutes(ctx, clientservingv1.WithService(name))
if err != nil {
return fn.Instance{}, err
Expand All @@ -89,6 +100,7 @@ func (d *Describer) Describe(ctx context.Context, name, namespace string) (fn.In
Routes: routeURLs,
Labels: service.Labels,
Generation: service.Generation,
Ready: strings.ToLower(string(ready)),
}

// get used image (including the sha)
Expand Down
Loading