container.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package kubemodel
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. type Container struct {
  7. PodUID string `json:"podUid"`
  8. Name string `json:"name"`
  9. Start time.Time `json:"start"`
  10. End time.Time `json:"end"`
  11. CpuMillicoreSecondsAllocated uint64 `json:"cpuMillicoreSecondsAllocated"`
  12. CpuMillicoreRequestAverageAllocated uint64 `json:"cpuMillicoreRequestAverageAllocated"`
  13. CpuMillicoreUsageAverage uint64 `json:"cpuMillicoreUsageAverage"`
  14. CpuMillicoreUsageMax uint64 `json:"cpuMillicoreUsageMax"`
  15. RAMByteSecondsAllocated uint64 `json:"ramByteSecondsAllocated"`
  16. RAMByteRequestAverageAllocated uint64 `json:"ramByteRequestAverageAllocated"`
  17. RAMByteUsageAverage uint64 `json:"ramByteUsageAverage"`
  18. RAMByteUsageMax uint64 `json:"ramByteUsageMax"`
  19. StorageByteSecondsAllocated uint64 `json:"storageByteSecondsAllocated"`
  20. StorageByteRequestAverageAllocated uint64 `json:"storageByteRequestAverageAllocated"`
  21. StorageByteUsageAverage uint64 `json:"storageByteUsageAverage"`
  22. StorageByteUsageMax uint64 `json:"storageByteUsageMax"`
  23. }
  24. func (kms *KubeModelSet) RegisterContainer(uid, name, podUID string) error {
  25. if uid == "" {
  26. err := fmt.Errorf("UID is nil for Container '%s'", name)
  27. kms.Error(err)
  28. return err
  29. }
  30. if _, ok := kms.Containers[uid]; !ok {
  31. kms.Containers[uid] = &Container{
  32. PodUID: podUID,
  33. Name: name,
  34. }
  35. kms.Metadata.ObjectCount++
  36. }
  37. return nil
  38. }