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
38 changes: 33 additions & 5 deletions cli/cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func DashboardCmd(ctx cli.Context) *cobra.Command {
}

if args.wait > 0 {
if err := waitForDashboard(cmd.Context(), client.Kube(), dashboardNamespace, args.wait); err != nil {
if err := waitForDashboard(cmd.Context(), client.Kube(), dashboardNamespace, dashboardWaitDeploymentNames(files), args.wait); err != nil {
return err
}
if _, err := fmt.Fprintln(cmd.OutOrStdout(), "dashboard ready"); err != nil {
Expand All @@ -97,11 +97,17 @@ func DashboardCmd(ctx cli.Context) *cobra.Command {
}

_, err = fmt.Fprintf(cmd.OutOrStdout(), "prometheus: kubectl -n %s port-forward svc/prometheus 9090:9090\ngrafana: kubectl -n %s port-forward svc/grafana 3000:3000\n", dashboardNamespace, dashboardNamespace)
if err != nil {
return err
}
if dashboardHasTracing(files) {
_, err = fmt.Fprintf(cmd.OutOrStdout(), "tracing: kubectl -n %s port-forward svc/tracing 16686:16686\n", dashboardNamespace)
}
return err
},
}
command.Flags().StringVar(&args.manifests, "manifests", args.manifests, "Dashboard manifest file or samples/addons directory")
command.Flags().DurationVar(&args.wait, "wait", args.wait, "Maximum time to wait for Prometheus and Grafana deployments; 0 disables waiting")
command.Flags().DurationVar(&args.wait, "wait", args.wait, "Maximum time to wait for observability deployments; 0 disables waiting")
return command
}

Expand All @@ -126,7 +132,29 @@ func dashboardManifestFiles(path string) ([]string, error) {
if _, err := os.Stat(grafana); err != nil {
return nil, fmt.Errorf("dashboard grafana manifest not found in %s", path)
}
return []string{prometheus, grafana}, nil
files := []string{prometheus, grafana}
tracing := filepath.Join(path, "tracing.yaml")
if _, err := os.Stat(tracing); err == nil {
files = append(files, tracing)
}
return files, nil
}

func dashboardHasTracing(files []string) bool {
for _, file := range files {
if filepath.Base(file) == "tracing.yaml" {
return true
}
}
return false
}

func dashboardWaitDeploymentNames(files []string) []string {
names := []string{"prometheus", "grafana"}
if dashboardHasTracing(files) {
names = append(names, "tracing")
}
return names
}

func applyManifestFile(ctx context.Context, client kube.CLIClient, file string) ([]appliedObject, error) {
Expand Down Expand Up @@ -226,8 +254,8 @@ func printAppliedDashboard(writer io.Writer, objects []appliedObject) error {
return nil
}

func waitForDashboard(ctx context.Context, client kubernetes.Interface, namespace string, timeout time.Duration) error {
for _, name := range []string{"prometheus", "grafana"} {
func waitForDashboard(ctx context.Context, client kubernetes.Interface, namespace string, names []string, timeout time.Duration) error {
for _, name := range names {
if err := waitForAvailableDeployment(ctx, client, namespace, name, timeout); err != nil {
return err
}
Expand Down
30 changes: 30 additions & 0 deletions cli/cmd/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,36 @@ func TestDashboardManifestFiles(t *testing.T) {
if !reflect.DeepEqual(got, want) {
t.Fatalf("dashboardManifestFiles() = %v, want %v", got, want)
}
if dashboardHasTracing(got) {
t.Fatalf("dashboardHasTracing() = true, want false")
}
if names := dashboardWaitDeploymentNames(got); !reflect.DeepEqual(names, []string{"prometheus", "grafana"}) {
t.Fatalf("dashboardWaitDeploymentNames() = %v", names)
}
}

func TestDashboardManifestFilesIncludesTracingWhenPresent(t *testing.T) {
dir := t.TempDir()
for _, name := range []string{"prometheus.yaml", "grafana.yaml", "tracing.yaml"} {
if err := os.WriteFile(filepath.Join(dir, name), []byte("apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: "+name+"\n"), 0o600); err != nil {
t.Fatal(err)
}
}

got, err := dashboardManifestFiles(dir)
if err != nil {
t.Fatalf("dashboardManifestFiles() returned error: %v", err)
}
want := []string{filepath.Join(dir, "prometheus.yaml"), filepath.Join(dir, "grafana.yaml"), filepath.Join(dir, "tracing.yaml")}
if !reflect.DeepEqual(got, want) {
t.Fatalf("dashboardManifestFiles() = %v, want %v", got, want)
}
if !dashboardHasTracing(got) {
t.Fatalf("dashboardHasTracing() = false, want true")
}
if names := dashboardWaitDeploymentNames(got); !reflect.DeepEqual(names, []string{"prometheus", "grafana", "tracing"}) {
t.Fatalf("dashboardWaitDeploymentNames() = %v", names)
}
}

func TestReadManifestObjects(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func proxylessGRPCRuntimeConfigNeedsUpdate(req *discoverymodel.PushRequest) bool
}
for cfg := range req.ConfigsUpdated {
switch cfg.Kind {
case kind.HTTPRoute, kind.CircuitBreakerPolicy, kind.PeerAuthentication, kind.RequestAuthentication, kind.AuthorizationPolicy, kind.Service, kind.EndpointSlice, kind.Endpoints, kind.Pod, kind.Namespace:
case kind.HTTPRoute, kind.BackendTLSPolicy, kind.CircuitBreakerPolicy, kind.PeerAuthentication, kind.RequestAuthentication, kind.AuthorizationPolicy, kind.Service, kind.EndpointSlice, kind.Endpoints, kind.Pod, kind.Namespace:
return true
}
}
Expand Down
3 changes: 3 additions & 0 deletions dubbod/discovery/pkg/bootstrap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ func (s *Server) initRegistryEventHandlers() {
configKind = kind.KubernetesGateway
case "HTTPRoute":
configKind = kind.HTTPRoute
case "BackendTLSPolicy":
configKind = kind.BackendTLSPolicy
case "CircuitBreakerPolicy":
configKind = kind.CircuitBreakerPolicy
default:
Expand All @@ -535,6 +537,7 @@ func (s *Server) initRegistryEventHandlers() {
configKind == kind.RequestAuthentication ||
configKind == kind.AuthorizationPolicy ||
configKind == kind.HTTPRoute ||
configKind == kind.BackendTLSPolicy ||
configKind == kind.CircuitBreakerPolicy

// Trigger ConfigUpdate to push changes to all connected proxies
Expand Down
51 changes: 51 additions & 0 deletions dubbod/discovery/pkg/config/kube/crdclient/types.gen.go

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

Loading