Skip to content

Commit b32706e

Browse files
author
xiejingru
authored
add app mode to node view (#248)
1 parent b956d61 commit b32706e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/v1/node.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
coreV1 "k8s.io/api/core/v1"
1212
"k8s.io/apimachinery/pkg/api/resource"
1313

14+
"github.com/baetyl/baetyl-go/v2/context"
1415
"github.com/baetyl/baetyl-go/v2/errors"
1516
"github.com/baetyl/baetyl-go/v2/log"
1617
)
@@ -82,6 +83,7 @@ type NodeView struct {
8283
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
8384
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
8485
Report *ReportView `json:"report,omitempty" yaml:"report,omitempty"`
86+
AppMode string `json:"appMode,omitempty" yaml:"appMode,omitempty"`
8587
Desire Desire `json:"desire,omitempty" yaml:"desire,omitempty"`
8688
SysApps []string `json:"sysApps,omitempty" yaml:"sysApps,omitempty"`
8789
Description string `json:"description,omitempty" yaml:"description,omitempty"`
@@ -299,6 +301,7 @@ func (n *Node) View(timeout time.Duration) (*NodeView, error) {
299301
}
300302
}
301303
report.countInstanceNum()
304+
view.AppMode = report.calculateAppMode()
302305
}
303306
return view, nil
304307
}
@@ -454,6 +457,15 @@ func (s *NodeStats) processResourcePercent(status *NodeStats, resourceType strin
454457
return "0", nil
455458
}
456459

460+
func (view *ReportView) calculateAppMode() string {
461+
for _, node := range view.Node {
462+
if node.ContainerRuntime == "" && node.MachineID == "" {
463+
return context.RunModeNative
464+
}
465+
}
466+
return context.RunModeKube
467+
}
468+
457469
func (view *ReportView) countInstanceNum() {
458470
nums := map[string]int{}
459471
if view.AppStats != nil {

0 commit comments

Comments
 (0)