From 2341e5318116fc95e14ac1417a934e289f1c99ed Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 21:01:55 +0300 Subject: [PATCH 001/146] [all] Switch vendor to feature_dynamic_nodes branch Signed-off-by: Mykola Kobets --- cmserver/cmserver.go | 2 +- cmserver/cmserver_test.go | 2 +- go.mod | 4 +- go.sum | 4 +- iamclient/iamclient.go | 2 +- iamclient/iamclient_test.go | 2 +- smcontroller/smcontroller.go | 2 +- smcontroller/smcontroller_test.go | 2 +- smcontroller/smhandler.go | 2 +- umcontroller/umcontroller_internal_test.go | 2 +- umcontroller/umcontroller_test.go | 2 +- umcontroller/umctrlserver.go | 2 +- umcontroller/umhandler.go | 2 +- .../aosedge/aos_common/aostypes/aostypes.go | 144 +- .../aos_common/api/cloudprotocol/alerts.go | 129 + .../api/cloudprotocol/certificates.go | 103 + .../api/cloudprotocol/cloudprotocol.go | 647 +--- .../api/cloudprotocol/desiredstatus.go | 224 ++ .../aos_common/api/cloudprotocol/envvars.go | 71 + .../aos_common/api/cloudprotocol/log.go | 90 + .../api/cloudprotocol/monitoring.go | 72 + .../api/cloudprotocol/servicediscovery.go | 85 + .../aos_common/api/cloudprotocol/state.go | 68 + .../api/cloudprotocol/unitstatus.go | 220 ++ .../aos_common/api/common/common.pb.go | 244 ++ .../updatescheduler.pb.go | 834 +++++ .../{v2 => }/updatescheduler_grpc.pb.go | 58 +- .../v2/updatescheduler.pb.go | 813 ----- .../aos_common/api/iamanager/iamanager.pb.go | 3223 +++++++++++++++++ .../iamanager/{v4 => }/iamanager_grpc.pb.go | 680 ++-- .../api/iamanager/v4/iamanager.pb.go | 1925 ---------- .../{v3 => }/servicemanager.pb.go | 2800 +++++++------- .../{v3 => }/servicemanager_grpc.pb.go | 10 +- .../api/updatemanager/updatemanager.pb.go | 918 +++++ .../{v1 => }/updatemanager_grpc.pb.go | 10 +- .../api/updatemanager/v1/updatemanager.pb.go | 906 ----- .../aosedge/aos_common/image/image.go | 27 - .../aos_common/journalalerts/journalalerts.go | 10 +- .../aosedge/aos_common/migration/migration.go | 1 + .../resourcemonitor/alertprocessor.go | 102 +- .../aos_common/resourcemonitor/averagecalc.go | 64 + .../resourcemonitor/resourcemonitor.go | 633 ++-- .../resourcemonitor/xensystemusage.go | 2 +- .../aos_common/utils/pbconvert/pbconvert.go | 166 +- .../aos_common/utils/testtools/crypto.go | 6 +- vendor/modules.txt | 11 +- 46 files changed, 8881 insertions(+), 6445 deletions(-) create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/servicediscovery.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/state.go create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go create mode 100644 vendor/github.com/aosedge/aos_common/api/common/common.pb.go create mode 100644 vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go rename vendor/github.com/aosedge/aos_common/api/communicationmanager/{v2 => }/updatescheduler_grpc.pb.go (76%) delete mode 100644 vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler.pb.go create mode 100644 vendor/github.com/aosedge/aos_common/api/iamanager/iamanager.pb.go rename vendor/github.com/aosedge/aos_common/api/iamanager/{v4 => }/iamanager_grpc.pb.go (59%) delete mode 100644 vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager.pb.go rename vendor/github.com/aosedge/aos_common/api/servicemanager/{v3 => }/servicemanager.pb.go (50%) rename vendor/github.com/aosedge/aos_common/api/servicemanager/{v3 => }/servicemanager_grpc.pb.go (94%) create mode 100644 vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager.pb.go rename vendor/github.com/aosedge/aos_common/api/updatemanager/{v1 => }/updatemanager_grpc.pb.go (93%) delete mode 100644 vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager.pb.go create mode 100644 vendor/github.com/aosedge/aos_common/resourcemonitor/averagecalc.go diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index ecc1e9fc..8ec1d913 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -24,7 +24,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/communicationmanager/v2" + pb "github.com/aosedge/aos_common/api/communicationmanager" "github.com/aosedge/aos_common/utils/cryptutils" "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 518e410a..e710c16a 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -25,7 +25,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/communicationmanager/v2" + pb "github.com/aosedge/aos_common/api/communicationmanager" log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" diff --git a/go.mod b/go.mod index d708d0df..dce8f84c 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240701123742-84e62a5773fc + github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf @@ -16,6 +16,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/google/go-tpm v0.9.0 github.com/google/uuid v1.4.0 + github.com/hashicorp/go-version v1.6.0 github.com/jackpal/gateway v1.0.11 github.com/looplab/fsm v1.0.1 github.com/mattn/go-sqlite3 v1.14.18 @@ -40,7 +41,6 @@ require ( github.com/golang-migrate/migrate/v4 v4.16.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect github.com/lib/pq v1.10.9 // indirect github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f // indirect github.com/moby/sys/mountinfo v0.7.1 // indirect diff --git a/go.sum b/go.sum index f7a0e6d6..b397375b 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240701123742-84e62a5773fc h1:+g8nW2vQMq4iS307OKzLtd8u5ZQ9WcvpJNmpfZhtxG4= -github.com/aosedge/aos_common v0.0.0-20240701123742-84e62a5773fc/go.mod h1:fVk+1Za6Vaef1ysZvjJeFaA8NUS/8U4tJuCqLd5fky0= +github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b h1:+BLcX0YXKgbsBTouS4H855Ks6Ozb21GD2gdoR+jpQck= +github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 9ba81a5e..734d2fbb 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -25,7 +25,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/iamanager/v4" + pb "github.com/aosedge/aos_common/api/iamanager" "github.com/aosedge/aos_common/utils/cryptutils" "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index 1a0f9d86..a8db2e1c 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -32,7 +32,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/iamanager/v4" + pb "github.com/aosedge/aos_common/api/iamanager" "github.com/aosedge/aos_common/utils/cryptutils" "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 6f4fc9c1..8c98ad83 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -24,7 +24,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/servicemanager/v3" + pb "github.com/aosedge/aos_common/api/servicemanager" "github.com/aosedge/aos_common/utils/cryptutils" log "github.com/sirupsen/logrus" "google.golang.org/grpc" diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 505aba5b..5989de17 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -28,7 +28,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/servicemanager/v3" + pb "github.com/aosedge/aos_common/api/servicemanager" log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 0697ac1b..e12d228b 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -28,7 +28,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/servicemanager/v3" + pb "github.com/aosedge/aos_common/api/servicemanager" "github.com/aosedge/aos_common/utils/pbconvert" "github.com/aosedge/aos_common/utils/syncstream" log "github.com/sirupsen/logrus" diff --git a/umcontroller/umcontroller_internal_test.go b/umcontroller/umcontroller_internal_test.go index daa2c582..3568dbb9 100644 --- a/umcontroller/umcontroller_internal_test.go +++ b/umcontroller/umcontroller_internal_test.go @@ -26,7 +26,7 @@ import ( "google.golang.org/grpc" "github.com/aosedge/aos_common/aoserrors" - pb "github.com/aosedge/aos_common/api/updatemanager/v1" + pb "github.com/aosedge/aos_common/api/updatemanager" ) /*********************************************************************************************************************** diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 8c2c683f..55a35282 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -36,7 +36,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" - pb "github.com/aosedge/aos_common/api/updatemanager/v1" + pb "github.com/aosedge/aos_common/api/updatemanager" "github.com/aosedge/aos_common/image" "github.com/aosedge/aos_common/api/cloudprotocol" diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index 1ebb24bf..004fd769 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -28,7 +28,7 @@ import ( "google.golang.org/grpc/credentials" "github.com/aosedge/aos_common/aoserrors" - pb "github.com/aosedge/aos_common/api/updatemanager/v1" + pb "github.com/aosedge/aos_common/api/updatemanager" "github.com/aosedge/aos_common/utils/cryptutils" "github.com/aosedge/aos_communicationmanager/config" diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index c2341b87..4d968202 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -26,7 +26,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/aosedge/aos_common/aoserrors" - pb "github.com/aosedge/aos_common/api/updatemanager/v1" + pb "github.com/aosedge/aos_common/api/updatemanager" ) /*********************************************************************************************************************** diff --git a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go index f176fa45..cf1d5559 100644 --- a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go +++ b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go @@ -46,6 +46,21 @@ const ( monthDuration = yearDuration / 12 ) +// Partition types. +const ( + GenericPartition = "generic" + StoragesPartition = "storages" + StatesPartition = "states" + ServicesPartition = "services" + LayersPartition = "layers" +) + +// BalancingPolicy types. +const ( + BalancingEnabled = "enabled" + BalancingDisabled = "disabled" +) + /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -60,103 +75,25 @@ type Time struct { time.Time } -// AlertRuleParam describes alert rule. -type AlertRuleParam struct { - MinTimeout Duration `json:"minTimeout"` - MinThreshold uint64 `json:"minThreshold"` - MaxThreshold uint64 `json:"maxThreshold"` -} - -// PartitionAlertRuleParam describes alert rule. -type PartitionAlertRuleParam struct { - AlertRuleParam - Name string `json:"name"` -} - -// AlertRules define service monitoring alerts rules. -type AlertRules struct { - RAM *AlertRuleParam `json:"ram,omitempty"` - CPU *AlertRuleParam `json:"cpu,omitempty"` - UsedDisks []PartitionAlertRuleParam `json:"usedDisks,omitempty"` - InTraffic *AlertRuleParam `json:"inTraffic,omitempty"` - OutTraffic *AlertRuleParam `json:"outTraffic,omitempty"` -} - -// FileSystemMount specifies a mount instructions. -type FileSystemMount struct { - Destination string `json:"destination"` - Type string `json:"type,omitempty"` - Source string `json:"source,omitempty"` - Options []string `json:"options,omitempty"` -} - -// Host struct represents entry in /etc/hosts. -type Host struct { - IP string `json:"ip"` - Hostname string `json:"hostname"` -} - -// DeviceInfo device information. -type DeviceInfo struct { - Name string `json:"name"` - SharedCount int `json:"sharedCount,omitempty"` - Groups []string `json:"groups,omitempty"` - HostDevices []string `json:"hostDevices"` -} - -// ResourceInfo resource information. -type ResourceInfo struct { - Name string `json:"name"` - Groups []string `json:"groups,omitempty"` - Mounts []FileSystemMount `json:"mounts,omitempty"` - Env []string `json:"env,omitempty"` - Hosts []Host `json:"hosts,omitempty"` -} - -// NodeConfig node configuration. -type NodeUnitConfig struct { - NodeType string `json:"nodeType"` - Devices []DeviceInfo `json:"devices,omitempty"` - Resources []ResourceInfo `json:"resources,omitempty"` - Labels []string `json:"labels,omitempty"` - Priority uint32 `json:"priority,omitempty"` -} - -// UnitConfig board configuration. -type UnitConfig struct { - FormatVersion uint64 `json:"formatVersion"` - VendorVersion string `json:"vendorVersion"` - Nodes []NodeUnitConfig `json:"nodes"` -} - // ServiceInfo service info. type ServiceInfo struct { - VersionInfo - ID string `json:"id"` + ServiceID string `json:"serviceId"` ProviderID string `json:"providerId"` + Version string `json:"version"` GID uint32 `json:"gid"` URL string `json:"url"` Sha256 []byte `json:"sha256"` - Sha512 []byte `json:"sha512"` Size uint64 `json:"size"` } // LayerInfo layer info. type LayerInfo struct { - VersionInfo - ID string `json:"id"` - Digest string `json:"digest"` - URL string `json:"url"` - Sha256 []byte `json:"sha256"` - Sha512 []byte `json:"sha512"` - Size uint64 `json:"size"` -} - -// VersionInfo common version structure. -type VersionInfo struct { - AosVersion uint64 `json:"aosVersion"` - VendorVersion string `json:"vendorVersion"` - Description string `json:"description"` + LayerID string `json:"layerId"` + Digest string `json:"digest"` + Version string `json:"version"` + URL string `json:"url"` + Sha256 []byte `json:"sha256"` + Size uint64 `json:"size"` } // InstanceIdent instance identification information. @@ -228,21 +165,52 @@ type RunParameters struct { RestartInterval Duration `json:"restartInterval,omitempty"` } +// AlertRuleParam describes alert rule. +type AlertRuleParam struct { + Timeout Duration `json:"timeout"` + Low uint64 `json:"low"` + High uint64 `json:"high"` +} + +// PartitionAlertRuleParam describes alert rule. +type PartitionAlertRuleParam struct { + AlertRuleParam + Name string `json:"name"` +} + +// AlertRules define service monitoring alerts rules. +type AlertRules struct { + RAM *AlertRuleParam `json:"ram,omitempty"` + CPU *AlertRuleParam `json:"cpu,omitempty"` + UsedDisks []PartitionAlertRuleParam `json:"usedDisks,omitempty"` + InTraffic *AlertRuleParam `json:"inTraffic,omitempty"` + OutTraffic *AlertRuleParam `json:"outTraffic,omitempty"` +} + +// ResourceRatiosInfo resource ratios info. +type ResourceRatiosInfo struct { + CPU float32 `json:"cpu"` + Mem float32 `json:"mem"` + Storage float32 `json:"storage"` +} + // ServiceConfig Aos service configuration. type ServiceConfig struct { Created time.Time `json:"created"` Author string `json:"author"` Hostname *string `json:"hostname,omitempty"` + BalancingPolicy string `json:"balancingPolicy"` Runner string `json:"runner"` + RunParameters RunParameters `json:"runParameters,omitempty"` Sysctl map[string]string `json:"sysctl,omitempty"` OfflineTTL Duration `json:"offlineTtl,omitempty"` Quotas ServiceQuotas `json:"quotas"` + ResourceRatios *ResourceRatiosInfo `json:"resourceRatios"` AllowedConnections map[string]struct{} `json:"allowedConnections,omitempty"` Devices []ServiceDevice `json:"devices,omitempty"` Resources []string `json:"resources,omitempty"` Permissions map[string]map[string]string `json:"permissions,omitempty"` AlertRules *AlertRules `json:"alertRules,omitempty"` - RunParameters RunParameters `json:"runParameters,omitempty"` } /*********************************************************************************************************************** @@ -289,7 +257,7 @@ func (t *Time) UnmarshalJSON(b []byte) (err error) { return aoserrors.Errorf(errFormat, value) } - intFields := make([]int, 3) //nolint:gomnd //time format has 3 fields HH:MM:SS + intFields := make([]int, 3) //nolint:mnd //time format has 3 fields HH:MM:SS for i, field := range strFields { if intFields[i], err = strconv.Atoi(field); err != nil { diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go new file mode 100644 index 00000000..23cc4cf8 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import ( + "time" + + "github.com/aosedge/aos_common/aostypes" +) + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// AlertsMessageType alerts message type. +const AlertsMessageType = "alerts" + +// Alert tags. +const ( + AlertTagSystemError = "systemAlert" + AlertTagAosCore = "coreAlert" + AlertTagResourceValidate = "resourceValidateAlert" + AlertTagDeviceAllocate = "deviceAllocateAlert" + AlertTagSystemQuota = "systemQuotaAlert" + AlertTagInstanceQuota = "instanceQuotaAlert" + AlertTagDownloadProgress = "downloadProgressAlert" + AlertTagServiceInstance = "serviceInstanceAlert" +) + +// Download target types. +const ( + DownloadTargetComponent = "component" + DownloadTargetLayer = "layer" + DownloadTargetService = "service" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// SystemAlert system alert structure. +type SystemAlert struct { + NodeID string `json:"nodeId"` + Message string `json:"message"` +} + +// CoreAlert system alert structure. +type CoreAlert struct { + NodeID string `json:"nodeId"` + CoreComponent string `json:"coreComponent"` + Message string `json:"message"` +} + +// DownloadAlert download alert structure. +type DownloadAlert struct { + TargetType string `json:"targetType"` + TargetID string `json:"targetId"` + Version string `json:"version"` + Message string `json:"message"` + URL string `json:"url"` + DownloadedBytes string `json:"downloadedBytes"` + TotalBytes string `json:"totalBytes"` +} + +// SystemQuotaAlert system quota alert structure. +type SystemQuotaAlert struct { + NodeID string `json:"nodeId"` + Parameter string `json:"parameter"` + Value uint64 `json:"value"` + Status string `json:"-"` +} + +// InstanceQuotaAlert instance quota alert structure. +type InstanceQuotaAlert struct { + aostypes.InstanceIdent + Parameter string `json:"parameter"` + Value uint64 `json:"value"` + Status string `json:"-"` +} + +// DeviceAllocateAlert device allocate alert structure. +type DeviceAllocateAlert struct { + aostypes.InstanceIdent + NodeID string `json:"nodeId"` + Device string `json:"device"` + Message string `json:"message"` +} + +// ResourceValidateAlert resource validate alert structure. +type ResourceValidateAlert struct { + NodeID string `json:"nodeId"` + Name string `json:"name"` + Errors []ErrorInfo `json:"errors"` +} + +// ServiceInstanceAlert system alert structure. +type ServiceInstanceAlert struct { + aostypes.InstanceIdent + ServiceVersion string `json:"version"` + Message string `json:"message"` +} + +// AlertItem alert item structure. +type AlertItem struct { + Timestamp time.Time `json:"timestamp"` + Tag string `json:"tag"` + Payload interface{} `json:"payload"` +} + +// Alerts alerts message structure. +type Alerts struct { + MessageType string `json:"messageType"` + Items []AlertItem +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go new file mode 100644 index 00000000..4f65d5dc --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import "time" + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// Certificate message types. +const ( + RenewCertsNotificationMessageType = "renewCertificatesNotification" + IssuedUnitCertsMessageType = "issuedUnitCertificates" + IssueUnitCertsMessageType = "issueUnitCertificates" + InstallUnitCertsConfirmationMessageType = "installUnitCertificatesConfirmation" +) + +// UnitSecretVersion specifies supported version of UnitSecret message. +const UnitSecretVersion = 2 + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// IssuedCertData issued unit certificate data. +type IssuedCertData struct { + Type string `json:"type"` + NodeID string `json:"nodeId,omitempty"` + CertificateChain string `json:"certificateChain"` +} + +// InstallCertData install certificate data. +type InstallCertData struct { + Type string `json:"type"` + NodeID string `json:"nodeId,omitempty"` + Serial string `json:"serial"` + Status string `json:"status"` + Description string `json:"description,omitempty"` +} + +// RenewCertData renew certificate data. +type RenewCertData struct { + Type string `json:"type"` + NodeID string `json:"nodeId,omitempty"` + Serial string `json:"serial"` + ValidTill time.Time `json:"validTill"` +} + +// UnitSecret keeps unit secret used to decode secure device password. +type UnitSecret struct { + Version int `json:"version"` + Data struct { + OwnerPassword string `json:"ownerPassword"` + } `json:"data"` +} + +// IssueCertData issue certificate data. +type IssueCertData struct { + Type string `json:"type"` + NodeID string `json:"nodeId,omitempty"` + Csr string `json:"csr"` +} + +// RenewCertsNotification renew certificate notification from cloud with pwd. +type RenewCertsNotification struct { + MessageType string `json:"messageType"` + Certificates []RenewCertData `json:"certificates"` + UnitSecret UnitSecret `json:"unitSecret"` +} + +// IssuedUnitCerts issued unit certificates info. +type IssuedUnitCerts struct { + MessageType string `json:"messageType"` + Certificates []IssuedCertData `json:"certificates"` +} + +// IssueUnitCerts issue unit certificates request. +type IssueUnitCerts struct { + MessageType string `json:"messageType"` + Requests []IssueCertData `json:"requests"` +} + +// InstallUnitCertsConfirmation install unit certificates confirmation. +type InstallUnitCertsConfirmation struct { + MessageType string `json:"messageType"` + Certificates []InstallCertData `json:"certificates"` +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go index 9fa561ff..7bf77129 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go @@ -17,112 +17,12 @@ package cloudprotocol -import ( - "encoding/json" - "fmt" - "time" - - "github.com/aosedge/aos_common/aostypes" -) - /*********************************************************************************************************************** * Consts **********************************************************************************************************************/ // ProtocolVersion specifies supported protocol version. -const ProtocolVersion = 5 - -// UnitSecretVersion specifies supported version of UnitSecret message. -const UnitSecretVersion = 2 - -// Cloud message types. -const ( - DesiredStatusType = "desiredStatus" - RequestLogType = "requestLog" - ServiceDiscoveryType = "serviceDiscovery" - StateAcceptanceType = "stateAcceptance" - UpdateStateType = "updateState" - DeviceErrors = "deviceErrors" - RenewCertsNotificationType = "renewCertificatesNotification" - IssuedUnitCertsType = "issuedUnitCertificates" - OverrideEnvVarsType = "overrideEnvVars" -) - -// Device message types. -const ( - AlertsType = "alerts" - MonitoringDataType = "monitoringData" - NewStateType = "newState" - PushLogType = "pushLog" - StateRequestType = "stateRequest" - UnitStatusType = "unitStatus" - IssueUnitCertsType = "issueUnitCertificates" - InstallUnitCertsConfirmationType = "installUnitCertificatesConfirmation" - OverrideEnvVarsStatusType = "overrideEnvVarsStatus" -) - -// Alert tags. -const ( - AlertTagSystemError = "systemAlert" - AlertTagAosCore = "coreAlert" - AlertTagResourceValidate = "resourceValidateAlert" - AlertTagDeviceAllocate = "deviceAllocateAlert" - AlertTagSystemQuota = "systemQuotaAlert" - AlertTagInstanceQuota = "instanceQuotaAlert" - AlertTagDownloadProgress = "downloadProgressAlert" - AlertTagServiceInstance = "serviceInstanceAlert" -) - -// Unit statuses. -const ( - UnknownStatus = "unknown" - PendingStatus = "pending" - DownloadingStatus = "downloading" - DownloadedStatus = "downloaded" - InstallingStatus = "installing" - InstalledStatus = "installed" - RemovingStatus = "removing" - RemovedStatus = "removed" - ErrorStatus = "error" -) - -// SOTA/FOTA schedule type. -const ( - ForceUpdate = "force" - TriggerUpdate = "trigger" - TimetableUpdate = "timetable" -) - -// Service instance states. -const ( - InstanceStateActivating = "activating" - InstanceStateActive = "active" - InstanceStateInactive = "inactive" - InstanceStateFailed = "failed" -) - -// Download target types. -const ( - DownloadTargetComponent = "component" - DownloadTargetLayer = "layer" - DownloadTargetService = "service" -) - -// Partition types. -const ( - GenericPartition = "generic" - StoragesPartition = "storages" - StatesPartition = "states" - ServicesPartition = "services" - LayersPartition = "layers" -) - -// Log types. -const ( - SystemLog = "systemLog" - ServiceLog = "serviceLog" - CrashLog = "crashLog" -) +const ProtocolVersion = 6 /*********************************************************************************************************************** * Types @@ -147,308 +47,6 @@ type MessageHeader struct { MessageType string `json:"messageType"` } -// ServiceDiscoveryRequest service discovery request. -type ServiceDiscoveryRequest struct{} - -// ServiceDiscoveryResponse service discovery response. -type ServiceDiscoveryResponse struct { - Version uint64 `json:"version"` - Connection ConnectionInfo `json:"connection"` -} - -// ConnectionInfo AMQP connection info. -type ConnectionInfo struct { - SendParams SendParams `json:"sendParams"` - ReceiveParams ReceiveParams `json:"receiveParams"` -} - -// SendParams AMQP send parameters. -type SendParams struct { - Host string `json:"host"` - User string `json:"user"` - Password string `json:"password"` - Mandatory bool `json:"mandatory"` - Immediate bool `json:"immediate"` - Exchange ExchangeParams `json:"exchange"` -} - -// ExchangeParams AMQP exchange parameters. -type ExchangeParams struct { - Name string `json:"name"` - Durable bool `json:"durable"` - AutoDetect bool `json:"autoDetect"` - Internal bool `json:"internal"` - NoWait bool `json:"noWait"` -} - -// ReceiveParams AMQP receive parameters. -type ReceiveParams struct { - Host string `json:"host"` - User string `json:"user"` - Password string `json:"password"` - Consumer string `json:"consumer"` - AutoAck bool `json:"autoAck"` - Exclusive bool `json:"exclusive"` - NoLocal bool `json:"noLocal"` - NoWait bool `json:"noWait"` - Queue QueueInfo `json:"queue"` -} - -// QueueInfo AMQP queue info. -type QueueInfo struct { - Name string `json:"name"` - Durable bool `json:"durable"` - DeleteWhenUnused bool `json:"deleteWhenUnused"` - Exclusive bool `json:"exclusive"` - NoWait bool `json:"noWait"` -} - -// InstanceFilter instance filter structure. -type InstanceFilter struct { - ServiceID *string `json:"serviceId,omitempty"` - SubjectID *string `json:"subjectId,omitempty"` - Instance *uint64 `json:"instance,omitempty"` -} - -// LogFilter request log message. -type LogFilter struct { - From *time.Time `json:"from"` - Till *time.Time `json:"till"` - NodeIDs []string `json:"nodeIds,omitempty"` - InstanceFilter -} - -// RequestLog request log message. -type RequestLog struct { - LogID string `json:"logId"` - LogType string `json:"logType"` - Filter LogFilter `json:"filter"` -} - -// DecryptionInfo update decryption info. -type DecryptionInfo struct { - BlockAlg string `json:"blockAlg"` - BlockIv []byte `json:"blockIv"` - BlockKey []byte `json:"blockKey"` - AsymAlg string `json:"asymAlg"` - ReceiverInfo *struct { - Serial string `json:"serial"` - Issuer []byte `json:"issuer"` - } `json:"receiverInfo"` -} - -// Signs message signature. -type Signs struct { - ChainName string `json:"chainName"` - Alg string `json:"alg"` - Value []byte `json:"value"` - TrustedTimestamp string `json:"trustedTimestamp"` - OcspValues []string `json:"ocspValues"` -} - -// CertificateChain certificate chain. -type CertificateChain struct { - Name string `json:"name"` - Fingerprints []string `json:"fingerprints"` -} - -// Certificate certificate structure. -type Certificate struct { - Fingerprint string `json:"fingerprint"` - Certificate []byte `json:"certificate"` -} - -// DecryptDataStruct struct contains how to decrypt data. -type DecryptDataStruct struct { - URLs []string `json:"urls"` - Sha256 []byte `json:"sha256"` - Sha512 []byte `json:"sha512"` - Size uint64 `json:"size"` - DecryptionInfo *DecryptionInfo `json:"decryptionInfo,omitempty"` - Signs *Signs `json:"signs,omitempty"` -} - -// StateAcceptance state acceptance message. -type StateAcceptance struct { - aostypes.InstanceIdent - Checksum string `json:"checksum"` - Result string `json:"result"` - Reason string `json:"reason"` -} - -// UpdateState state update message. -type UpdateState struct { - aostypes.InstanceIdent - Checksum string `json:"stateChecksum"` - State string `json:"state"` -} - -// NewState new state structure. -type NewState struct { - aostypes.InstanceIdent - Checksum string `json:"stateChecksum"` - State string `json:"state"` -} - -// StateRequest state request structure. -type StateRequest struct { - aostypes.InstanceIdent - Default bool `json:"default"` -} - -// SystemAlert system alert structure. -type SystemAlert struct { - NodeID string `json:"nodeId"` - Message string `json:"message"` -} - -// CoreAlert system alert structure. -type CoreAlert struct { - NodeID string `json:"nodeId"` - CoreComponent string `json:"coreComponent"` - Message string `json:"message"` -} - -// DownloadAlert download alert structure. -type DownloadAlert struct { - TargetType string `json:"targetType"` - TargetID string `json:"targetId"` - TargetAosVersion uint64 `json:"targetAosVersion"` - TargetVendorVersion string `json:"targetVendorVersion"` - Message string `json:"message"` - Progress string `json:"progress"` - URL string `json:"url"` - DownloadedBytes string `json:"downloadedBytes"` - TotalBytes string `json:"totalBytes"` -} - -// SystemQuotaAlert system quota alert structure. -type SystemQuotaAlert struct { - NodeID string `json:"nodeId"` - Parameter string `json:"parameter"` - Value uint64 `json:"value"` -} - -// InstanceQuotaAlert instance quota alert structure. -type InstanceQuotaAlert struct { - aostypes.InstanceIdent - Parameter string `json:"parameter"` - Value uint64 `json:"value"` -} - -// DeviceAllocateAlert device allocate alert structure. -type DeviceAllocateAlert struct { - aostypes.InstanceIdent - NodeID string `json:"nodeId"` - Device string `json:"device"` - Message string `json:"message"` -} - -// ResourceValidateError resource validate error structure. -type ResourceValidateError struct { - Name string `json:"name"` - Errors []string `json:"error"` -} - -// ResourceValidateAlert resource validate alert structure. -type ResourceValidateAlert struct { - NodeID string `json:"nodeId"` - ResourcesErrors []ResourceValidateError `json:"resourcesErrors"` -} - -// ServiceInstanceAlert system alert structure. -type ServiceInstanceAlert struct { - aostypes.InstanceIdent - AosVersion uint64 `json:"aosVersion"` - Message string `json:"message"` -} - -// AlertItem alert item structure. -type AlertItem struct { - Timestamp time.Time `json:"timestamp"` - Tag string `json:"tag"` - Payload interface{} `json:"payload"` -} - -// Alerts alerts message structure. -type Alerts []AlertItem - -// Monitoring monitoring message structure. -type Monitoring struct { - Nodes []NodeMonitoringData `json:"nodes"` -} - -// NodeMonitoringData node monitoring data. -type NodeMonitoringData struct { - MonitoringData - NodeID string `json:"nodeId"` - Timestamp time.Time `json:"timestamp"` - ServiceInstances []InstanceMonitoringData `json:"serviceInstances"` -} - -// MonitoringData monitoring data. -type MonitoringData struct { - RAM uint64 `json:"ram"` - CPU uint64 `json:"cpu"` - InTraffic uint64 `json:"inTraffic"` - OutTraffic uint64 `json:"outTraffic"` - Disk []PartitionUsage `json:"disk"` -} - -// PartitionUsage partition usage information. -type PartitionUsage struct { - Name string `json:"name"` - UsedSize uint64 `json:"usedSize"` -} - -// InstanceMonitoringData monitoring data for service. -type InstanceMonitoringData struct { - aostypes.InstanceIdent - MonitoringData -} - -// PushLog push service log structure. -type PushLog struct { - NodeID string `json:"nodeId"` - LogID string `json:"logId"` - PartsCount uint64 `json:"partsCount,omitempty"` - Part uint64 `json:"part,omitempty"` - Content []byte `json:"content,omitempty"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` -} - -// UnitStatus unit status structure. -type UnitStatus struct { - UnitConfig []UnitConfigStatus `json:"unitConfig"` - Services []ServiceStatus `json:"services"` - Layers []LayerStatus `json:"layers,omitempty"` - Components []ComponentStatus `json:"components"` - Instances []InstanceStatus `json:"instances"` - UnitSubjects []string `json:"unitSubjects"` - Nodes []NodeInfo `json:"nodes"` -} - -// PartitionInfo partition information. -type PartitionInfo struct { - Name string `json:"name"` - Types []string `json:"types"` - TotalSize uint64 `json:"totalSize"` -} - -// SystemInfo system information. -type SystemInfo struct { - NumCPUs uint64 `json:"numCpus"` - TotalRAM uint64 `json:"totalRam"` - Partitions []PartitionInfo `json:"partitions"` -} - -// NodeInfo node information. -type NodeInfo struct { - NodeID string `json:"nodeId"` - NodeType string `json:"nodeType"` - SystemInfo -} - // ErrorInfo error information. type ErrorInfo struct { AosCode int `json:"aosCode"` @@ -456,242 +54,9 @@ type ErrorInfo struct { Message string `json:"message,omitempty"` } -// InstanceStatus service instance runtime status. -type InstanceStatus struct { - aostypes.InstanceIdent - AosVersion uint64 `json:"aosVersion"` - StateChecksum string `json:"stateChecksum,omitempty"` - RunState string `json:"runState"` - NodeID string `json:"nodeId"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` -} - -// UnitConfigStatus unit config status. -type UnitConfigStatus struct { - VendorVersion string `json:"vendorVersion"` - Status string `json:"status"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` -} - -// ServiceStatus service status. -type ServiceStatus struct { - ID string `json:"id"` - AosVersion uint64 `json:"aosVersion"` - Status string `json:"status"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` -} - -// LayerStatus layer status. -type LayerStatus struct { - ID string `json:"id"` - AosVersion uint64 `json:"aosVersion"` - Digest string `json:"digest"` - Status string `json:"status"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` -} - -// ComponentStatus component status. -type ComponentStatus struct { - ID string `json:"id"` - AosVersion uint64 `json:"aosVersion"` - VendorVersion string `json:"vendorVersion"` - Status string `json:"status"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` -} - -// ServiceInfo decrypted service info. -type ServiceInfo struct { - aostypes.VersionInfo - ID string `json:"id"` - ProviderID string `json:"providerId"` - DecryptDataStruct -} - -// LayerInfo decrypted layer info. -type LayerInfo struct { - aostypes.VersionInfo - ID string `json:"id"` - Digest string `json:"digest"` - DecryptDataStruct -} - -// ComponentInfo decrypted component info. -type ComponentInfo struct { - aostypes.VersionInfo - ID string `json:"id"` - Annotations json.RawMessage `json:"annotations,omitempty"` - DecryptDataStruct -} - -// InstanceInfo decrypted desired instance runtime info. -type InstanceInfo struct { - ServiceID string `json:"serviceId"` - SubjectID string `json:"subjectId"` - Priority uint64 `json:"priority"` - NumInstances uint64 `json:"numInstances"` - Labels []string `json:"labels"` -} - -// TimeSlot time slot with start and finish time. -type TimeSlot struct { - Start aostypes.Time `json:"start"` - Finish aostypes.Time `json:"finish"` -} - -// TimetableEntry entry for update timetable. -type TimetableEntry struct { - DayOfWeek uint `json:"dayOfWeek"` - TimeSlots []TimeSlot `json:"timeSlots"` -} - -// ScheduleRule rule for performing schedule update. -type ScheduleRule struct { - TTL uint64 `json:"ttl"` - Type string `json:"type"` - Timetable []TimetableEntry `json:"timetable"` -} - -// DesiredStatus desired status. -type DesiredStatus struct { - UnitConfig json.RawMessage `json:"unitConfig"` - Components []ComponentInfo `json:"components"` - Layers []LayerInfo `json:"layers"` - Services []ServiceInfo `json:"services"` - Instances []InstanceInfo `json:"instances"` - FOTASchedule ScheduleRule `json:"fotaSchedule"` - SOTASchedule ScheduleRule `json:"sotaSchedule"` - CertificateChains []CertificateChain `json:"certificateChains,omitempty"` - Certificates []Certificate `json:"certificates,omitempty"` -} - -// RenewCertData renew certificate data. -type RenewCertData struct { - Type string `json:"type"` - NodeID string `json:"nodeId,omitempty"` - Serial string `json:"serial"` - ValidTill time.Time `json:"validTill"` -} - -// RenewCertsNotification renew certificate notification from cloud with pwd. -type RenewCertsNotification struct { - Certificates []RenewCertData `json:"certificates"` - UnitSecret UnitSecret `json:"unitSecret"` -} - -// IssueCertData issue certificate data. -type IssueCertData struct { - Type string `json:"type"` - NodeID string `json:"nodeId,omitempty"` - Csr string `json:"csr"` -} - -// IssueUnitCerts issue unit certificates request. -type IssueUnitCerts struct { - Requests []IssueCertData `json:"requests"` -} - -// IssuedCertData issued unit certificate data. -type IssuedCertData struct { - Type string `json:"type"` - NodeID string `json:"nodeId,omitempty"` - CertificateChain string `json:"certificateChain"` -} - -// IssuedUnitCerts issued unit certificates info. -type IssuedUnitCerts struct { - Certificates []IssuedCertData `json:"certificates"` -} - -// InstallCertData install certificate data. -type InstallCertData struct { - Type string `json:"type"` - NodeID string `json:"nodeId,omitempty"` - Serial string `json:"serial"` - Status string `json:"status"` - Description string `json:"description,omitempty"` -} - -// InstallUnitCertsConfirmation install unit certificates confirmation. -type InstallUnitCertsConfirmation struct { - Certificates []InstallCertData `json:"certificates"` -} - -// OverrideEnvVars request to override service environment variables. -type OverrideEnvVars struct { - OverrideEnvVars []EnvVarsInstanceInfo `json:"overrideEnvVars"` -} - -// EnvVarsInstanceInfo struct with envs and related service and user. -type EnvVarsInstanceInfo struct { - InstanceFilter - EnvVars []EnvVarInfo `json:"envVars"` -} - -// EnvVarInfo env info with id and time to live. -type EnvVarInfo struct { - ID string `json:"id"` - Variable string `json:"variable"` - TTL *time.Time `json:"ttl"` -} - -// OverrideEnvVarsStatus override env status. -type OverrideEnvVarsStatus struct { - OverrideEnvVarsStatus []EnvVarsInstanceStatus `json:"overrideEnvVarsStatus"` -} - -// EnvVarsInstanceStatus struct with envs status and related service and user. -type EnvVarsInstanceStatus struct { - InstanceFilter - Statuses []EnvVarStatus `json:"statuses"` -} - -// EnvVarStatus env status with error message. -type EnvVarStatus struct { - ID string `json:"id"` - Error string `json:"error,omitempty"` -} - -// UnitSecret keeps unit secret used to decode secure device password. -type UnitSecret struct { - Version int `json:"version"` - Data struct { - OwnerPassword string `json:"ownerPassword"` - } `json:"data"` -} - -/*********************************************************************************************************************** - * Public - **********************************************************************************************************************/ - -func (service ServiceInfo) String() string { - return fmt.Sprintf("{id: %s, vendorVersion: %s aosVersion: %d, description: %s}", - service.ID, service.VendorVersion, service.AosVersion, service.Description) -} - -func (layer LayerInfo) String() string { - return fmt.Sprintf("{id: %s, digest: %s, vendorVersion: %s aosVersion: %d, description: %s}", - layer.ID, layer.Digest, layer.VendorVersion, layer.AosVersion, layer.Description) -} - -func (component ComponentInfo) String() string { - return fmt.Sprintf("{id: %s, annotations: %s, vendorVersion: %s aosVersion: %d, description: %s}", - component.ID, component.Annotations, component.VendorVersion, component.AosVersion, component.Description) -} - -func NewInstanceFilter(serviceID, subjectID string, instance int64) (filter InstanceFilter) { - if serviceID != "" { - filter.ServiceID = &serviceID - } - - if subjectID != "" { - filter.SubjectID = &subjectID - } - - if instance != -1 { - localInstance := (uint64)(instance) - - filter.Instance = &localInstance - } - - return filter +// InstanceFilter instance filter structure. +type InstanceFilter struct { + ServiceID *string `json:"serviceId,omitempty"` + SubjectID *string `json:"subjectId,omitempty"` + Instance *uint64 `json:"instance,omitempty"` } diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go new file mode 100644 index 00000000..a8bbbdb8 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go @@ -0,0 +1,224 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import ( + "encoding/json" + "fmt" + + "github.com/aosedge/aos_common/aostypes" +) + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// DesiredStatusMessageType desired status message type. +const DesiredStatusMessageType = "desiredStatus" + +// SOTA/FOTA schedule type. +const ( + ForceUpdate = "force" + TriggerUpdate = "trigger" + TimetableUpdate = "timetable" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// FileSystemMount specifies a mount instructions. +type FileSystemMount struct { + Destination string `json:"destination"` + Type string `json:"type,omitempty"` + Source string `json:"source,omitempty"` + Options []string `json:"options,omitempty"` +} + +// HostInfo struct represents entry in /etc/hosts. +type HostInfo struct { + IP string `json:"ip"` + Hostname string `json:"hostname"` +} + +// DeviceInfo device information. +type DeviceInfo struct { + Name string `json:"name"` + SharedCount int `json:"sharedCount,omitempty"` + Groups []string `json:"groups,omitempty"` + HostDevices []string `json:"hostDevices"` +} + +// ResourceInfo resource information. +type ResourceInfo struct { + Name string `json:"name"` + Groups []string `json:"groups,omitempty"` + Mounts []FileSystemMount `json:"mounts,omitempty"` + Env []string `json:"env,omitempty"` + Hosts []HostInfo `json:"hosts,omitempty"` +} + +// NodeConfig node configuration. +type NodeConfig struct { + NodeID *string `json:"nodeId,omitempty"` + NodeType string `json:"nodeType"` + ResourceRatios *aostypes.ResourceRatiosInfo `json:"resourceRatios,omitempty"` + AlertRules *aostypes.AlertRules `json:"alertRules,omitempty"` + Devices []DeviceInfo `json:"devices,omitempty"` + Resources []ResourceInfo `json:"resources,omitempty"` + Labels []string `json:"labels,omitempty"` + Priority uint32 `json:"priority,omitempty"` +} + +// UnitConfig unit configuration. +type UnitConfig struct { + FormatVersion string `json:"formatVersion"` + Version string `json:"version"` + Nodes []NodeConfig `json:"nodes"` +} + +// DecryptionInfo update decryption info. +type DecryptionInfo struct { + BlockAlg string `json:"blockAlg"` + BlockIv []byte `json:"blockIv"` + BlockKey []byte `json:"blockKey"` + AsymAlg string `json:"asymAlg"` + ReceiverInfo *struct { + Serial string `json:"serial"` + Issuer []byte `json:"issuer"` + } `json:"receiverInfo"` +} + +// DownloadInfo struct contains how to download item. +type DownloadInfo struct { + URLs []string `json:"urls"` + Sha256 []byte `json:"sha256"` + Size uint64 `json:"size"` +} + +// NodeStatus node status. +type NodeStatus struct { + NodeID string `json:"nodeId"` + Status string `json:"status"` +} + +// ServiceInfo decrypted service info. +type ServiceInfo struct { + ServiceID string `json:"id"` + ProviderID string `json:"providerId"` + Version string `json:"version"` + DownloadInfo + DecryptionInfo DecryptionInfo `json:"decryptionInfo"` +} + +// LayerInfo decrypted layer info. +type LayerInfo struct { + LayerID string `json:"id"` + Digest string `json:"digest"` + Version string `json:"version"` + DownloadInfo + DecryptionInfo DecryptionInfo `json:"decryptionInfo"` +} + +// ComponentInfo decrypted component info. +type ComponentInfo struct { + ComponentID *string `json:"id,omitempty"` + ComponentType string `json:"type"` + Version string `json:"version"` + Annotations json.RawMessage `json:"annotations,omitempty"` + DownloadInfo + DecryptionInfo DecryptionInfo `json:"decryptionInfo"` +} + +// InstanceInfo decrypted desired instance runtime info. +type InstanceInfo struct { + ServiceID string `json:"serviceId"` + SubjectID string `json:"subjectId"` + Priority uint64 `json:"priority"` + NumInstances uint64 `json:"numInstances"` + Labels []string `json:"labels"` +} + +// Certificate certificate structure. +type Certificate struct { + Certificate []byte `json:"certificate"` + Fingerprint string `json:"fingerprint"` +} + +// CertificateChain certificate chain. +type CertificateChain struct { + Name string `json:"name"` + Fingerprints []string `json:"fingerprints"` +} + +// TimeSlot time slot with start and finish time. +type TimeSlot struct { + Start aostypes.Time `json:"start"` + Finish aostypes.Time `json:"finish"` +} + +// TimetableEntry entry for update timetable. +type TimetableEntry struct { + DayOfWeek uint `json:"dayOfWeek"` + TimeSlots []TimeSlot `json:"timeSlots"` +} + +// ScheduleRule rule for performing schedule update. +type ScheduleRule struct { + TTL uint64 `json:"ttl"` + Type string `json:"type"` + Timetable []TimetableEntry `json:"timetable"` +} + +// DesiredStatus desired status. +type DesiredStatus struct { + MessageType string `json:"messageType"` + UnitConfig *UnitConfig `json:"unitConfig,omitempty"` + Nodes []NodeStatus `json:"nodes"` + Components []ComponentInfo `json:"components"` + Layers []LayerInfo `json:"layers"` + Services []ServiceInfo `json:"services"` + Instances []InstanceInfo `json:"instances"` + FOTASchedule ScheduleRule `json:"fotaSchedule"` + SOTASchedule ScheduleRule `json:"sotaSchedule"` + Certificates []Certificate `json:"certificates,omitempty"` + CertificateChains []CertificateChain `json:"certificateChains,omitempty"` +} + +/*********************************************************************************************************************** + * Public + **********************************************************************************************************************/ + +func (service ServiceInfo) String() string { + return fmt.Sprintf("{id: %s, version: %s}", service.ServiceID, service.Version) +} + +func (layer LayerInfo) String() string { + return fmt.Sprintf("{id: %s, digest: %s, version: %s}", layer.LayerID, layer.Digest, layer.Version) +} + +func (component ComponentInfo) String() string { + id := "none" + + if component.ComponentID != nil { + id = *component.ComponentID + } + + return fmt.Sprintf("{id: %s, type: %s, annotations: %s, version: %s}", + id, component.ComponentType, component.Annotations, component.Version) +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go new file mode 100644 index 00000000..fa156482 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import "time" + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// EnvVars message types. +const ( + OverrideEnvVarsMessageType = "overrideEnvVars" + OverrideEnvVarsStatusMessageType = "overrideEnvVarsStatus" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// EnvVarsInstanceInfo struct with envs and related service and user. +type EnvVarsInstanceInfo struct { + InstanceFilter + EnvVars []EnvVarInfo `json:"envVars"` +} + +// EnvVarInfo env info with id and time to live. +type EnvVarInfo struct { + ID string `json:"id"` + Variable string `json:"variable"` + TTL *time.Time `json:"ttl"` +} + +// EnvVarsInstanceStatus struct with envs status and related service and user. +type EnvVarsInstanceStatus struct { + InstanceFilter + Statuses []EnvVarStatus `json:"statuses"` +} + +// EnvVarStatus env status with error message. +type EnvVarStatus struct { + ID string `json:"id"` + ErrorInfo *ErrorInfo `json:"error,omitempty"` +} + +// OverrideEnvVars request to override service environment variables. +type OverrideEnvVars struct { + MessageType string `json:"messageType"` + OverrideEnvVars []EnvVarsInstanceInfo `json:"overrideEnvVars"` +} + +// OverrideEnvVarsStatus override env status. +type OverrideEnvVarsStatus struct { + MessageType string `json:"messageType"` + OverrideEnvVarsStatus []EnvVarsInstanceStatus `json:"overrideEnvVarsStatus"` +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go new file mode 100644 index 00000000..c128880d --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import "time" + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// Log message types. +const ( + RequestLogMessageType = "requestLog" + PushLogMessageType = "pushLog" +) + +// Log types. +const ( + SystemLog = "systemLog" + ServiceLog = "serviceLog" + CrashLog = "crashLog" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// LogFilter request log message. +type LogFilter struct { + From *time.Time `json:"from"` + Till *time.Time `json:"till"` + NodeIDs []string `json:"nodeIds,omitempty"` + InstanceFilter +} + +// RequestLog request log message. +type RequestLog struct { + MessageType string `json:"messageType"` + LogID string `json:"logId"` + LogType string `json:"logType"` + Filter LogFilter `json:"filter"` +} + +// PushLog push service log structure. +type PushLog struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + LogID string `json:"logId"` + PartsCount uint64 `json:"partsCount,omitempty"` + Part uint64 `json:"part,omitempty"` + Content []byte `json:"content,omitempty"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +/*********************************************************************************************************************** + * Public + **********************************************************************************************************************/ + +func NewInstanceFilter(serviceID, subjectID string, instance int64) (filter InstanceFilter) { + if serviceID != "" { + filter.ServiceID = &serviceID + } + + if subjectID != "" { + filter.SubjectID = &subjectID + } + + if instance != -1 { + localInstance := (uint64)(instance) + + filter.Instance = &localInstance + } + + return filter +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go new file mode 100644 index 00000000..87cee354 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import ( + "time" + + "github.com/aosedge/aos_common/aostypes" +) + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// MonitoringMessageType monitoring message type. +const MonitoringMessageType = "monitoringData" + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// PartitionUsage partition usage information. +type PartitionUsage struct { + Name string `json:"name"` + UsedSize uint64 `json:"usedSize"` +} + +// MonitoringData monitoring data. +type MonitoringData struct { + RAM uint64 `json:"ram"` + CPU uint64 `json:"cpu"` + InTraffic uint64 `json:"inTraffic"` + OutTraffic uint64 `json:"outTraffic"` + Disk []PartitionUsage `json:"disk"` +} + +// NodeMonitoringData node monitoring data. +type NodeMonitoringData struct { + MonitoringData + NodeID string `json:"nodeId"` + Timestamp time.Time `json:"timestamp"` + ServiceInstances []InstanceMonitoringData `json:"serviceInstances"` +} + +// InstanceMonitoringData monitoring data for service. +type InstanceMonitoringData struct { + aostypes.InstanceIdent + NodeID string `json:"nodeId"` + MonitoringData +} + +// Monitoring monitoring message structure. +type Monitoring struct { + MessageType string `json:"messageType"` + Nodes []NodeMonitoringData `json:"nodes"` + ServiceInstances []InstanceMonitoringData `json:"serviceInstances"` +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/servicediscovery.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/servicediscovery.go new file mode 100644 index 00000000..ab5fc041 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/servicediscovery.go @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// ServiceDiscoveryType service discovery message type. +const ServiceDiscoveryType = "serviceDiscovery" + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// ServiceDiscoveryRequest service discovery request. +type ServiceDiscoveryRequest struct{} + +// ServiceDiscoveryResponse service discovery response. +type ServiceDiscoveryResponse struct { + Version uint64 `json:"version"` + Connection ConnectionInfo `json:"connection"` +} + +// ConnectionInfo AMQP connection info. +type ConnectionInfo struct { + SendParams SendParams `json:"sendParams"` + ReceiveParams ReceiveParams `json:"receiveParams"` +} + +// SendParams AMQP send parameters. +type SendParams struct { + Host string `json:"host"` + User string `json:"user"` + Password string `json:"password"` + Mandatory bool `json:"mandatory"` + Immediate bool `json:"immediate"` + Exchange ExchangeParams `json:"exchange"` +} + +// ExchangeParams AMQP exchange parameters. +type ExchangeParams struct { + Name string `json:"name"` + Durable bool `json:"durable"` + AutoDetect bool `json:"autoDetect"` + Internal bool `json:"internal"` + NoWait bool `json:"noWait"` +} + +// ReceiveParams AMQP receive parameters. +type ReceiveParams struct { + Host string `json:"host"` + User string `json:"user"` + Password string `json:"password"` + Consumer string `json:"consumer"` + AutoAck bool `json:"autoAck"` + Exclusive bool `json:"exclusive"` + NoLocal bool `json:"noLocal"` + NoWait bool `json:"noWait"` + Queue QueueInfo `json:"queue"` +} + +// QueueInfo AMQP queue info. +type QueueInfo struct { + Name string `json:"name"` + Durable bool `json:"durable"` + DeleteWhenUnused bool `json:"deleteWhenUnused"` + Exclusive bool `json:"exclusive"` + NoWait bool `json:"noWait"` +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/state.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/state.go new file mode 100644 index 00000000..a86adfaf --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/state.go @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import "github.com/aosedge/aos_common/aostypes" + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// State message types. +const ( + StateAcceptanceMessageType = "stateAcceptance" + UpdateStateMessageType = "updateState" + NewStateMessageType = "newState" + StateRequestMessageType = "stateRequest" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// StateAcceptance state acceptance message. +type StateAcceptance struct { + MessageType string `json:"messageType"` + aostypes.InstanceIdent + Checksum string `json:"checksum"` + Result string `json:"result"` + Reason string `json:"reason"` +} + +// UpdateState state update message. +type UpdateState struct { + MessageType string `json:"messageType"` + aostypes.InstanceIdent + Checksum string `json:"stateChecksum"` + State string `json:"state"` +} + +// NewState new state structure. +type NewState struct { + MessageType string `json:"messageType"` + aostypes.InstanceIdent + Checksum string `json:"stateChecksum"` + State string `json:"state"` +} + +// StateRequest state request structure. +type StateRequest struct { + MessageType string `json:"messageType"` + aostypes.InstanceIdent + Default bool `json:"default"` +} diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go new file mode 100644 index 00000000..ad066770 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2021 Renesas Electronics Corporation. +// Copyright (C) 2021 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +import ( + "strings" + + "github.com/aosedge/aos_common/aoserrors" + "github.com/aosedge/aos_common/aostypes" +) + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// UnitStatusMessageType unit status message type. +const UnitStatusMessageType = "unitStatus" + +// Instance statuses. +const ( + InstanceStateActivating = "activating" + InstanceStateActive = "active" + InstanceStateInactive = "inactive" + InstanceStateFailed = "failed" +) + +// Service/layers/components statuses. +const ( + UnknownStatus = "unknown" + PendingStatus = "pending" + DownloadingStatus = "downloading" + DownloadedStatus = "downloaded" + InstallingStatus = "installing" + InstalledStatus = "installed" + RemovingStatus = "removing" + RemovedStatus = "removed" + ErrorStatus = "error" +) + +// Partition types. +const ( + GenericPartition = "generic" + StoragesPartition = "storages" + StatesPartition = "states" + ServicesPartition = "services" + LayersPartition = "layers" +) + +// Node statuses. +const ( + NodeStatusUnprovisioned = "unprovisioned" + NodeStatusProvisioned = "provisioned" + NodeStatusPaused = "paused" + NodeStatusError = "error" +) + +// Node attribute names. +const ( + NodeAttrMainNode = "MainNode" + NodeAttrAosComponents = "AosComponents" + NodeAttrRunners = "NodeRunners" +) + +// Node attribute values. +const ( + AosComponentCM = "cm" + AosComponentIAM = "iam" + AosComponentSM = "sm" + AosComponentUM = "um" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// UnitConfigStatus unit config status. +type UnitConfigStatus struct { + Version string `json:"version"` + Status string `json:"status"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// CPUInfo cpu information. +type CPUInfo struct { + ModelName string `json:"modelName"` + NumCores uint64 `json:"totalNumCores"` + NumThreads uint64 `json:"totalNumThreads"` + Arch string `json:"arch"` + ArchFamily string `json:"archFamily"` + MaxDMIPs uint64 `json:"maxDmips"` +} + +// PartitionInfo partition information. +type PartitionInfo struct { + Name string `json:"name"` + Types []string `json:"types"` + TotalSize uint64 `json:"totalSize"` + Path string `json:"-"` +} + +// NodeInfo node information. +type NodeInfo struct { + NodeID string `json:"nodeId"` + NodeType string `json:"nodeType"` + Name string `json:"name"` + Status string `json:"status"` + CPUs []CPUInfo `json:"cpus"` + OSType string `json:"osType"` + MaxDMIPs uint64 `json:"maxDmips"` + TotalRAM uint64 `json:"totalRam"` + Attrs map[string]interface{} `json:"attrs,omitempty"` + Partitions []PartitionInfo `json:"partitions,omitempty"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// ServiceStatus service status. +type ServiceStatus struct { + ServiceID string `json:"serviceId"` + Version string `json:"version"` + Status string `json:"status"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// InstanceStatus service instance runtime status. +type InstanceStatus struct { + aostypes.InstanceIdent + ServiceVersion string `json:"version"` + StateChecksum string `json:"stateChecksum,omitempty"` + RunState string `json:"runState"` + NodeID string `json:"nodeId"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// LayerStatus layer status. +type LayerStatus struct { + LayerID string `json:"layerId"` + Digest string `json:"digest"` + Version string `json:"version"` + Status string `json:"status"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// ComponentStatus component status. +type ComponentStatus struct { + ComponentID string `json:"componentId"` + ComponentType string `json:"componentType"` + Version string `json:"version"` + Status string `json:"status"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// UnitStatus unit status structure. +type UnitStatus struct { + MessageType string `json:"messageType"` + IsDeltaInfo bool `json:"isDeltaInfo"` + UnitConfig []UnitConfigStatus `json:"unitConfig"` + Nodes []NodeInfo `json:"nodes"` + Services []ServiceStatus `json:"services"` + Instances []InstanceStatus `json:"instances"` + Layers []LayerStatus `json:"layers,omitempty"` + Components []ComponentStatus `json:"components"` + UnitSubjects []string `json:"unitSubjects"` +} + +/*********************************************************************************************************************** + * Public + **********************************************************************************************************************/ + +func (nodeInfo *NodeInfo) IsMainNode() bool { + _, ok := nodeInfo.Attrs[NodeAttrMainNode] + + return ok +} + +func (nodeInfo *NodeInfo) GetAosComponents() ([]string, error) { + return nodeInfo.attrToStringSlice(NodeAttrAosComponents) +} + +func (nodeInfo *NodeInfo) GetNodeRunners() ([]string, error) { + return nodeInfo.attrToStringSlice(NodeAttrRunners) +} + +/*********************************************************************************************************************** + * Private + **********************************************************************************************************************/ + +func (nodeInfo *NodeInfo) attrToStringSlice(attrName string) ([]string, error) { + attrValue, ok := nodeInfo.Attrs[attrName] + if !ok { + return nil, aoserrors.Errorf("attribute %s not found", attrName) + } + + attrString, ok := attrValue.(string) + if !ok { + return nil, aoserrors.New("invalid attribute type") + } + + values := strings.Split(attrString, ",") + + for i := range values { + values[i] = strings.TrimSpace(values[i]) + } + + return values, nil +} diff --git a/vendor/github.com/aosedge/aos_common/api/common/common.pb.go b/vendor/github.com/aosedge/aos_common/api/common/common.pb.go new file mode 100644 index 00000000..b518971c --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/common/common.pb.go @@ -0,0 +1,244 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.26.0 +// source: common/v1/common.proto + +package common + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ErrorInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AosCode int32 `protobuf:"varint,1,opt,name=aos_code,json=aosCode,proto3" json:"aos_code,omitempty"` + ExitCode int32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *ErrorInfo) Reset() { + *x = ErrorInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_common_v1_common_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ErrorInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ErrorInfo) ProtoMessage() {} + +func (x *ErrorInfo) ProtoReflect() protoreflect.Message { + mi := &file_common_v1_common_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ErrorInfo.ProtoReflect.Descriptor instead. +func (*ErrorInfo) Descriptor() ([]byte, []int) { + return file_common_v1_common_proto_rawDescGZIP(), []int{0} +} + +func (x *ErrorInfo) GetAosCode() int32 { + if x != nil { + return x.AosCode + } + return 0 +} + +func (x *ErrorInfo) GetExitCode() int32 { + if x != nil { + return x.ExitCode + } + return 0 +} + +func (x *ErrorInfo) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type InstanceIdent struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + SubjectId string `protobuf:"bytes,2,opt,name=subject_id,json=subjectId,proto3" json:"subject_id,omitempty"` + Instance uint64 `protobuf:"varint,3,opt,name=instance,proto3" json:"instance,omitempty"` +} + +func (x *InstanceIdent) Reset() { + *x = InstanceIdent{} + if protoimpl.UnsafeEnabled { + mi := &file_common_v1_common_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InstanceIdent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InstanceIdent) ProtoMessage() {} + +func (x *InstanceIdent) ProtoReflect() protoreflect.Message { + mi := &file_common_v1_common_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InstanceIdent.ProtoReflect.Descriptor instead. +func (*InstanceIdent) Descriptor() ([]byte, []int) { + return file_common_v1_common_proto_rawDescGZIP(), []int{1} +} + +func (x *InstanceIdent) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *InstanceIdent) GetSubjectId() string { + if x != nil { + return x.SubjectId + } + return "" +} + +func (x *InstanceIdent) GetInstance() uint64 { + if x != nil { + return x.Instance + } + return 0 +} + +var File_common_v1_common_proto protoreflect.FileDescriptor + +var file_common_v1_common_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x22, 0x5d, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x19, 0x0a, 0x08, 0x61, 0x6f, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x07, 0x61, 0x6f, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, + 0x78, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, + 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x22, 0x69, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, + 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_common_v1_common_proto_rawDescOnce sync.Once + file_common_v1_common_proto_rawDescData = file_common_v1_common_proto_rawDesc +) + +func file_common_v1_common_proto_rawDescGZIP() []byte { + file_common_v1_common_proto_rawDescOnce.Do(func() { + file_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_common_v1_common_proto_rawDescData) + }) + return file_common_v1_common_proto_rawDescData +} + +var file_common_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_common_v1_common_proto_goTypes = []interface{}{ + (*ErrorInfo)(nil), // 0: common.v1.ErrorInfo + (*InstanceIdent)(nil), // 1: common.v1.InstanceIdent +} +var file_common_v1_common_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_common_v1_common_proto_init() } +func file_common_v1_common_proto_init() { + if File_common_v1_common_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_common_v1_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ErrorInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_common_v1_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InstanceIdent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_common_v1_common_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_common_v1_common_proto_goTypes, + DependencyIndexes: file_common_v1_common_proto_depIdxs, + MessageInfos: file_common_v1_common_proto_msgTypes, + }.Build() + File_common_v1_common_proto = out.File + file_common_v1_common_proto_rawDesc = nil + file_common_v1_common_proto_goTypes = nil + file_common_v1_common_proto_depIdxs = nil +} diff --git a/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go b/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go new file mode 100644 index 00000000..c62071fa --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go @@ -0,0 +1,834 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.26.0 +// source: communicationmanager/v3/updatescheduler.proto + +package communicationmanager + +import ( + common "github.com/aosedge/aos_common/api/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdateState int32 + +const ( + UpdateState_NO_UPDATE UpdateState = 0 + UpdateState_DOWNLOADING UpdateState = 1 + UpdateState_READY_TO_UPDATE UpdateState = 2 + UpdateState_UPDATING UpdateState = 3 +) + +// Enum value maps for UpdateState. +var ( + UpdateState_name = map[int32]string{ + 0: "NO_UPDATE", + 1: "DOWNLOADING", + 2: "READY_TO_UPDATE", + 3: "UPDATING", + } + UpdateState_value = map[string]int32{ + "NO_UPDATE": 0, + "DOWNLOADING": 1, + "READY_TO_UPDATE": 2, + "UPDATING": 3, + } +) + +func (x UpdateState) Enum() *UpdateState { + p := new(UpdateState) + *p = x + return p +} + +func (x UpdateState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (UpdateState) Descriptor() protoreflect.EnumDescriptor { + return file_communicationmanager_v3_updatescheduler_proto_enumTypes[0].Descriptor() +} + +func (UpdateState) Type() protoreflect.EnumType { + return &file_communicationmanager_v3_updatescheduler_proto_enumTypes[0] +} + +func (x UpdateState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use UpdateState.Descriptor instead. +func (UpdateState) EnumDescriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{0} +} + +type SchedulerNotifications struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to SchedulerNotification: + // + // *SchedulerNotifications_SotaStatus + // *SchedulerNotifications_FotaStatus + SchedulerNotification isSchedulerNotifications_SchedulerNotification `protobuf_oneof:"SchedulerNotification"` +} + +func (x *SchedulerNotifications) Reset() { + *x = SchedulerNotifications{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SchedulerNotifications) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchedulerNotifications) ProtoMessage() {} + +func (x *SchedulerNotifications) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SchedulerNotifications.ProtoReflect.Descriptor instead. +func (*SchedulerNotifications) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{0} +} + +func (m *SchedulerNotifications) GetSchedulerNotification() isSchedulerNotifications_SchedulerNotification { + if m != nil { + return m.SchedulerNotification + } + return nil +} + +func (x *SchedulerNotifications) GetSotaStatus() *UpdateSOTAStatus { + if x, ok := x.GetSchedulerNotification().(*SchedulerNotifications_SotaStatus); ok { + return x.SotaStatus + } + return nil +} + +func (x *SchedulerNotifications) GetFotaStatus() *UpdateFOTAStatus { + if x, ok := x.GetSchedulerNotification().(*SchedulerNotifications_FotaStatus); ok { + return x.FotaStatus + } + return nil +} + +type isSchedulerNotifications_SchedulerNotification interface { + isSchedulerNotifications_SchedulerNotification() +} + +type SchedulerNotifications_SotaStatus struct { + SotaStatus *UpdateSOTAStatus `protobuf:"bytes,1,opt,name=sota_status,json=sotaStatus,proto3,oneof"` +} + +type SchedulerNotifications_FotaStatus struct { + FotaStatus *UpdateFOTAStatus `protobuf:"bytes,2,opt,name=fota_status,json=fotaStatus,proto3,oneof"` +} + +func (*SchedulerNotifications_SotaStatus) isSchedulerNotifications_SchedulerNotification() {} + +func (*SchedulerNotifications_FotaStatus) isSchedulerNotifications_SchedulerNotification() {} + +type UpdateFOTAStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + State UpdateState `protobuf:"varint,1,opt,name=state,proto3,enum=communicationmanager.v3.UpdateState" json:"state,omitempty"` + Components []*ComponentInfo `protobuf:"bytes,2,rep,name=components,proto3" json:"components,omitempty"` + UnitConfig *UnitConfigInfo `protobuf:"bytes,3,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *UpdateFOTAStatus) Reset() { + *x = UpdateFOTAStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateFOTAStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateFOTAStatus) ProtoMessage() {} + +func (x *UpdateFOTAStatus) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateFOTAStatus.ProtoReflect.Descriptor instead. +func (*UpdateFOTAStatus) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{1} +} + +func (x *UpdateFOTAStatus) GetState() UpdateState { + if x != nil { + return x.State + } + return UpdateState_NO_UPDATE +} + +func (x *UpdateFOTAStatus) GetComponents() []*ComponentInfo { + if x != nil { + return x.Components + } + return nil +} + +func (x *UpdateFOTAStatus) GetUnitConfig() *UnitConfigInfo { + if x != nil { + return x.UnitConfig + } + return nil +} + +func (x *UpdateFOTAStatus) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type UpdateSOTAStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + State UpdateState `protobuf:"varint,1,opt,name=state,proto3,enum=communicationmanager.v3.UpdateState" json:"state,omitempty"` + InstallServices []*ServiceInfo `protobuf:"bytes,2,rep,name=install_services,json=installServices,proto3" json:"install_services,omitempty"` + RemoveServices []*ServiceInfo `protobuf:"bytes,3,rep,name=remove_services,json=removeServices,proto3" json:"remove_services,omitempty"` + InstallLayers []*LayerInfo `protobuf:"bytes,4,rep,name=install_layers,json=installLayers,proto3" json:"install_layers,omitempty"` + RemoveLayers []*LayerInfo `protobuf:"bytes,5,rep,name=remove_layers,json=removeLayers,proto3" json:"remove_layers,omitempty"` + RebalanceRequest bool `protobuf:"varint,6,opt,name=rebalance_request,json=rebalanceRequest,proto3" json:"rebalance_request,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,7,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *UpdateSOTAStatus) Reset() { + *x = UpdateSOTAStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateSOTAStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateSOTAStatus) ProtoMessage() {} + +func (x *UpdateSOTAStatus) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateSOTAStatus.ProtoReflect.Descriptor instead. +func (*UpdateSOTAStatus) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdateSOTAStatus) GetState() UpdateState { + if x != nil { + return x.State + } + return UpdateState_NO_UPDATE +} + +func (x *UpdateSOTAStatus) GetInstallServices() []*ServiceInfo { + if x != nil { + return x.InstallServices + } + return nil +} + +func (x *UpdateSOTAStatus) GetRemoveServices() []*ServiceInfo { + if x != nil { + return x.RemoveServices + } + return nil +} + +func (x *UpdateSOTAStatus) GetInstallLayers() []*LayerInfo { + if x != nil { + return x.InstallLayers + } + return nil +} + +func (x *UpdateSOTAStatus) GetRemoveLayers() []*LayerInfo { + if x != nil { + return x.RemoveLayers + } + return nil +} + +func (x *UpdateSOTAStatus) GetRebalanceRequest() bool { + if x != nil { + return x.RebalanceRequest + } + return false +} + +func (x *UpdateSOTAStatus) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type ComponentInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ComponentId string `protobuf:"bytes,1,opt,name=component_id,json=componentId,proto3" json:"component_id,omitempty"` + ComponentType string `protobuf:"bytes,2,opt,name=component_type,json=componentType,proto3" json:"component_type,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *ComponentInfo) Reset() { + *x = ComponentInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComponentInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComponentInfo) ProtoMessage() {} + +func (x *ComponentInfo) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ComponentInfo.ProtoReflect.Descriptor instead. +func (*ComponentInfo) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{3} +} + +func (x *ComponentInfo) GetComponentId() string { + if x != nil { + return x.ComponentId + } + return "" +} + +func (x *ComponentInfo) GetComponentType() string { + if x != nil { + return x.ComponentType + } + return "" +} + +func (x *ComponentInfo) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +type UnitConfigInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *UnitConfigInfo) Reset() { + *x = UnitConfigInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UnitConfigInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnitConfigInfo) ProtoMessage() {} + +func (x *UnitConfigInfo) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnitConfigInfo.ProtoReflect.Descriptor instead. +func (*UnitConfigInfo) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{4} +} + +func (x *UnitConfigInfo) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +type ServiceInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *ServiceInfo) Reset() { + *x = ServiceInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServiceInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceInfo) ProtoMessage() {} + +func (x *ServiceInfo) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServiceInfo.ProtoReflect.Descriptor instead. +func (*ServiceInfo) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{5} +} + +func (x *ServiceInfo) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *ServiceInfo) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +type LayerInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LayerId string `protobuf:"bytes,1,opt,name=layer_id,json=layerId,proto3" json:"layer_id,omitempty"` + Digest string `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` +} + +func (x *LayerInfo) Reset() { + *x = LayerInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LayerInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LayerInfo) ProtoMessage() {} + +func (x *LayerInfo) ProtoReflect() protoreflect.Message { + mi := &file_communicationmanager_v3_updatescheduler_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LayerInfo.ProtoReflect.Descriptor instead. +func (*LayerInfo) Descriptor() ([]byte, []int) { + return file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP(), []int{6} +} + +func (x *LayerInfo) GetLayerId() string { + if x != nil { + return x.LayerId + } + return "" +} + +func (x *LayerInfo) GetDigest() string { + if x != nil { + return x.Digest + } + return "" +} + +func (x *LayerInfo) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +var File_communicationmanager_v3_updatescheduler_proto protoreflect.FileDescriptor + +var file_communicationmanager_v3_updatescheduler_proto_rawDesc = []byte{ + 0x0a, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x76, 0x33, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x17, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x01, + 0x0a, 0x16, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4c, 0x0a, 0x0b, 0x73, 0x6f, 0x74, 0x61, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x4f, + 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x0a, 0x73, 0x6f, 0x74, 0x61, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4c, 0x0a, 0x0b, 0x66, 0x6f, 0x74, 0x61, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x4f, 0x54, 0x41, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x0a, 0x66, 0x6f, 0x74, 0x61, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x42, 0x17, 0x0a, 0x15, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, + 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x02, + 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x46, + 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6f, 0x6d, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x48, 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xdb, 0x03, 0x0a, + 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, 0x0a, + 0x10, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x4d, + 0x0a, 0x0f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0e, 0x72, + 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x49, 0x0a, + 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, + 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x47, 0x0a, 0x0d, 0x72, 0x65, 0x6d, 0x6f, + 0x76, 0x65, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x0c, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x79, 0x65, 0x72, + 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x72, 0x65, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x72, 0x65, + 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x73, 0x0a, 0x0d, 0x43, 0x6f, + 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x25, + 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x2a, 0x0a, 0x0e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x46, 0x0a, 0x0b, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x22, 0x58, 0x0a, 0x09, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x64, + 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, + 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x50, 0x0a, + 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0d, 0x0a, 0x09, + 0x4e, 0x4f, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x44, + 0x4f, 0x57, 0x4e, 0x4c, 0x4f, 0x41, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, + 0x52, 0x45, 0x41, 0x44, 0x59, 0x5f, 0x54, 0x4f, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, + 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x50, 0x44, 0x41, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x32, + 0x89, 0x02, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, + 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0f, 0x53, 0x74, + 0x61, 0x72, 0x74, 0x46, 0x4f, 0x54, 0x41, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, + 0x43, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x4f, 0x54, 0x41, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x16, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, + 0x65, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, + 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x00, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_communicationmanager_v3_updatescheduler_proto_rawDescOnce sync.Once + file_communicationmanager_v3_updatescheduler_proto_rawDescData = file_communicationmanager_v3_updatescheduler_proto_rawDesc +) + +func file_communicationmanager_v3_updatescheduler_proto_rawDescGZIP() []byte { + file_communicationmanager_v3_updatescheduler_proto_rawDescOnce.Do(func() { + file_communicationmanager_v3_updatescheduler_proto_rawDescData = protoimpl.X.CompressGZIP(file_communicationmanager_v3_updatescheduler_proto_rawDescData) + }) + return file_communicationmanager_v3_updatescheduler_proto_rawDescData +} + +var file_communicationmanager_v3_updatescheduler_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_communicationmanager_v3_updatescheduler_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_communicationmanager_v3_updatescheduler_proto_goTypes = []interface{}{ + (UpdateState)(0), // 0: communicationmanager.v3.UpdateState + (*SchedulerNotifications)(nil), // 1: communicationmanager.v3.SchedulerNotifications + (*UpdateFOTAStatus)(nil), // 2: communicationmanager.v3.UpdateFOTAStatus + (*UpdateSOTAStatus)(nil), // 3: communicationmanager.v3.UpdateSOTAStatus + (*ComponentInfo)(nil), // 4: communicationmanager.v3.ComponentInfo + (*UnitConfigInfo)(nil), // 5: communicationmanager.v3.UnitConfigInfo + (*ServiceInfo)(nil), // 6: communicationmanager.v3.ServiceInfo + (*LayerInfo)(nil), // 7: communicationmanager.v3.LayerInfo + (*common.ErrorInfo)(nil), // 8: common.v1.ErrorInfo + (*emptypb.Empty)(nil), // 9: google.protobuf.Empty +} +var file_communicationmanager_v3_updatescheduler_proto_depIdxs = []int32{ + 3, // 0: communicationmanager.v3.SchedulerNotifications.sota_status:type_name -> communicationmanager.v3.UpdateSOTAStatus + 2, // 1: communicationmanager.v3.SchedulerNotifications.fota_status:type_name -> communicationmanager.v3.UpdateFOTAStatus + 0, // 2: communicationmanager.v3.UpdateFOTAStatus.state:type_name -> communicationmanager.v3.UpdateState + 4, // 3: communicationmanager.v3.UpdateFOTAStatus.components:type_name -> communicationmanager.v3.ComponentInfo + 5, // 4: communicationmanager.v3.UpdateFOTAStatus.unit_config:type_name -> communicationmanager.v3.UnitConfigInfo + 8, // 5: communicationmanager.v3.UpdateFOTAStatus.error:type_name -> common.v1.ErrorInfo + 0, // 6: communicationmanager.v3.UpdateSOTAStatus.state:type_name -> communicationmanager.v3.UpdateState + 6, // 7: communicationmanager.v3.UpdateSOTAStatus.install_services:type_name -> communicationmanager.v3.ServiceInfo + 6, // 8: communicationmanager.v3.UpdateSOTAStatus.remove_services:type_name -> communicationmanager.v3.ServiceInfo + 7, // 9: communicationmanager.v3.UpdateSOTAStatus.install_layers:type_name -> communicationmanager.v3.LayerInfo + 7, // 10: communicationmanager.v3.UpdateSOTAStatus.remove_layers:type_name -> communicationmanager.v3.LayerInfo + 8, // 11: communicationmanager.v3.UpdateSOTAStatus.error:type_name -> common.v1.ErrorInfo + 9, // 12: communicationmanager.v3.UpdateSchedulerService.StartFOTAUpdate:input_type -> google.protobuf.Empty + 9, // 13: communicationmanager.v3.UpdateSchedulerService.StartSOTAUpdate:input_type -> google.protobuf.Empty + 9, // 14: communicationmanager.v3.UpdateSchedulerService.SubscribeNotifications:input_type -> google.protobuf.Empty + 9, // 15: communicationmanager.v3.UpdateSchedulerService.StartFOTAUpdate:output_type -> google.protobuf.Empty + 9, // 16: communicationmanager.v3.UpdateSchedulerService.StartSOTAUpdate:output_type -> google.protobuf.Empty + 1, // 17: communicationmanager.v3.UpdateSchedulerService.SubscribeNotifications:output_type -> communicationmanager.v3.SchedulerNotifications + 15, // [15:18] is the sub-list for method output_type + 12, // [12:15] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name +} + +func init() { file_communicationmanager_v3_updatescheduler_proto_init() } +func file_communicationmanager_v3_updatescheduler_proto_init() { + if File_communicationmanager_v3_updatescheduler_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_communicationmanager_v3_updatescheduler_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SchedulerNotifications); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateFOTAStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateSOTAStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComponentInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UnitConfigInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServiceInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LayerInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_communicationmanager_v3_updatescheduler_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*SchedulerNotifications_SotaStatus)(nil), + (*SchedulerNotifications_FotaStatus)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_communicationmanager_v3_updatescheduler_proto_rawDesc, + NumEnums: 1, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_communicationmanager_v3_updatescheduler_proto_goTypes, + DependencyIndexes: file_communicationmanager_v3_updatescheduler_proto_depIdxs, + EnumInfos: file_communicationmanager_v3_updatescheduler_proto_enumTypes, + MessageInfos: file_communicationmanager_v3_updatescheduler_proto_msgTypes, + }.Build() + File_communicationmanager_v3_updatescheduler_proto = out.File + file_communicationmanager_v3_updatescheduler_proto_rawDesc = nil + file_communicationmanager_v3_updatescheduler_proto_goTypes = nil + file_communicationmanager_v3_updatescheduler_proto_depIdxs = nil +} diff --git a/vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler_grpc.pb.go b/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler_grpc.pb.go similarity index 76% rename from vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler_grpc.pb.go rename to vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler_grpc.pb.go index 0ffdd2a0..14adaadb 100644 --- a/vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler_grpc.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler_grpc.pb.go @@ -1,13 +1,17 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v5.26.0 +// source: communicationmanager/v3/updatescheduler.proto package communicationmanager import ( context "context" - empty "github.com/golang/protobuf/ptypes/empty" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -19,9 +23,9 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type UpdateSchedulerServiceClient interface { - StartFOTAUpdate(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) - StartSOTAUpdate(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) - SubscribeNotifications(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (UpdateSchedulerService_SubscribeNotificationsClient, error) + StartFOTAUpdate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) + StartSOTAUpdate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) + SubscribeNotifications(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (UpdateSchedulerService_SubscribeNotificationsClient, error) } type updateSchedulerServiceClient struct { @@ -32,26 +36,26 @@ func NewUpdateSchedulerServiceClient(cc grpc.ClientConnInterface) UpdateSchedule return &updateSchedulerServiceClient{cc} } -func (c *updateSchedulerServiceClient) StartFOTAUpdate(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/communicationmanager.v2.UpdateSchedulerService/StartFOTAUpdate", in, out, opts...) +func (c *updateSchedulerServiceClient) StartFOTAUpdate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/communicationmanager.v3.UpdateSchedulerService/StartFOTAUpdate", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *updateSchedulerServiceClient) StartSOTAUpdate(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/communicationmanager.v2.UpdateSchedulerService/StartSOTAUpdate", in, out, opts...) +func (c *updateSchedulerServiceClient) StartSOTAUpdate(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/communicationmanager.v3.UpdateSchedulerService/StartSOTAUpdate", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *updateSchedulerServiceClient) SubscribeNotifications(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (UpdateSchedulerService_SubscribeNotificationsClient, error) { - stream, err := c.cc.NewStream(ctx, &UpdateSchedulerService_ServiceDesc.Streams[0], "/communicationmanager.v2.UpdateSchedulerService/SubscribeNotifications", opts...) +func (c *updateSchedulerServiceClient) SubscribeNotifications(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (UpdateSchedulerService_SubscribeNotificationsClient, error) { + stream, err := c.cc.NewStream(ctx, &UpdateSchedulerService_ServiceDesc.Streams[0], "/communicationmanager.v3.UpdateSchedulerService/SubscribeNotifications", opts...) if err != nil { return nil, err } @@ -86,9 +90,9 @@ func (x *updateSchedulerServiceSubscribeNotificationsClient) Recv() (*SchedulerN // All implementations must embed UnimplementedUpdateSchedulerServiceServer // for forward compatibility type UpdateSchedulerServiceServer interface { - StartFOTAUpdate(context.Context, *empty.Empty) (*empty.Empty, error) - StartSOTAUpdate(context.Context, *empty.Empty) (*empty.Empty, error) - SubscribeNotifications(*empty.Empty, UpdateSchedulerService_SubscribeNotificationsServer) error + StartFOTAUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) + StartSOTAUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) + SubscribeNotifications(*emptypb.Empty, UpdateSchedulerService_SubscribeNotificationsServer) error mustEmbedUnimplementedUpdateSchedulerServiceServer() } @@ -96,13 +100,13 @@ type UpdateSchedulerServiceServer interface { type UnimplementedUpdateSchedulerServiceServer struct { } -func (UnimplementedUpdateSchedulerServiceServer) StartFOTAUpdate(context.Context, *empty.Empty) (*empty.Empty, error) { +func (UnimplementedUpdateSchedulerServiceServer) StartFOTAUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method StartFOTAUpdate not implemented") } -func (UnimplementedUpdateSchedulerServiceServer) StartSOTAUpdate(context.Context, *empty.Empty) (*empty.Empty, error) { +func (UnimplementedUpdateSchedulerServiceServer) StartSOTAUpdate(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method StartSOTAUpdate not implemented") } -func (UnimplementedUpdateSchedulerServiceServer) SubscribeNotifications(*empty.Empty, UpdateSchedulerService_SubscribeNotificationsServer) error { +func (UnimplementedUpdateSchedulerServiceServer) SubscribeNotifications(*emptypb.Empty, UpdateSchedulerService_SubscribeNotificationsServer) error { return status.Errorf(codes.Unimplemented, "method SubscribeNotifications not implemented") } func (UnimplementedUpdateSchedulerServiceServer) mustEmbedUnimplementedUpdateSchedulerServiceServer() { @@ -120,7 +124,7 @@ func RegisterUpdateSchedulerServiceServer(s grpc.ServiceRegistrar, srv UpdateSch } func _UpdateSchedulerService_StartFOTAUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) + in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } @@ -129,16 +133,16 @@ func _UpdateSchedulerService_StartFOTAUpdate_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/communicationmanager.v2.UpdateSchedulerService/StartFOTAUpdate", + FullMethod: "/communicationmanager.v3.UpdateSchedulerService/StartFOTAUpdate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UpdateSchedulerServiceServer).StartFOTAUpdate(ctx, req.(*empty.Empty)) + return srv.(UpdateSchedulerServiceServer).StartFOTAUpdate(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _UpdateSchedulerService_StartSOTAUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) + in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } @@ -147,16 +151,16 @@ func _UpdateSchedulerService_StartSOTAUpdate_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/communicationmanager.v2.UpdateSchedulerService/StartSOTAUpdate", + FullMethod: "/communicationmanager.v3.UpdateSchedulerService/StartSOTAUpdate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UpdateSchedulerServiceServer).StartSOTAUpdate(ctx, req.(*empty.Empty)) + return srv.(UpdateSchedulerServiceServer).StartSOTAUpdate(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _UpdateSchedulerService_SubscribeNotifications_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(empty.Empty) + m := new(emptypb.Empty) if err := stream.RecvMsg(m); err != nil { return err } @@ -180,7 +184,7 @@ func (x *updateSchedulerServiceSubscribeNotificationsServer) Send(m *SchedulerNo // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var UpdateSchedulerService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "communicationmanager.v2.UpdateSchedulerService", + ServiceName: "communicationmanager.v3.UpdateSchedulerService", HandlerType: (*UpdateSchedulerServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -199,5 +203,5 @@ var UpdateSchedulerService_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "communicationmanager/v2/updatescheduler.proto", + Metadata: "communicationmanager/v3/updatescheduler.proto", } diff --git a/vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler.pb.go b/vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler.pb.go deleted file mode 100644 index 25efd56c..00000000 --- a/vendor/github.com/aosedge/aos_common/api/communicationmanager/v2/updatescheduler.pb.go +++ /dev/null @@ -1,813 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.1 -// protoc v3.6.1 -// source: communicationmanager/v2/updatescheduler.proto - -package communicationmanager - -import ( - empty "github.com/golang/protobuf/ptypes/empty" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UpdateState int32 - -const ( - UpdateState_NO_UPDATE UpdateState = 0 - UpdateState_DOWNLOADING UpdateState = 1 - UpdateState_READY_TO_UPDATE UpdateState = 2 - UpdateState_UPDATING UpdateState = 3 -) - -// Enum value maps for UpdateState. -var ( - UpdateState_name = map[int32]string{ - 0: "NO_UPDATE", - 1: "DOWNLOADING", - 2: "READY_TO_UPDATE", - 3: "UPDATING", - } - UpdateState_value = map[string]int32{ - "NO_UPDATE": 0, - "DOWNLOADING": 1, - "READY_TO_UPDATE": 2, - "UPDATING": 3, - } -) - -func (x UpdateState) Enum() *UpdateState { - p := new(UpdateState) - *p = x - return p -} - -func (x UpdateState) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (UpdateState) Descriptor() protoreflect.EnumDescriptor { - return file_communicationmanager_v2_updatescheduler_proto_enumTypes[0].Descriptor() -} - -func (UpdateState) Type() protoreflect.EnumType { - return &file_communicationmanager_v2_updatescheduler_proto_enumTypes[0] -} - -func (x UpdateState) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use UpdateState.Descriptor instead. -func (UpdateState) EnumDescriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{0} -} - -type SchedulerNotifications struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to SchedulerNotification: - // *SchedulerNotifications_SotaStatus - // *SchedulerNotifications_FotaStatus - SchedulerNotification isSchedulerNotifications_SchedulerNotification `protobuf_oneof:"SchedulerNotification"` -} - -func (x *SchedulerNotifications) Reset() { - *x = SchedulerNotifications{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SchedulerNotifications) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SchedulerNotifications) ProtoMessage() {} - -func (x *SchedulerNotifications) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SchedulerNotifications.ProtoReflect.Descriptor instead. -func (*SchedulerNotifications) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{0} -} - -func (m *SchedulerNotifications) GetSchedulerNotification() isSchedulerNotifications_SchedulerNotification { - if m != nil { - return m.SchedulerNotification - } - return nil -} - -func (x *SchedulerNotifications) GetSotaStatus() *UpdateSOTAStatus { - if x, ok := x.GetSchedulerNotification().(*SchedulerNotifications_SotaStatus); ok { - return x.SotaStatus - } - return nil -} - -func (x *SchedulerNotifications) GetFotaStatus() *UpdateFOTAStatus { - if x, ok := x.GetSchedulerNotification().(*SchedulerNotifications_FotaStatus); ok { - return x.FotaStatus - } - return nil -} - -type isSchedulerNotifications_SchedulerNotification interface { - isSchedulerNotifications_SchedulerNotification() -} - -type SchedulerNotifications_SotaStatus struct { - SotaStatus *UpdateSOTAStatus `protobuf:"bytes,1,opt,name=sota_status,json=sotaStatus,proto3,oneof"` -} - -type SchedulerNotifications_FotaStatus struct { - FotaStatus *UpdateFOTAStatus `protobuf:"bytes,2,opt,name=fota_status,json=fotaStatus,proto3,oneof"` -} - -func (*SchedulerNotifications_SotaStatus) isSchedulerNotifications_SchedulerNotification() {} - -func (*SchedulerNotifications_FotaStatus) isSchedulerNotifications_SchedulerNotification() {} - -type UpdateFOTAStatus struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - State UpdateState `protobuf:"varint,1,opt,name=state,proto3,enum=communicationmanager.v2.UpdateState" json:"state,omitempty"` - Components []*ComponentInfo `protobuf:"bytes,2,rep,name=components,proto3" json:"components,omitempty"` - UnitConfig *UnitConfigInfo `protobuf:"bytes,3,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` - Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` -} - -func (x *UpdateFOTAStatus) Reset() { - *x = UpdateFOTAStatus{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateFOTAStatus) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateFOTAStatus) ProtoMessage() {} - -func (x *UpdateFOTAStatus) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateFOTAStatus.ProtoReflect.Descriptor instead. -func (*UpdateFOTAStatus) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{1} -} - -func (x *UpdateFOTAStatus) GetState() UpdateState { - if x != nil { - return x.State - } - return UpdateState_NO_UPDATE -} - -func (x *UpdateFOTAStatus) GetComponents() []*ComponentInfo { - if x != nil { - return x.Components - } - return nil -} - -func (x *UpdateFOTAStatus) GetUnitConfig() *UnitConfigInfo { - if x != nil { - return x.UnitConfig - } - return nil -} - -func (x *UpdateFOTAStatus) GetError() string { - if x != nil { - return x.Error - } - return "" -} - -type UpdateSOTAStatus struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - State UpdateState `protobuf:"varint,1,opt,name=state,proto3,enum=communicationmanager.v2.UpdateState" json:"state,omitempty"` - InstallServices []*ServiceInfo `protobuf:"bytes,2,rep,name=install_services,json=installServices,proto3" json:"install_services,omitempty"` - RemoveServices []*ServiceInfo `protobuf:"bytes,3,rep,name=remove_services,json=removeServices,proto3" json:"remove_services,omitempty"` - InstallLayers []*LayerInfo `protobuf:"bytes,4,rep,name=install_layers,json=installLayers,proto3" json:"install_layers,omitempty"` - RemoveLayers []*LayerInfo `protobuf:"bytes,5,rep,name=remove_layers,json=removeLayers,proto3" json:"remove_layers,omitempty"` - Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"` -} - -func (x *UpdateSOTAStatus) Reset() { - *x = UpdateSOTAStatus{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateSOTAStatus) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateSOTAStatus) ProtoMessage() {} - -func (x *UpdateSOTAStatus) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateSOTAStatus.ProtoReflect.Descriptor instead. -func (*UpdateSOTAStatus) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{2} -} - -func (x *UpdateSOTAStatus) GetState() UpdateState { - if x != nil { - return x.State - } - return UpdateState_NO_UPDATE -} - -func (x *UpdateSOTAStatus) GetInstallServices() []*ServiceInfo { - if x != nil { - return x.InstallServices - } - return nil -} - -func (x *UpdateSOTAStatus) GetRemoveServices() []*ServiceInfo { - if x != nil { - return x.RemoveServices - } - return nil -} - -func (x *UpdateSOTAStatus) GetInstallLayers() []*LayerInfo { - if x != nil { - return x.InstallLayers - } - return nil -} - -func (x *UpdateSOTAStatus) GetRemoveLayers() []*LayerInfo { - if x != nil { - return x.RemoveLayers - } - return nil -} - -func (x *UpdateSOTAStatus) GetError() string { - if x != nil { - return x.Error - } - return "" -} - -type ComponentInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - AosVersion uint64 `protobuf:"varint,2,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - VendorVersion string `protobuf:"bytes,3,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` -} - -func (x *ComponentInfo) Reset() { - *x = ComponentInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ComponentInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ComponentInfo) ProtoMessage() {} - -func (x *ComponentInfo) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ComponentInfo.ProtoReflect.Descriptor instead. -func (*ComponentInfo) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{3} -} - -func (x *ComponentInfo) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ComponentInfo) GetAosVersion() uint64 { - if x != nil { - return x.AosVersion - } - return 0 -} - -func (x *ComponentInfo) GetVendorVersion() string { - if x != nil { - return x.VendorVersion - } - return "" -} - -type UnitConfigInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - VendorVersion string `protobuf:"bytes,1,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` -} - -func (x *UnitConfigInfo) Reset() { - *x = UnitConfigInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UnitConfigInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UnitConfigInfo) ProtoMessage() {} - -func (x *UnitConfigInfo) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UnitConfigInfo.ProtoReflect.Descriptor instead. -func (*UnitConfigInfo) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{4} -} - -func (x *UnitConfigInfo) GetVendorVersion() string { - if x != nil { - return x.VendorVersion - } - return "" -} - -type ServiceInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - AosVersion uint64 `protobuf:"varint,2,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` -} - -func (x *ServiceInfo) Reset() { - *x = ServiceInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServiceInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceInfo) ProtoMessage() {} - -func (x *ServiceInfo) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServiceInfo.ProtoReflect.Descriptor instead. -func (*ServiceInfo) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{5} -} - -func (x *ServiceInfo) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ServiceInfo) GetAosVersion() uint64 { - if x != nil { - return x.AosVersion - } - return 0 -} - -type LayerInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - AosVersion uint64 `protobuf:"varint,2,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - Digest string `protobuf:"bytes,3,opt,name=digest,proto3" json:"digest,omitempty"` -} - -func (x *LayerInfo) Reset() { - *x = LayerInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *LayerInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LayerInfo) ProtoMessage() {} - -func (x *LayerInfo) ProtoReflect() protoreflect.Message { - mi := &file_communicationmanager_v2_updatescheduler_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LayerInfo.ProtoReflect.Descriptor instead. -func (*LayerInfo) Descriptor() ([]byte, []int) { - return file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP(), []int{6} -} - -func (x *LayerInfo) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *LayerInfo) GetAosVersion() uint64 { - if x != nil { - return x.AosVersion - } - return 0 -} - -func (x *LayerInfo) GetDigest() string { - if x != nil { - return x.Digest - } - return "" -} - -var File_communicationmanager_v2_updatescheduler_proto protoreflect.FileDescriptor - -var file_communicationmanager_v2_updatescheduler_proto_rawDesc = []byte{ - 0x0a, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x76, 0x32, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x17, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x01, 0x0a, 0x16, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, - 0x6c, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x4c, 0x0a, 0x0b, 0x73, 0x6f, 0x74, 0x61, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x48, 0x00, 0x52, 0x0a, 0x73, 0x6f, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4c, - 0x0a, 0x0b, 0x66, 0x6f, 0x74, 0x61, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x46, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, - 0x52, 0x0a, 0x66, 0x6f, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x17, 0x0a, 0x15, - 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xf6, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x46, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, - 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x46, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x48, - 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x6e, - 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x75, 0x6e, - 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x98, - 0x03, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x4f, 0x0a, 0x10, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x12, 0x4d, 0x0a, 0x0f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, - 0x49, 0x0a, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x32, 0x2e, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x47, 0x0a, 0x0d, 0x72, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x61, 0x79, 0x65, - 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0c, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x79, - 0x65, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x67, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, - 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x0a, 0x61, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x76, - 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x37, 0x0a, 0x0e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x76, 0x65, - 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3e, 0x0a, 0x0b, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, - 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x0a, 0x61, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x54, 0x0a, 0x09, 0x4c, - 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, 0x73, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x61, - 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, - 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, - 0x74, 0x2a, 0x50, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x00, 0x12, - 0x0f, 0x0a, 0x0b, 0x44, 0x4f, 0x57, 0x4e, 0x4c, 0x4f, 0x41, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x01, - 0x12, 0x13, 0x0a, 0x0f, 0x52, 0x45, 0x41, 0x44, 0x59, 0x5f, 0x54, 0x4f, 0x5f, 0x55, 0x50, 0x44, - 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x50, 0x44, 0x41, 0x54, 0x49, 0x4e, - 0x47, 0x10, 0x03, 0x32, 0x89, 0x02, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x63, - 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, - 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x46, 0x4f, 0x54, 0x41, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x4f, 0x54, 0x41, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x16, 0x53, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x62, 0x65, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x72, 0x4e, 0x6f, - 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x00, 0x30, 0x01, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_communicationmanager_v2_updatescheduler_proto_rawDescOnce sync.Once - file_communicationmanager_v2_updatescheduler_proto_rawDescData = file_communicationmanager_v2_updatescheduler_proto_rawDesc -) - -func file_communicationmanager_v2_updatescheduler_proto_rawDescGZIP() []byte { - file_communicationmanager_v2_updatescheduler_proto_rawDescOnce.Do(func() { - file_communicationmanager_v2_updatescheduler_proto_rawDescData = protoimpl.X.CompressGZIP(file_communicationmanager_v2_updatescheduler_proto_rawDescData) - }) - return file_communicationmanager_v2_updatescheduler_proto_rawDescData -} - -var file_communicationmanager_v2_updatescheduler_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_communicationmanager_v2_updatescheduler_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_communicationmanager_v2_updatescheduler_proto_goTypes = []interface{}{ - (UpdateState)(0), // 0: communicationmanager.v2.UpdateState - (*SchedulerNotifications)(nil), // 1: communicationmanager.v2.SchedulerNotifications - (*UpdateFOTAStatus)(nil), // 2: communicationmanager.v2.UpdateFOTAStatus - (*UpdateSOTAStatus)(nil), // 3: communicationmanager.v2.UpdateSOTAStatus - (*ComponentInfo)(nil), // 4: communicationmanager.v2.ComponentInfo - (*UnitConfigInfo)(nil), // 5: communicationmanager.v2.UnitConfigInfo - (*ServiceInfo)(nil), // 6: communicationmanager.v2.ServiceInfo - (*LayerInfo)(nil), // 7: communicationmanager.v2.LayerInfo - (*empty.Empty)(nil), // 8: google.protobuf.Empty -} -var file_communicationmanager_v2_updatescheduler_proto_depIdxs = []int32{ - 3, // 0: communicationmanager.v2.SchedulerNotifications.sota_status:type_name -> communicationmanager.v2.UpdateSOTAStatus - 2, // 1: communicationmanager.v2.SchedulerNotifications.fota_status:type_name -> communicationmanager.v2.UpdateFOTAStatus - 0, // 2: communicationmanager.v2.UpdateFOTAStatus.state:type_name -> communicationmanager.v2.UpdateState - 4, // 3: communicationmanager.v2.UpdateFOTAStatus.components:type_name -> communicationmanager.v2.ComponentInfo - 5, // 4: communicationmanager.v2.UpdateFOTAStatus.unit_config:type_name -> communicationmanager.v2.UnitConfigInfo - 0, // 5: communicationmanager.v2.UpdateSOTAStatus.state:type_name -> communicationmanager.v2.UpdateState - 6, // 6: communicationmanager.v2.UpdateSOTAStatus.install_services:type_name -> communicationmanager.v2.ServiceInfo - 6, // 7: communicationmanager.v2.UpdateSOTAStatus.remove_services:type_name -> communicationmanager.v2.ServiceInfo - 7, // 8: communicationmanager.v2.UpdateSOTAStatus.install_layers:type_name -> communicationmanager.v2.LayerInfo - 7, // 9: communicationmanager.v2.UpdateSOTAStatus.remove_layers:type_name -> communicationmanager.v2.LayerInfo - 8, // 10: communicationmanager.v2.UpdateSchedulerService.StartFOTAUpdate:input_type -> google.protobuf.Empty - 8, // 11: communicationmanager.v2.UpdateSchedulerService.StartSOTAUpdate:input_type -> google.protobuf.Empty - 8, // 12: communicationmanager.v2.UpdateSchedulerService.SubscribeNotifications:input_type -> google.protobuf.Empty - 8, // 13: communicationmanager.v2.UpdateSchedulerService.StartFOTAUpdate:output_type -> google.protobuf.Empty - 8, // 14: communicationmanager.v2.UpdateSchedulerService.StartSOTAUpdate:output_type -> google.protobuf.Empty - 1, // 15: communicationmanager.v2.UpdateSchedulerService.SubscribeNotifications:output_type -> communicationmanager.v2.SchedulerNotifications - 13, // [13:16] is the sub-list for method output_type - 10, // [10:13] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name -} - -func init() { file_communicationmanager_v2_updatescheduler_proto_init() } -func file_communicationmanager_v2_updatescheduler_proto_init() { - if File_communicationmanager_v2_updatescheduler_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_communicationmanager_v2_updatescheduler_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SchedulerNotifications); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateFOTAStatus); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateSOTAStatus); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ComponentInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UnitConfigInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServiceInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LayerInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_communicationmanager_v2_updatescheduler_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*SchedulerNotifications_SotaStatus)(nil), - (*SchedulerNotifications_FotaStatus)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_communicationmanager_v2_updatescheduler_proto_rawDesc, - NumEnums: 1, - NumMessages: 7, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_communicationmanager_v2_updatescheduler_proto_goTypes, - DependencyIndexes: file_communicationmanager_v2_updatescheduler_proto_depIdxs, - EnumInfos: file_communicationmanager_v2_updatescheduler_proto_enumTypes, - MessageInfos: file_communicationmanager_v2_updatescheduler_proto_msgTypes, - }.Build() - File_communicationmanager_v2_updatescheduler_proto = out.File - file_communicationmanager_v2_updatescheduler_proto_rawDesc = nil - file_communicationmanager_v2_updatescheduler_proto_goTypes = nil - file_communicationmanager_v2_updatescheduler_proto_depIdxs = nil -} diff --git a/vendor/github.com/aosedge/aos_common/api/iamanager/iamanager.pb.go b/vendor/github.com/aosedge/aos_common/api/iamanager/iamanager.pb.go new file mode 100644 index 00000000..351bd5c9 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/iamanager/iamanager.pb.go @@ -0,0 +1,3223 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.26.0 +// source: iamanager/v5/iamanager.proto + +package iamanager + +import ( + common "github.com/aosedge/aos_common/api/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PartitionInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Types []string `protobuf:"bytes,2,rep,name=types,proto3" json:"types,omitempty"` + TotalSize uint64 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` + Path string `protobuf:"bytes,4,opt,name=path,proto3" json:"path,omitempty"` +} + +func (x *PartitionInfo) Reset() { + *x = PartitionInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PartitionInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PartitionInfo) ProtoMessage() {} + +func (x *PartitionInfo) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PartitionInfo.ProtoReflect.Descriptor instead. +func (*PartitionInfo) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{0} +} + +func (x *PartitionInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *PartitionInfo) GetTypes() []string { + if x != nil { + return x.Types + } + return nil +} + +func (x *PartitionInfo) GetTotalSize() uint64 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *PartitionInfo) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +type CPUInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ModelName string `protobuf:"bytes,1,opt,name=model_name,json=modelName,proto3" json:"model_name,omitempty"` + NumCores uint64 `protobuf:"varint,2,opt,name=num_cores,json=numCores,proto3" json:"num_cores,omitempty"` + NumThreads uint64 `protobuf:"varint,3,opt,name=num_threads,json=numThreads,proto3" json:"num_threads,omitempty"` + Arch string `protobuf:"bytes,4,opt,name=arch,proto3" json:"arch,omitempty"` + ArchFamily string `protobuf:"bytes,5,opt,name=arch_family,json=archFamily,proto3" json:"arch_family,omitempty"` + MaxDmips uint64 `protobuf:"varint,6,opt,name=max_dmips,json=maxDmips,proto3" json:"max_dmips,omitempty"` +} + +func (x *CPUInfo) Reset() { + *x = CPUInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CPUInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CPUInfo) ProtoMessage() {} + +func (x *CPUInfo) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CPUInfo.ProtoReflect.Descriptor instead. +func (*CPUInfo) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{1} +} + +func (x *CPUInfo) GetModelName() string { + if x != nil { + return x.ModelName + } + return "" +} + +func (x *CPUInfo) GetNumCores() uint64 { + if x != nil { + return x.NumCores + } + return 0 +} + +func (x *CPUInfo) GetNumThreads() uint64 { + if x != nil { + return x.NumThreads + } + return 0 +} + +func (x *CPUInfo) GetArch() string { + if x != nil { + return x.Arch + } + return "" +} + +func (x *CPUInfo) GetArchFamily() string { + if x != nil { + return x.ArchFamily + } + return "" +} + +func (x *CPUInfo) GetMaxDmips() uint64 { + if x != nil { + return x.MaxDmips + } + return 0 +} + +type NodeAttribute struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *NodeAttribute) Reset() { + *x = NodeAttribute{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeAttribute) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeAttribute) ProtoMessage() {} + +func (x *NodeAttribute) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodeAttribute.ProtoReflect.Descriptor instead. +func (*NodeAttribute) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{2} +} + +func (x *NodeAttribute) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NodeAttribute) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +type NodeInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + NodeType string `protobuf:"bytes,2,opt,name=node_type,json=nodeType,proto3" json:"node_type,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` + OsType string `protobuf:"bytes,5,opt,name=os_type,json=osType,proto3" json:"os_type,omitempty"` + Cpus []*CPUInfo `protobuf:"bytes,6,rep,name=cpus,proto3" json:"cpus,omitempty"` + MaxDmips uint64 `protobuf:"varint,7,opt,name=max_dmips,json=maxDmips,proto3" json:"max_dmips,omitempty"` + TotalRam uint64 `protobuf:"varint,8,opt,name=total_ram,json=totalRam,proto3" json:"total_ram,omitempty"` + Partitions []*PartitionInfo `protobuf:"bytes,9,rep,name=partitions,proto3" json:"partitions,omitempty"` + Attrs []*NodeAttribute `protobuf:"bytes,10,rep,name=attrs,proto3" json:"attrs,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,11,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *NodeInfo) Reset() { + *x = NodeInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodeInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodeInfo) ProtoMessage() {} + +func (x *NodeInfo) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodeInfo.ProtoReflect.Descriptor instead. +func (*NodeInfo) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{3} +} + +func (x *NodeInfo) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *NodeInfo) GetNodeType() string { + if x != nil { + return x.NodeType + } + return "" +} + +func (x *NodeInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NodeInfo) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *NodeInfo) GetOsType() string { + if x != nil { + return x.OsType + } + return "" +} + +func (x *NodeInfo) GetCpus() []*CPUInfo { + if x != nil { + return x.Cpus + } + return nil +} + +func (x *NodeInfo) GetMaxDmips() uint64 { + if x != nil { + return x.MaxDmips + } + return 0 +} + +func (x *NodeInfo) GetTotalRam() uint64 { + if x != nil { + return x.TotalRam + } + return 0 +} + +func (x *NodeInfo) GetPartitions() []*PartitionInfo { + if x != nil { + return x.Partitions + } + return nil +} + +func (x *NodeInfo) GetAttrs() []*NodeAttribute { + if x != nil { + return x.Attrs + } + return nil +} + +func (x *NodeInfo) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type GetCertRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Issuer []byte `protobuf:"bytes,2,opt,name=issuer,proto3" json:"issuer,omitempty"` + Serial string `protobuf:"bytes,3,opt,name=serial,proto3" json:"serial,omitempty"` +} + +func (x *GetCertRequest) Reset() { + *x = GetCertRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCertRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCertRequest) ProtoMessage() {} + +func (x *GetCertRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCertRequest.ProtoReflect.Descriptor instead. +func (*GetCertRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{4} +} + +func (x *GetCertRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *GetCertRequest) GetIssuer() []byte { + if x != nil { + return x.Issuer + } + return nil +} + +func (x *GetCertRequest) GetSerial() string { + if x != nil { + return x.Serial + } + return "" +} + +type GetCertResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + CertUrl string `protobuf:"bytes,2,opt,name=cert_url,json=certUrl,proto3" json:"cert_url,omitempty"` + KeyUrl string `protobuf:"bytes,3,opt,name=key_url,json=keyUrl,proto3" json:"key_url,omitempty"` +} + +func (x *GetCertResponse) Reset() { + *x = GetCertResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCertResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCertResponse) ProtoMessage() {} + +func (x *GetCertResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCertResponse.ProtoReflect.Descriptor instead. +func (*GetCertResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{5} +} + +func (x *GetCertResponse) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *GetCertResponse) GetCertUrl() string { + if x != nil { + return x.CertUrl + } + return "" +} + +func (x *GetCertResponse) GetKeyUrl() string { + if x != nil { + return x.KeyUrl + } + return "" +} + +type SystemInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SystemId string `protobuf:"bytes,1,opt,name=system_id,json=systemId,proto3" json:"system_id,omitempty"` + UnitModel string `protobuf:"bytes,2,opt,name=unit_model,json=unitModel,proto3" json:"unit_model,omitempty"` +} + +func (x *SystemInfo) Reset() { + *x = SystemInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SystemInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SystemInfo) ProtoMessage() {} + +func (x *SystemInfo) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SystemInfo.ProtoReflect.Descriptor instead. +func (*SystemInfo) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{6} +} + +func (x *SystemInfo) GetSystemId() string { + if x != nil { + return x.SystemId + } + return "" +} + +func (x *SystemInfo) GetUnitModel() string { + if x != nil { + return x.UnitModel + } + return "" +} + +type Subjects struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Subjects []string `protobuf:"bytes,1,rep,name=subjects,proto3" json:"subjects,omitempty"` +} + +func (x *Subjects) Reset() { + *x = Subjects{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Subjects) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Subjects) ProtoMessage() {} + +func (x *Subjects) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Subjects.ProtoReflect.Descriptor instead. +func (*Subjects) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{7} +} + +func (x *Subjects) GetSubjects() []string { + if x != nil { + return x.Subjects + } + return nil +} + +type PermissionsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Secret string `protobuf:"bytes,1,opt,name=secret,proto3" json:"secret,omitempty"` + FunctionalServerId string `protobuf:"bytes,2,opt,name=functional_server_id,json=functionalServerId,proto3" json:"functional_server_id,omitempty"` +} + +func (x *PermissionsRequest) Reset() { + *x = PermissionsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PermissionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionsRequest) ProtoMessage() {} + +func (x *PermissionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionsRequest.ProtoReflect.Descriptor instead. +func (*PermissionsRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{8} +} + +func (x *PermissionsRequest) GetSecret() string { + if x != nil { + return x.Secret + } + return "" +} + +func (x *PermissionsRequest) GetFunctionalServerId() string { + if x != nil { + return x.FunctionalServerId + } + return "" +} + +type PermissionsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + Permissions *Permissions `protobuf:"bytes,2,opt,name=permissions,proto3" json:"permissions,omitempty"` +} + +func (x *PermissionsResponse) Reset() { + *x = PermissionsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PermissionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionsResponse) ProtoMessage() {} + +func (x *PermissionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionsResponse.ProtoReflect.Descriptor instead. +func (*PermissionsResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{9} +} + +func (x *PermissionsResponse) GetInstance() *common.InstanceIdent { + if x != nil { + return x.Instance + } + return nil +} + +func (x *PermissionsResponse) GetPermissions() *Permissions { + if x != nil { + return x.Permissions + } + return nil +} + +type NodesID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` +} + +func (x *NodesID) Reset() { + *x = NodesID{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NodesID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NodesID) ProtoMessage() {} + +func (x *NodesID) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NodesID.ProtoReflect.Descriptor instead. +func (*NodesID) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{10} +} + +func (x *NodesID) GetIds() []string { + if x != nil { + return x.Ids + } + return nil +} + +type GetCertTypesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *GetCertTypesRequest) Reset() { + *x = GetCertTypesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCertTypesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCertTypesRequest) ProtoMessage() {} + +func (x *GetCertTypesRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCertTypesRequest.ProtoReflect.Descriptor instead. +func (*GetCertTypesRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{11} +} + +func (x *GetCertTypesRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +type CertTypes struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Types []string `protobuf:"bytes,1,rep,name=types,proto3" json:"types,omitempty"` +} + +func (x *CertTypes) Reset() { + *x = CertTypes{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CertTypes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CertTypes) ProtoMessage() {} + +func (x *CertTypes) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CertTypes.ProtoReflect.Descriptor instead. +func (*CertTypes) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{12} +} + +func (x *CertTypes) GetTypes() []string { + if x != nil { + return x.Types + } + return nil +} + +type CreateKeyRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *CreateKeyRequest) Reset() { + *x = CreateKeyRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateKeyRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateKeyRequest) ProtoMessage() {} + +func (x *CreateKeyRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateKeyRequest.ProtoReflect.Descriptor instead. +func (*CreateKeyRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{13} +} + +func (x *CreateKeyRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *CreateKeyRequest) GetSubject() string { + if x != nil { + return x.Subject + } + return "" +} + +func (x *CreateKeyRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *CreateKeyRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type CreateKeyResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Csr string `protobuf:"bytes,3,opt,name=csr,proto3" json:"csr,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *CreateKeyResponse) Reset() { + *x = CreateKeyResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateKeyResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateKeyResponse) ProtoMessage() {} + +func (x *CreateKeyResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateKeyResponse.ProtoReflect.Descriptor instead. +func (*CreateKeyResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{14} +} + +func (x *CreateKeyResponse) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *CreateKeyResponse) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *CreateKeyResponse) GetCsr() string { + if x != nil { + return x.Csr + } + return "" +} + +func (x *CreateKeyResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type ApplyCertRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Cert string `protobuf:"bytes,3,opt,name=cert,proto3" json:"cert,omitempty"` +} + +func (x *ApplyCertRequest) Reset() { + *x = ApplyCertRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyCertRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyCertRequest) ProtoMessage() {} + +func (x *ApplyCertRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApplyCertRequest.ProtoReflect.Descriptor instead. +func (*ApplyCertRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{15} +} + +func (x *ApplyCertRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *ApplyCertRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *ApplyCertRequest) GetCert() string { + if x != nil { + return x.Cert + } + return "" +} + +type ApplyCertResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + CertUrl string `protobuf:"bytes,3,opt,name=cert_url,json=certUrl,proto3" json:"cert_url,omitempty"` + Serial string `protobuf:"bytes,4,opt,name=serial,proto3" json:"serial,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *ApplyCertResponse) Reset() { + *x = ApplyCertResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyCertResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyCertResponse) ProtoMessage() {} + +func (x *ApplyCertResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApplyCertResponse.ProtoReflect.Descriptor instead. +func (*ApplyCertResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{16} +} + +func (x *ApplyCertResponse) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *ApplyCertResponse) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *ApplyCertResponse) GetCertUrl() string { + if x != nil { + return x.CertUrl + } + return "" +} + +func (x *ApplyCertResponse) GetSerial() string { + if x != nil { + return x.Serial + } + return "" +} + +func (x *ApplyCertResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type Permissions struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Permissions map[string]string `protobuf:"bytes,1,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Permissions) Reset() { + *x = Permissions{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Permissions) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Permissions) ProtoMessage() {} + +func (x *Permissions) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Permissions.ProtoReflect.Descriptor instead. +func (*Permissions) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{17} +} + +func (x *Permissions) GetPermissions() map[string]string { + if x != nil { + return x.Permissions + } + return nil +} + +type RegisterInstanceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + Permissions map[string]*Permissions `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *RegisterInstanceRequest) Reset() { + *x = RegisterInstanceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterInstanceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterInstanceRequest) ProtoMessage() {} + +func (x *RegisterInstanceRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterInstanceRequest.ProtoReflect.Descriptor instead. +func (*RegisterInstanceRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{18} +} + +func (x *RegisterInstanceRequest) GetInstance() *common.InstanceIdent { + if x != nil { + return x.Instance + } + return nil +} + +func (x *RegisterInstanceRequest) GetPermissions() map[string]*Permissions { + if x != nil { + return x.Permissions + } + return nil +} + +type RegisterInstanceResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Secret string `protobuf:"bytes,1,opt,name=secret,proto3" json:"secret,omitempty"` +} + +func (x *RegisterInstanceResponse) Reset() { + *x = RegisterInstanceResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterInstanceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterInstanceResponse) ProtoMessage() {} + +func (x *RegisterInstanceResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterInstanceResponse.ProtoReflect.Descriptor instead. +func (*RegisterInstanceResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{19} +} + +func (x *RegisterInstanceResponse) GetSecret() string { + if x != nil { + return x.Secret + } + return "" +} + +type UnregisterInstanceRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` +} + +func (x *UnregisterInstanceRequest) Reset() { + *x = UnregisterInstanceRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UnregisterInstanceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UnregisterInstanceRequest) ProtoMessage() {} + +func (x *UnregisterInstanceRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UnregisterInstanceRequest.ProtoReflect.Descriptor instead. +func (*UnregisterInstanceRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{20} +} + +func (x *UnregisterInstanceRequest) GetInstance() *common.InstanceIdent { + if x != nil { + return x.Instance + } + return nil +} + +type GetNodeInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *GetNodeInfoRequest) Reset() { + *x = GetNodeInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetNodeInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetNodeInfoRequest) ProtoMessage() {} + +func (x *GetNodeInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetNodeInfoRequest.ProtoReflect.Descriptor instead. +func (*GetNodeInfoRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{21} +} + +func (x *GetNodeInfoRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +type PauseNodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *PauseNodeRequest) Reset() { + *x = PauseNodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PauseNodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PauseNodeRequest) ProtoMessage() {} + +func (x *PauseNodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PauseNodeRequest.ProtoReflect.Descriptor instead. +func (*PauseNodeRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{22} +} + +func (x *PauseNodeRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +type PauseNodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error *common.ErrorInfo `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *PauseNodeResponse) Reset() { + *x = PauseNodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PauseNodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PauseNodeResponse) ProtoMessage() {} + +func (x *PauseNodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[23] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PauseNodeResponse.ProtoReflect.Descriptor instead. +func (*PauseNodeResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{23} +} + +func (x *PauseNodeResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type ResumeNodeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *ResumeNodeRequest) Reset() { + *x = ResumeNodeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResumeNodeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResumeNodeRequest) ProtoMessage() {} + +func (x *ResumeNodeRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[24] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResumeNodeRequest.ProtoReflect.Descriptor instead. +func (*ResumeNodeRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{24} +} + +func (x *ResumeNodeRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +type ResumeNodeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error *common.ErrorInfo `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *ResumeNodeResponse) Reset() { + *x = ResumeNodeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResumeNodeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResumeNodeResponse) ProtoMessage() {} + +func (x *ResumeNodeResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[25] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResumeNodeResponse.ProtoReflect.Descriptor instead. +func (*ResumeNodeResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{25} +} + +func (x *ResumeNodeResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type StartProvisioningRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *StartProvisioningRequest) Reset() { + *x = StartProvisioningRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartProvisioningRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartProvisioningRequest) ProtoMessage() {} + +func (x *StartProvisioningRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[26] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartProvisioningRequest.ProtoReflect.Descriptor instead. +func (*StartProvisioningRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{26} +} + +func (x *StartProvisioningRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *StartProvisioningRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type StartProvisioningResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error *common.ErrorInfo `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *StartProvisioningResponse) Reset() { + *x = StartProvisioningResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartProvisioningResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartProvisioningResponse) ProtoMessage() {} + +func (x *StartProvisioningResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[27] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartProvisioningResponse.ProtoReflect.Descriptor instead. +func (*StartProvisioningResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{27} +} + +func (x *StartProvisioningResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type FinishProvisioningRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *FinishProvisioningRequest) Reset() { + *x = FinishProvisioningRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FinishProvisioningRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FinishProvisioningRequest) ProtoMessage() {} + +func (x *FinishProvisioningRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FinishProvisioningRequest.ProtoReflect.Descriptor instead. +func (*FinishProvisioningRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{28} +} + +func (x *FinishProvisioningRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *FinishProvisioningRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type FinishProvisioningResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error *common.ErrorInfo `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *FinishProvisioningResponse) Reset() { + *x = FinishProvisioningResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FinishProvisioningResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FinishProvisioningResponse) ProtoMessage() {} + +func (x *FinishProvisioningResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[29] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FinishProvisioningResponse.ProtoReflect.Descriptor instead. +func (*FinishProvisioningResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{29} +} + +func (x *FinishProvisioningResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type DeprovisionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *DeprovisionRequest) Reset() { + *x = DeprovisionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeprovisionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeprovisionRequest) ProtoMessage() {} + +func (x *DeprovisionRequest) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[30] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeprovisionRequest.ProtoReflect.Descriptor instead. +func (*DeprovisionRequest) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{30} +} + +func (x *DeprovisionRequest) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *DeprovisionRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type DeprovisionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error *common.ErrorInfo `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *DeprovisionResponse) Reset() { + *x = DeprovisionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeprovisionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeprovisionResponse) ProtoMessage() {} + +func (x *DeprovisionResponse) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[31] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeprovisionResponse.ProtoReflect.Descriptor instead. +func (*DeprovisionResponse) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{31} +} + +func (x *DeprovisionResponse) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type IAMIncomingMessages struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to IAMIncomingMessage: + // + // *IAMIncomingMessages_StartProvisioningRequest + // *IAMIncomingMessages_GetCertTypesRequest + // *IAMIncomingMessages_FinishProvisioningRequest + // *IAMIncomingMessages_DeprovisionRequest + // *IAMIncomingMessages_PauseNodeRequest + // *IAMIncomingMessages_ResumeNodeRequest + // *IAMIncomingMessages_CreateKeyRequest + // *IAMIncomingMessages_ApplyCertRequest + IAMIncomingMessage isIAMIncomingMessages_IAMIncomingMessage `protobuf_oneof:"IAMIncomingMessage"` +} + +func (x *IAMIncomingMessages) Reset() { + *x = IAMIncomingMessages{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IAMIncomingMessages) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IAMIncomingMessages) ProtoMessage() {} + +func (x *IAMIncomingMessages) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[32] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IAMIncomingMessages.ProtoReflect.Descriptor instead. +func (*IAMIncomingMessages) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{32} +} + +func (m *IAMIncomingMessages) GetIAMIncomingMessage() isIAMIncomingMessages_IAMIncomingMessage { + if m != nil { + return m.IAMIncomingMessage + } + return nil +} + +func (x *IAMIncomingMessages) GetStartProvisioningRequest() *StartProvisioningRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_StartProvisioningRequest); ok { + return x.StartProvisioningRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetGetCertTypesRequest() *GetCertTypesRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_GetCertTypesRequest); ok { + return x.GetCertTypesRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetFinishProvisioningRequest() *FinishProvisioningRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_FinishProvisioningRequest); ok { + return x.FinishProvisioningRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetDeprovisionRequest() *DeprovisionRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_DeprovisionRequest); ok { + return x.DeprovisionRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetPauseNodeRequest() *PauseNodeRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_PauseNodeRequest); ok { + return x.PauseNodeRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetResumeNodeRequest() *ResumeNodeRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_ResumeNodeRequest); ok { + return x.ResumeNodeRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetCreateKeyRequest() *CreateKeyRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_CreateKeyRequest); ok { + return x.CreateKeyRequest + } + return nil +} + +func (x *IAMIncomingMessages) GetApplyCertRequest() *ApplyCertRequest { + if x, ok := x.GetIAMIncomingMessage().(*IAMIncomingMessages_ApplyCertRequest); ok { + return x.ApplyCertRequest + } + return nil +} + +type isIAMIncomingMessages_IAMIncomingMessage interface { + isIAMIncomingMessages_IAMIncomingMessage() +} + +type IAMIncomingMessages_StartProvisioningRequest struct { + StartProvisioningRequest *StartProvisioningRequest `protobuf:"bytes,1,opt,name=start_provisioning_request,json=startProvisioningRequest,proto3,oneof"` +} + +type IAMIncomingMessages_GetCertTypesRequest struct { + GetCertTypesRequest *GetCertTypesRequest `protobuf:"bytes,2,opt,name=get_cert_types_request,json=getCertTypesRequest,proto3,oneof"` +} + +type IAMIncomingMessages_FinishProvisioningRequest struct { + FinishProvisioningRequest *FinishProvisioningRequest `protobuf:"bytes,3,opt,name=finish_provisioning_request,json=finishProvisioningRequest,proto3,oneof"` +} + +type IAMIncomingMessages_DeprovisionRequest struct { + DeprovisionRequest *DeprovisionRequest `protobuf:"bytes,4,opt,name=deprovision_request,json=deprovisionRequest,proto3,oneof"` +} + +type IAMIncomingMessages_PauseNodeRequest struct { + PauseNodeRequest *PauseNodeRequest `protobuf:"bytes,5,opt,name=pause_node_request,json=pauseNodeRequest,proto3,oneof"` +} + +type IAMIncomingMessages_ResumeNodeRequest struct { + ResumeNodeRequest *ResumeNodeRequest `protobuf:"bytes,6,opt,name=resume_node_request,json=resumeNodeRequest,proto3,oneof"` +} + +type IAMIncomingMessages_CreateKeyRequest struct { + CreateKeyRequest *CreateKeyRequest `protobuf:"bytes,7,opt,name=create_key_request,json=createKeyRequest,proto3,oneof"` +} + +type IAMIncomingMessages_ApplyCertRequest struct { + ApplyCertRequest *ApplyCertRequest `protobuf:"bytes,8,opt,name=apply_cert_request,json=applyCertRequest,proto3,oneof"` +} + +func (*IAMIncomingMessages_StartProvisioningRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_GetCertTypesRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_FinishProvisioningRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_DeprovisionRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_PauseNodeRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_ResumeNodeRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_CreateKeyRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +func (*IAMIncomingMessages_ApplyCertRequest) isIAMIncomingMessages_IAMIncomingMessage() {} + +type IAMOutgoingMessages struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to IAMOutgoingMessage: + // + // *IAMOutgoingMessages_NodeInfo + // *IAMOutgoingMessages_StartProvisioningResponse + // *IAMOutgoingMessages_CertTypesResponse + // *IAMOutgoingMessages_FinishProvisioningResponse + // *IAMOutgoingMessages_DeprovisionResponse + // *IAMOutgoingMessages_PauseNodeResponse + // *IAMOutgoingMessages_ResumeNodeResponse + // *IAMOutgoingMessages_CreateKeyResponse + // *IAMOutgoingMessages_ApplyCertResponse + IAMOutgoingMessage isIAMOutgoingMessages_IAMOutgoingMessage `protobuf_oneof:"IAMOutgoingMessage"` +} + +func (x *IAMOutgoingMessages) Reset() { + *x = IAMOutgoingMessages{} + if protoimpl.UnsafeEnabled { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IAMOutgoingMessages) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IAMOutgoingMessages) ProtoMessage() {} + +func (x *IAMOutgoingMessages) ProtoReflect() protoreflect.Message { + mi := &file_iamanager_v5_iamanager_proto_msgTypes[33] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IAMOutgoingMessages.ProtoReflect.Descriptor instead. +func (*IAMOutgoingMessages) Descriptor() ([]byte, []int) { + return file_iamanager_v5_iamanager_proto_rawDescGZIP(), []int{33} +} + +func (m *IAMOutgoingMessages) GetIAMOutgoingMessage() isIAMOutgoingMessages_IAMOutgoingMessage { + if m != nil { + return m.IAMOutgoingMessage + } + return nil +} + +func (x *IAMOutgoingMessages) GetNodeInfo() *NodeInfo { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_NodeInfo); ok { + return x.NodeInfo + } + return nil +} + +func (x *IAMOutgoingMessages) GetStartProvisioningResponse() *StartProvisioningResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_StartProvisioningResponse); ok { + return x.StartProvisioningResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetCertTypesResponse() *CertTypes { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_CertTypesResponse); ok { + return x.CertTypesResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetFinishProvisioningResponse() *FinishProvisioningResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_FinishProvisioningResponse); ok { + return x.FinishProvisioningResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetDeprovisionResponse() *DeprovisionResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_DeprovisionResponse); ok { + return x.DeprovisionResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetPauseNodeResponse() *PauseNodeResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_PauseNodeResponse); ok { + return x.PauseNodeResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetResumeNodeResponse() *ResumeNodeResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_ResumeNodeResponse); ok { + return x.ResumeNodeResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetCreateKeyResponse() *CreateKeyResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_CreateKeyResponse); ok { + return x.CreateKeyResponse + } + return nil +} + +func (x *IAMOutgoingMessages) GetApplyCertResponse() *ApplyCertResponse { + if x, ok := x.GetIAMOutgoingMessage().(*IAMOutgoingMessages_ApplyCertResponse); ok { + return x.ApplyCertResponse + } + return nil +} + +type isIAMOutgoingMessages_IAMOutgoingMessage interface { + isIAMOutgoingMessages_IAMOutgoingMessage() +} + +type IAMOutgoingMessages_NodeInfo struct { + NodeInfo *NodeInfo `protobuf:"bytes,1,opt,name=node_info,json=nodeInfo,proto3,oneof"` +} + +type IAMOutgoingMessages_StartProvisioningResponse struct { + StartProvisioningResponse *StartProvisioningResponse `protobuf:"bytes,2,opt,name=start_provisioning_response,json=startProvisioningResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_CertTypesResponse struct { + CertTypesResponse *CertTypes `protobuf:"bytes,3,opt,name=cert_types_response,json=certTypesResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_FinishProvisioningResponse struct { + FinishProvisioningResponse *FinishProvisioningResponse `protobuf:"bytes,4,opt,name=finish_provisioning_response,json=finishProvisioningResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_DeprovisionResponse struct { + DeprovisionResponse *DeprovisionResponse `protobuf:"bytes,5,opt,name=deprovision_response,json=deprovisionResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_PauseNodeResponse struct { + PauseNodeResponse *PauseNodeResponse `protobuf:"bytes,6,opt,name=pause_node_response,json=pauseNodeResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_ResumeNodeResponse struct { + ResumeNodeResponse *ResumeNodeResponse `protobuf:"bytes,7,opt,name=resume_node_response,json=resumeNodeResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_CreateKeyResponse struct { + CreateKeyResponse *CreateKeyResponse `protobuf:"bytes,8,opt,name=create_key_response,json=createKeyResponse,proto3,oneof"` +} + +type IAMOutgoingMessages_ApplyCertResponse struct { + ApplyCertResponse *ApplyCertResponse `protobuf:"bytes,9,opt,name=apply_cert_response,json=applyCertResponse,proto3,oneof"` +} + +func (*IAMOutgoingMessages_NodeInfo) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_StartProvisioningResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_CertTypesResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_FinishProvisioningResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_DeprovisionResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_PauseNodeResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_ResumeNodeResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_CreateKeyResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +func (*IAMOutgoingMessages_ApplyCertResponse) isIAMOutgoingMessages_IAMOutgoingMessage() {} + +var File_iamanager_v5_iamanager_proto protoreflect.FileDescriptor + +var file_iamanager_v5_iamanager_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x76, 0x35, 0x2f, 0x69, + 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, + 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x1a, 0x1b, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, + 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x6c, 0x0a, 0x0d, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, + 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, + 0xb8, 0x01, 0x0a, 0x07, 0x43, 0x50, 0x55, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x75, + 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6e, + 0x75, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, 0x75, 0x6d, 0x5f, 0x74, + 0x68, 0x72, 0x65, 0x61, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6e, 0x75, + 0x6d, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x72, 0x63, 0x68, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x72, 0x63, 0x68, 0x12, 0x1f, 0x0a, 0x0b, + 0x61, 0x72, 0x63, 0x68, 0x5f, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x61, 0x72, 0x63, 0x68, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x1b, 0x0a, + 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x64, 0x6d, 0x69, 0x70, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x08, 0x6d, 0x61, 0x78, 0x44, 0x6d, 0x69, 0x70, 0x73, 0x22, 0x39, 0x0a, 0x0d, 0x4e, 0x6f, + 0x64, 0x65, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x86, 0x03, 0x0a, 0x08, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6e, + 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x6e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x6f, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, + 0x04, 0x63, 0x70, 0x75, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x69, 0x61, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x43, 0x50, 0x55, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x04, 0x63, 0x70, 0x75, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, + 0x64, 0x6d, 0x69, 0x70, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, + 0x44, 0x6d, 0x69, 0x70, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, + 0x61, 0x6d, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, + 0x61, 0x6d, 0x12, 0x3b, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x31, 0x0a, 0x05, 0x61, 0x74, 0x74, 0x72, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x4e, 0x6f, + 0x64, 0x65, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x52, 0x05, 0x61, 0x74, 0x74, + 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x54, + 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, + 0x72, 0x69, 0x61, 0x6c, 0x22, 0x59, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x63, + 0x65, 0x72, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, + 0x65, 0x72, 0x74, 0x55, 0x72, 0x6c, 0x12, 0x17, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x5f, 0x75, 0x72, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6b, 0x65, 0x79, 0x55, 0x72, 0x6c, 0x22, + 0x48, 0x0a, 0x0a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1b, 0x0a, + 0x09, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x6e, + 0x69, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x75, 0x6e, 0x69, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x22, 0x26, 0x0a, 0x08, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x22, 0x5e, 0x0a, 0x12, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, + 0x30, 0x0a, 0x14, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x66, + 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, + 0x64, 0x22, 0x88, 0x01, 0x0a, 0x13, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, + 0x3b, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x1b, 0x0a, 0x07, + 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x2e, 0x0a, 0x13, 0x47, 0x65, 0x74, + 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0x21, 0x0a, 0x09, 0x43, 0x65, 0x72, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0x75, 0x0a, 0x10, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x22, 0x7e, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x73, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x63, 0x73, 0x72, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x22, 0x53, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x63, 0x65, 0x72, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x11, 0x41, 0x70, 0x70, + 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, + 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x63, + 0x65, 0x72, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, + 0x65, 0x72, 0x74, 0x55, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x12, 0x2a, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x9b, 0x01, 0x0a, 0x0b, 0x50, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4c, 0x0a, 0x0b, 0x70, 0x65, + 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x65, 0x72, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3e, 0x0a, 0x10, 0x50, 0x65, 0x72, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x84, 0x02, 0x0a, 0x17, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, + 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x0b, 0x70, 0x65, + 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x36, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x59, 0x0a, 0x10, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x69, 0x61, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0x32, 0x0a, 0x18, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, + 0x72, 0x65, 0x74, 0x22, 0x51, 0x0a, 0x19, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x2d, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, + 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, + 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0x2b, 0x0a, 0x10, 0x50, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, + 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, + 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x11, 0x50, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x22, 0x2c, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, + 0x64, 0x22, 0x40, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x22, 0x4f, 0x0a, 0x18, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x22, 0x47, 0x0a, 0x19, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x50, 0x0a, + 0x19, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, + 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, + 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, + 0x48, 0x0a, 0x1a, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x49, 0x0a, 0x12, 0x44, 0x65, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x22, 0x41, 0x0a, 0x13, 0x44, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xf0, 0x05, 0x0a, 0x13, 0x49, 0x41, 0x4d, 0x49, + 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, + 0x66, 0x0a, 0x1a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x35, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x18, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x58, 0x0a, 0x16, 0x67, 0x65, 0x74, 0x5f, 0x63, + 0x65, 0x72, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x13, 0x67, 0x65, + 0x74, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x69, 0x0a, 0x1b, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, + 0x00, 0x52, 0x19, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x13, + 0x64, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x12, 0x64, + 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x4e, 0x0a, 0x12, 0x70, 0x61, 0x75, 0x73, 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x61, 0x75, + 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, + 0x10, 0x70, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x51, 0x0a, 0x13, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, 0x65, + 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, + 0x00, 0x52, 0x11, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x4e, 0x0a, 0x12, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x6b, + 0x65, 0x79, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x48, 0x00, 0x52, 0x10, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x4e, 0x0a, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x5f, 0x63, 0x65, + 0x72, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, + 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x48, 0x00, 0x52, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x42, 0x14, 0x0a, 0x12, 0x49, 0x41, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xad, 0x06, 0x0a, 0x13, 0x49, + 0x41, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x73, 0x12, 0x35, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, + 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x69, 0x0a, 0x1b, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, + 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x53, 0x74, + 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x19, 0x73, 0x74, 0x61, 0x72, 0x74, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x13, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, + 0x2e, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x48, 0x00, 0x52, 0x11, 0x63, 0x65, + 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x6c, 0x0a, 0x1c, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, + 0x00, 0x52, 0x1a, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, + 0x14, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x61, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, + 0x52, 0x13, 0x64, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, 0x13, 0x70, 0x61, 0x75, 0x73, 0x65, 0x5f, 0x6e, + 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x35, 0x2e, 0x50, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x11, 0x70, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x14, 0x72, 0x65, 0x73, 0x75, + 0x6d, 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x12, 0x72, 0x65, 0x73, 0x75, + 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, + 0x0a, 0x13, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x61, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x11, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x51, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x41, 0x70, + 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, + 0x00, 0x52, 0x11, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x14, 0x0a, 0x12, 0x49, 0x41, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x9d, 0x01, 0x0a, 0x10, 0x49, + 0x41, 0x4d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x3f, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, + 0x12, 0x48, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x12, 0x1c, 0x2e, 0x69, 0x61, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x65, + 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x69, 0x61, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0xf0, 0x01, 0x0a, 0x18, 0x49, + 0x41, 0x4d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x1a, 0x18, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, + 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x0b, + 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x35, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x00, 0x12, 0x4e, 0x0a, + 0x18, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, + 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x00, 0x30, 0x01, 0x32, 0x76, 0x0a, + 0x1b, 0x49, 0x41, 0x4d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x0e, + 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x20, + 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x65, + 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, + 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0xcc, 0x02, 0x0a, 0x15, 0x49, 0x41, 0x4d, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x40, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x73, + 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x44, 0x22, + 0x00, 0x12, 0x49, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, + 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x35, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x14, + 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x69, + 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x4e, 0x6f, 0x64, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x30, 0x01, 0x12, 0x5a, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x49, 0x41, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x21, 0x2e, 0x69, 0x61, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x49, 0x41, 0x4d, 0x49, 0x6e, + 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x00, + 0x28, 0x01, 0x30, 0x01, 0x32, 0xb4, 0x01, 0x0a, 0x0f, 0x49, 0x41, 0x4d, 0x4e, 0x6f, 0x64, 0x65, + 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x50, 0x61, 0x75, 0x73, + 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x50, 0x61, 0x75, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x51, 0x0a, 0x0a, 0x52, 0x65, 0x73, 0x75, + 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0x8f, 0x03, 0x0a, 0x16, + 0x49, 0x41, 0x4d, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4c, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x69, 0x61, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x73, 0x22, 0x00, 0x12, 0x66, 0x0a, 0x11, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x2e, 0x69, 0x61, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x27, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, + 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x69, 0x0a, 0x12, + 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, + 0x6e, 0x67, 0x12, 0x27, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x35, 0x2e, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x69, 0x61, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x46, 0x69, 0x6e, 0x69, 0x73, + 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0b, 0x44, 0x65, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x44, 0x65, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0xb7, 0x01, + 0x0a, 0x15, 0x49, 0x41, 0x4d, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x35, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x35, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x6c, 0x79, + 0x43, 0x65, 0x72, 0x74, 0x12, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x35, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x35, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0xd5, 0x01, 0x0a, 0x15, 0x49, 0x41, 0x4d, 0x50, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x63, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x25, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x69, + 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x12, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x2e, 0x69, + 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x35, 0x2e, 0x55, 0x6e, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_iamanager_v5_iamanager_proto_rawDescOnce sync.Once + file_iamanager_v5_iamanager_proto_rawDescData = file_iamanager_v5_iamanager_proto_rawDesc +) + +func file_iamanager_v5_iamanager_proto_rawDescGZIP() []byte { + file_iamanager_v5_iamanager_proto_rawDescOnce.Do(func() { + file_iamanager_v5_iamanager_proto_rawDescData = protoimpl.X.CompressGZIP(file_iamanager_v5_iamanager_proto_rawDescData) + }) + return file_iamanager_v5_iamanager_proto_rawDescData +} + +var file_iamanager_v5_iamanager_proto_msgTypes = make([]protoimpl.MessageInfo, 36) +var file_iamanager_v5_iamanager_proto_goTypes = []interface{}{ + (*PartitionInfo)(nil), // 0: iamanager.v5.PartitionInfo + (*CPUInfo)(nil), // 1: iamanager.v5.CPUInfo + (*NodeAttribute)(nil), // 2: iamanager.v5.NodeAttribute + (*NodeInfo)(nil), // 3: iamanager.v5.NodeInfo + (*GetCertRequest)(nil), // 4: iamanager.v5.GetCertRequest + (*GetCertResponse)(nil), // 5: iamanager.v5.GetCertResponse + (*SystemInfo)(nil), // 6: iamanager.v5.SystemInfo + (*Subjects)(nil), // 7: iamanager.v5.Subjects + (*PermissionsRequest)(nil), // 8: iamanager.v5.PermissionsRequest + (*PermissionsResponse)(nil), // 9: iamanager.v5.PermissionsResponse + (*NodesID)(nil), // 10: iamanager.v5.NodesID + (*GetCertTypesRequest)(nil), // 11: iamanager.v5.GetCertTypesRequest + (*CertTypes)(nil), // 12: iamanager.v5.CertTypes + (*CreateKeyRequest)(nil), // 13: iamanager.v5.CreateKeyRequest + (*CreateKeyResponse)(nil), // 14: iamanager.v5.CreateKeyResponse + (*ApplyCertRequest)(nil), // 15: iamanager.v5.ApplyCertRequest + (*ApplyCertResponse)(nil), // 16: iamanager.v5.ApplyCertResponse + (*Permissions)(nil), // 17: iamanager.v5.Permissions + (*RegisterInstanceRequest)(nil), // 18: iamanager.v5.RegisterInstanceRequest + (*RegisterInstanceResponse)(nil), // 19: iamanager.v5.RegisterInstanceResponse + (*UnregisterInstanceRequest)(nil), // 20: iamanager.v5.UnregisterInstanceRequest + (*GetNodeInfoRequest)(nil), // 21: iamanager.v5.GetNodeInfoRequest + (*PauseNodeRequest)(nil), // 22: iamanager.v5.PauseNodeRequest + (*PauseNodeResponse)(nil), // 23: iamanager.v5.PauseNodeResponse + (*ResumeNodeRequest)(nil), // 24: iamanager.v5.ResumeNodeRequest + (*ResumeNodeResponse)(nil), // 25: iamanager.v5.ResumeNodeResponse + (*StartProvisioningRequest)(nil), // 26: iamanager.v5.StartProvisioningRequest + (*StartProvisioningResponse)(nil), // 27: iamanager.v5.StartProvisioningResponse + (*FinishProvisioningRequest)(nil), // 28: iamanager.v5.FinishProvisioningRequest + (*FinishProvisioningResponse)(nil), // 29: iamanager.v5.FinishProvisioningResponse + (*DeprovisionRequest)(nil), // 30: iamanager.v5.DeprovisionRequest + (*DeprovisionResponse)(nil), // 31: iamanager.v5.DeprovisionResponse + (*IAMIncomingMessages)(nil), // 32: iamanager.v5.IAMIncomingMessages + (*IAMOutgoingMessages)(nil), // 33: iamanager.v5.IAMOutgoingMessages + nil, // 34: iamanager.v5.Permissions.PermissionsEntry + nil, // 35: iamanager.v5.RegisterInstanceRequest.PermissionsEntry + (*common.ErrorInfo)(nil), // 36: common.v1.ErrorInfo + (*common.InstanceIdent)(nil), // 37: common.v1.InstanceIdent + (*emptypb.Empty)(nil), // 38: google.protobuf.Empty +} +var file_iamanager_v5_iamanager_proto_depIdxs = []int32{ + 1, // 0: iamanager.v5.NodeInfo.cpus:type_name -> iamanager.v5.CPUInfo + 0, // 1: iamanager.v5.NodeInfo.partitions:type_name -> iamanager.v5.PartitionInfo + 2, // 2: iamanager.v5.NodeInfo.attrs:type_name -> iamanager.v5.NodeAttribute + 36, // 3: iamanager.v5.NodeInfo.error:type_name -> common.v1.ErrorInfo + 37, // 4: iamanager.v5.PermissionsResponse.instance:type_name -> common.v1.InstanceIdent + 17, // 5: iamanager.v5.PermissionsResponse.permissions:type_name -> iamanager.v5.Permissions + 36, // 6: iamanager.v5.CreateKeyResponse.error:type_name -> common.v1.ErrorInfo + 36, // 7: iamanager.v5.ApplyCertResponse.error:type_name -> common.v1.ErrorInfo + 34, // 8: iamanager.v5.Permissions.permissions:type_name -> iamanager.v5.Permissions.PermissionsEntry + 37, // 9: iamanager.v5.RegisterInstanceRequest.instance:type_name -> common.v1.InstanceIdent + 35, // 10: iamanager.v5.RegisterInstanceRequest.permissions:type_name -> iamanager.v5.RegisterInstanceRequest.PermissionsEntry + 37, // 11: iamanager.v5.UnregisterInstanceRequest.instance:type_name -> common.v1.InstanceIdent + 36, // 12: iamanager.v5.PauseNodeResponse.error:type_name -> common.v1.ErrorInfo + 36, // 13: iamanager.v5.ResumeNodeResponse.error:type_name -> common.v1.ErrorInfo + 36, // 14: iamanager.v5.StartProvisioningResponse.error:type_name -> common.v1.ErrorInfo + 36, // 15: iamanager.v5.FinishProvisioningResponse.error:type_name -> common.v1.ErrorInfo + 36, // 16: iamanager.v5.DeprovisionResponse.error:type_name -> common.v1.ErrorInfo + 26, // 17: iamanager.v5.IAMIncomingMessages.start_provisioning_request:type_name -> iamanager.v5.StartProvisioningRequest + 11, // 18: iamanager.v5.IAMIncomingMessages.get_cert_types_request:type_name -> iamanager.v5.GetCertTypesRequest + 28, // 19: iamanager.v5.IAMIncomingMessages.finish_provisioning_request:type_name -> iamanager.v5.FinishProvisioningRequest + 30, // 20: iamanager.v5.IAMIncomingMessages.deprovision_request:type_name -> iamanager.v5.DeprovisionRequest + 22, // 21: iamanager.v5.IAMIncomingMessages.pause_node_request:type_name -> iamanager.v5.PauseNodeRequest + 24, // 22: iamanager.v5.IAMIncomingMessages.resume_node_request:type_name -> iamanager.v5.ResumeNodeRequest + 13, // 23: iamanager.v5.IAMIncomingMessages.create_key_request:type_name -> iamanager.v5.CreateKeyRequest + 15, // 24: iamanager.v5.IAMIncomingMessages.apply_cert_request:type_name -> iamanager.v5.ApplyCertRequest + 3, // 25: iamanager.v5.IAMOutgoingMessages.node_info:type_name -> iamanager.v5.NodeInfo + 27, // 26: iamanager.v5.IAMOutgoingMessages.start_provisioning_response:type_name -> iamanager.v5.StartProvisioningResponse + 12, // 27: iamanager.v5.IAMOutgoingMessages.cert_types_response:type_name -> iamanager.v5.CertTypes + 29, // 28: iamanager.v5.IAMOutgoingMessages.finish_provisioning_response:type_name -> iamanager.v5.FinishProvisioningResponse + 31, // 29: iamanager.v5.IAMOutgoingMessages.deprovision_response:type_name -> iamanager.v5.DeprovisionResponse + 23, // 30: iamanager.v5.IAMOutgoingMessages.pause_node_response:type_name -> iamanager.v5.PauseNodeResponse + 25, // 31: iamanager.v5.IAMOutgoingMessages.resume_node_response:type_name -> iamanager.v5.ResumeNodeResponse + 14, // 32: iamanager.v5.IAMOutgoingMessages.create_key_response:type_name -> iamanager.v5.CreateKeyResponse + 16, // 33: iamanager.v5.IAMOutgoingMessages.apply_cert_response:type_name -> iamanager.v5.ApplyCertResponse + 17, // 34: iamanager.v5.RegisterInstanceRequest.PermissionsEntry.value:type_name -> iamanager.v5.Permissions + 38, // 35: iamanager.v5.IAMPublicService.GetNodeInfo:input_type -> google.protobuf.Empty + 4, // 36: iamanager.v5.IAMPublicService.GetCert:input_type -> iamanager.v5.GetCertRequest + 38, // 37: iamanager.v5.IAMPublicIdentityService.GetSystemInfo:input_type -> google.protobuf.Empty + 38, // 38: iamanager.v5.IAMPublicIdentityService.GetSubjects:input_type -> google.protobuf.Empty + 38, // 39: iamanager.v5.IAMPublicIdentityService.SubscribeSubjectsChanged:input_type -> google.protobuf.Empty + 8, // 40: iamanager.v5.IAMPublicPermissionsService.GetPermissions:input_type -> iamanager.v5.PermissionsRequest + 38, // 41: iamanager.v5.IAMPublicNodesService.GetAllNodeIDs:input_type -> google.protobuf.Empty + 21, // 42: iamanager.v5.IAMPublicNodesService.GetNodeInfo:input_type -> iamanager.v5.GetNodeInfoRequest + 38, // 43: iamanager.v5.IAMPublicNodesService.SubscribeNodeChanged:input_type -> google.protobuf.Empty + 33, // 44: iamanager.v5.IAMPublicNodesService.RegisterNode:input_type -> iamanager.v5.IAMOutgoingMessages + 22, // 45: iamanager.v5.IAMNodesService.PauseNode:input_type -> iamanager.v5.PauseNodeRequest + 24, // 46: iamanager.v5.IAMNodesService.ResumeNode:input_type -> iamanager.v5.ResumeNodeRequest + 11, // 47: iamanager.v5.IAMProvisioningService.GetCertTypes:input_type -> iamanager.v5.GetCertTypesRequest + 26, // 48: iamanager.v5.IAMProvisioningService.StartProvisioning:input_type -> iamanager.v5.StartProvisioningRequest + 28, // 49: iamanager.v5.IAMProvisioningService.FinishProvisioning:input_type -> iamanager.v5.FinishProvisioningRequest + 30, // 50: iamanager.v5.IAMProvisioningService.Deprovision:input_type -> iamanager.v5.DeprovisionRequest + 13, // 51: iamanager.v5.IAMCertificateService.CreateKey:input_type -> iamanager.v5.CreateKeyRequest + 15, // 52: iamanager.v5.IAMCertificateService.ApplyCert:input_type -> iamanager.v5.ApplyCertRequest + 18, // 53: iamanager.v5.IAMPermissionsService.RegisterInstance:input_type -> iamanager.v5.RegisterInstanceRequest + 20, // 54: iamanager.v5.IAMPermissionsService.UnregisterInstance:input_type -> iamanager.v5.UnregisterInstanceRequest + 3, // 55: iamanager.v5.IAMPublicService.GetNodeInfo:output_type -> iamanager.v5.NodeInfo + 5, // 56: iamanager.v5.IAMPublicService.GetCert:output_type -> iamanager.v5.GetCertResponse + 6, // 57: iamanager.v5.IAMPublicIdentityService.GetSystemInfo:output_type -> iamanager.v5.SystemInfo + 7, // 58: iamanager.v5.IAMPublicIdentityService.GetSubjects:output_type -> iamanager.v5.Subjects + 7, // 59: iamanager.v5.IAMPublicIdentityService.SubscribeSubjectsChanged:output_type -> iamanager.v5.Subjects + 9, // 60: iamanager.v5.IAMPublicPermissionsService.GetPermissions:output_type -> iamanager.v5.PermissionsResponse + 10, // 61: iamanager.v5.IAMPublicNodesService.GetAllNodeIDs:output_type -> iamanager.v5.NodesID + 3, // 62: iamanager.v5.IAMPublicNodesService.GetNodeInfo:output_type -> iamanager.v5.NodeInfo + 3, // 63: iamanager.v5.IAMPublicNodesService.SubscribeNodeChanged:output_type -> iamanager.v5.NodeInfo + 32, // 64: iamanager.v5.IAMPublicNodesService.RegisterNode:output_type -> iamanager.v5.IAMIncomingMessages + 23, // 65: iamanager.v5.IAMNodesService.PauseNode:output_type -> iamanager.v5.PauseNodeResponse + 25, // 66: iamanager.v5.IAMNodesService.ResumeNode:output_type -> iamanager.v5.ResumeNodeResponse + 12, // 67: iamanager.v5.IAMProvisioningService.GetCertTypes:output_type -> iamanager.v5.CertTypes + 27, // 68: iamanager.v5.IAMProvisioningService.StartProvisioning:output_type -> iamanager.v5.StartProvisioningResponse + 29, // 69: iamanager.v5.IAMProvisioningService.FinishProvisioning:output_type -> iamanager.v5.FinishProvisioningResponse + 31, // 70: iamanager.v5.IAMProvisioningService.Deprovision:output_type -> iamanager.v5.DeprovisionResponse + 14, // 71: iamanager.v5.IAMCertificateService.CreateKey:output_type -> iamanager.v5.CreateKeyResponse + 16, // 72: iamanager.v5.IAMCertificateService.ApplyCert:output_type -> iamanager.v5.ApplyCertResponse + 19, // 73: iamanager.v5.IAMPermissionsService.RegisterInstance:output_type -> iamanager.v5.RegisterInstanceResponse + 38, // 74: iamanager.v5.IAMPermissionsService.UnregisterInstance:output_type -> google.protobuf.Empty + 55, // [55:75] is the sub-list for method output_type + 35, // [35:55] is the sub-list for method input_type + 35, // [35:35] is the sub-list for extension type_name + 35, // [35:35] is the sub-list for extension extendee + 0, // [0:35] is the sub-list for field type_name +} + +func init() { file_iamanager_v5_iamanager_proto_init() } +func file_iamanager_v5_iamanager_proto_init() { + if File_iamanager_v5_iamanager_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_iamanager_v5_iamanager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PartitionInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CPUInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodeAttribute); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodeInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCertRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCertResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SystemInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Subjects); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PermissionsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PermissionsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NodesID); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCertTypesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CertTypes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateKeyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateKeyResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyCertRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyCertResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Permissions); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterInstanceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterInstanceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UnregisterInstanceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetNodeInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PauseNodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PauseNodeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResumeNodeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResumeNodeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartProvisioningRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartProvisioningResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FinishProvisioningRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FinishProvisioningResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeprovisionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeprovisionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IAMIncomingMessages); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_iamanager_v5_iamanager_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IAMOutgoingMessages); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_iamanager_v5_iamanager_proto_msgTypes[32].OneofWrappers = []interface{}{ + (*IAMIncomingMessages_StartProvisioningRequest)(nil), + (*IAMIncomingMessages_GetCertTypesRequest)(nil), + (*IAMIncomingMessages_FinishProvisioningRequest)(nil), + (*IAMIncomingMessages_DeprovisionRequest)(nil), + (*IAMIncomingMessages_PauseNodeRequest)(nil), + (*IAMIncomingMessages_ResumeNodeRequest)(nil), + (*IAMIncomingMessages_CreateKeyRequest)(nil), + (*IAMIncomingMessages_ApplyCertRequest)(nil), + } + file_iamanager_v5_iamanager_proto_msgTypes[33].OneofWrappers = []interface{}{ + (*IAMOutgoingMessages_NodeInfo)(nil), + (*IAMOutgoingMessages_StartProvisioningResponse)(nil), + (*IAMOutgoingMessages_CertTypesResponse)(nil), + (*IAMOutgoingMessages_FinishProvisioningResponse)(nil), + (*IAMOutgoingMessages_DeprovisionResponse)(nil), + (*IAMOutgoingMessages_PauseNodeResponse)(nil), + (*IAMOutgoingMessages_ResumeNodeResponse)(nil), + (*IAMOutgoingMessages_CreateKeyResponse)(nil), + (*IAMOutgoingMessages_ApplyCertResponse)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_iamanager_v5_iamanager_proto_rawDesc, + NumEnums: 0, + NumMessages: 36, + NumExtensions: 0, + NumServices: 8, + }, + GoTypes: file_iamanager_v5_iamanager_proto_goTypes, + DependencyIndexes: file_iamanager_v5_iamanager_proto_depIdxs, + MessageInfos: file_iamanager_v5_iamanager_proto_msgTypes, + }.Build() + File_iamanager_v5_iamanager_proto = out.File + file_iamanager_v5_iamanager_proto_rawDesc = nil + file_iamanager_v5_iamanager_proto_goTypes = nil + file_iamanager_v5_iamanager_proto_depIdxs = nil +} diff --git a/vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager_grpc.pb.go b/vendor/github.com/aosedge/aos_common/api/iamanager/iamanager_grpc.pb.go similarity index 59% rename from vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager_grpc.pb.go rename to vendor/github.com/aosedge/aos_common/api/iamanager/iamanager_grpc.pb.go index 27f9b014..dd5d5939 100644 --- a/vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager_grpc.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/iamanager/iamanager_grpc.pb.go @@ -1,17 +1,17 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.12.4 -// source: iamanager/v4/iamanager.proto +// - protoc v5.26.0 +// source: iamanager/v5/iamanager.proto package iamanager import ( context "context" - empty "github.com/golang/protobuf/ptypes/empty" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -23,8 +23,7 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type IAMPublicServiceClient interface { - GetAPIVersion(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*APIVersion, error) - GetNodeInfo(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodeInfo, error) + GetNodeInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NodeInfo, error) GetCert(ctx context.Context, in *GetCertRequest, opts ...grpc.CallOption) (*GetCertResponse, error) } @@ -36,18 +35,9 @@ func NewIAMPublicServiceClient(cc grpc.ClientConnInterface) IAMPublicServiceClie return &iAMPublicServiceClient{cc} } -func (c *iAMPublicServiceClient) GetAPIVersion(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*APIVersion, error) { - out := new(APIVersion) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPublicService/GetAPIVersion", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *iAMPublicServiceClient) GetNodeInfo(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodeInfo, error) { +func (c *iAMPublicServiceClient) GetNodeInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NodeInfo, error) { out := new(NodeInfo) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPublicService/GetNodeInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicService/GetNodeInfo", in, out, opts...) if err != nil { return nil, err } @@ -56,7 +46,7 @@ func (c *iAMPublicServiceClient) GetNodeInfo(ctx context.Context, in *empty.Empt func (c *iAMPublicServiceClient) GetCert(ctx context.Context, in *GetCertRequest, opts ...grpc.CallOption) (*GetCertResponse, error) { out := new(GetCertResponse) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPublicService/GetCert", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicService/GetCert", in, out, opts...) if err != nil { return nil, err } @@ -67,8 +57,7 @@ func (c *iAMPublicServiceClient) GetCert(ctx context.Context, in *GetCertRequest // All implementations must embed UnimplementedIAMPublicServiceServer // for forward compatibility type IAMPublicServiceServer interface { - GetAPIVersion(context.Context, *empty.Empty) (*APIVersion, error) - GetNodeInfo(context.Context, *empty.Empty) (*NodeInfo, error) + GetNodeInfo(context.Context, *emptypb.Empty) (*NodeInfo, error) GetCert(context.Context, *GetCertRequest) (*GetCertResponse, error) mustEmbedUnimplementedIAMPublicServiceServer() } @@ -77,10 +66,7 @@ type IAMPublicServiceServer interface { type UnimplementedIAMPublicServiceServer struct { } -func (UnimplementedIAMPublicServiceServer) GetAPIVersion(context.Context, *empty.Empty) (*APIVersion, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAPIVersion not implemented") -} -func (UnimplementedIAMPublicServiceServer) GetNodeInfo(context.Context, *empty.Empty) (*NodeInfo, error) { +func (UnimplementedIAMPublicServiceServer) GetNodeInfo(context.Context, *emptypb.Empty) (*NodeInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetNodeInfo not implemented") } func (UnimplementedIAMPublicServiceServer) GetCert(context.Context, *GetCertRequest) (*GetCertResponse, error) { @@ -99,26 +85,8 @@ func RegisterIAMPublicServiceServer(s grpc.ServiceRegistrar, srv IAMPublicServic s.RegisterService(&IAMPublicService_ServiceDesc, srv) } -func _IAMPublicService_GetAPIVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(IAMPublicServiceServer).GetAPIVersion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/iamanager.v4.IAMPublicService/GetAPIVersion", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMPublicServiceServer).GetAPIVersion(ctx, req.(*empty.Empty)) - } - return interceptor(ctx, in, info, handler) -} - func _IAMPublicService_GetNodeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) + in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } @@ -127,10 +95,10 @@ func _IAMPublicService_GetNodeInfo_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPublicService/GetNodeInfo", + FullMethod: "/iamanager.v5.IAMPublicService/GetNodeInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMPublicServiceServer).GetNodeInfo(ctx, req.(*empty.Empty)) + return srv.(IAMPublicServiceServer).GetNodeInfo(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } @@ -145,7 +113,7 @@ func _IAMPublicService_GetCert_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPublicService/GetCert", + FullMethod: "/iamanager.v5.IAMPublicService/GetCert", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(IAMPublicServiceServer).GetCert(ctx, req.(*GetCertRequest)) @@ -157,13 +125,9 @@ func _IAMPublicService_GetCert_Handler(srv interface{}, ctx context.Context, dec // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var IAMPublicService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "iamanager.v4.IAMPublicService", + ServiceName: "iamanager.v5.IAMPublicService", HandlerType: (*IAMPublicServiceServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "GetAPIVersion", - Handler: _IAMPublicService_GetAPIVersion_Handler, - }, { MethodName: "GetNodeInfo", Handler: _IAMPublicService_GetNodeInfo_Handler, @@ -174,16 +138,16 @@ var IAMPublicService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "iamanager/v4/iamanager.proto", + Metadata: "iamanager/v5/iamanager.proto", } // IAMPublicIdentityServiceClient is the client API for IAMPublicIdentityService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type IAMPublicIdentityServiceClient interface { - GetSystemInfo(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*SystemInfo, error) - GetSubjects(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Subjects, error) - SubscribeSubjectsChanged(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (IAMPublicIdentityService_SubscribeSubjectsChangedClient, error) + GetSystemInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SystemInfo, error) + GetSubjects(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Subjects, error) + SubscribeSubjectsChanged(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (IAMPublicIdentityService_SubscribeSubjectsChangedClient, error) } type iAMPublicIdentityServiceClient struct { @@ -194,26 +158,26 @@ func NewIAMPublicIdentityServiceClient(cc grpc.ClientConnInterface) IAMPublicIde return &iAMPublicIdentityServiceClient{cc} } -func (c *iAMPublicIdentityServiceClient) GetSystemInfo(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*SystemInfo, error) { +func (c *iAMPublicIdentityServiceClient) GetSystemInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SystemInfo, error) { out := new(SystemInfo) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPublicIdentityService/GetSystemInfo", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicIdentityService/GetSystemInfo", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *iAMPublicIdentityServiceClient) GetSubjects(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*Subjects, error) { +func (c *iAMPublicIdentityServiceClient) GetSubjects(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Subjects, error) { out := new(Subjects) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPublicIdentityService/GetSubjects", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicIdentityService/GetSubjects", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *iAMPublicIdentityServiceClient) SubscribeSubjectsChanged(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (IAMPublicIdentityService_SubscribeSubjectsChangedClient, error) { - stream, err := c.cc.NewStream(ctx, &IAMPublicIdentityService_ServiceDesc.Streams[0], "/iamanager.v4.IAMPublicIdentityService/SubscribeSubjectsChanged", opts...) +func (c *iAMPublicIdentityServiceClient) SubscribeSubjectsChanged(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (IAMPublicIdentityService_SubscribeSubjectsChangedClient, error) { + stream, err := c.cc.NewStream(ctx, &IAMPublicIdentityService_ServiceDesc.Streams[0], "/iamanager.v5.IAMPublicIdentityService/SubscribeSubjectsChanged", opts...) if err != nil { return nil, err } @@ -248,9 +212,9 @@ func (x *iAMPublicIdentityServiceSubscribeSubjectsChangedClient) Recv() (*Subjec // All implementations must embed UnimplementedIAMPublicIdentityServiceServer // for forward compatibility type IAMPublicIdentityServiceServer interface { - GetSystemInfo(context.Context, *empty.Empty) (*SystemInfo, error) - GetSubjects(context.Context, *empty.Empty) (*Subjects, error) - SubscribeSubjectsChanged(*empty.Empty, IAMPublicIdentityService_SubscribeSubjectsChangedServer) error + GetSystemInfo(context.Context, *emptypb.Empty) (*SystemInfo, error) + GetSubjects(context.Context, *emptypb.Empty) (*Subjects, error) + SubscribeSubjectsChanged(*emptypb.Empty, IAMPublicIdentityService_SubscribeSubjectsChangedServer) error mustEmbedUnimplementedIAMPublicIdentityServiceServer() } @@ -258,13 +222,13 @@ type IAMPublicIdentityServiceServer interface { type UnimplementedIAMPublicIdentityServiceServer struct { } -func (UnimplementedIAMPublicIdentityServiceServer) GetSystemInfo(context.Context, *empty.Empty) (*SystemInfo, error) { +func (UnimplementedIAMPublicIdentityServiceServer) GetSystemInfo(context.Context, *emptypb.Empty) (*SystemInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSystemInfo not implemented") } -func (UnimplementedIAMPublicIdentityServiceServer) GetSubjects(context.Context, *empty.Empty) (*Subjects, error) { +func (UnimplementedIAMPublicIdentityServiceServer) GetSubjects(context.Context, *emptypb.Empty) (*Subjects, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSubjects not implemented") } -func (UnimplementedIAMPublicIdentityServiceServer) SubscribeSubjectsChanged(*empty.Empty, IAMPublicIdentityService_SubscribeSubjectsChangedServer) error { +func (UnimplementedIAMPublicIdentityServiceServer) SubscribeSubjectsChanged(*emptypb.Empty, IAMPublicIdentityService_SubscribeSubjectsChangedServer) error { return status.Errorf(codes.Unimplemented, "method SubscribeSubjectsChanged not implemented") } func (UnimplementedIAMPublicIdentityServiceServer) mustEmbedUnimplementedIAMPublicIdentityServiceServer() { @@ -282,7 +246,7 @@ func RegisterIAMPublicIdentityServiceServer(s grpc.ServiceRegistrar, srv IAMPubl } func _IAMPublicIdentityService_GetSystemInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) + in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } @@ -291,16 +255,16 @@ func _IAMPublicIdentityService_GetSystemInfo_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPublicIdentityService/GetSystemInfo", + FullMethod: "/iamanager.v5.IAMPublicIdentityService/GetSystemInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMPublicIdentityServiceServer).GetSystemInfo(ctx, req.(*empty.Empty)) + return srv.(IAMPublicIdentityServiceServer).GetSystemInfo(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _IAMPublicIdentityService_GetSubjects_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) + in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } @@ -309,16 +273,16 @@ func _IAMPublicIdentityService_GetSubjects_Handler(srv interface{}, ctx context. } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPublicIdentityService/GetSubjects", + FullMethod: "/iamanager.v5.IAMPublicIdentityService/GetSubjects", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMPublicIdentityServiceServer).GetSubjects(ctx, req.(*empty.Empty)) + return srv.(IAMPublicIdentityServiceServer).GetSubjects(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _IAMPublicIdentityService_SubscribeSubjectsChanged_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(empty.Empty) + m := new(emptypb.Empty) if err := stream.RecvMsg(m); err != nil { return err } @@ -342,7 +306,7 @@ func (x *iAMPublicIdentityServiceSubscribeSubjectsChangedServer) Send(m *Subject // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var IAMPublicIdentityService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "iamanager.v4.IAMPublicIdentityService", + ServiceName: "iamanager.v5.IAMPublicIdentityService", HandlerType: (*IAMPublicIdentityServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -361,7 +325,7 @@ var IAMPublicIdentityService_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "iamanager/v4/iamanager.proto", + Metadata: "iamanager/v5/iamanager.proto", } // IAMPublicPermissionsServiceClient is the client API for IAMPublicPermissionsService service. @@ -381,7 +345,7 @@ func NewIAMPublicPermissionsServiceClient(cc grpc.ClientConnInterface) IAMPublic func (c *iAMPublicPermissionsServiceClient) GetPermissions(ctx context.Context, in *PermissionsRequest, opts ...grpc.CallOption) (*PermissionsResponse, error) { out := new(PermissionsResponse) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPublicPermissionsService/GetPermissions", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicPermissionsService/GetPermissions", in, out, opts...) if err != nil { return nil, err } @@ -427,7 +391,7 @@ func _IAMPublicPermissionsService_GetPermissions_Handler(srv interface{}, ctx co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPublicPermissionsService/GetPermissions", + FullMethod: "/iamanager.v5.IAMPublicPermissionsService/GetPermissions", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(IAMPublicPermissionsServiceServer).GetPermissions(ctx, req.(*PermissionsRequest)) @@ -439,7 +403,7 @@ func _IAMPublicPermissionsService_GetPermissions_Handler(srv interface{}, ctx co // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var IAMPublicPermissionsService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "iamanager.v4.IAMPublicPermissionsService", + ServiceName: "iamanager.v5.IAMPublicPermissionsService", HandlerType: (*IAMPublicPermissionsServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -448,236 +412,548 @@ var IAMPublicPermissionsService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "iamanager/v4/iamanager.proto", + Metadata: "iamanager/v5/iamanager.proto", } -// IAMProvisioningServiceClient is the client API for IAMProvisioningService service. +// IAMPublicNodesServiceClient is the client API for IAMPublicNodesService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type IAMProvisioningServiceClient interface { - GetAllNodeIDs(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodesID, error) - GetCertTypes(ctx context.Context, in *GetCertTypesRequest, opts ...grpc.CallOption) (*CertTypes, error) - SetOwner(ctx context.Context, in *SetOwnerRequest, opts ...grpc.CallOption) (*empty.Empty, error) - Clear(ctx context.Context, in *ClearRequest, opts ...grpc.CallOption) (*empty.Empty, error) - EncryptDisk(ctx context.Context, in *EncryptDiskRequest, opts ...grpc.CallOption) (*empty.Empty, error) - FinishProvisioning(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) +type IAMPublicNodesServiceClient interface { + GetAllNodeIDs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NodesID, error) + GetNodeInfo(ctx context.Context, in *GetNodeInfoRequest, opts ...grpc.CallOption) (*NodeInfo, error) + SubscribeNodeChanged(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (IAMPublicNodesService_SubscribeNodeChangedClient, error) + RegisterNode(ctx context.Context, opts ...grpc.CallOption) (IAMPublicNodesService_RegisterNodeClient, error) } -type iAMProvisioningServiceClient struct { +type iAMPublicNodesServiceClient struct { cc grpc.ClientConnInterface } -func NewIAMProvisioningServiceClient(cc grpc.ClientConnInterface) IAMProvisioningServiceClient { - return &iAMProvisioningServiceClient{cc} +func NewIAMPublicNodesServiceClient(cc grpc.ClientConnInterface) IAMPublicNodesServiceClient { + return &iAMPublicNodesServiceClient{cc} } -func (c *iAMProvisioningServiceClient) GetAllNodeIDs(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*NodesID, error) { +func (c *iAMPublicNodesServiceClient) GetAllNodeIDs(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*NodesID, error) { out := new(NodesID) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMProvisioningService/GetAllNodeIDs", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicNodesService/GetAllNodeIDs", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *iAMProvisioningServiceClient) GetCertTypes(ctx context.Context, in *GetCertTypesRequest, opts ...grpc.CallOption) (*CertTypes, error) { - out := new(CertTypes) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMProvisioningService/GetCertTypes", in, out, opts...) +func (c *iAMPublicNodesServiceClient) GetNodeInfo(ctx context.Context, in *GetNodeInfoRequest, opts ...grpc.CallOption) (*NodeInfo, error) { + out := new(NodeInfo) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPublicNodesService/GetNodeInfo", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *iAMProvisioningServiceClient) SetOwner(ctx context.Context, in *SetOwnerRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMProvisioningService/SetOwner", in, out, opts...) +func (c *iAMPublicNodesServiceClient) SubscribeNodeChanged(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (IAMPublicNodesService_SubscribeNodeChangedClient, error) { + stream, err := c.cc.NewStream(ctx, &IAMPublicNodesService_ServiceDesc.Streams[0], "/iamanager.v5.IAMPublicNodesService/SubscribeNodeChanged", opts...) if err != nil { return nil, err } - return out, nil + x := &iAMPublicNodesServiceSubscribeNodeChangedClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil } -func (c *iAMProvisioningServiceClient) Clear(ctx context.Context, in *ClearRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMProvisioningService/Clear", in, out, opts...) - if err != nil { +type IAMPublicNodesService_SubscribeNodeChangedClient interface { + Recv() (*NodeInfo, error) + grpc.ClientStream +} + +type iAMPublicNodesServiceSubscribeNodeChangedClient struct { + grpc.ClientStream +} + +func (x *iAMPublicNodesServiceSubscribeNodeChangedClient) Recv() (*NodeInfo, error) { + m := new(NodeInfo) + if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } - return out, nil + return m, nil } -func (c *iAMProvisioningServiceClient) EncryptDisk(ctx context.Context, in *EncryptDiskRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMProvisioningService/EncryptDisk", in, out, opts...) +func (c *iAMPublicNodesServiceClient) RegisterNode(ctx context.Context, opts ...grpc.CallOption) (IAMPublicNodesService_RegisterNodeClient, error) { + stream, err := c.cc.NewStream(ctx, &IAMPublicNodesService_ServiceDesc.Streams[1], "/iamanager.v5.IAMPublicNodesService/RegisterNode", opts...) if err != nil { return nil, err } - return out, nil + x := &iAMPublicNodesServiceRegisterNodeClient{stream} + return x, nil } -func (c *iAMProvisioningServiceClient) FinishProvisioning(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMProvisioningService/FinishProvisioning", in, out, opts...) - if err != nil { +type IAMPublicNodesService_RegisterNodeClient interface { + Send(*IAMOutgoingMessages) error + Recv() (*IAMIncomingMessages, error) + grpc.ClientStream +} + +type iAMPublicNodesServiceRegisterNodeClient struct { + grpc.ClientStream +} + +func (x *iAMPublicNodesServiceRegisterNodeClient) Send(m *IAMOutgoingMessages) error { + return x.ClientStream.SendMsg(m) +} + +func (x *iAMPublicNodesServiceRegisterNodeClient) Recv() (*IAMIncomingMessages, error) { + m := new(IAMIncomingMessages) + if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } - return out, nil + return m, nil } -// IAMProvisioningServiceServer is the server API for IAMProvisioningService service. -// All implementations must embed UnimplementedIAMProvisioningServiceServer +// IAMPublicNodesServiceServer is the server API for IAMPublicNodesService service. +// All implementations must embed UnimplementedIAMPublicNodesServiceServer // for forward compatibility -type IAMProvisioningServiceServer interface { - GetAllNodeIDs(context.Context, *empty.Empty) (*NodesID, error) - GetCertTypes(context.Context, *GetCertTypesRequest) (*CertTypes, error) - SetOwner(context.Context, *SetOwnerRequest) (*empty.Empty, error) - Clear(context.Context, *ClearRequest) (*empty.Empty, error) - EncryptDisk(context.Context, *EncryptDiskRequest) (*empty.Empty, error) - FinishProvisioning(context.Context, *empty.Empty) (*empty.Empty, error) - mustEmbedUnimplementedIAMProvisioningServiceServer() +type IAMPublicNodesServiceServer interface { + GetAllNodeIDs(context.Context, *emptypb.Empty) (*NodesID, error) + GetNodeInfo(context.Context, *GetNodeInfoRequest) (*NodeInfo, error) + SubscribeNodeChanged(*emptypb.Empty, IAMPublicNodesService_SubscribeNodeChangedServer) error + RegisterNode(IAMPublicNodesService_RegisterNodeServer) error + mustEmbedUnimplementedIAMPublicNodesServiceServer() } -// UnimplementedIAMProvisioningServiceServer must be embedded to have forward compatible implementations. -type UnimplementedIAMProvisioningServiceServer struct { +// UnimplementedIAMPublicNodesServiceServer must be embedded to have forward compatible implementations. +type UnimplementedIAMPublicNodesServiceServer struct { } -func (UnimplementedIAMProvisioningServiceServer) GetAllNodeIDs(context.Context, *empty.Empty) (*NodesID, error) { +func (UnimplementedIAMPublicNodesServiceServer) GetAllNodeIDs(context.Context, *emptypb.Empty) (*NodesID, error) { return nil, status.Errorf(codes.Unimplemented, "method GetAllNodeIDs not implemented") } -func (UnimplementedIAMProvisioningServiceServer) GetCertTypes(context.Context, *GetCertTypesRequest) (*CertTypes, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCertTypes not implemented") +func (UnimplementedIAMPublicNodesServiceServer) GetNodeInfo(context.Context, *GetNodeInfoRequest) (*NodeInfo, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetNodeInfo not implemented") } -func (UnimplementedIAMProvisioningServiceServer) SetOwner(context.Context, *SetOwnerRequest) (*empty.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetOwner not implemented") +func (UnimplementedIAMPublicNodesServiceServer) SubscribeNodeChanged(*emptypb.Empty, IAMPublicNodesService_SubscribeNodeChangedServer) error { + return status.Errorf(codes.Unimplemented, "method SubscribeNodeChanged not implemented") } -func (UnimplementedIAMProvisioningServiceServer) Clear(context.Context, *ClearRequest) (*empty.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Clear not implemented") +func (UnimplementedIAMPublicNodesServiceServer) RegisterNode(IAMPublicNodesService_RegisterNodeServer) error { + return status.Errorf(codes.Unimplemented, "method RegisterNode not implemented") } -func (UnimplementedIAMProvisioningServiceServer) EncryptDisk(context.Context, *EncryptDiskRequest) (*empty.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method EncryptDisk not implemented") +func (UnimplementedIAMPublicNodesServiceServer) mustEmbedUnimplementedIAMPublicNodesServiceServer() {} + +// UnsafeIAMPublicNodesServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to IAMPublicNodesServiceServer will +// result in compilation errors. +type UnsafeIAMPublicNodesServiceServer interface { + mustEmbedUnimplementedIAMPublicNodesServiceServer() } -func (UnimplementedIAMProvisioningServiceServer) FinishProvisioning(context.Context, *empty.Empty) (*empty.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinishProvisioning not implemented") + +func RegisterIAMPublicNodesServiceServer(s grpc.ServiceRegistrar, srv IAMPublicNodesServiceServer) { + s.RegisterService(&IAMPublicNodesService_ServiceDesc, srv) } -func (UnimplementedIAMProvisioningServiceServer) mustEmbedUnimplementedIAMProvisioningServiceServer() { + +func _IAMPublicNodesService_GetAllNodeIDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IAMPublicNodesServiceServer).GetAllNodeIDs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/iamanager.v5.IAMPublicNodesService/GetAllNodeIDs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IAMPublicNodesServiceServer).GetAllNodeIDs(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) } -// UnsafeIAMProvisioningServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to IAMProvisioningServiceServer will +func _IAMPublicNodesService_GetNodeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetNodeInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IAMPublicNodesServiceServer).GetNodeInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/iamanager.v5.IAMPublicNodesService/GetNodeInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IAMPublicNodesServiceServer).GetNodeInfo(ctx, req.(*GetNodeInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _IAMPublicNodesService_SubscribeNodeChanged_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(emptypb.Empty) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(IAMPublicNodesServiceServer).SubscribeNodeChanged(m, &iAMPublicNodesServiceSubscribeNodeChangedServer{stream}) +} + +type IAMPublicNodesService_SubscribeNodeChangedServer interface { + Send(*NodeInfo) error + grpc.ServerStream +} + +type iAMPublicNodesServiceSubscribeNodeChangedServer struct { + grpc.ServerStream +} + +func (x *iAMPublicNodesServiceSubscribeNodeChangedServer) Send(m *NodeInfo) error { + return x.ServerStream.SendMsg(m) +} + +func _IAMPublicNodesService_RegisterNode_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(IAMPublicNodesServiceServer).RegisterNode(&iAMPublicNodesServiceRegisterNodeServer{stream}) +} + +type IAMPublicNodesService_RegisterNodeServer interface { + Send(*IAMIncomingMessages) error + Recv() (*IAMOutgoingMessages, error) + grpc.ServerStream +} + +type iAMPublicNodesServiceRegisterNodeServer struct { + grpc.ServerStream +} + +func (x *iAMPublicNodesServiceRegisterNodeServer) Send(m *IAMIncomingMessages) error { + return x.ServerStream.SendMsg(m) +} + +func (x *iAMPublicNodesServiceRegisterNodeServer) Recv() (*IAMOutgoingMessages, error) { + m := new(IAMOutgoingMessages) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// IAMPublicNodesService_ServiceDesc is the grpc.ServiceDesc for IAMPublicNodesService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var IAMPublicNodesService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "iamanager.v5.IAMPublicNodesService", + HandlerType: (*IAMPublicNodesServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetAllNodeIDs", + Handler: _IAMPublicNodesService_GetAllNodeIDs_Handler, + }, + { + MethodName: "GetNodeInfo", + Handler: _IAMPublicNodesService_GetNodeInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "SubscribeNodeChanged", + Handler: _IAMPublicNodesService_SubscribeNodeChanged_Handler, + ServerStreams: true, + }, + { + StreamName: "RegisterNode", + Handler: _IAMPublicNodesService_RegisterNode_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "iamanager/v5/iamanager.proto", +} + +// IAMNodesServiceClient is the client API for IAMNodesService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type IAMNodesServiceClient interface { + PauseNode(ctx context.Context, in *PauseNodeRequest, opts ...grpc.CallOption) (*PauseNodeResponse, error) + ResumeNode(ctx context.Context, in *ResumeNodeRequest, opts ...grpc.CallOption) (*ResumeNodeResponse, error) +} + +type iAMNodesServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewIAMNodesServiceClient(cc grpc.ClientConnInterface) IAMNodesServiceClient { + return &iAMNodesServiceClient{cc} +} + +func (c *iAMNodesServiceClient) PauseNode(ctx context.Context, in *PauseNodeRequest, opts ...grpc.CallOption) (*PauseNodeResponse, error) { + out := new(PauseNodeResponse) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMNodesService/PauseNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *iAMNodesServiceClient) ResumeNode(ctx context.Context, in *ResumeNodeRequest, opts ...grpc.CallOption) (*ResumeNodeResponse, error) { + out := new(ResumeNodeResponse) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMNodesService/ResumeNode", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// IAMNodesServiceServer is the server API for IAMNodesService service. +// All implementations must embed UnimplementedIAMNodesServiceServer +// for forward compatibility +type IAMNodesServiceServer interface { + PauseNode(context.Context, *PauseNodeRequest) (*PauseNodeResponse, error) + ResumeNode(context.Context, *ResumeNodeRequest) (*ResumeNodeResponse, error) + mustEmbedUnimplementedIAMNodesServiceServer() +} + +// UnimplementedIAMNodesServiceServer must be embedded to have forward compatible implementations. +type UnimplementedIAMNodesServiceServer struct { +} + +func (UnimplementedIAMNodesServiceServer) PauseNode(context.Context, *PauseNodeRequest) (*PauseNodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PauseNode not implemented") +} +func (UnimplementedIAMNodesServiceServer) ResumeNode(context.Context, *ResumeNodeRequest) (*ResumeNodeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ResumeNode not implemented") +} +func (UnimplementedIAMNodesServiceServer) mustEmbedUnimplementedIAMNodesServiceServer() {} + +// UnsafeIAMNodesServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to IAMNodesServiceServer will // result in compilation errors. -type UnsafeIAMProvisioningServiceServer interface { - mustEmbedUnimplementedIAMProvisioningServiceServer() +type UnsafeIAMNodesServiceServer interface { + mustEmbedUnimplementedIAMNodesServiceServer() } -func RegisterIAMProvisioningServiceServer(s grpc.ServiceRegistrar, srv IAMProvisioningServiceServer) { - s.RegisterService(&IAMProvisioningService_ServiceDesc, srv) +func RegisterIAMNodesServiceServer(s grpc.ServiceRegistrar, srv IAMNodesServiceServer) { + s.RegisterService(&IAMNodesService_ServiceDesc, srv) } -func _IAMProvisioningService_GetAllNodeIDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) +func _IAMNodesService_PauseNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PauseNodeRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IAMProvisioningServiceServer).GetAllNodeIDs(ctx, in) + return srv.(IAMNodesServiceServer).PauseNode(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMProvisioningService/GetAllNodeIDs", + FullMethod: "/iamanager.v5.IAMNodesService/PauseNode", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMProvisioningServiceServer).GetAllNodeIDs(ctx, req.(*empty.Empty)) + return srv.(IAMNodesServiceServer).PauseNode(ctx, req.(*PauseNodeRequest)) } return interceptor(ctx, in, info, handler) } -func _IAMProvisioningService_GetCertTypes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetCertTypesRequest) +func _IAMNodesService_ResumeNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ResumeNodeRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IAMProvisioningServiceServer).GetCertTypes(ctx, in) + return srv.(IAMNodesServiceServer).ResumeNode(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMProvisioningService/GetCertTypes", + FullMethod: "/iamanager.v5.IAMNodesService/ResumeNode", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMProvisioningServiceServer).GetCertTypes(ctx, req.(*GetCertTypesRequest)) + return srv.(IAMNodesServiceServer).ResumeNode(ctx, req.(*ResumeNodeRequest)) } return interceptor(ctx, in, info, handler) } -func _IAMProvisioningService_SetOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetOwnerRequest) +// IAMNodesService_ServiceDesc is the grpc.ServiceDesc for IAMNodesService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var IAMNodesService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "iamanager.v5.IAMNodesService", + HandlerType: (*IAMNodesServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PauseNode", + Handler: _IAMNodesService_PauseNode_Handler, + }, + { + MethodName: "ResumeNode", + Handler: _IAMNodesService_ResumeNode_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "iamanager/v5/iamanager.proto", +} + +// IAMProvisioningServiceClient is the client API for IAMProvisioningService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type IAMProvisioningServiceClient interface { + GetCertTypes(ctx context.Context, in *GetCertTypesRequest, opts ...grpc.CallOption) (*CertTypes, error) + StartProvisioning(ctx context.Context, in *StartProvisioningRequest, opts ...grpc.CallOption) (*StartProvisioningResponse, error) + FinishProvisioning(ctx context.Context, in *FinishProvisioningRequest, opts ...grpc.CallOption) (*FinishProvisioningResponse, error) + Deprovision(ctx context.Context, in *DeprovisionRequest, opts ...grpc.CallOption) (*DeprovisionResponse, error) +} + +type iAMProvisioningServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewIAMProvisioningServiceClient(cc grpc.ClientConnInterface) IAMProvisioningServiceClient { + return &iAMProvisioningServiceClient{cc} +} + +func (c *iAMProvisioningServiceClient) GetCertTypes(ctx context.Context, in *GetCertTypesRequest, opts ...grpc.CallOption) (*CertTypes, error) { + out := new(CertTypes) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMProvisioningService/GetCertTypes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *iAMProvisioningServiceClient) StartProvisioning(ctx context.Context, in *StartProvisioningRequest, opts ...grpc.CallOption) (*StartProvisioningResponse, error) { + out := new(StartProvisioningResponse) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMProvisioningService/StartProvisioning", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *iAMProvisioningServiceClient) FinishProvisioning(ctx context.Context, in *FinishProvisioningRequest, opts ...grpc.CallOption) (*FinishProvisioningResponse, error) { + out := new(FinishProvisioningResponse) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMProvisioningService/FinishProvisioning", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *iAMProvisioningServiceClient) Deprovision(ctx context.Context, in *DeprovisionRequest, opts ...grpc.CallOption) (*DeprovisionResponse, error) { + out := new(DeprovisionResponse) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMProvisioningService/Deprovision", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// IAMProvisioningServiceServer is the server API for IAMProvisioningService service. +// All implementations must embed UnimplementedIAMProvisioningServiceServer +// for forward compatibility +type IAMProvisioningServiceServer interface { + GetCertTypes(context.Context, *GetCertTypesRequest) (*CertTypes, error) + StartProvisioning(context.Context, *StartProvisioningRequest) (*StartProvisioningResponse, error) + FinishProvisioning(context.Context, *FinishProvisioningRequest) (*FinishProvisioningResponse, error) + Deprovision(context.Context, *DeprovisionRequest) (*DeprovisionResponse, error) + mustEmbedUnimplementedIAMProvisioningServiceServer() +} + +// UnimplementedIAMProvisioningServiceServer must be embedded to have forward compatible implementations. +type UnimplementedIAMProvisioningServiceServer struct { +} + +func (UnimplementedIAMProvisioningServiceServer) GetCertTypes(context.Context, *GetCertTypesRequest) (*CertTypes, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCertTypes not implemented") +} +func (UnimplementedIAMProvisioningServiceServer) StartProvisioning(context.Context, *StartProvisioningRequest) (*StartProvisioningResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartProvisioning not implemented") +} +func (UnimplementedIAMProvisioningServiceServer) FinishProvisioning(context.Context, *FinishProvisioningRequest) (*FinishProvisioningResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinishProvisioning not implemented") +} +func (UnimplementedIAMProvisioningServiceServer) Deprovision(context.Context, *DeprovisionRequest) (*DeprovisionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Deprovision not implemented") +} +func (UnimplementedIAMProvisioningServiceServer) mustEmbedUnimplementedIAMProvisioningServiceServer() { +} + +// UnsafeIAMProvisioningServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to IAMProvisioningServiceServer will +// result in compilation errors. +type UnsafeIAMProvisioningServiceServer interface { + mustEmbedUnimplementedIAMProvisioningServiceServer() +} + +func RegisterIAMProvisioningServiceServer(s grpc.ServiceRegistrar, srv IAMProvisioningServiceServer) { + s.RegisterService(&IAMProvisioningService_ServiceDesc, srv) +} + +func _IAMProvisioningService_GetCertTypes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCertTypesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IAMProvisioningServiceServer).SetOwner(ctx, in) + return srv.(IAMProvisioningServiceServer).GetCertTypes(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMProvisioningService/SetOwner", + FullMethod: "/iamanager.v5.IAMProvisioningService/GetCertTypes", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMProvisioningServiceServer).SetOwner(ctx, req.(*SetOwnerRequest)) + return srv.(IAMProvisioningServiceServer).GetCertTypes(ctx, req.(*GetCertTypesRequest)) } return interceptor(ctx, in, info, handler) } -func _IAMProvisioningService_Clear_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ClearRequest) +func _IAMProvisioningService_StartProvisioning_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartProvisioningRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IAMProvisioningServiceServer).Clear(ctx, in) + return srv.(IAMProvisioningServiceServer).StartProvisioning(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMProvisioningService/Clear", + FullMethod: "/iamanager.v5.IAMProvisioningService/StartProvisioning", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMProvisioningServiceServer).Clear(ctx, req.(*ClearRequest)) + return srv.(IAMProvisioningServiceServer).StartProvisioning(ctx, req.(*StartProvisioningRequest)) } return interceptor(ctx, in, info, handler) } -func _IAMProvisioningService_EncryptDisk_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EncryptDiskRequest) +func _IAMProvisioningService_FinishProvisioning_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FinishProvisioningRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IAMProvisioningServiceServer).EncryptDisk(ctx, in) + return srv.(IAMProvisioningServiceServer).FinishProvisioning(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMProvisioningService/EncryptDisk", + FullMethod: "/iamanager.v5.IAMProvisioningService/FinishProvisioning", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMProvisioningServiceServer).EncryptDisk(ctx, req.(*EncryptDiskRequest)) + return srv.(IAMProvisioningServiceServer).FinishProvisioning(ctx, req.(*FinishProvisioningRequest)) } return interceptor(ctx, in, info, handler) } -func _IAMProvisioningService_FinishProvisioning_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(empty.Empty) +func _IAMProvisioningService_Deprovision_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeprovisionRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(IAMProvisioningServiceServer).FinishProvisioning(ctx, in) + return srv.(IAMProvisioningServiceServer).Deprovision(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMProvisioningService/FinishProvisioning", + FullMethod: "/iamanager.v5.IAMProvisioningService/Deprovision", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(IAMProvisioningServiceServer).FinishProvisioning(ctx, req.(*empty.Empty)) + return srv.(IAMProvisioningServiceServer).Deprovision(ctx, req.(*DeprovisionRequest)) } return interceptor(ctx, in, info, handler) } @@ -686,36 +962,28 @@ func _IAMProvisioningService_FinishProvisioning_Handler(srv interface{}, ctx con // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var IAMProvisioningService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "iamanager.v4.IAMProvisioningService", + ServiceName: "iamanager.v5.IAMProvisioningService", HandlerType: (*IAMProvisioningServiceServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "GetAllNodeIDs", - Handler: _IAMProvisioningService_GetAllNodeIDs_Handler, - }, { MethodName: "GetCertTypes", Handler: _IAMProvisioningService_GetCertTypes_Handler, }, { - MethodName: "SetOwner", - Handler: _IAMProvisioningService_SetOwner_Handler, - }, - { - MethodName: "Clear", - Handler: _IAMProvisioningService_Clear_Handler, - }, - { - MethodName: "EncryptDisk", - Handler: _IAMProvisioningService_EncryptDisk_Handler, + MethodName: "StartProvisioning", + Handler: _IAMProvisioningService_StartProvisioning_Handler, }, { MethodName: "FinishProvisioning", Handler: _IAMProvisioningService_FinishProvisioning_Handler, }, + { + MethodName: "Deprovision", + Handler: _IAMProvisioningService_Deprovision_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "iamanager/v4/iamanager.proto", + Metadata: "iamanager/v5/iamanager.proto", } // IAMCertificateServiceClient is the client API for IAMCertificateService service. @@ -736,7 +1004,7 @@ func NewIAMCertificateServiceClient(cc grpc.ClientConnInterface) IAMCertificateS func (c *iAMCertificateServiceClient) CreateKey(ctx context.Context, in *CreateKeyRequest, opts ...grpc.CallOption) (*CreateKeyResponse, error) { out := new(CreateKeyResponse) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMCertificateService/CreateKey", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMCertificateService/CreateKey", in, out, opts...) if err != nil { return nil, err } @@ -745,7 +1013,7 @@ func (c *iAMCertificateServiceClient) CreateKey(ctx context.Context, in *CreateK func (c *iAMCertificateServiceClient) ApplyCert(ctx context.Context, in *ApplyCertRequest, opts ...grpc.CallOption) (*ApplyCertResponse, error) { out := new(ApplyCertResponse) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMCertificateService/ApplyCert", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMCertificateService/ApplyCert", in, out, opts...) if err != nil { return nil, err } @@ -794,7 +1062,7 @@ func _IAMCertificateService_CreateKey_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMCertificateService/CreateKey", + FullMethod: "/iamanager.v5.IAMCertificateService/CreateKey", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(IAMCertificateServiceServer).CreateKey(ctx, req.(*CreateKeyRequest)) @@ -812,7 +1080,7 @@ func _IAMCertificateService_ApplyCert_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMCertificateService/ApplyCert", + FullMethod: "/iamanager.v5.IAMCertificateService/ApplyCert", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(IAMCertificateServiceServer).ApplyCert(ctx, req.(*ApplyCertRequest)) @@ -824,7 +1092,7 @@ func _IAMCertificateService_ApplyCert_Handler(srv interface{}, ctx context.Conte // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var IAMCertificateService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "iamanager.v4.IAMCertificateService", + ServiceName: "iamanager.v5.IAMCertificateService", HandlerType: (*IAMCertificateServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -837,7 +1105,7 @@ var IAMCertificateService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "iamanager/v4/iamanager.proto", + Metadata: "iamanager/v5/iamanager.proto", } // IAMPermissionsServiceClient is the client API for IAMPermissionsService service. @@ -845,7 +1113,7 @@ var IAMCertificateService_ServiceDesc = grpc.ServiceDesc{ // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type IAMPermissionsServiceClient interface { RegisterInstance(ctx context.Context, in *RegisterInstanceRequest, opts ...grpc.CallOption) (*RegisterInstanceResponse, error) - UnregisterInstance(ctx context.Context, in *UnregisterInstanceRequest, opts ...grpc.CallOption) (*empty.Empty, error) + UnregisterInstance(ctx context.Context, in *UnregisterInstanceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type iAMPermissionsServiceClient struct { @@ -858,16 +1126,16 @@ func NewIAMPermissionsServiceClient(cc grpc.ClientConnInterface) IAMPermissionsS func (c *iAMPermissionsServiceClient) RegisterInstance(ctx context.Context, in *RegisterInstanceRequest, opts ...grpc.CallOption) (*RegisterInstanceResponse, error) { out := new(RegisterInstanceResponse) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPermissionsService/RegisterInstance", in, out, opts...) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPermissionsService/RegisterInstance", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *iAMPermissionsServiceClient) UnregisterInstance(ctx context.Context, in *UnregisterInstanceRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/iamanager.v4.IAMPermissionsService/UnregisterInstance", in, out, opts...) +func (c *iAMPermissionsServiceClient) UnregisterInstance(ctx context.Context, in *UnregisterInstanceRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/iamanager.v5.IAMPermissionsService/UnregisterInstance", in, out, opts...) if err != nil { return nil, err } @@ -879,7 +1147,7 @@ func (c *iAMPermissionsServiceClient) UnregisterInstance(ctx context.Context, in // for forward compatibility type IAMPermissionsServiceServer interface { RegisterInstance(context.Context, *RegisterInstanceRequest) (*RegisterInstanceResponse, error) - UnregisterInstance(context.Context, *UnregisterInstanceRequest) (*empty.Empty, error) + UnregisterInstance(context.Context, *UnregisterInstanceRequest) (*emptypb.Empty, error) mustEmbedUnimplementedIAMPermissionsServiceServer() } @@ -890,7 +1158,7 @@ type UnimplementedIAMPermissionsServiceServer struct { func (UnimplementedIAMPermissionsServiceServer) RegisterInstance(context.Context, *RegisterInstanceRequest) (*RegisterInstanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RegisterInstance not implemented") } -func (UnimplementedIAMPermissionsServiceServer) UnregisterInstance(context.Context, *UnregisterInstanceRequest) (*empty.Empty, error) { +func (UnimplementedIAMPermissionsServiceServer) UnregisterInstance(context.Context, *UnregisterInstanceRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method UnregisterInstance not implemented") } func (UnimplementedIAMPermissionsServiceServer) mustEmbedUnimplementedIAMPermissionsServiceServer() {} @@ -916,7 +1184,7 @@ func _IAMPermissionsService_RegisterInstance_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPermissionsService/RegisterInstance", + FullMethod: "/iamanager.v5.IAMPermissionsService/RegisterInstance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(IAMPermissionsServiceServer).RegisterInstance(ctx, req.(*RegisterInstanceRequest)) @@ -934,7 +1202,7 @@ func _IAMPermissionsService_UnregisterInstance_Handler(srv interface{}, ctx cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/iamanager.v4.IAMPermissionsService/UnregisterInstance", + FullMethod: "/iamanager.v5.IAMPermissionsService/UnregisterInstance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(IAMPermissionsServiceServer).UnregisterInstance(ctx, req.(*UnregisterInstanceRequest)) @@ -946,7 +1214,7 @@ func _IAMPermissionsService_UnregisterInstance_Handler(srv interface{}, ctx cont // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var IAMPermissionsService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "iamanager.v4.IAMPermissionsService", + ServiceName: "iamanager.v5.IAMPermissionsService", HandlerType: (*IAMPermissionsServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -959,5 +1227,5 @@ var IAMPermissionsService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "iamanager/v4/iamanager.proto", + Metadata: "iamanager/v5/iamanager.proto", } diff --git a/vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager.pb.go b/vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager.pb.go deleted file mode 100644 index 1a280893..00000000 --- a/vendor/github.com/aosedge/aos_common/api/iamanager/v4/iamanager.pb.go +++ /dev/null @@ -1,1925 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: iamanager/v4/iamanager.proto - -package iamanager - -import ( - empty "github.com/golang/protobuf/ptypes/empty" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type APIVersion struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` -} - -func (x *APIVersion) Reset() { - *x = APIVersion{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *APIVersion) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*APIVersion) ProtoMessage() {} - -func (x *APIVersion) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use APIVersion.ProtoReflect.Descriptor instead. -func (*APIVersion) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{0} -} - -func (x *APIVersion) GetVersion() uint64 { - if x != nil { - return x.Version - } - return 0 -} - -type NodeInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - NodeType string `protobuf:"bytes,2,opt,name=node_type,json=nodeType,proto3" json:"node_type,omitempty"` -} - -func (x *NodeInfo) Reset() { - *x = NodeInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NodeInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NodeInfo) ProtoMessage() {} - -func (x *NodeInfo) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NodeInfo.ProtoReflect.Descriptor instead. -func (*NodeInfo) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{1} -} - -func (x *NodeInfo) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *NodeInfo) GetNodeType() string { - if x != nil { - return x.NodeType - } - return "" -} - -type GetCertRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Issuer []byte `protobuf:"bytes,2,opt,name=issuer,proto3" json:"issuer,omitempty"` - Serial string `protobuf:"bytes,3,opt,name=serial,proto3" json:"serial,omitempty"` -} - -func (x *GetCertRequest) Reset() { - *x = GetCertRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetCertRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetCertRequest) ProtoMessage() {} - -func (x *GetCertRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetCertRequest.ProtoReflect.Descriptor instead. -func (*GetCertRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{2} -} - -func (x *GetCertRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *GetCertRequest) GetIssuer() []byte { - if x != nil { - return x.Issuer - } - return nil -} - -func (x *GetCertRequest) GetSerial() string { - if x != nil { - return x.Serial - } - return "" -} - -type GetCertResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - CertUrl string `protobuf:"bytes,2,opt,name=cert_url,json=certUrl,proto3" json:"cert_url,omitempty"` - KeyUrl string `protobuf:"bytes,3,opt,name=key_url,json=keyUrl,proto3" json:"key_url,omitempty"` -} - -func (x *GetCertResponse) Reset() { - *x = GetCertResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetCertResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetCertResponse) ProtoMessage() {} - -func (x *GetCertResponse) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetCertResponse.ProtoReflect.Descriptor instead. -func (*GetCertResponse) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{3} -} - -func (x *GetCertResponse) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *GetCertResponse) GetCertUrl() string { - if x != nil { - return x.CertUrl - } - return "" -} - -func (x *GetCertResponse) GetKeyUrl() string { - if x != nil { - return x.KeyUrl - } - return "" -} - -type SystemInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SystemId string `protobuf:"bytes,1,opt,name=system_id,json=systemId,proto3" json:"system_id,omitempty"` - UnitModel string `protobuf:"bytes,2,opt,name=unit_model,json=unitModel,proto3" json:"unit_model,omitempty"` -} - -func (x *SystemInfo) Reset() { - *x = SystemInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SystemInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SystemInfo) ProtoMessage() {} - -func (x *SystemInfo) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SystemInfo.ProtoReflect.Descriptor instead. -func (*SystemInfo) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{4} -} - -func (x *SystemInfo) GetSystemId() string { - if x != nil { - return x.SystemId - } - return "" -} - -func (x *SystemInfo) GetUnitModel() string { - if x != nil { - return x.UnitModel - } - return "" -} - -type Subjects struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Subjects []string `protobuf:"bytes,1,rep,name=subjects,proto3" json:"subjects,omitempty"` -} - -func (x *Subjects) Reset() { - *x = Subjects{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Subjects) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Subjects) ProtoMessage() {} - -func (x *Subjects) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Subjects.ProtoReflect.Descriptor instead. -func (*Subjects) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{5} -} - -func (x *Subjects) GetSubjects() []string { - if x != nil { - return x.Subjects - } - return nil -} - -type PermissionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Secret string `protobuf:"bytes,1,opt,name=secret,proto3" json:"secret,omitempty"` - FunctionalServerId string `protobuf:"bytes,2,opt,name=functional_server_id,json=functionalServerId,proto3" json:"functional_server_id,omitempty"` -} - -func (x *PermissionsRequest) Reset() { - *x = PermissionsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PermissionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionsRequest) ProtoMessage() {} - -func (x *PermissionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionsRequest.ProtoReflect.Descriptor instead. -func (*PermissionsRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{6} -} - -func (x *PermissionsRequest) GetSecret() string { - if x != nil { - return x.Secret - } - return "" -} - -func (x *PermissionsRequest) GetFunctionalServerId() string { - if x != nil { - return x.FunctionalServerId - } - return "" -} - -type InstanceIdent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - SubjectId string `protobuf:"bytes,2,opt,name=subject_id,json=subjectId,proto3" json:"subject_id,omitempty"` - Instance uint64 `protobuf:"varint,3,opt,name=instance,proto3" json:"instance,omitempty"` -} - -func (x *InstanceIdent) Reset() { - *x = InstanceIdent{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InstanceIdent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InstanceIdent) ProtoMessage() {} - -func (x *InstanceIdent) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InstanceIdent.ProtoReflect.Descriptor instead. -func (*InstanceIdent) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{7} -} - -func (x *InstanceIdent) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *InstanceIdent) GetSubjectId() string { - if x != nil { - return x.SubjectId - } - return "" -} - -func (x *InstanceIdent) GetInstance() uint64 { - if x != nil { - return x.Instance - } - return 0 -} - -type PermissionsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - Permissions *Permissions `protobuf:"bytes,2,opt,name=permissions,proto3" json:"permissions,omitempty"` -} - -func (x *PermissionsResponse) Reset() { - *x = PermissionsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PermissionsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionsResponse) ProtoMessage() {} - -func (x *PermissionsResponse) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionsResponse.ProtoReflect.Descriptor instead. -func (*PermissionsResponse) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{8} -} - -func (x *PermissionsResponse) GetInstance() *InstanceIdent { - if x != nil { - return x.Instance - } - return nil -} - -func (x *PermissionsResponse) GetPermissions() *Permissions { - if x != nil { - return x.Permissions - } - return nil -} - -type NodesID struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` -} - -func (x *NodesID) Reset() { - *x = NodesID{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NodesID) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NodesID) ProtoMessage() {} - -func (x *NodesID) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NodesID.ProtoReflect.Descriptor instead. -func (*NodesID) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{9} -} - -func (x *NodesID) GetIds() []string { - if x != nil { - return x.Ids - } - return nil -} - -type GetCertTypesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` -} - -func (x *GetCertTypesRequest) Reset() { - *x = GetCertTypesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetCertTypesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetCertTypesRequest) ProtoMessage() {} - -func (x *GetCertTypesRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetCertTypesRequest.ProtoReflect.Descriptor instead. -func (*GetCertTypesRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{10} -} - -func (x *GetCertTypesRequest) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -type CertTypes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Types []string `protobuf:"bytes,1,rep,name=types,proto3" json:"types,omitempty"` -} - -func (x *CertTypes) Reset() { - *x = CertTypes{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CertTypes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CertTypes) ProtoMessage() {} - -func (x *CertTypes) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CertTypes.ProtoReflect.Descriptor instead. -func (*CertTypes) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{11} -} - -func (x *CertTypes) GetTypes() []string { - if x != nil { - return x.Types - } - return nil -} - -type SetOwnerRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *SetOwnerRequest) Reset() { - *x = SetOwnerRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SetOwnerRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SetOwnerRequest) ProtoMessage() {} - -func (x *SetOwnerRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SetOwnerRequest.ProtoReflect.Descriptor instead. -func (*SetOwnerRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{12} -} - -func (x *SetOwnerRequest) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *SetOwnerRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *SetOwnerRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type ClearRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` -} - -func (x *ClearRequest) Reset() { - *x = ClearRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClearRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClearRequest) ProtoMessage() {} - -func (x *ClearRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ClearRequest.ProtoReflect.Descriptor instead. -func (*ClearRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{13} -} - -func (x *ClearRequest) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *ClearRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -type EncryptDiskRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *EncryptDiskRequest) Reset() { - *x = EncryptDiskRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EncryptDiskRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EncryptDiskRequest) ProtoMessage() {} - -func (x *EncryptDiskRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use EncryptDiskRequest.ProtoReflect.Descriptor instead. -func (*EncryptDiskRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{14} -} - -func (x *EncryptDiskRequest) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *EncryptDiskRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type CreateKeyRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` - Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` - Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *CreateKeyRequest) Reset() { - *x = CreateKeyRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateKeyRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateKeyRequest) ProtoMessage() {} - -func (x *CreateKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateKeyRequest.ProtoReflect.Descriptor instead. -func (*CreateKeyRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{15} -} - -func (x *CreateKeyRequest) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *CreateKeyRequest) GetSubject() string { - if x != nil { - return x.Subject - } - return "" -} - -func (x *CreateKeyRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CreateKeyRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type CreateKeyResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Csr string `protobuf:"bytes,3,opt,name=csr,proto3" json:"csr,omitempty"` -} - -func (x *CreateKeyResponse) Reset() { - *x = CreateKeyResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateKeyResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateKeyResponse) ProtoMessage() {} - -func (x *CreateKeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateKeyResponse.ProtoReflect.Descriptor instead. -func (*CreateKeyResponse) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{16} -} - -func (x *CreateKeyResponse) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *CreateKeyResponse) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CreateKeyResponse) GetCsr() string { - if x != nil { - return x.Csr - } - return "" -} - -type ApplyCertRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Cert string `protobuf:"bytes,3,opt,name=cert,proto3" json:"cert,omitempty"` -} - -func (x *ApplyCertRequest) Reset() { - *x = ApplyCertRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyCertRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyCertRequest) ProtoMessage() {} - -func (x *ApplyCertRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyCertRequest.ProtoReflect.Descriptor instead. -func (*ApplyCertRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{17} -} - -func (x *ApplyCertRequest) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *ApplyCertRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *ApplyCertRequest) GetCert() string { - if x != nil { - return x.Cert - } - return "" -} - -type ApplyCertResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - CertUrl string `protobuf:"bytes,3,opt,name=cert_url,json=certUrl,proto3" json:"cert_url,omitempty"` - Serial string `protobuf:"bytes,4,opt,name=serial,proto3" json:"serial,omitempty"` -} - -func (x *ApplyCertResponse) Reset() { - *x = ApplyCertResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyCertResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyCertResponse) ProtoMessage() {} - -func (x *ApplyCertResponse) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyCertResponse.ProtoReflect.Descriptor instead. -func (*ApplyCertResponse) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{18} -} - -func (x *ApplyCertResponse) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *ApplyCertResponse) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *ApplyCertResponse) GetCertUrl() string { - if x != nil { - return x.CertUrl - } - return "" -} - -func (x *ApplyCertResponse) GetSerial() string { - if x != nil { - return x.Serial - } - return "" -} - -type Permissions struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Permissions map[string]string `protobuf:"bytes,1,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *Permissions) Reset() { - *x = Permissions{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Permissions) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Permissions) ProtoMessage() {} - -func (x *Permissions) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[19] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Permissions.ProtoReflect.Descriptor instead. -func (*Permissions) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{19} -} - -func (x *Permissions) GetPermissions() map[string]string { - if x != nil { - return x.Permissions - } - return nil -} - -type RegisterInstanceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - Permissions map[string]*Permissions `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *RegisterInstanceRequest) Reset() { - *x = RegisterInstanceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterInstanceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterInstanceRequest) ProtoMessage() {} - -func (x *RegisterInstanceRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterInstanceRequest.ProtoReflect.Descriptor instead. -func (*RegisterInstanceRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{20} -} - -func (x *RegisterInstanceRequest) GetInstance() *InstanceIdent { - if x != nil { - return x.Instance - } - return nil -} - -func (x *RegisterInstanceRequest) GetPermissions() map[string]*Permissions { - if x != nil { - return x.Permissions - } - return nil -} - -type RegisterInstanceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Secret string `protobuf:"bytes,1,opt,name=secret,proto3" json:"secret,omitempty"` -} - -func (x *RegisterInstanceResponse) Reset() { - *x = RegisterInstanceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterInstanceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterInstanceResponse) ProtoMessage() {} - -func (x *RegisterInstanceResponse) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[21] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterInstanceResponse.ProtoReflect.Descriptor instead. -func (*RegisterInstanceResponse) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{21} -} - -func (x *RegisterInstanceResponse) GetSecret() string { - if x != nil { - return x.Secret - } - return "" -} - -type UnregisterInstanceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` -} - -func (x *UnregisterInstanceRequest) Reset() { - *x = UnregisterInstanceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UnregisterInstanceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UnregisterInstanceRequest) ProtoMessage() {} - -func (x *UnregisterInstanceRequest) ProtoReflect() protoreflect.Message { - mi := &file_iamanager_v4_iamanager_proto_msgTypes[22] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UnregisterInstanceRequest.ProtoReflect.Descriptor instead. -func (*UnregisterInstanceRequest) Descriptor() ([]byte, []int) { - return file_iamanager_v4_iamanager_proto_rawDescGZIP(), []int{22} -} - -func (x *UnregisterInstanceRequest) GetInstance() *InstanceIdent { - if x != nil { - return x.Instance - } - return nil -} - -var File_iamanager_v4_iamanager_proto protoreflect.FileDescriptor - -var file_iamanager_v4_iamanager_proto_rawDesc = []byte{ - 0x0a, 0x1c, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x76, 0x34, 0x2f, 0x69, - 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, - 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x1a, 0x1b, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, - 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x26, 0x0a, 0x0a, 0x41, 0x50, 0x49, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x22, 0x40, 0x0a, 0x08, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x17, 0x0a, - 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x22, 0x54, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, - 0x75, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, - 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x22, 0x59, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x19, 0x0a, 0x08, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x63, 0x65, 0x72, 0x74, 0x55, 0x72, 0x6c, 0x12, 0x17, 0x0a, 0x07, 0x6b, - 0x65, 0x79, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6b, 0x65, - 0x79, 0x55, 0x72, 0x6c, 0x22, 0x48, 0x0a, 0x0a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x6e, 0x69, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x22, 0x26, - 0x0a, 0x08, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x75, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x5e, 0x0a, 0x12, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, - 0x63, 0x72, 0x65, 0x74, 0x12, 0x30, 0x0a, 0x14, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x61, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x12, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0x69, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x22, 0x8b, 0x01, 0x0a, 0x13, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x61, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, - 0x1b, 0x0a, 0x07, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x2e, 0x0a, 0x13, - 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0x21, 0x0a, 0x09, - 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x22, - 0x5a, 0x0a, 0x0f, 0x53, 0x65, 0x74, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x3b, 0x0a, 0x0c, 0x43, - 0x6c, 0x65, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, - 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, - 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x49, 0x0a, 0x12, 0x45, 0x6e, 0x63, 0x72, - 0x79, 0x70, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, - 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, - 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, - 0x6f, 0x72, 0x64, 0x22, 0x75, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x52, 0x0a, 0x11, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, - 0x63, 0x73, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x73, 0x72, 0x22, 0x53, - 0x0a, 0x10, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x63, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, - 0x65, 0x72, 0x74, 0x22, 0x73, 0x0a, 0x11, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x75, 0x72, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x65, 0x72, 0x74, 0x55, 0x72, 0x6c, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x22, 0x9b, 0x01, 0x0a, 0x0b, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4c, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, - 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3e, 0x0a, 0x10, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x87, 0x02, 0x0a, 0x17, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x0b, 0x70, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x36, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x59, 0x0a, 0x10, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x69, 0x61, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0x32, 0x0a, 0x18, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, - 0x63, 0x72, 0x65, 0x74, 0x22, 0x54, 0x0a, 0x19, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x37, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x32, 0xe2, 0x01, 0x0a, 0x10, 0x49, - 0x41, 0x4d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x43, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x69, 0x61, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, - 0x12, 0x1c, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, - 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x47, 0x65, - 0x74, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, - 0xf0, 0x01, 0x0a, 0x18, 0x49, 0x41, 0x4d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0d, - 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x22, - 0x00, 0x12, 0x3f, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, - 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, - 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x18, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x53, - 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x12, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x00, - 0x30, 0x01, 0x32, 0x76, 0x0a, 0x1b, 0x49, 0x41, 0x4d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x50, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x57, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0xbf, 0x03, 0x0a, 0x16, 0x49, - 0x41, 0x4d, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x40, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x4e, - 0x6f, 0x64, 0x65, 0x49, 0x44, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, - 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4e, 0x6f, - 0x64, 0x65, 0x73, 0x49, 0x44, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x43, 0x65, - 0x72, 0x74, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x21, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x69, 0x61, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x65, 0x72, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x73, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x4f, 0x77, 0x6e, 0x65, - 0x72, 0x12, 0x1d, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, - 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x05, 0x43, 0x6c, - 0x65, 0x61, 0x72, 0x12, 0x1a, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x0b, 0x45, 0x6e, 0x63, - 0x72, 0x79, 0x70, 0x74, 0x44, 0x69, 0x73, 0x6b, 0x12, 0x20, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x44, - 0x69, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x12, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x32, 0xb7, 0x01, 0x0a, - 0x15, 0x49, 0x41, 0x4d, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4e, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4b, 0x65, 0x79, 0x12, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, - 0x65, 0x72, 0x74, 0x12, 0x1e, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x43, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x32, 0xd5, 0x01, 0x0a, 0x15, 0x49, 0x41, 0x4d, 0x50, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x63, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x12, 0x25, 0x2e, 0x69, 0x61, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x69, 0x61, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x12, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x2e, 0x69, 0x61, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_iamanager_v4_iamanager_proto_rawDescOnce sync.Once - file_iamanager_v4_iamanager_proto_rawDescData = file_iamanager_v4_iamanager_proto_rawDesc -) - -func file_iamanager_v4_iamanager_proto_rawDescGZIP() []byte { - file_iamanager_v4_iamanager_proto_rawDescOnce.Do(func() { - file_iamanager_v4_iamanager_proto_rawDescData = protoimpl.X.CompressGZIP(file_iamanager_v4_iamanager_proto_rawDescData) - }) - return file_iamanager_v4_iamanager_proto_rawDescData -} - -var file_iamanager_v4_iamanager_proto_msgTypes = make([]protoimpl.MessageInfo, 25) -var file_iamanager_v4_iamanager_proto_goTypes = []interface{}{ - (*APIVersion)(nil), // 0: iamanager.v4.APIVersion - (*NodeInfo)(nil), // 1: iamanager.v4.NodeInfo - (*GetCertRequest)(nil), // 2: iamanager.v4.GetCertRequest - (*GetCertResponse)(nil), // 3: iamanager.v4.GetCertResponse - (*SystemInfo)(nil), // 4: iamanager.v4.SystemInfo - (*Subjects)(nil), // 5: iamanager.v4.Subjects - (*PermissionsRequest)(nil), // 6: iamanager.v4.PermissionsRequest - (*InstanceIdent)(nil), // 7: iamanager.v4.InstanceIdent - (*PermissionsResponse)(nil), // 8: iamanager.v4.PermissionsResponse - (*NodesID)(nil), // 9: iamanager.v4.NodesID - (*GetCertTypesRequest)(nil), // 10: iamanager.v4.GetCertTypesRequest - (*CertTypes)(nil), // 11: iamanager.v4.CertTypes - (*SetOwnerRequest)(nil), // 12: iamanager.v4.SetOwnerRequest - (*ClearRequest)(nil), // 13: iamanager.v4.ClearRequest - (*EncryptDiskRequest)(nil), // 14: iamanager.v4.EncryptDiskRequest - (*CreateKeyRequest)(nil), // 15: iamanager.v4.CreateKeyRequest - (*CreateKeyResponse)(nil), // 16: iamanager.v4.CreateKeyResponse - (*ApplyCertRequest)(nil), // 17: iamanager.v4.ApplyCertRequest - (*ApplyCertResponse)(nil), // 18: iamanager.v4.ApplyCertResponse - (*Permissions)(nil), // 19: iamanager.v4.Permissions - (*RegisterInstanceRequest)(nil), // 20: iamanager.v4.RegisterInstanceRequest - (*RegisterInstanceResponse)(nil), // 21: iamanager.v4.RegisterInstanceResponse - (*UnregisterInstanceRequest)(nil), // 22: iamanager.v4.UnregisterInstanceRequest - nil, // 23: iamanager.v4.Permissions.PermissionsEntry - nil, // 24: iamanager.v4.RegisterInstanceRequest.PermissionsEntry - (*empty.Empty)(nil), // 25: google.protobuf.Empty -} -var file_iamanager_v4_iamanager_proto_depIdxs = []int32{ - 7, // 0: iamanager.v4.PermissionsResponse.instance:type_name -> iamanager.v4.InstanceIdent - 19, // 1: iamanager.v4.PermissionsResponse.permissions:type_name -> iamanager.v4.Permissions - 23, // 2: iamanager.v4.Permissions.permissions:type_name -> iamanager.v4.Permissions.PermissionsEntry - 7, // 3: iamanager.v4.RegisterInstanceRequest.instance:type_name -> iamanager.v4.InstanceIdent - 24, // 4: iamanager.v4.RegisterInstanceRequest.permissions:type_name -> iamanager.v4.RegisterInstanceRequest.PermissionsEntry - 7, // 5: iamanager.v4.UnregisterInstanceRequest.instance:type_name -> iamanager.v4.InstanceIdent - 19, // 6: iamanager.v4.RegisterInstanceRequest.PermissionsEntry.value:type_name -> iamanager.v4.Permissions - 25, // 7: iamanager.v4.IAMPublicService.GetAPIVersion:input_type -> google.protobuf.Empty - 25, // 8: iamanager.v4.IAMPublicService.GetNodeInfo:input_type -> google.protobuf.Empty - 2, // 9: iamanager.v4.IAMPublicService.GetCert:input_type -> iamanager.v4.GetCertRequest - 25, // 10: iamanager.v4.IAMPublicIdentityService.GetSystemInfo:input_type -> google.protobuf.Empty - 25, // 11: iamanager.v4.IAMPublicIdentityService.GetSubjects:input_type -> google.protobuf.Empty - 25, // 12: iamanager.v4.IAMPublicIdentityService.SubscribeSubjectsChanged:input_type -> google.protobuf.Empty - 6, // 13: iamanager.v4.IAMPublicPermissionsService.GetPermissions:input_type -> iamanager.v4.PermissionsRequest - 25, // 14: iamanager.v4.IAMProvisioningService.GetAllNodeIDs:input_type -> google.protobuf.Empty - 10, // 15: iamanager.v4.IAMProvisioningService.GetCertTypes:input_type -> iamanager.v4.GetCertTypesRequest - 12, // 16: iamanager.v4.IAMProvisioningService.SetOwner:input_type -> iamanager.v4.SetOwnerRequest - 13, // 17: iamanager.v4.IAMProvisioningService.Clear:input_type -> iamanager.v4.ClearRequest - 14, // 18: iamanager.v4.IAMProvisioningService.EncryptDisk:input_type -> iamanager.v4.EncryptDiskRequest - 25, // 19: iamanager.v4.IAMProvisioningService.FinishProvisioning:input_type -> google.protobuf.Empty - 15, // 20: iamanager.v4.IAMCertificateService.CreateKey:input_type -> iamanager.v4.CreateKeyRequest - 17, // 21: iamanager.v4.IAMCertificateService.ApplyCert:input_type -> iamanager.v4.ApplyCertRequest - 20, // 22: iamanager.v4.IAMPermissionsService.RegisterInstance:input_type -> iamanager.v4.RegisterInstanceRequest - 22, // 23: iamanager.v4.IAMPermissionsService.UnregisterInstance:input_type -> iamanager.v4.UnregisterInstanceRequest - 0, // 24: iamanager.v4.IAMPublicService.GetAPIVersion:output_type -> iamanager.v4.APIVersion - 1, // 25: iamanager.v4.IAMPublicService.GetNodeInfo:output_type -> iamanager.v4.NodeInfo - 3, // 26: iamanager.v4.IAMPublicService.GetCert:output_type -> iamanager.v4.GetCertResponse - 4, // 27: iamanager.v4.IAMPublicIdentityService.GetSystemInfo:output_type -> iamanager.v4.SystemInfo - 5, // 28: iamanager.v4.IAMPublicIdentityService.GetSubjects:output_type -> iamanager.v4.Subjects - 5, // 29: iamanager.v4.IAMPublicIdentityService.SubscribeSubjectsChanged:output_type -> iamanager.v4.Subjects - 8, // 30: iamanager.v4.IAMPublicPermissionsService.GetPermissions:output_type -> iamanager.v4.PermissionsResponse - 9, // 31: iamanager.v4.IAMProvisioningService.GetAllNodeIDs:output_type -> iamanager.v4.NodesID - 11, // 32: iamanager.v4.IAMProvisioningService.GetCertTypes:output_type -> iamanager.v4.CertTypes - 25, // 33: iamanager.v4.IAMProvisioningService.SetOwner:output_type -> google.protobuf.Empty - 25, // 34: iamanager.v4.IAMProvisioningService.Clear:output_type -> google.protobuf.Empty - 25, // 35: iamanager.v4.IAMProvisioningService.EncryptDisk:output_type -> google.protobuf.Empty - 25, // 36: iamanager.v4.IAMProvisioningService.FinishProvisioning:output_type -> google.protobuf.Empty - 16, // 37: iamanager.v4.IAMCertificateService.CreateKey:output_type -> iamanager.v4.CreateKeyResponse - 18, // 38: iamanager.v4.IAMCertificateService.ApplyCert:output_type -> iamanager.v4.ApplyCertResponse - 21, // 39: iamanager.v4.IAMPermissionsService.RegisterInstance:output_type -> iamanager.v4.RegisterInstanceResponse - 25, // 40: iamanager.v4.IAMPermissionsService.UnregisterInstance:output_type -> google.protobuf.Empty - 24, // [24:41] is the sub-list for method output_type - 7, // [7:24] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_iamanager_v4_iamanager_proto_init() } -func file_iamanager_v4_iamanager_proto_init() { - if File_iamanager_v4_iamanager_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_iamanager_v4_iamanager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*APIVersion); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodeInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetCertRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetCertResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SystemInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Subjects); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PermissionsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InstanceIdent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PermissionsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodesID); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetCertTypesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CertTypes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetOwnerRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClearRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EncryptDiskRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateKeyRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateKeyResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyCertRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyCertResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Permissions); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterInstanceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterInstanceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_iamanager_v4_iamanager_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UnregisterInstanceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_iamanager_v4_iamanager_proto_rawDesc, - NumEnums: 0, - NumMessages: 25, - NumExtensions: 0, - NumServices: 6, - }, - GoTypes: file_iamanager_v4_iamanager_proto_goTypes, - DependencyIndexes: file_iamanager_v4_iamanager_proto_depIdxs, - MessageInfos: file_iamanager_v4_iamanager_proto_msgTypes, - }.Build() - File_iamanager_v4_iamanager_proto = out.File - file_iamanager_v4_iamanager_proto_rawDesc = nil - file_iamanager_v4_iamanager_proto_goTypes = nil - file_iamanager_v4_iamanager_proto_depIdxs = nil -} diff --git a/vendor/github.com/aosedge/aos_common/api/servicemanager/v3/servicemanager.pb.go b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go similarity index 50% rename from vendor/github.com/aosedge/aos_common/api/servicemanager/v3/servicemanager.pb.go rename to vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go index 63df4142..aeeada6d 100644 --- a/vendor/github.com/aosedge/aos_common/api/servicemanager/v3/servicemanager.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v4.25.0 -// source: servicemanager/v3/servicemanager.proto +// protoc v5.26.0 +// source: servicemanager/v4/servicemanager.proto package servicemanager import ( + common "github.com/aosedge/aos_common/api/common" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" @@ -51,11 +52,11 @@ func (x ConnectionEnum) String() string { } func (ConnectionEnum) Descriptor() protoreflect.EnumDescriptor { - return file_servicemanager_v3_servicemanager_proto_enumTypes[0].Descriptor() + return file_servicemanager_v4_servicemanager_proto_enumTypes[0].Descriptor() } func (ConnectionEnum) Type() protoreflect.EnumType { - return &file_servicemanager_v3_servicemanager_proto_enumTypes[0] + return &file_servicemanager_v4_servicemanager_proto_enumTypes[0] } func (x ConnectionEnum) Number() protoreflect.EnumNumber { @@ -64,7 +65,7 @@ func (x ConnectionEnum) Number() protoreflect.EnumNumber { // Deprecated: Use ConnectionEnum.Descriptor instead. func (ConnectionEnum) EnumDescriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{0} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{0} } type SMIncomingMessages struct { @@ -82,7 +83,7 @@ type SMIncomingMessages struct { // *SMIncomingMessages_SystemLogRequest // *SMIncomingMessages_InstanceLogRequest // *SMIncomingMessages_InstanceCrashLogRequest - // *SMIncomingMessages_GetNodeMonitoring + // *SMIncomingMessages_GetAverageMonitoring // *SMIncomingMessages_ConnectionStatus // *SMIncomingMessages_ImageContentInfo // *SMIncomingMessages_ImageContent @@ -94,7 +95,7 @@ type SMIncomingMessages struct { func (x *SMIncomingMessages) Reset() { *x = SMIncomingMessages{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[0] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -107,7 +108,7 @@ func (x *SMIncomingMessages) String() string { func (*SMIncomingMessages) ProtoMessage() {} func (x *SMIncomingMessages) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[0] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -120,7 +121,7 @@ func (x *SMIncomingMessages) ProtoReflect() protoreflect.Message { // Deprecated: Use SMIncomingMessages.ProtoReflect.Descriptor instead. func (*SMIncomingMessages) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{0} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{0} } func (m *SMIncomingMessages) GetSMIncomingMessage() isSMIncomingMessages_SMIncomingMessage { @@ -186,9 +187,9 @@ func (x *SMIncomingMessages) GetInstanceCrashLogRequest() *InstanceCrashLogReque return nil } -func (x *SMIncomingMessages) GetGetNodeMonitoring() *GetNodeMonitoring { - if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_GetNodeMonitoring); ok { - return x.GetNodeMonitoring +func (x *SMIncomingMessages) GetGetAverageMonitoring() *GetAverageMonitoring { + if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_GetAverageMonitoring); ok { + return x.GetAverageMonitoring } return nil } @@ -264,8 +265,8 @@ type SMIncomingMessages_InstanceCrashLogRequest struct { InstanceCrashLogRequest *InstanceCrashLogRequest `protobuf:"bytes,8,opt,name=instance_crash_log_request,json=instanceCrashLogRequest,proto3,oneof"` } -type SMIncomingMessages_GetNodeMonitoring struct { - GetNodeMonitoring *GetNodeMonitoring `protobuf:"bytes,9,opt,name=get_node_monitoring,json=getNodeMonitoring,proto3,oneof"` +type SMIncomingMessages_GetAverageMonitoring struct { + GetAverageMonitoring *GetAverageMonitoring `protobuf:"bytes,9,opt,name=get_average_monitoring,json=getAverageMonitoring,proto3,oneof"` } type SMIncomingMessages_ConnectionStatus struct { @@ -304,7 +305,7 @@ func (*SMIncomingMessages_InstanceLogRequest) isSMIncomingMessages_SMIncomingMes func (*SMIncomingMessages_InstanceCrashLogRequest) isSMIncomingMessages_SMIncomingMessage() {} -func (*SMIncomingMessages_GetNodeMonitoring) isSMIncomingMessages_SMIncomingMessage() {} +func (*SMIncomingMessages_GetAverageMonitoring) isSMIncomingMessages_SMIncomingMessage() {} func (*SMIncomingMessages_ConnectionStatus) isSMIncomingMessages_SMIncomingMessage() {} @@ -325,7 +326,7 @@ type GetUnitConfigStatus struct { func (x *GetUnitConfigStatus) Reset() { *x = GetUnitConfigStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[1] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -338,7 +339,7 @@ func (x *GetUnitConfigStatus) String() string { func (*GetUnitConfigStatus) ProtoMessage() {} func (x *GetUnitConfigStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[1] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -351,7 +352,7 @@ func (x *GetUnitConfigStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUnitConfigStatus.ProtoReflect.Descriptor instead. func (*GetUnitConfigStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{1} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{1} } type CheckUnitConfig struct { @@ -359,14 +360,14 @@ type CheckUnitConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UnitConfig string `protobuf:"bytes,1,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` - VendorVersion string `protobuf:"bytes,2,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` + UnitConfig string `protobuf:"bytes,1,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` } func (x *CheckUnitConfig) Reset() { *x = CheckUnitConfig{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[2] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -379,7 +380,7 @@ func (x *CheckUnitConfig) String() string { func (*CheckUnitConfig) ProtoMessage() {} func (x *CheckUnitConfig) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[2] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -392,7 +393,7 @@ func (x *CheckUnitConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use CheckUnitConfig.ProtoReflect.Descriptor instead. func (*CheckUnitConfig) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{2} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{2} } func (x *CheckUnitConfig) GetUnitConfig() string { @@ -402,9 +403,9 @@ func (x *CheckUnitConfig) GetUnitConfig() string { return "" } -func (x *CheckUnitConfig) GetVendorVersion() string { +func (x *CheckUnitConfig) GetVersion() string { if x != nil { - return x.VendorVersion + return x.Version } return "" } @@ -414,14 +415,14 @@ type SetUnitConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UnitConfig string `protobuf:"bytes,1,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` - VendorVersion string `protobuf:"bytes,2,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` + UnitConfig string `protobuf:"bytes,1,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` } func (x *SetUnitConfig) Reset() { *x = SetUnitConfig{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[3] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -434,7 +435,7 @@ func (x *SetUnitConfig) String() string { func (*SetUnitConfig) ProtoMessage() {} func (x *SetUnitConfig) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[3] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -447,7 +448,7 @@ func (x *SetUnitConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use SetUnitConfig.ProtoReflect.Descriptor instead. func (*SetUnitConfig) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{3} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{3} } func (x *SetUnitConfig) GetUnitConfig() string { @@ -457,9 +458,9 @@ func (x *SetUnitConfig) GetUnitConfig() string { return "" } -func (x *SetUnitConfig) GetVendorVersion() string { +func (x *SetUnitConfig) GetVersion() string { if x != nil { - return x.VendorVersion + return x.Version } return "" } @@ -475,7 +476,7 @@ type UpdateNetworks struct { func (x *UpdateNetworks) Reset() { *x = UpdateNetworks{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[4] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -488,7 +489,7 @@ func (x *UpdateNetworks) String() string { func (*UpdateNetworks) ProtoMessage() {} func (x *UpdateNetworks) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[4] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -501,7 +502,7 @@ func (x *UpdateNetworks) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateNetworks.ProtoReflect.Descriptor instead. func (*UpdateNetworks) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{4} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{4} } func (x *UpdateNetworks) GetNetworks() []*NetworkParameters { @@ -522,7 +523,7 @@ type ClockSync struct { func (x *ClockSync) Reset() { *x = ClockSync{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[5] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -535,7 +536,7 @@ func (x *ClockSync) String() string { func (*ClockSync) ProtoMessage() {} func (x *ClockSync) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[5] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -548,7 +549,7 @@ func (x *ClockSync) ProtoReflect() protoreflect.Message { // Deprecated: Use ClockSync.ProtoReflect.Descriptor instead. func (*ClockSync) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{5} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{5} } func (x *ClockSync) GetCurrentTime() *timestamppb.Timestamp { @@ -572,7 +573,7 @@ type RunInstances struct { func (x *RunInstances) Reset() { *x = RunInstances{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[6] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -585,7 +586,7 @@ func (x *RunInstances) String() string { func (*RunInstances) ProtoMessage() {} func (x *RunInstances) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[6] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -598,7 +599,7 @@ func (x *RunInstances) ProtoReflect() protoreflect.Message { // Deprecated: Use RunInstances.ProtoReflect.Descriptor instead. func (*RunInstances) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{6} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{6} } func (x *RunInstances) GetServices() []*ServiceInfo { @@ -634,20 +635,19 @@ type ServiceInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VersionInfo *VersionInfo `protobuf:"bytes,1,opt,name=version_info,json=versionInfo,proto3" json:"version_info,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` - ServiceId string `protobuf:"bytes,3,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - ProviderId string `protobuf:"bytes,4,opt,name=provider_id,json=providerId,proto3" json:"provider_id,omitempty"` - Gid uint32 `protobuf:"varint,5,opt,name=gid,proto3" json:"gid,omitempty"` - Sha256 []byte `protobuf:"bytes,6,opt,name=sha256,proto3" json:"sha256,omitempty"` - Sha512 []byte `protobuf:"bytes,7,opt,name=sha512,proto3" json:"sha512,omitempty"` - Size uint64 `protobuf:"varint,8,opt,name=size,proto3" json:"size,omitempty"` + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + ProviderId string `protobuf:"bytes,2,opt,name=provider_id,json=providerId,proto3" json:"provider_id,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + Gid uint32 `protobuf:"varint,4,opt,name=gid,proto3" json:"gid,omitempty"` + Url string `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"` + Sha256 []byte `protobuf:"bytes,6,opt,name=sha256,proto3" json:"sha256,omitempty"` + Size uint64 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"` } func (x *ServiceInfo) Reset() { *x = ServiceInfo{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[7] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -660,7 +660,7 @@ func (x *ServiceInfo) String() string { func (*ServiceInfo) ProtoMessage() {} func (x *ServiceInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[7] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -673,33 +673,26 @@ func (x *ServiceInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ServiceInfo.ProtoReflect.Descriptor instead. func (*ServiceInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{7} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{7} } -func (x *ServiceInfo) GetVersionInfo() *VersionInfo { - if x != nil { - return x.VersionInfo - } - return nil -} - -func (x *ServiceInfo) GetUrl() string { +func (x *ServiceInfo) GetServiceId() string { if x != nil { - return x.Url + return x.ServiceId } return "" } -func (x *ServiceInfo) GetServiceId() string { +func (x *ServiceInfo) GetProviderId() string { if x != nil { - return x.ServiceId + return x.ProviderId } return "" } -func (x *ServiceInfo) GetProviderId() string { +func (x *ServiceInfo) GetVersion() string { if x != nil { - return x.ProviderId + return x.Version } return "" } @@ -711,16 +704,16 @@ func (x *ServiceInfo) GetGid() uint32 { return 0 } -func (x *ServiceInfo) GetSha256() []byte { +func (x *ServiceInfo) GetUrl() string { if x != nil { - return x.Sha256 + return x.Url } - return nil + return "" } -func (x *ServiceInfo) GetSha512() []byte { +func (x *ServiceInfo) GetSha256() []byte { if x != nil { - return x.Sha512 + return x.Sha256 } return nil } @@ -737,19 +730,18 @@ type LayerInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VersionInfo *VersionInfo `protobuf:"bytes,1,opt,name=version_info,json=versionInfo,proto3" json:"version_info,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` - LayerId string `protobuf:"bytes,3,opt,name=layer_id,json=layerId,proto3" json:"layer_id,omitempty"` - Digest string `protobuf:"bytes,4,opt,name=digest,proto3" json:"digest,omitempty"` - Sha256 []byte `protobuf:"bytes,5,opt,name=sha256,proto3" json:"sha256,omitempty"` - Sha512 []byte `protobuf:"bytes,6,opt,name=sha512,proto3" json:"sha512,omitempty"` - Size uint64 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"` + LayerId string `protobuf:"bytes,1,opt,name=layer_id,json=layerId,proto3" json:"layer_id,omitempty"` + Digest string `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"` + Sha256 []byte `protobuf:"bytes,5,opt,name=sha256,proto3" json:"sha256,omitempty"` + Size uint64 `protobuf:"varint,6,opt,name=size,proto3" json:"size,omitempty"` } func (x *LayerInfo) Reset() { *x = LayerInfo{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[8] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -762,7 +754,7 @@ func (x *LayerInfo) String() string { func (*LayerInfo) ProtoMessage() {} func (x *LayerInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[8] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -775,33 +767,33 @@ func (x *LayerInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use LayerInfo.ProtoReflect.Descriptor instead. func (*LayerInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{8} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{8} } -func (x *LayerInfo) GetVersionInfo() *VersionInfo { +func (x *LayerInfo) GetLayerId() string { if x != nil { - return x.VersionInfo + return x.LayerId } - return nil + return "" } -func (x *LayerInfo) GetUrl() string { +func (x *LayerInfo) GetDigest() string { if x != nil { - return x.Url + return x.Digest } return "" } -func (x *LayerInfo) GetLayerId() string { +func (x *LayerInfo) GetVersion() string { if x != nil { - return x.LayerId + return x.Version } return "" } -func (x *LayerInfo) GetDigest() string { +func (x *LayerInfo) GetUrl() string { if x != nil { - return x.Digest + return x.Url } return "" } @@ -813,13 +805,6 @@ func (x *LayerInfo) GetSha256() []byte { return nil } -func (x *LayerInfo) GetSha512() []byte { - if x != nil { - return x.Sha512 - } - return nil -} - func (x *LayerInfo) GetSize() uint64 { if x != nil { return x.Size @@ -827,69 +812,6 @@ func (x *LayerInfo) GetSize() uint64 { return 0 } -type VersionInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - AosVersion uint64 `protobuf:"varint,1,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - VendorVersion string `protobuf:"bytes,2,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` -} - -func (x *VersionInfo) Reset() { - *x = VersionInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VersionInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VersionInfo) ProtoMessage() {} - -func (x *VersionInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VersionInfo.ProtoReflect.Descriptor instead. -func (*VersionInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{9} -} - -func (x *VersionInfo) GetAosVersion() uint64 { - if x != nil { - return x.AosVersion - } - return 0 -} - -func (x *VersionInfo) GetVendorVersion() string { - if x != nil { - return x.VendorVersion - } - return "" -} - -func (x *VersionInfo) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - type FirewallRule struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -904,7 +826,7 @@ type FirewallRule struct { func (x *FirewallRule) Reset() { *x = FirewallRule{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[10] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -917,7 +839,7 @@ func (x *FirewallRule) String() string { func (*FirewallRule) ProtoMessage() {} func (x *FirewallRule) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[10] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -930,7 +852,7 @@ func (x *FirewallRule) ProtoReflect() protoreflect.Message { // Deprecated: Use FirewallRule.ProtoReflect.Descriptor instead. func (*FirewallRule) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{10} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{9} } func (x *FirewallRule) GetDstIp() string { @@ -977,7 +899,7 @@ type NetworkParameters struct { func (x *NetworkParameters) Reset() { *x = NetworkParameters{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[11] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -990,7 +912,7 @@ func (x *NetworkParameters) String() string { func (*NetworkParameters) ProtoMessage() {} func (x *NetworkParameters) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[11] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1003,7 +925,7 @@ func (x *NetworkParameters) ProtoReflect() protoreflect.Message { // Deprecated: Use NetworkParameters.ProtoReflect.Descriptor instead. func (*NetworkParameters) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{11} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{10} } func (x *NetworkParameters) GetNetworkId() string { @@ -1053,18 +975,18 @@ type InstanceInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - Uid uint32 `protobuf:"varint,2,opt,name=uid,proto3" json:"uid,omitempty"` - Priority uint64 `protobuf:"varint,3,opt,name=priority,proto3" json:"priority,omitempty"` - StoragePath string `protobuf:"bytes,4,opt,name=storage_path,json=storagePath,proto3" json:"storage_path,omitempty"` - StatePath string `protobuf:"bytes,5,opt,name=state_path,json=statePath,proto3" json:"state_path,omitempty"` - NetworkParameters *NetworkParameters `protobuf:"bytes,6,opt,name=network_parameters,json=networkParameters,proto3" json:"network_parameters,omitempty"` + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + Uid uint32 `protobuf:"varint,2,opt,name=uid,proto3" json:"uid,omitempty"` + Priority uint64 `protobuf:"varint,3,opt,name=priority,proto3" json:"priority,omitempty"` + StoragePath string `protobuf:"bytes,4,opt,name=storage_path,json=storagePath,proto3" json:"storage_path,omitempty"` + StatePath string `protobuf:"bytes,5,opt,name=state_path,json=statePath,proto3" json:"state_path,omitempty"` + NetworkParameters *NetworkParameters `protobuf:"bytes,6,opt,name=network_parameters,json=networkParameters,proto3" json:"network_parameters,omitempty"` } func (x *InstanceInfo) Reset() { *x = InstanceInfo{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[12] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1077,7 +999,7 @@ func (x *InstanceInfo) String() string { func (*InstanceInfo) ProtoMessage() {} func (x *InstanceInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[12] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1090,10 +1012,10 @@ func (x *InstanceInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceInfo.ProtoReflect.Descriptor instead. func (*InstanceInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{12} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{11} } -func (x *InstanceInfo) GetInstance() *InstanceIdent { +func (x *InstanceInfo) GetInstance() *common.InstanceIdent { if x != nil { return x.Instance } @@ -1146,7 +1068,7 @@ type OverrideEnvVars struct { func (x *OverrideEnvVars) Reset() { *x = OverrideEnvVars{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[13] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1159,7 +1081,7 @@ func (x *OverrideEnvVars) String() string { func (*OverrideEnvVars) ProtoMessage() {} func (x *OverrideEnvVars) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[13] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1172,7 +1094,7 @@ func (x *OverrideEnvVars) ProtoReflect() protoreflect.Message { // Deprecated: Use OverrideEnvVars.ProtoReflect.Descriptor instead. func (*OverrideEnvVars) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{13} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{12} } func (x *OverrideEnvVars) GetEnvVars() []*OverrideInstanceEnvVar { @@ -1187,14 +1109,14 @@ type OverrideInstanceEnvVar struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - Vars []*EnvVarInfo `protobuf:"bytes,2,rep,name=vars,proto3" json:"vars,omitempty"` + InstanceFilter *InstanceFilter `protobuf:"bytes,1,opt,name=instance_filter,json=instanceFilter,proto3" json:"instance_filter,omitempty"` + Vars []*EnvVarInfo `protobuf:"bytes,2,rep,name=vars,proto3" json:"vars,omitempty"` } func (x *OverrideInstanceEnvVar) Reset() { *x = OverrideInstanceEnvVar{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[14] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1207,7 +1129,7 @@ func (x *OverrideInstanceEnvVar) String() string { func (*OverrideInstanceEnvVar) ProtoMessage() {} func (x *OverrideInstanceEnvVar) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[14] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1220,12 +1142,12 @@ func (x *OverrideInstanceEnvVar) ProtoReflect() protoreflect.Message { // Deprecated: Use OverrideInstanceEnvVar.ProtoReflect.Descriptor instead. func (*OverrideInstanceEnvVar) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{14} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{13} } -func (x *OverrideInstanceEnvVar) GetInstance() *InstanceIdent { +func (x *OverrideInstanceEnvVar) GetInstanceFilter() *InstanceFilter { if x != nil { - return x.Instance + return x.InstanceFilter } return nil } @@ -1250,7 +1172,7 @@ type EnvVarInfo struct { func (x *EnvVarInfo) Reset() { *x = EnvVarInfo{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[15] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1263,7 +1185,7 @@ func (x *EnvVarInfo) String() string { func (*EnvVarInfo) ProtoMessage() {} func (x *EnvVarInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[15] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1276,7 +1198,7 @@ func (x *EnvVarInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvVarInfo.ProtoReflect.Descriptor instead. func (*EnvVarInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{15} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{14} } func (x *EnvVarInfo) GetVarId() string { @@ -1313,7 +1235,7 @@ type SystemLogRequest struct { func (x *SystemLogRequest) Reset() { *x = SystemLogRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[16] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1326,7 +1248,7 @@ func (x *SystemLogRequest) String() string { func (*SystemLogRequest) ProtoMessage() {} func (x *SystemLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[16] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1339,7 +1261,7 @@ func (x *SystemLogRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemLogRequest.ProtoReflect.Descriptor instead. func (*SystemLogRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{16} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{15} } func (x *SystemLogRequest) GetLogId() string { @@ -1363,21 +1285,84 @@ func (x *SystemLogRequest) GetTill() *timestamppb.Timestamp { return nil } +type InstanceFilter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + SubjectId string `protobuf:"bytes,2,opt,name=subject_id,json=subjectId,proto3" json:"subject_id,omitempty"` + Instance int64 `protobuf:"varint,3,opt,name=instance,proto3" json:"instance,omitempty"` +} + +func (x *InstanceFilter) Reset() { + *x = InstanceFilter{} + if protoimpl.UnsafeEnabled { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InstanceFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InstanceFilter) ProtoMessage() {} + +func (x *InstanceFilter) ProtoReflect() protoreflect.Message { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InstanceFilter.ProtoReflect.Descriptor instead. +func (*InstanceFilter) Descriptor() ([]byte, []int) { + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{16} +} + +func (x *InstanceFilter) GetServiceId() string { + if x != nil { + return x.ServiceId + } + return "" +} + +func (x *InstanceFilter) GetSubjectId() string { + if x != nil { + return x.SubjectId + } + return "" +} + +func (x *InstanceFilter) GetInstance() int64 { + if x != nil { + return x.Instance + } + return 0 +} + type InstanceLogRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LogId string `protobuf:"bytes,1,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` - Instance *InstanceIdent `protobuf:"bytes,2,opt,name=instance,proto3" json:"instance,omitempty"` - From *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"` - Till *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=till,proto3" json:"till,omitempty"` + LogId string `protobuf:"bytes,1,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` + InstanceFilter *InstanceFilter `protobuf:"bytes,2,opt,name=instance_filter,json=instanceFilter,proto3" json:"instance_filter,omitempty"` + From *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"` + Till *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=till,proto3" json:"till,omitempty"` } func (x *InstanceLogRequest) Reset() { *x = InstanceLogRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[17] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1390,7 +1375,7 @@ func (x *InstanceLogRequest) String() string { func (*InstanceLogRequest) ProtoMessage() {} func (x *InstanceLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[17] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1403,7 +1388,7 @@ func (x *InstanceLogRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceLogRequest.ProtoReflect.Descriptor instead. func (*InstanceLogRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{17} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{17} } func (x *InstanceLogRequest) GetLogId() string { @@ -1413,9 +1398,9 @@ func (x *InstanceLogRequest) GetLogId() string { return "" } -func (x *InstanceLogRequest) GetInstance() *InstanceIdent { +func (x *InstanceLogRequest) GetInstanceFilter() *InstanceFilter { if x != nil { - return x.Instance + return x.InstanceFilter } return nil } @@ -1439,16 +1424,16 @@ type InstanceCrashLogRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LogId string `protobuf:"bytes,1,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` - Instance *InstanceIdent `protobuf:"bytes,2,opt,name=instance,proto3" json:"instance,omitempty"` - From *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"` - Till *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=till,proto3" json:"till,omitempty"` + LogId string `protobuf:"bytes,1,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` + InstanceFilter *InstanceFilter `protobuf:"bytes,2,opt,name=instance_filter,json=instanceFilter,proto3" json:"instance_filter,omitempty"` + From *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"` + Till *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=till,proto3" json:"till,omitempty"` } func (x *InstanceCrashLogRequest) Reset() { *x = InstanceCrashLogRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[18] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1461,7 +1446,7 @@ func (x *InstanceCrashLogRequest) String() string { func (*InstanceCrashLogRequest) ProtoMessage() {} func (x *InstanceCrashLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[18] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1474,7 +1459,7 @@ func (x *InstanceCrashLogRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceCrashLogRequest.ProtoReflect.Descriptor instead. func (*InstanceCrashLogRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{18} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{18} } func (x *InstanceCrashLogRequest) GetLogId() string { @@ -1484,9 +1469,9 @@ func (x *InstanceCrashLogRequest) GetLogId() string { return "" } -func (x *InstanceCrashLogRequest) GetInstance() *InstanceIdent { +func (x *InstanceCrashLogRequest) GetInstanceFilter() *InstanceFilter { if x != nil { - return x.Instance + return x.InstanceFilter } return nil } @@ -1505,29 +1490,29 @@ func (x *InstanceCrashLogRequest) GetTill() *timestamppb.Timestamp { return nil } -type GetNodeMonitoring struct { +type GetAverageMonitoring struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *GetNodeMonitoring) Reset() { - *x = GetNodeMonitoring{} +func (x *GetAverageMonitoring) Reset() { + *x = GetAverageMonitoring{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[19] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *GetNodeMonitoring) String() string { +func (x *GetAverageMonitoring) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetNodeMonitoring) ProtoMessage() {} +func (*GetAverageMonitoring) ProtoMessage() {} -func (x *GetNodeMonitoring) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[19] +func (x *GetAverageMonitoring) ProtoReflect() protoreflect.Message { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1538,9 +1523,9 @@ func (x *GetNodeMonitoring) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetNodeMonitoring.ProtoReflect.Descriptor instead. -func (*GetNodeMonitoring) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{19} +// Deprecated: Use GetAverageMonitoring.ProtoReflect.Descriptor instead. +func (*GetAverageMonitoring) Descriptor() ([]byte, []int) { + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{19} } type ConnectionStatus struct { @@ -1548,13 +1533,13 @@ type ConnectionStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - CloudStatus ConnectionEnum `protobuf:"varint,1,opt,name=cloud_status,json=cloudStatus,proto3,enum=servicemanager.v3.ConnectionEnum" json:"cloud_status,omitempty"` + CloudStatus ConnectionEnum `protobuf:"varint,1,opt,name=cloud_status,json=cloudStatus,proto3,enum=servicemanager.v4.ConnectionEnum" json:"cloud_status,omitempty"` } func (x *ConnectionStatus) Reset() { *x = ConnectionStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[20] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1567,7 +1552,7 @@ func (x *ConnectionStatus) String() string { func (*ConnectionStatus) ProtoMessage() {} func (x *ConnectionStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[20] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1580,7 +1565,7 @@ func (x *ConnectionStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use ConnectionStatus.ProtoReflect.Descriptor instead. func (*ConnectionStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{20} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{20} } func (x *ConnectionStatus) GetCloudStatus() ConnectionEnum { @@ -1595,15 +1580,15 @@ type ImageContentInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` - ImageFiles []*ImageFile `protobuf:"bytes,2,rep,name=image_files,json=imageFiles,proto3" json:"image_files,omitempty"` - Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` + RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + ImageFiles []*ImageFile `protobuf:"bytes,2,rep,name=image_files,json=imageFiles,proto3" json:"image_files,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` } func (x *ImageContentInfo) Reset() { *x = ImageContentInfo{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[21] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1616,7 +1601,7 @@ func (x *ImageContentInfo) String() string { func (*ImageContentInfo) ProtoMessage() {} func (x *ImageContentInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[21] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1629,7 +1614,7 @@ func (x *ImageContentInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ImageContentInfo.ProtoReflect.Descriptor instead. func (*ImageContentInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{21} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{21} } func (x *ImageContentInfo) GetRequestId() uint64 { @@ -1646,11 +1631,11 @@ func (x *ImageContentInfo) GetImageFiles() []*ImageFile { return nil } -func (x *ImageContentInfo) GetError() string { +func (x *ImageContentInfo) GetError() *common.ErrorInfo { if x != nil { return x.Error } - return "" + return nil } type ImageFile struct { @@ -1666,7 +1651,7 @@ type ImageFile struct { func (x *ImageFile) Reset() { *x = ImageFile{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[22] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1679,7 +1664,7 @@ func (x *ImageFile) String() string { func (*ImageFile) ProtoMessage() {} func (x *ImageFile) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[22] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1692,7 +1677,7 @@ func (x *ImageFile) ProtoReflect() protoreflect.Message { // Deprecated: Use ImageFile.ProtoReflect.Descriptor instead. func (*ImageFile) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{22} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{22} } func (x *ImageFile) GetRelativePath() string { @@ -1731,7 +1716,7 @@ type ImageContent struct { func (x *ImageContent) Reset() { *x = ImageContent{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[23] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1744,7 +1729,7 @@ func (x *ImageContent) String() string { func (*ImageContent) ProtoMessage() {} func (x *ImageContent) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[23] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1757,7 +1742,7 @@ func (x *ImageContent) ProtoReflect() protoreflect.Message { // Deprecated: Use ImageContent.ProtoReflect.Descriptor instead. func (*ImageContent) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{23} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{23} } func (x *ImageContent) GetRequestId() uint64 { @@ -1795,6 +1780,53 @@ func (x *ImageContent) GetData() []byte { return nil } +type RegisterSM struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` +} + +func (x *RegisterSM) Reset() { + *x = RegisterSM{} + if protoimpl.UnsafeEnabled { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RegisterSM) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterSM) ProtoMessage() {} + +func (x *RegisterSM) ProtoReflect() protoreflect.Message { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[24] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterSM.ProtoReflect.Descriptor instead. +func (*RegisterSM) Descriptor() ([]byte, []int) { + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{24} +} + +func (x *RegisterSM) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + type SMOutgoingMessages struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1802,13 +1834,14 @@ type SMOutgoingMessages struct { // Types that are assignable to SMOutgoingMessage: // - // *SMOutgoingMessages_NodeConfiguration + // *SMOutgoingMessages_RegisterSm // *SMOutgoingMessages_UnitConfigStatus // *SMOutgoingMessages_RunInstancesStatus // *SMOutgoingMessages_UpdateInstancesStatus // *SMOutgoingMessages_OverrideEnvVarStatus // *SMOutgoingMessages_Log - // *SMOutgoingMessages_NodeMonitoring + // *SMOutgoingMessages_InstantMonitoring + // *SMOutgoingMessages_AverageMonitoring // *SMOutgoingMessages_Alert // *SMOutgoingMessages_ImageContentRequest // *SMOutgoingMessages_ClockSyncRequest @@ -1818,7 +1851,7 @@ type SMOutgoingMessages struct { func (x *SMOutgoingMessages) Reset() { *x = SMOutgoingMessages{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[24] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1831,7 +1864,7 @@ func (x *SMOutgoingMessages) String() string { func (*SMOutgoingMessages) ProtoMessage() {} func (x *SMOutgoingMessages) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[24] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1844,7 +1877,7 @@ func (x *SMOutgoingMessages) ProtoReflect() protoreflect.Message { // Deprecated: Use SMOutgoingMessages.ProtoReflect.Descriptor instead. func (*SMOutgoingMessages) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{24} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{25} } func (m *SMOutgoingMessages) GetSMOutgoingMessage() isSMOutgoingMessages_SMOutgoingMessage { @@ -1854,9 +1887,9 @@ func (m *SMOutgoingMessages) GetSMOutgoingMessage() isSMOutgoingMessages_SMOutgo return nil } -func (x *SMOutgoingMessages) GetNodeConfiguration() *NodeConfiguration { - if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_NodeConfiguration); ok { - return x.NodeConfiguration +func (x *SMOutgoingMessages) GetRegisterSm() *RegisterSM { + if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_RegisterSm); ok { + return x.RegisterSm } return nil } @@ -1896,9 +1929,16 @@ func (x *SMOutgoingMessages) GetLog() *LogData { return nil } -func (x *SMOutgoingMessages) GetNodeMonitoring() *NodeMonitoring { - if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_NodeMonitoring); ok { - return x.NodeMonitoring +func (x *SMOutgoingMessages) GetInstantMonitoring() *InstantMonitoring { + if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_InstantMonitoring); ok { + return x.InstantMonitoring + } + return nil +} + +func (x *SMOutgoingMessages) GetAverageMonitoring() *AverageMonitoring { + if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_AverageMonitoring); ok { + return x.AverageMonitoring } return nil } @@ -1928,8 +1968,8 @@ type isSMOutgoingMessages_SMOutgoingMessage interface { isSMOutgoingMessages_SMOutgoingMessage() } -type SMOutgoingMessages_NodeConfiguration struct { - NodeConfiguration *NodeConfiguration `protobuf:"bytes,1,opt,name=node_configuration,json=nodeConfiguration,proto3,oneof"` +type SMOutgoingMessages_RegisterSm struct { + RegisterSm *RegisterSM `protobuf:"bytes,1,opt,name=register_sm,json=registerSm,proto3,oneof"` } type SMOutgoingMessages_UnitConfigStatus struct { @@ -1952,23 +1992,27 @@ type SMOutgoingMessages_Log struct { Log *LogData `protobuf:"bytes,6,opt,name=log,proto3,oneof"` } -type SMOutgoingMessages_NodeMonitoring struct { - NodeMonitoring *NodeMonitoring `protobuf:"bytes,7,opt,name=node_monitoring,json=nodeMonitoring,proto3,oneof"` +type SMOutgoingMessages_InstantMonitoring struct { + InstantMonitoring *InstantMonitoring `protobuf:"bytes,7,opt,name=instant_monitoring,json=instantMonitoring,proto3,oneof"` +} + +type SMOutgoingMessages_AverageMonitoring struct { + AverageMonitoring *AverageMonitoring `protobuf:"bytes,8,opt,name=average_monitoring,json=averageMonitoring,proto3,oneof"` } type SMOutgoingMessages_Alert struct { - Alert *Alert `protobuf:"bytes,8,opt,name=alert,proto3,oneof"` + Alert *Alert `protobuf:"bytes,9,opt,name=alert,proto3,oneof"` } type SMOutgoingMessages_ImageContentRequest struct { - ImageContentRequest *ImageContentRequest `protobuf:"bytes,9,opt,name=image_content_request,json=imageContentRequest,proto3,oneof"` + ImageContentRequest *ImageContentRequest `protobuf:"bytes,10,opt,name=image_content_request,json=imageContentRequest,proto3,oneof"` } type SMOutgoingMessages_ClockSyncRequest struct { - ClockSyncRequest *ClockSyncRequest `protobuf:"bytes,10,opt,name=clock_sync_request,json=clockSyncRequest,proto3,oneof"` + ClockSyncRequest *ClockSyncRequest `protobuf:"bytes,11,opt,name=clock_sync_request,json=clockSyncRequest,proto3,oneof"` } -func (*SMOutgoingMessages_NodeConfiguration) isSMOutgoingMessages_SMOutgoingMessage() {} +func (*SMOutgoingMessages_RegisterSm) isSMOutgoingMessages_SMOutgoingMessage() {} func (*SMOutgoingMessages_UnitConfigStatus) isSMOutgoingMessages_SMOutgoingMessage() {} @@ -1980,7 +2024,9 @@ func (*SMOutgoingMessages_OverrideEnvVarStatus) isSMOutgoingMessages_SMOutgoingM func (*SMOutgoingMessages_Log) isSMOutgoingMessages_SMOutgoingMessage() {} -func (*SMOutgoingMessages_NodeMonitoring) isSMOutgoingMessages_SMOutgoingMessage() {} +func (*SMOutgoingMessages_InstantMonitoring) isSMOutgoingMessages_SMOutgoingMessage() {} + +func (*SMOutgoingMessages_AverageMonitoring) isSMOutgoingMessages_SMOutgoingMessage() {} func (*SMOutgoingMessages_Alert) isSMOutgoingMessages_SMOutgoingMessage() {} @@ -1988,101 +2034,6 @@ func (*SMOutgoingMessages_ImageContentRequest) isSMOutgoingMessages_SMOutgoingMe func (*SMOutgoingMessages_ClockSyncRequest) isSMOutgoingMessages_SMOutgoingMessage() {} -type NodeConfiguration struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` - NodeType string `protobuf:"bytes,2,opt,name=node_type,json=nodeType,proto3" json:"node_type,omitempty"` - RemoteNode bool `protobuf:"varint,3,opt,name=remote_node,json=remoteNode,proto3" json:"remote_node,omitempty"` - RunnerFeatures []string `protobuf:"bytes,4,rep,name=runner_features,json=runnerFeatures,proto3" json:"runner_features,omitempty"` - NumCpus uint64 `protobuf:"varint,5,opt,name=num_cpus,json=numCpus,proto3" json:"num_cpus,omitempty"` - TotalRam uint64 `protobuf:"varint,6,opt,name=total_ram,json=totalRam,proto3" json:"total_ram,omitempty"` - Partitions []*Partition `protobuf:"bytes,7,rep,name=partitions,proto3" json:"partitions,omitempty"` -} - -func (x *NodeConfiguration) Reset() { - *x = NodeConfiguration{} - if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *NodeConfiguration) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NodeConfiguration) ProtoMessage() {} - -func (x *NodeConfiguration) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[25] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NodeConfiguration.ProtoReflect.Descriptor instead. -func (*NodeConfiguration) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{25} -} - -func (x *NodeConfiguration) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - -func (x *NodeConfiguration) GetNodeType() string { - if x != nil { - return x.NodeType - } - return "" -} - -func (x *NodeConfiguration) GetRemoteNode() bool { - if x != nil { - return x.RemoteNode - } - return false -} - -func (x *NodeConfiguration) GetRunnerFeatures() []string { - if x != nil { - return x.RunnerFeatures - } - return nil -} - -func (x *NodeConfiguration) GetNumCpus() uint64 { - if x != nil { - return x.NumCpus - } - return 0 -} - -func (x *NodeConfiguration) GetTotalRam() uint64 { - if x != nil { - return x.TotalRam - } - return 0 -} - -func (x *NodeConfiguration) GetPartitions() []*Partition { - if x != nil { - return x.Partitions - } - return nil -} - type Partition struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2096,7 +2047,7 @@ type Partition struct { func (x *Partition) Reset() { *x = Partition{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[26] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2109,7 +2060,7 @@ func (x *Partition) String() string { func (*Partition) ProtoMessage() {} func (x *Partition) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[26] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2122,7 +2073,7 @@ func (x *Partition) ProtoReflect() protoreflect.Message { // Deprecated: Use Partition.ProtoReflect.Descriptor instead. func (*Partition) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{26} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{26} } func (x *Partition) GetName() string { @@ -2151,14 +2102,14 @@ type UnitConfigStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VendorVersion string `protobuf:"bytes,1,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } func (x *UnitConfigStatus) Reset() { *x = UnitConfigStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[27] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2171,7 +2122,7 @@ func (x *UnitConfigStatus) String() string { func (*UnitConfigStatus) ProtoMessage() {} func (x *UnitConfigStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[27] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2184,21 +2135,21 @@ func (x *UnitConfigStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use UnitConfigStatus.ProtoReflect.Descriptor instead. func (*UnitConfigStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{27} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{27} } -func (x *UnitConfigStatus) GetVendorVersion() string { +func (x *UnitConfigStatus) GetVersion() string { if x != nil { - return x.VendorVersion + return x.Version } return "" } -func (x *UnitConfigStatus) GetError() string { +func (x *UnitConfigStatus) GetError() *common.ErrorInfo { if x != nil { return x.Error } - return "" + return nil } type RunInstancesStatus struct { @@ -2212,7 +2163,7 @@ type RunInstancesStatus struct { func (x *RunInstancesStatus) Reset() { *x = RunInstancesStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[28] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2225,7 +2176,7 @@ func (x *RunInstancesStatus) String() string { func (*RunInstancesStatus) ProtoMessage() {} func (x *RunInstancesStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[28] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2238,7 +2189,7 @@ func (x *RunInstancesStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use RunInstancesStatus.ProtoReflect.Descriptor instead. func (*RunInstancesStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{28} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{28} } func (x *RunInstancesStatus) GetInstances() []*InstanceStatus { @@ -2259,7 +2210,7 @@ type UpdateInstancesStatus struct { func (x *UpdateInstancesStatus) Reset() { *x = UpdateInstancesStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[29] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2272,7 +2223,7 @@ func (x *UpdateInstancesStatus) String() string { func (*UpdateInstancesStatus) ProtoMessage() {} func (x *UpdateInstancesStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[29] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2285,7 +2236,7 @@ func (x *UpdateInstancesStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateInstancesStatus.ProtoReflect.Descriptor instead. func (*UpdateInstancesStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{29} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{29} } func (x *UpdateInstancesStatus) GetInstances() []*InstanceStatus { @@ -2300,16 +2251,16 @@ type InstanceStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - AosVersion uint64 `protobuf:"varint,2,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - RunState string `protobuf:"bytes,3,opt,name=run_state,json=runState,proto3" json:"run_state,omitempty"` - ErrorInfo *ErrorInfo `protobuf:"bytes,4,opt,name=error_info,json=errorInfo,proto3" json:"error_info,omitempty"` + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + ServiceVersion string `protobuf:"bytes,2,opt,name=service_version,json=serviceVersion,proto3" json:"service_version,omitempty"` + RunState string `protobuf:"bytes,3,opt,name=run_state,json=runState,proto3" json:"run_state,omitempty"` + ErrorInfo *common.ErrorInfo `protobuf:"bytes,4,opt,name=error_info,json=errorInfo,proto3" json:"error_info,omitempty"` } func (x *InstanceStatus) Reset() { *x = InstanceStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[30] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2322,7 +2273,7 @@ func (x *InstanceStatus) String() string { func (*InstanceStatus) ProtoMessage() {} func (x *InstanceStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[30] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2335,21 +2286,21 @@ func (x *InstanceStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceStatus.ProtoReflect.Descriptor instead. func (*InstanceStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{30} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{30} } -func (x *InstanceStatus) GetInstance() *InstanceIdent { +func (x *InstanceStatus) GetInstance() *common.InstanceIdent { if x != nil { return x.Instance } return nil } -func (x *InstanceStatus) GetAosVersion() uint64 { +func (x *InstanceStatus) GetServiceVersion() string { if x != nil { - return x.AosVersion + return x.ServiceVersion } - return 0 + return "" } func (x *InstanceStatus) GetRunState() string { @@ -2359,152 +2310,26 @@ func (x *InstanceStatus) GetRunState() string { return "" } -func (x *InstanceStatus) GetErrorInfo() *ErrorInfo { +func (x *InstanceStatus) GetErrorInfo() *common.ErrorInfo { if x != nil { return x.ErrorInfo } return nil } -type InstanceIdent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ServiceId string `protobuf:"bytes,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - SubjectId string `protobuf:"bytes,2,opt,name=subject_id,json=subjectId,proto3" json:"subject_id,omitempty"` - Instance int64 `protobuf:"varint,3,opt,name=instance,proto3" json:"instance,omitempty"` -} - -func (x *InstanceIdent) Reset() { - *x = InstanceIdent{} - if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[31] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InstanceIdent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InstanceIdent) ProtoMessage() {} - -func (x *InstanceIdent) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[31] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InstanceIdent.ProtoReflect.Descriptor instead. -func (*InstanceIdent) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{31} -} - -func (x *InstanceIdent) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *InstanceIdent) GetSubjectId() string { - if x != nil { - return x.SubjectId - } - return "" -} - -func (x *InstanceIdent) GetInstance() int64 { - if x != nil { - return x.Instance - } - return 0 -} - -type ErrorInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - AosCode int32 `protobuf:"varint,1,opt,name=aos_code,json=aosCode,proto3" json:"aos_code,omitempty"` - ExitCode int32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *ErrorInfo) Reset() { - *x = ErrorInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ErrorInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ErrorInfo) ProtoMessage() {} - -func (x *ErrorInfo) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[32] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ErrorInfo.ProtoReflect.Descriptor instead. -func (*ErrorInfo) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{32} -} - -func (x *ErrorInfo) GetAosCode() int32 { - if x != nil { - return x.AosCode - } - return 0 -} - -func (x *ErrorInfo) GetExitCode() int32 { - if x != nil { - return x.ExitCode - } - return 0 -} - -func (x *ErrorInfo) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - type OverrideEnvVarStatus struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields EnvVarsStatus []*EnvVarInstanceStatus `protobuf:"bytes,1,rep,name=env_vars_status,json=envVarsStatus,proto3" json:"env_vars_status,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } func (x *OverrideEnvVarStatus) Reset() { *x = OverrideEnvVarStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[33] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2517,7 +2342,7 @@ func (x *OverrideEnvVarStatus) String() string { func (*OverrideEnvVarStatus) ProtoMessage() {} func (x *OverrideEnvVarStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[33] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2530,7 +2355,7 @@ func (x *OverrideEnvVarStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use OverrideEnvVarStatus.ProtoReflect.Descriptor instead. func (*OverrideEnvVarStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{33} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{31} } func (x *OverrideEnvVarStatus) GetEnvVarsStatus() []*EnvVarInstanceStatus { @@ -2540,11 +2365,11 @@ func (x *OverrideEnvVarStatus) GetEnvVarsStatus() []*EnvVarInstanceStatus { return nil } -func (x *OverrideEnvVarStatus) GetError() string { +func (x *OverrideEnvVarStatus) GetError() *common.ErrorInfo { if x != nil { return x.Error } - return "" + return nil } type EnvVarInstanceStatus struct { @@ -2552,14 +2377,14 @@ type EnvVarInstanceStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - VarsStatus []*EnvVarStatus `protobuf:"bytes,2,rep,name=vars_status,json=varsStatus,proto3" json:"vars_status,omitempty"` + InstanceFilter *InstanceFilter `protobuf:"bytes,1,opt,name=instance_filter,json=instanceFilter,proto3" json:"instance_filter,omitempty"` + VarsStatus []*EnvVarStatus `protobuf:"bytes,2,rep,name=vars_status,json=varsStatus,proto3" json:"vars_status,omitempty"` } func (x *EnvVarInstanceStatus) Reset() { *x = EnvVarInstanceStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[34] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2572,7 +2397,7 @@ func (x *EnvVarInstanceStatus) String() string { func (*EnvVarInstanceStatus) ProtoMessage() {} func (x *EnvVarInstanceStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[34] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2585,12 +2410,12 @@ func (x *EnvVarInstanceStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvVarInstanceStatus.ProtoReflect.Descriptor instead. func (*EnvVarInstanceStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{34} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{32} } -func (x *EnvVarInstanceStatus) GetInstance() *InstanceIdent { +func (x *EnvVarInstanceStatus) GetInstanceFilter() *InstanceFilter { if x != nil { - return x.Instance + return x.InstanceFilter } return nil } @@ -2607,14 +2432,14 @@ type EnvVarStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VarId string `protobuf:"bytes,1,opt,name=var_id,json=varId,proto3" json:"var_id,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` + VarId string `protobuf:"bytes,1,opt,name=var_id,json=varId,proto3" json:"var_id,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } func (x *EnvVarStatus) Reset() { *x = EnvVarStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[35] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2627,7 +2452,7 @@ func (x *EnvVarStatus) String() string { func (*EnvVarStatus) ProtoMessage() {} func (x *EnvVarStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[35] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2640,7 +2465,7 @@ func (x *EnvVarStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvVarStatus.ProtoReflect.Descriptor instead. func (*EnvVarStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{35} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{33} } func (x *EnvVarStatus) GetVarId() string { @@ -2650,11 +2475,11 @@ func (x *EnvVarStatus) GetVarId() string { return "" } -func (x *EnvVarStatus) GetError() string { +func (x *EnvVarStatus) GetError() *common.ErrorInfo { if x != nil { return x.Error } - return "" + return nil } type LogData struct { @@ -2662,17 +2487,17 @@ type LogData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LogId string `protobuf:"bytes,1,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` - PartCount uint64 `protobuf:"varint,2,opt,name=part_count,json=partCount,proto3" json:"part_count,omitempty"` - Part uint64 `protobuf:"varint,3,opt,name=part,proto3" json:"part,omitempty"` - Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` - Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + LogId string `protobuf:"bytes,1,opt,name=log_id,json=logId,proto3" json:"log_id,omitempty"` + PartCount uint64 `protobuf:"varint,2,opt,name=part_count,json=partCount,proto3" json:"part_count,omitempty"` + Part uint64 `protobuf:"varint,3,opt,name=part,proto3" json:"part,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` } func (x *LogData) Reset() { *x = LogData{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[36] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2685,7 +2510,7 @@ func (x *LogData) String() string { func (*LogData) ProtoMessage() {} func (x *LogData) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[36] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2698,7 +2523,7 @@ func (x *LogData) ProtoReflect() protoreflect.Message { // Deprecated: Use LogData.ProtoReflect.Descriptor instead. func (*LogData) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{36} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{34} } func (x *LogData) GetLogId() string { @@ -2729,40 +2554,40 @@ func (x *LogData) GetData() []byte { return nil } -func (x *LogData) GetError() string { +func (x *LogData) GetError() *common.ErrorInfo { if x != nil { return x.Error } - return "" + return nil } -type NodeMonitoring struct { +type InstantMonitoring struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - MonitoringData *MonitoringData `protobuf:"bytes,2,opt,name=monitoring_data,json=monitoringData,proto3" json:"monitoring_data,omitempty"` + NodeMonitoring *MonitoringData `protobuf:"bytes,2,opt,name=node_monitoring,json=nodeMonitoring,proto3" json:"node_monitoring,omitempty"` InstanceMonitoring []*InstanceMonitoring `protobuf:"bytes,3,rep,name=instance_monitoring,json=instanceMonitoring,proto3" json:"instance_monitoring,omitempty"` } -func (x *NodeMonitoring) Reset() { - *x = NodeMonitoring{} +func (x *InstantMonitoring) Reset() { + *x = InstantMonitoring{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[37] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *NodeMonitoring) String() string { +func (x *InstantMonitoring) String() string { return protoimpl.X.MessageStringOf(x) } -func (*NodeMonitoring) ProtoMessage() {} +func (*InstantMonitoring) ProtoMessage() {} -func (x *NodeMonitoring) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[37] +func (x *InstantMonitoring) ProtoReflect() protoreflect.Message { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2773,26 +2598,89 @@ func (x *NodeMonitoring) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use NodeMonitoring.ProtoReflect.Descriptor instead. -func (*NodeMonitoring) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{37} +// Deprecated: Use InstantMonitoring.ProtoReflect.Descriptor instead. +func (*InstantMonitoring) Descriptor() ([]byte, []int) { + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{35} } -func (x *NodeMonitoring) GetTimestamp() *timestamppb.Timestamp { +func (x *InstantMonitoring) GetTimestamp() *timestamppb.Timestamp { if x != nil { return x.Timestamp } return nil } -func (x *NodeMonitoring) GetMonitoringData() *MonitoringData { +func (x *InstantMonitoring) GetNodeMonitoring() *MonitoringData { if x != nil { - return x.MonitoringData + return x.NodeMonitoring } return nil } -func (x *NodeMonitoring) GetInstanceMonitoring() []*InstanceMonitoring { +func (x *InstantMonitoring) GetInstanceMonitoring() []*InstanceMonitoring { + if x != nil { + return x.InstanceMonitoring + } + return nil +} + +type AverageMonitoring struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + NodeMonitoring *MonitoringData `protobuf:"bytes,2,opt,name=node_monitoring,json=nodeMonitoring,proto3" json:"node_monitoring,omitempty"` + InstanceMonitoring []*InstanceMonitoring `protobuf:"bytes,3,rep,name=instance_monitoring,json=instanceMonitoring,proto3" json:"instance_monitoring,omitempty"` +} + +func (x *AverageMonitoring) Reset() { + *x = AverageMonitoring{} + if protoimpl.UnsafeEnabled { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AverageMonitoring) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AverageMonitoring) ProtoMessage() {} + +func (x *AverageMonitoring) ProtoReflect() protoreflect.Message { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[36] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AverageMonitoring.ProtoReflect.Descriptor instead. +func (*AverageMonitoring) Descriptor() ([]byte, []int) { + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{36} +} + +func (x *AverageMonitoring) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *AverageMonitoring) GetNodeMonitoring() *MonitoringData { + if x != nil { + return x.NodeMonitoring + } + return nil +} + +func (x *AverageMonitoring) GetInstanceMonitoring() []*InstanceMonitoring { if x != nil { return x.InstanceMonitoring } @@ -2814,7 +2702,7 @@ type MonitoringData struct { func (x *MonitoringData) Reset() { *x = MonitoringData{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[38] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2827,7 +2715,7 @@ func (x *MonitoringData) String() string { func (*MonitoringData) ProtoMessage() {} func (x *MonitoringData) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[38] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2840,7 +2728,7 @@ func (x *MonitoringData) ProtoReflect() protoreflect.Message { // Deprecated: Use MonitoringData.ProtoReflect.Descriptor instead. func (*MonitoringData) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{38} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{37} } func (x *MonitoringData) GetRam() uint64 { @@ -2890,7 +2778,7 @@ type PartitionUsage struct { func (x *PartitionUsage) Reset() { *x = PartitionUsage{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[39] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2903,7 +2791,7 @@ func (x *PartitionUsage) String() string { func (*PartitionUsage) ProtoMessage() {} func (x *PartitionUsage) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[39] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[38] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2916,7 +2804,7 @@ func (x *PartitionUsage) ProtoReflect() protoreflect.Message { // Deprecated: Use PartitionUsage.ProtoReflect.Descriptor instead. func (*PartitionUsage) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{39} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{38} } func (x *PartitionUsage) GetName() string { @@ -2938,14 +2826,14 @@ type InstanceMonitoring struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - MonitoringData *MonitoringData `protobuf:"bytes,2,opt,name=monitoring_data,json=monitoringData,proto3" json:"monitoring_data,omitempty"` + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + MonitoringData *MonitoringData `protobuf:"bytes,2,opt,name=monitoring_data,json=monitoringData,proto3" json:"monitoring_data,omitempty"` } func (x *InstanceMonitoring) Reset() { *x = InstanceMonitoring{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[40] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2958,7 +2846,7 @@ func (x *InstanceMonitoring) String() string { func (*InstanceMonitoring) ProtoMessage() {} func (x *InstanceMonitoring) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[40] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2971,10 +2859,10 @@ func (x *InstanceMonitoring) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceMonitoring.ProtoReflect.Descriptor instead. func (*InstanceMonitoring) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{40} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{39} } -func (x *InstanceMonitoring) GetInstance() *InstanceIdent { +func (x *InstanceMonitoring) GetInstance() *common.InstanceIdent { if x != nil { return x.Instance } @@ -3010,7 +2898,7 @@ type Alert struct { func (x *Alert) Reset() { *x = Alert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[41] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3023,7 +2911,7 @@ func (x *Alert) String() string { func (*Alert) ProtoMessage() {} func (x *Alert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[41] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3036,7 +2924,7 @@ func (x *Alert) ProtoReflect() protoreflect.Message { // Deprecated: Use Alert.ProtoReflect.Descriptor instead. func (*Alert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{41} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{40} } func (x *Alert) GetTimestamp() *timestamppb.Timestamp { @@ -3168,7 +3056,7 @@ type ImageContentRequest struct { func (x *ImageContentRequest) Reset() { *x = ImageContentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[42] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3181,7 +3069,7 @@ func (x *ImageContentRequest) String() string { func (*ImageContentRequest) ProtoMessage() {} func (x *ImageContentRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[42] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[41] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3194,7 +3082,7 @@ func (x *ImageContentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ImageContentRequest.ProtoReflect.Descriptor instead. func (*ImageContentRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{42} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{41} } func (x *ImageContentRequest) GetUrl() string { @@ -3227,7 +3115,7 @@ type ClockSyncRequest struct { func (x *ClockSyncRequest) Reset() { *x = ClockSyncRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[43] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3240,7 +3128,7 @@ func (x *ClockSyncRequest) String() string { func (*ClockSyncRequest) ProtoMessage() {} func (x *ClockSyncRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[43] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[42] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3253,7 +3141,7 @@ func (x *ClockSyncRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ClockSyncRequest.ProtoReflect.Descriptor instead. func (*ClockSyncRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{43} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{42} } type SystemQuotaAlert struct { @@ -3263,12 +3151,13 @@ type SystemQuotaAlert struct { Parameter string `protobuf:"bytes,1,opt,name=parameter,proto3" json:"parameter,omitempty"` Value uint64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` + Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` } func (x *SystemQuotaAlert) Reset() { *x = SystemQuotaAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[44] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3281,7 +3170,7 @@ func (x *SystemQuotaAlert) String() string { func (*SystemQuotaAlert) ProtoMessage() {} func (x *SystemQuotaAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[44] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[43] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3294,7 +3183,7 @@ func (x *SystemQuotaAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemQuotaAlert.ProtoReflect.Descriptor instead. func (*SystemQuotaAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{44} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{43} } func (x *SystemQuotaAlert) GetParameter() string { @@ -3311,20 +3200,28 @@ func (x *SystemQuotaAlert) GetValue() uint64 { return 0 } +func (x *SystemQuotaAlert) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + type InstanceQuotaAlert struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - Parameter string `protobuf:"bytes,2,opt,name=parameter,proto3" json:"parameter,omitempty"` - Value uint64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"` + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + Parameter string `protobuf:"bytes,2,opt,name=parameter,proto3" json:"parameter,omitempty"` + Value uint64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"` + Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` } func (x *InstanceQuotaAlert) Reset() { *x = InstanceQuotaAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[45] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3337,7 +3234,7 @@ func (x *InstanceQuotaAlert) String() string { func (*InstanceQuotaAlert) ProtoMessage() {} func (x *InstanceQuotaAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[45] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[44] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3350,10 +3247,10 @@ func (x *InstanceQuotaAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceQuotaAlert.ProtoReflect.Descriptor instead. func (*InstanceQuotaAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{45} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{44} } -func (x *InstanceQuotaAlert) GetInstance() *InstanceIdent { +func (x *InstanceQuotaAlert) GetInstance() *common.InstanceIdent { if x != nil { return x.Instance } @@ -3374,20 +3271,27 @@ func (x *InstanceQuotaAlert) GetValue() uint64 { return 0 } +func (x *InstanceQuotaAlert) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + type DeviceAllocateAlert struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - Device string `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + Device string `protobuf:"bytes,2,opt,name=device,proto3" json:"device,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` } func (x *DeviceAllocateAlert) Reset() { *x = DeviceAllocateAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[46] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3400,7 +3304,7 @@ func (x *DeviceAllocateAlert) String() string { func (*DeviceAllocateAlert) ProtoMessage() {} func (x *DeviceAllocateAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[46] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[45] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3413,10 +3317,10 @@ func (x *DeviceAllocateAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use DeviceAllocateAlert.ProtoReflect.Descriptor instead. func (*DeviceAllocateAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{46} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{45} } -func (x *DeviceAllocateAlert) GetInstance() *InstanceIdent { +func (x *DeviceAllocateAlert) GetInstance() *common.InstanceIdent { if x != nil { return x.Instance } @@ -3442,13 +3346,14 @@ type ResourceValidateAlert struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Errors []*ResourceValidateErrors `protobuf:"bytes,1,rep,name=errors,proto3" json:"errors,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Errors []*common.ErrorInfo `protobuf:"bytes,2,rep,name=errors,proto3" json:"errors,omitempty"` } func (x *ResourceValidateAlert) Reset() { *x = ResourceValidateAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[47] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3461,7 +3366,7 @@ func (x *ResourceValidateAlert) String() string { func (*ResourceValidateAlert) ProtoMessage() {} func (x *ResourceValidateAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[47] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[46] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3474,67 +3379,19 @@ func (x *ResourceValidateAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceValidateAlert.ProtoReflect.Descriptor instead. func (*ResourceValidateAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{47} -} - -func (x *ResourceValidateAlert) GetErrors() []*ResourceValidateErrors { - if x != nil { - return x.Errors - } - return nil -} - -type ResourceValidateErrors struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ErrorMsg []string `protobuf:"bytes,2,rep,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` -} - -func (x *ResourceValidateErrors) Reset() { - *x = ResourceValidateErrors{} - if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[48] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ResourceValidateErrors) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResourceValidateErrors) ProtoMessage() {} - -func (x *ResourceValidateErrors) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[48] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ResourceValidateErrors.ProtoReflect.Descriptor instead. -func (*ResourceValidateErrors) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{48} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{46} } -func (x *ResourceValidateErrors) GetName() string { +func (x *ResourceValidateAlert) GetName() string { if x != nil { return x.Name } return "" } -func (x *ResourceValidateErrors) GetErrorMsg() []string { +func (x *ResourceValidateAlert) GetErrors() []*common.ErrorInfo { if x != nil { - return x.ErrorMsg + return x.Errors } return nil } @@ -3550,7 +3407,7 @@ type SystemAlert struct { func (x *SystemAlert) Reset() { *x = SystemAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[49] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3563,7 +3420,7 @@ func (x *SystemAlert) String() string { func (*SystemAlert) ProtoMessage() {} func (x *SystemAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[49] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[47] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3576,7 +3433,7 @@ func (x *SystemAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemAlert.ProtoReflect.Descriptor instead. func (*SystemAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{49} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{47} } func (x *SystemAlert) GetMessage() string { @@ -3598,7 +3455,7 @@ type CoreAlert struct { func (x *CoreAlert) Reset() { *x = CoreAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[50] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3611,7 +3468,7 @@ func (x *CoreAlert) String() string { func (*CoreAlert) ProtoMessage() {} func (x *CoreAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[50] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[48] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3624,7 +3481,7 @@ func (x *CoreAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use CoreAlert.ProtoReflect.Descriptor instead. func (*CoreAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{50} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{48} } func (x *CoreAlert) GetCoreComponent() string { @@ -3646,15 +3503,15 @@ type InstanceAlert struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Instance *InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` - AosVersion uint64 `protobuf:"varint,2,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Instance *common.InstanceIdent `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` + ServiceVersion string `protobuf:"bytes,2,opt,name=service_version,json=serviceVersion,proto3" json:"service_version,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` } func (x *InstanceAlert) Reset() { *x = InstanceAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[51] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[49] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3667,7 +3524,7 @@ func (x *InstanceAlert) String() string { func (*InstanceAlert) ProtoMessage() {} func (x *InstanceAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v3_servicemanager_proto_msgTypes[51] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[49] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3680,21 +3537,21 @@ func (x *InstanceAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceAlert.ProtoReflect.Descriptor instead. func (*InstanceAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v3_servicemanager_proto_rawDescGZIP(), []int{51} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{49} } -func (x *InstanceAlert) GetInstance() *InstanceIdent { +func (x *InstanceAlert) GetInstance() *common.InstanceIdent { if x != nil { return x.Instance } return nil } -func (x *InstanceAlert) GetAosVersion() uint64 { +func (x *InstanceAlert) GetServiceVersion() string { if x != nil { - return x.AosVersion + return x.ServiceVersion } - return 0 + return "" } func (x *InstanceAlert) GetMessage() string { @@ -3704,747 +3561,743 @@ func (x *InstanceAlert) GetMessage() string { return "" } -var File_servicemanager_v3_servicemanager_proto protoreflect.FileDescriptor +var File_servicemanager_v4_servicemanager_proto protoreflect.FileDescriptor -var file_servicemanager_v3_servicemanager_proto_rawDesc = []byte{ +var file_servicemanager_v4_servicemanager_proto_rawDesc = []byte{ 0x0a, 0x26, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2f, 0x76, 0x33, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x2f, 0x76, 0x34, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb1, 0x09, 0x0a, - 0x12, 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x73, 0x12, 0x5d, 0x0a, 0x16, 0x67, 0x65, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x13, 0x67, - 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x50, 0x0a, 0x11, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x75, 0x6e, 0x69, 0x74, - 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x48, 0x00, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4a, 0x0a, 0x0f, 0x73, 0x65, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x74, - 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x53, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, - 0x00, 0x52, 0x0d, 0x73, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x46, 0x0a, 0x0d, 0x72, 0x75, 0x6e, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x75, 0x6e, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x48, 0x00, 0x52, 0x0c, 0x72, 0x75, 0x6e, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x50, 0x0a, 0x11, 0x6f, 0x76, 0x65, 0x72, - 0x72, 0x69, 0x64, 0x65, 0x5f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, - 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x48, 0x00, 0x52, 0x0f, 0x6f, 0x76, 0x65, 0x72, 0x72, - 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x12, 0x53, 0x0a, 0x12, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x10, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x59, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x69, 0x0a, 0x1a, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x63, 0x72, 0x61, 0x73, 0x68, 0x5f, 0x6c, 0x6f, 0x67, - 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xba, 0x09, 0x0a, 0x12, 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x5d, 0x0a, 0x16, 0x67, + 0x65, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x47, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x13, 0x67, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x50, 0x0a, 0x11, 0x63, 0x68, + 0x65, 0x63, 0x6b, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, + 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0f, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4a, 0x0a, 0x0f, + 0x73, 0x65, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x65, 0x74, 0x55, 0x6e, 0x69, + 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x65, 0x74, 0x55, 0x6e, + 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x46, 0x0a, 0x0d, 0x72, 0x75, 0x6e, 0x5f, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, + 0x48, 0x00, 0x52, 0x0c, 0x72, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, + 0x12, 0x50, 0x0a, 0x11, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x65, 0x6e, 0x76, + 0x5f, 0x76, 0x61, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x48, + 0x00, 0x52, 0x0f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, + 0x72, 0x73, 0x12, 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x6c, 0x6f, 0x67, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, - 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x56, 0x0a, 0x13, 0x67, 0x65, 0x74, 0x5f, 0x6e, 0x6f, 0x64, - 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, - 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x11, 0x67, 0x65, 0x74, 0x4e, - 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x52, 0x0a, - 0x11, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, - 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x53, 0x0a, 0x12, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x4c, 0x6f, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x12, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x69, 0x0a, 0x1a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x63, + 0x72, 0x61, 0x73, 0x68, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x17, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, + 0x61, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x5f, 0x0a, + 0x16, 0x67, 0x65, 0x74, 0x5f, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, + 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x6e, - 0x66, 0x6f, 0x48, 0x00, 0x52, 0x10, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x46, 0x0a, 0x0d, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x00, - 0x52, 0x0c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x4c, - 0x0a, 0x0f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x48, 0x00, 0x52, 0x0e, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x3d, 0x0a, 0x0a, - 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x00, - 0x52, 0x09, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x42, 0x13, 0x0a, 0x11, 0x53, - 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x59, 0x0a, 0x0f, 0x43, 0x68, 0x65, 0x63, 0x6b, - 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x6e, - 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x76, - 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x57, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x76, 0x65, - 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x52, 0x0a, 0x0e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x40, 0x0a, - 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x22, - 0x4a, 0x0a, 0x09, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x3d, 0x0a, 0x0c, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xe4, 0x01, 0x0a, 0x0c, - 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x08, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, + 0x34, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, + 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x14, 0x67, 0x65, 0x74, 0x41, 0x76, 0x65, + 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x52, + 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, + 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x53, 0x0a, 0x12, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x34, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, + 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x10, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x46, 0x0a, 0x0d, 0x69, 0x6d, 0x61, 0x67, 0x65, + 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x06, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x61, 0x79, - 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x3d, - 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x76, 0x34, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, + 0x00, 0x52, 0x0c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, + 0x4c, 0x0a, 0x0f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x48, 0x00, 0x52, 0x0e, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x3d, 0x0a, + 0x0a, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x18, 0x0e, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x48, + 0x00, 0x52, 0x09, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x42, 0x13, 0x0a, 0x11, + 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x4c, 0x0a, 0x0f, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x75, + 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x4a, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x55, 0x6e, 0x69, + 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x6e, + 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0x52, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x40, 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x08, 0x6e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x22, 0x4a, 0x0a, 0x09, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, + 0x79, 0x6e, 0x63, 0x12, 0x3d, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, + 0x6d, 0x65, 0x22, 0xe4, 0x01, 0x0a, 0x0c, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, + 0x34, 0x0a, 0x06, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x34, 0x2e, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x6c, + 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x3d, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x22, 0xb7, 0x01, 0x0a, 0x0b, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x03, 0x67, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, + 0x36, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, + 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, + 0x69, 0x7a, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x09, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, + 0x67, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x6d, 0x0a, 0x0c, + 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x15, 0x0a, 0x06, + 0x64, 0x73, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x73, + 0x74, 0x49, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x64, 0x73, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x73, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x0a, 0x06, 0x73, 0x72, 0x63, 0x5f, 0x69, 0x70, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x72, 0x63, 0x49, 0x70, 0x22, 0xcb, 0x01, 0x0a, 0x11, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x49, 0x64, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x6c, 0x61, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x76, 0x6c, 0x61, 0x6e, 0x49, + 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6e, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6e, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x73, 0x12, 0x35, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x23, 0x0a, - 0x0d, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x22, 0xf8, 0x01, 0x0a, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x41, 0x0a, 0x0c, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, - 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x69, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x67, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, - 0x32, 0x35, 0x36, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, - 0x36, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xd7, 0x01, - 0x0a, 0x09, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x41, 0x0a, 0x0c, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x0b, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x64, - 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, - 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x68, 0x61, 0x35, 0x31, 0x32, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, - 0x35, 0x31, 0x32, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x77, 0x0a, 0x0b, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, 0x73, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x61, 0x6f, 0x73, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, - 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, - 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x22, 0x6d, 0x0a, 0x0c, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, - 0x12, 0x15, 0x0a, 0x06, 0x64, 0x73, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x64, 0x73, 0x74, 0x49, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x64, 0x73, 0x74, 0x5f, 0x70, - 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x73, 0x74, 0x50, 0x6f, - 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x0a, 0x06, 0x73, 0x72, 0x63, 0x5f, - 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x72, 0x63, 0x49, 0x70, 0x22, - 0xcb, 0x01, 0x0a, 0x11, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x75, 0x62, 0x6e, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x17, 0x0a, 0x07, - 0x76, 0x6c, 0x61, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x76, - 0x6c, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x6e, 0x73, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6e, 0x73, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x35, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, - 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, - 0x6c, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x91, 0x02, - 0x0a, 0x0c, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x3c, - 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, - 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, - 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, - 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1d, 0x0a, - 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x53, 0x0a, 0x12, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, - 0x72, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x11, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, - 0x73, 0x22, 0x57, 0x0a, 0x0f, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, - 0x56, 0x61, 0x72, 0x73, 0x12, 0x44, 0x0a, 0x08, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, - 0x69, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, - 0x72, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x16, 0x4f, + 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x46, 0x69, 0x72, 0x65, 0x77, 0x61, 0x6c, 0x6c, 0x52, 0x75, + 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x89, 0x02, 0x0a, 0x0c, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x75, + 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x21, + 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, + 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x50, 0x61, 0x74, 0x68, + 0x12, 0x53, 0x0a, 0x12, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, + 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, + 0x72, 0x73, 0x52, 0x11, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x57, 0x0a, 0x0f, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, + 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x12, 0x44, 0x0a, 0x08, 0x65, 0x6e, 0x76, 0x5f, + 0x76, 0x61, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x45, - 0x6e, 0x76, 0x56, 0x61, 0x72, 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x04, 0x76, 0x61, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x04, 0x76, 0x61, 0x72, 0x73, 0x22, 0x6d, 0x0a, 0x0a, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x61, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x76, - 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, - 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x89, 0x01, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, - 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, - 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, - 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, - 0x6c, 0x22, 0xc9, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, - 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x2e, 0x0a, - 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, - 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0xce, 0x01, - 0x0a, 0x17, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, 0x4c, - 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, - 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, - 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x2e, - 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, - 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0x13, - 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, - 0x69, 0x6e, 0x67, 0x22, 0x58, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x44, 0x0a, 0x0c, 0x63, 0x6c, 0x6f, 0x75, 0x64, - 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, - 0x52, 0x0b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x86, 0x01, - 0x0a, 0x10, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, - 0x64, 0x12, 0x3d, 0x0a, 0x0b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, - 0x46, 0x69, 0x6c, 0x65, 0x52, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, - 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x5c, 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x46, - 0x69, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, - 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, - 0x35, 0x36, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, - 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, - 0x73, 0x69, 0x7a, 0x65, 0x22, 0x9b, 0x01, 0x0a, 0x0c, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, - 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x72, - 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, - 0x70, 0x61, 0x72, 0x74, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, - 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x22, 0xd9, 0x06, 0x0a, 0x12, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, - 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x55, 0x0a, 0x12, 0x6e, 0x6f, 0x64, - 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x11, 0x6e, - 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x53, 0x0a, 0x12, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, - 0x2e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x48, 0x00, 0x52, 0x10, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x59, 0x0a, 0x14, 0x72, 0x75, 0x6e, 0x5f, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x12, 0x72, 0x75, - 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x62, 0x0a, 0x17, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x15, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x60, 0x0a, 0x17, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, - 0x5f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, - 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, - 0x52, 0x14, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2e, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x6f, 0x67, 0x44, 0x61, 0x74, 0x61, 0x48, - 0x00, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x4c, 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, - 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, - 0x6e, 0x67, 0x48, 0x00, 0x52, 0x0e, 0x6e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, - 0x72, 0x69, 0x6e, 0x67, 0x12, 0x30, 0x0a, 0x05, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, - 0x05, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, - 0x13, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x12, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x79, - 0x6e, 0x63, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x10, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, - 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x13, 0x0a, 0x11, 0x53, 0x4d, 0x4f, - 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x89, - 0x02, 0x0a, 0x11, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, - 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, - 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x72, - 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x46, 0x65, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x75, 0x6d, 0x5f, 0x63, 0x70, 0x75, 0x73, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x6e, 0x75, 0x6d, 0x43, 0x70, 0x75, 0x73, 0x12, - 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x61, 0x6d, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x08, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x61, 0x6d, 0x12, 0x3c, 0x0a, 0x0a, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, - 0x70, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x54, 0x0a, 0x09, 0x50, 0x61, - 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, - 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, - 0x22, 0x4f, 0x0a, 0x10, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x76, 0x65, - 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x22, 0x55, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x58, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x73, 0x22, 0xc9, 0x01, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x61, 0x6f, 0x73, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x75, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x75, 0x6e, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x69, - 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, - 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, - 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, - 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x5d, 0x0a, 0x09, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x6f, 0x73, 0x5f, 0x63, 0x6f, - 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x61, 0x6f, 0x73, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x78, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x65, 0x78, 0x69, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x7d, 0x0a, 0x14, 0x4f, 0x76, 0x65, 0x72, - 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x4f, 0x0a, 0x0f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x6e, - 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x0d, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x96, 0x01, 0x0a, 0x14, 0x45, 0x6e, 0x76, 0x56, - 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, - 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x40, - 0x0a, 0x0b, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x76, 0x61, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x22, 0x3b, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x15, 0x0a, 0x06, 0x76, 0x61, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x7d, 0x0a, - 0x07, 0x4c, 0x6f, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x09, 0x70, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x70, 0x61, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, - 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xee, 0x01, 0x0a, - 0x0e, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, - 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x4a, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, - 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, + 0x6e, 0x76, 0x56, 0x61, 0x72, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x22, 0x97, + 0x01, 0x0a, 0x16, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x12, 0x4a, 0x0a, 0x0f, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, - 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, - 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x56, 0x0a, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, - 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xab, 0x01, - 0x0a, 0x0e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x72, - 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x03, 0x63, 0x70, 0x75, 0x12, 0x35, 0x0a, 0x04, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, 0x64, 0x69, 0x73, 0x6b, 0x12, 0x1d, 0x0a, 0x0a, 0x69, - 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x09, 0x69, 0x6e, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, - 0x74, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x0a, 0x6f, 0x75, 0x74, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x22, 0x41, 0x0a, 0x0e, 0x50, - 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x75, 0x73, 0x65, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x9e, - 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, - 0x67, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, - 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, - 0x0e, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x22, - 0x9f, 0x05, 0x0a, 0x05, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, - 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x31, 0x0a, 0x04, 0x76, 0x61, 0x72, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x04, 0x76, 0x61, 0x72, 0x73, 0x22, 0x6d, 0x0a, 0x0a, 0x45, 0x6e, 0x76, 0x56, + 0x61, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x61, 0x72, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, + 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x74, 0x74, 0x6c, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x89, 0x01, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, + 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, + 0x67, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, + 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, + 0x69, 0x6c, 0x6c, 0x22, 0x6a, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, + 0xd7, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x4a, 0x0a, + 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0xdc, 0x01, 0x0a, 0x17, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x4a, 0x0a, 0x0f, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x41, + 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, + 0x22, 0x58, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x44, 0x0a, 0x0c, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0b, 0x63, + 0x6c, 0x6f, 0x75, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x9c, 0x01, 0x0a, 0x10, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, + 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x3d, + 0x0a, 0x0b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, + 0x65, 0x52, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x2a, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x5c, 0x0a, 0x09, 0x49, 0x6d, 0x61, + 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, + 0x32, 0x35, 0x36, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x9b, 0x01, 0x0a, 0x0c, 0x49, 0x6d, 0x61, 0x67, + 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, + 0x70, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x70, 0x61, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, 0x72, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x25, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x53, 0x4d, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0xa4, 0x07, 0x0a, + 0x12, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, + 0x73, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x4d, 0x48, 0x00, 0x52, 0x0a, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x53, 0x6d, 0x12, 0x53, 0x0a, 0x12, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, - 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, - 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, - 0x00, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, - 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x62, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, - 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x64, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, - 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x65, 0x76, - 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, - 0x48, 0x00, 0x52, 0x13, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, - 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x10, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x59, 0x0a, 0x14, 0x72, 0x75, + 0x6e, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x75, 0x6e, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, + 0x00, 0x52, 0x12, 0x72, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x62, 0x0a, 0x17, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x48, 0x00, 0x52, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x60, 0x0a, 0x17, 0x6f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4f, + 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x14, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, + 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2e, 0x0a, 0x03, 0x6c, + 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4c, 0x6f, 0x67, + 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x55, 0x0a, 0x12, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, + 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, + 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x6e, 0x67, 0x12, 0x55, 0x0a, 0x12, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x6f, + 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x34, 0x2e, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, + 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x11, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, + 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x30, 0x0a, 0x05, 0x61, 0x6c, 0x65, + 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x41, 0x6c, 0x65, + 0x72, 0x74, 0x48, 0x00, 0x52, 0x05, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x69, + 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x13, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x12, 0x63, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, + 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x10, 0x63, 0x6c, + 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x13, + 0x0a, 0x11, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x22, 0x54, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x58, 0x0a, 0x10, 0x55, 0x6e, 0x69, + 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x22, 0x55, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, + 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x58, 0x0a, 0x15, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, + 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x75, 0x6e, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x75, 0x6e, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x33, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x66, + 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x93, 0x01, 0x0a, 0x14, 0x4f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x4f, 0x0a, 0x0f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, + 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x0d, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa4, + 0x01, 0x0a, 0x14, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4a, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x12, 0x40, 0x0a, 0x0b, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x76, + 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x76, 0x61, 0x72, 0x73, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x51, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x61, 0x72, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x93, 0x01, 0x0a, 0x07, 0x4c, 0x6f, 0x67, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, + 0x61, 0x72, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x09, 0x70, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, + 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xf1, + 0x01, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, + 0x72, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x4a, + 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, + 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6e, 0x6f, 0x64, 0x65, + 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x56, 0x0a, 0x13, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, + 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x6e, 0x67, 0x22, 0xf1, 0x01, 0x0a, 0x11, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, + 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x12, 0x4a, 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, + 0x6e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x56, + 0x0a, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x6e, 0x67, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, + 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xab, 0x01, 0x0a, 0x0e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x72, 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x63, + 0x70, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x35, 0x0a, + 0x04, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, + 0x64, 0x69, 0x73, 0x6b, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, + 0x69, 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x69, 0x6e, 0x54, 0x72, 0x61, 0x66, + 0x66, 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, + 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x54, 0x72, 0x61, + 0x66, 0x66, 0x69, 0x63, 0x22, 0x41, 0x0a, 0x0e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, + 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x75, + 0x73, 0x65, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x34, + 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x6e, 0x67, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x33, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, - 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3d, 0x0a, 0x0a, - 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, - 0x52, 0x09, 0x63, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x49, 0x0a, 0x0e, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, - 0x64, 0x22, 0x69, 0x0a, 0x13, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x12, 0x0a, 0x10, - 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x22, 0x46, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, - 0x6c, 0x65, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x86, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, - 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, 0x0a, - 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x22, 0x85, 0x01, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, - 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, + 0x34, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, + 0x52, 0x0e, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, + 0x22, 0x9f, 0x05, 0x0a, 0x05, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, + 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, + 0x65, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, + 0x48, 0x00, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, + 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x62, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, + 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, + 0x74, 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x64, 0x65, + 0x76, 0x69, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, + 0x65, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x44, 0x65, + 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, + 0x74, 0x48, 0x00, 0x52, 0x13, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, + 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, + 0x52, 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3d, 0x0a, + 0x0a, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, + 0x00, 0x52, 0x09, 0x63, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x49, 0x0a, 0x0e, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, + 0x61, 0x64, 0x22, 0x69, 0x0a, 0x13, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x12, 0x0a, + 0x10, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x5e, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, + 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, + 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, + 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, + 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x7d, 0x0a, 0x13, 0x44, 0x65, + 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, + 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5a, 0x0a, 0x15, 0x52, 0x65, 0x73, + 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x59, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, - 0x72, 0x74, 0x12, 0x41, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x52, 0x06, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x73, 0x22, 0x49, 0x0a, 0x16, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, - 0x22, 0x27, 0x0a, 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, 0x09, 0x43, 0x6f, 0x72, - 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x63, - 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, - 0x63, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, 0x73, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x61, 0x6f, - 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x2a, 0x31, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, - 0x43, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, - 0x54, 0x45, 0x44, 0x10, 0x01, 0x32, 0x6d, 0x0a, 0x09, 0x53, 0x4d, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x4d, - 0x12, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x4d, 0x49, 0x6e, - 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x00, - 0x28, 0x01, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x73, 0x22, 0x27, 0x0a, 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, + 0x09, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, + 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x0d, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, + 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x31, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, + 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, + 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x01, 0x32, 0x6d, 0x0a, 0x09, 0x53, 0x4d, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x53, 0x4d, 0x12, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x25, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_servicemanager_v3_servicemanager_proto_rawDescOnce sync.Once - file_servicemanager_v3_servicemanager_proto_rawDescData = file_servicemanager_v3_servicemanager_proto_rawDesc + file_servicemanager_v4_servicemanager_proto_rawDescOnce sync.Once + file_servicemanager_v4_servicemanager_proto_rawDescData = file_servicemanager_v4_servicemanager_proto_rawDesc ) -func file_servicemanager_v3_servicemanager_proto_rawDescGZIP() []byte { - file_servicemanager_v3_servicemanager_proto_rawDescOnce.Do(func() { - file_servicemanager_v3_servicemanager_proto_rawDescData = protoimpl.X.CompressGZIP(file_servicemanager_v3_servicemanager_proto_rawDescData) +func file_servicemanager_v4_servicemanager_proto_rawDescGZIP() []byte { + file_servicemanager_v4_servicemanager_proto_rawDescOnce.Do(func() { + file_servicemanager_v4_servicemanager_proto_rawDescData = protoimpl.X.CompressGZIP(file_servicemanager_v4_servicemanager_proto_rawDescData) }) - return file_servicemanager_v3_servicemanager_proto_rawDescData -} - -var file_servicemanager_v3_servicemanager_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_servicemanager_v3_servicemanager_proto_msgTypes = make([]protoimpl.MessageInfo, 52) -var file_servicemanager_v3_servicemanager_proto_goTypes = []interface{}{ - (ConnectionEnum)(0), // 0: servicemanager.v3.ConnectionEnum - (*SMIncomingMessages)(nil), // 1: servicemanager.v3.SMIncomingMessages - (*GetUnitConfigStatus)(nil), // 2: servicemanager.v3.GetUnitConfigStatus - (*CheckUnitConfig)(nil), // 3: servicemanager.v3.CheckUnitConfig - (*SetUnitConfig)(nil), // 4: servicemanager.v3.SetUnitConfig - (*UpdateNetworks)(nil), // 5: servicemanager.v3.UpdateNetworks - (*ClockSync)(nil), // 6: servicemanager.v3.ClockSync - (*RunInstances)(nil), // 7: servicemanager.v3.RunInstances - (*ServiceInfo)(nil), // 8: servicemanager.v3.ServiceInfo - (*LayerInfo)(nil), // 9: servicemanager.v3.LayerInfo - (*VersionInfo)(nil), // 10: servicemanager.v3.VersionInfo - (*FirewallRule)(nil), // 11: servicemanager.v3.FirewallRule - (*NetworkParameters)(nil), // 12: servicemanager.v3.NetworkParameters - (*InstanceInfo)(nil), // 13: servicemanager.v3.InstanceInfo - (*OverrideEnvVars)(nil), // 14: servicemanager.v3.OverrideEnvVars - (*OverrideInstanceEnvVar)(nil), // 15: servicemanager.v3.OverrideInstanceEnvVar - (*EnvVarInfo)(nil), // 16: servicemanager.v3.EnvVarInfo - (*SystemLogRequest)(nil), // 17: servicemanager.v3.SystemLogRequest - (*InstanceLogRequest)(nil), // 18: servicemanager.v3.InstanceLogRequest - (*InstanceCrashLogRequest)(nil), // 19: servicemanager.v3.InstanceCrashLogRequest - (*GetNodeMonitoring)(nil), // 20: servicemanager.v3.GetNodeMonitoring - (*ConnectionStatus)(nil), // 21: servicemanager.v3.ConnectionStatus - (*ImageContentInfo)(nil), // 22: servicemanager.v3.ImageContentInfo - (*ImageFile)(nil), // 23: servicemanager.v3.ImageFile - (*ImageContent)(nil), // 24: servicemanager.v3.ImageContent - (*SMOutgoingMessages)(nil), // 25: servicemanager.v3.SMOutgoingMessages - (*NodeConfiguration)(nil), // 26: servicemanager.v3.NodeConfiguration - (*Partition)(nil), // 27: servicemanager.v3.Partition - (*UnitConfigStatus)(nil), // 28: servicemanager.v3.UnitConfigStatus - (*RunInstancesStatus)(nil), // 29: servicemanager.v3.RunInstancesStatus - (*UpdateInstancesStatus)(nil), // 30: servicemanager.v3.UpdateInstancesStatus - (*InstanceStatus)(nil), // 31: servicemanager.v3.InstanceStatus - (*InstanceIdent)(nil), // 32: servicemanager.v3.InstanceIdent - (*ErrorInfo)(nil), // 33: servicemanager.v3.ErrorInfo - (*OverrideEnvVarStatus)(nil), // 34: servicemanager.v3.OverrideEnvVarStatus - (*EnvVarInstanceStatus)(nil), // 35: servicemanager.v3.EnvVarInstanceStatus - (*EnvVarStatus)(nil), // 36: servicemanager.v3.EnvVarStatus - (*LogData)(nil), // 37: servicemanager.v3.LogData - (*NodeMonitoring)(nil), // 38: servicemanager.v3.NodeMonitoring - (*MonitoringData)(nil), // 39: servicemanager.v3.MonitoringData - (*PartitionUsage)(nil), // 40: servicemanager.v3.PartitionUsage - (*InstanceMonitoring)(nil), // 41: servicemanager.v3.InstanceMonitoring - (*Alert)(nil), // 42: servicemanager.v3.Alert - (*ImageContentRequest)(nil), // 43: servicemanager.v3.ImageContentRequest - (*ClockSyncRequest)(nil), // 44: servicemanager.v3.ClockSyncRequest - (*SystemQuotaAlert)(nil), // 45: servicemanager.v3.SystemQuotaAlert - (*InstanceQuotaAlert)(nil), // 46: servicemanager.v3.InstanceQuotaAlert - (*DeviceAllocateAlert)(nil), // 47: servicemanager.v3.DeviceAllocateAlert - (*ResourceValidateAlert)(nil), // 48: servicemanager.v3.ResourceValidateAlert - (*ResourceValidateErrors)(nil), // 49: servicemanager.v3.ResourceValidateErrors - (*SystemAlert)(nil), // 50: servicemanager.v3.SystemAlert - (*CoreAlert)(nil), // 51: servicemanager.v3.CoreAlert - (*InstanceAlert)(nil), // 52: servicemanager.v3.InstanceAlert - (*timestamppb.Timestamp)(nil), // 53: google.protobuf.Timestamp -} -var file_servicemanager_v3_servicemanager_proto_depIdxs = []int32{ - 2, // 0: servicemanager.v3.SMIncomingMessages.get_unit_config_status:type_name -> servicemanager.v3.GetUnitConfigStatus - 3, // 1: servicemanager.v3.SMIncomingMessages.check_unit_config:type_name -> servicemanager.v3.CheckUnitConfig - 4, // 2: servicemanager.v3.SMIncomingMessages.set_unit_config:type_name -> servicemanager.v3.SetUnitConfig - 7, // 3: servicemanager.v3.SMIncomingMessages.run_instances:type_name -> servicemanager.v3.RunInstances - 14, // 4: servicemanager.v3.SMIncomingMessages.override_env_vars:type_name -> servicemanager.v3.OverrideEnvVars - 17, // 5: servicemanager.v3.SMIncomingMessages.system_log_request:type_name -> servicemanager.v3.SystemLogRequest - 18, // 6: servicemanager.v3.SMIncomingMessages.instance_log_request:type_name -> servicemanager.v3.InstanceLogRequest - 19, // 7: servicemanager.v3.SMIncomingMessages.instance_crash_log_request:type_name -> servicemanager.v3.InstanceCrashLogRequest - 20, // 8: servicemanager.v3.SMIncomingMessages.get_node_monitoring:type_name -> servicemanager.v3.GetNodeMonitoring - 21, // 9: servicemanager.v3.SMIncomingMessages.connection_status:type_name -> servicemanager.v3.ConnectionStatus - 22, // 10: servicemanager.v3.SMIncomingMessages.image_content_info:type_name -> servicemanager.v3.ImageContentInfo - 24, // 11: servicemanager.v3.SMIncomingMessages.image_content:type_name -> servicemanager.v3.ImageContent - 5, // 12: servicemanager.v3.SMIncomingMessages.update_networks:type_name -> servicemanager.v3.UpdateNetworks - 6, // 13: servicemanager.v3.SMIncomingMessages.clock_sync:type_name -> servicemanager.v3.ClockSync - 12, // 14: servicemanager.v3.UpdateNetworks.networks:type_name -> servicemanager.v3.NetworkParameters - 53, // 15: servicemanager.v3.ClockSync.current_time:type_name -> google.protobuf.Timestamp - 8, // 16: servicemanager.v3.RunInstances.services:type_name -> servicemanager.v3.ServiceInfo - 9, // 17: servicemanager.v3.RunInstances.layers:type_name -> servicemanager.v3.LayerInfo - 13, // 18: servicemanager.v3.RunInstances.instances:type_name -> servicemanager.v3.InstanceInfo - 10, // 19: servicemanager.v3.ServiceInfo.version_info:type_name -> servicemanager.v3.VersionInfo - 10, // 20: servicemanager.v3.LayerInfo.version_info:type_name -> servicemanager.v3.VersionInfo - 11, // 21: servicemanager.v3.NetworkParameters.rules:type_name -> servicemanager.v3.FirewallRule - 32, // 22: servicemanager.v3.InstanceInfo.instance:type_name -> servicemanager.v3.InstanceIdent - 12, // 23: servicemanager.v3.InstanceInfo.network_parameters:type_name -> servicemanager.v3.NetworkParameters - 15, // 24: servicemanager.v3.OverrideEnvVars.env_vars:type_name -> servicemanager.v3.OverrideInstanceEnvVar - 32, // 25: servicemanager.v3.OverrideInstanceEnvVar.instance:type_name -> servicemanager.v3.InstanceIdent - 16, // 26: servicemanager.v3.OverrideInstanceEnvVar.vars:type_name -> servicemanager.v3.EnvVarInfo - 53, // 27: servicemanager.v3.EnvVarInfo.ttl:type_name -> google.protobuf.Timestamp - 53, // 28: servicemanager.v3.SystemLogRequest.from:type_name -> google.protobuf.Timestamp - 53, // 29: servicemanager.v3.SystemLogRequest.till:type_name -> google.protobuf.Timestamp - 32, // 30: servicemanager.v3.InstanceLogRequest.instance:type_name -> servicemanager.v3.InstanceIdent - 53, // 31: servicemanager.v3.InstanceLogRequest.from:type_name -> google.protobuf.Timestamp - 53, // 32: servicemanager.v3.InstanceLogRequest.till:type_name -> google.protobuf.Timestamp - 32, // 33: servicemanager.v3.InstanceCrashLogRequest.instance:type_name -> servicemanager.v3.InstanceIdent - 53, // 34: servicemanager.v3.InstanceCrashLogRequest.from:type_name -> google.protobuf.Timestamp - 53, // 35: servicemanager.v3.InstanceCrashLogRequest.till:type_name -> google.protobuf.Timestamp - 0, // 36: servicemanager.v3.ConnectionStatus.cloud_status:type_name -> servicemanager.v3.ConnectionEnum - 23, // 37: servicemanager.v3.ImageContentInfo.image_files:type_name -> servicemanager.v3.ImageFile - 26, // 38: servicemanager.v3.SMOutgoingMessages.node_configuration:type_name -> servicemanager.v3.NodeConfiguration - 28, // 39: servicemanager.v3.SMOutgoingMessages.unit_config_status:type_name -> servicemanager.v3.UnitConfigStatus - 29, // 40: servicemanager.v3.SMOutgoingMessages.run_instances_status:type_name -> servicemanager.v3.RunInstancesStatus - 30, // 41: servicemanager.v3.SMOutgoingMessages.update_instances_status:type_name -> servicemanager.v3.UpdateInstancesStatus - 34, // 42: servicemanager.v3.SMOutgoingMessages.override_env_var_status:type_name -> servicemanager.v3.OverrideEnvVarStatus - 37, // 43: servicemanager.v3.SMOutgoingMessages.log:type_name -> servicemanager.v3.LogData - 38, // 44: servicemanager.v3.SMOutgoingMessages.node_monitoring:type_name -> servicemanager.v3.NodeMonitoring - 42, // 45: servicemanager.v3.SMOutgoingMessages.alert:type_name -> servicemanager.v3.Alert - 43, // 46: servicemanager.v3.SMOutgoingMessages.image_content_request:type_name -> servicemanager.v3.ImageContentRequest - 44, // 47: servicemanager.v3.SMOutgoingMessages.clock_sync_request:type_name -> servicemanager.v3.ClockSyncRequest - 27, // 48: servicemanager.v3.NodeConfiguration.partitions:type_name -> servicemanager.v3.Partition - 31, // 49: servicemanager.v3.RunInstancesStatus.instances:type_name -> servicemanager.v3.InstanceStatus - 31, // 50: servicemanager.v3.UpdateInstancesStatus.instances:type_name -> servicemanager.v3.InstanceStatus - 32, // 51: servicemanager.v3.InstanceStatus.instance:type_name -> servicemanager.v3.InstanceIdent - 33, // 52: servicemanager.v3.InstanceStatus.error_info:type_name -> servicemanager.v3.ErrorInfo - 35, // 53: servicemanager.v3.OverrideEnvVarStatus.env_vars_status:type_name -> servicemanager.v3.EnvVarInstanceStatus - 32, // 54: servicemanager.v3.EnvVarInstanceStatus.instance:type_name -> servicemanager.v3.InstanceIdent - 36, // 55: servicemanager.v3.EnvVarInstanceStatus.vars_status:type_name -> servicemanager.v3.EnvVarStatus - 53, // 56: servicemanager.v3.NodeMonitoring.timestamp:type_name -> google.protobuf.Timestamp - 39, // 57: servicemanager.v3.NodeMonitoring.monitoring_data:type_name -> servicemanager.v3.MonitoringData - 41, // 58: servicemanager.v3.NodeMonitoring.instance_monitoring:type_name -> servicemanager.v3.InstanceMonitoring - 40, // 59: servicemanager.v3.MonitoringData.disk:type_name -> servicemanager.v3.PartitionUsage - 32, // 60: servicemanager.v3.InstanceMonitoring.instance:type_name -> servicemanager.v3.InstanceIdent - 39, // 61: servicemanager.v3.InstanceMonitoring.monitoring_data:type_name -> servicemanager.v3.MonitoringData - 53, // 62: servicemanager.v3.Alert.timestamp:type_name -> google.protobuf.Timestamp - 45, // 63: servicemanager.v3.Alert.system_quota_alert:type_name -> servicemanager.v3.SystemQuotaAlert - 46, // 64: servicemanager.v3.Alert.instance_quota_alert:type_name -> servicemanager.v3.InstanceQuotaAlert - 48, // 65: servicemanager.v3.Alert.resource_validate_alert:type_name -> servicemanager.v3.ResourceValidateAlert - 47, // 66: servicemanager.v3.Alert.device_allocate_alert:type_name -> servicemanager.v3.DeviceAllocateAlert - 50, // 67: servicemanager.v3.Alert.system_alert:type_name -> servicemanager.v3.SystemAlert - 51, // 68: servicemanager.v3.Alert.core_alert:type_name -> servicemanager.v3.CoreAlert - 52, // 69: servicemanager.v3.Alert.instance_alert:type_name -> servicemanager.v3.InstanceAlert - 32, // 70: servicemanager.v3.InstanceQuotaAlert.instance:type_name -> servicemanager.v3.InstanceIdent - 32, // 71: servicemanager.v3.DeviceAllocateAlert.instance:type_name -> servicemanager.v3.InstanceIdent - 49, // 72: servicemanager.v3.ResourceValidateAlert.errors:type_name -> servicemanager.v3.ResourceValidateErrors - 32, // 73: servicemanager.v3.InstanceAlert.instance:type_name -> servicemanager.v3.InstanceIdent - 25, // 74: servicemanager.v3.SMService.RegisterSM:input_type -> servicemanager.v3.SMOutgoingMessages - 1, // 75: servicemanager.v3.SMService.RegisterSM:output_type -> servicemanager.v3.SMIncomingMessages - 75, // [75:76] is the sub-list for method output_type - 74, // [74:75] is the sub-list for method input_type - 74, // [74:74] is the sub-list for extension type_name - 74, // [74:74] is the sub-list for extension extendee - 0, // [0:74] is the sub-list for field type_name -} - -func init() { file_servicemanager_v3_servicemanager_proto_init() } -func file_servicemanager_v3_servicemanager_proto_init() { - if File_servicemanager_v3_servicemanager_proto != nil { + return file_servicemanager_v4_servicemanager_proto_rawDescData +} + +var file_servicemanager_v4_servicemanager_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_servicemanager_v4_servicemanager_proto_msgTypes = make([]protoimpl.MessageInfo, 50) +var file_servicemanager_v4_servicemanager_proto_goTypes = []interface{}{ + (ConnectionEnum)(0), // 0: servicemanager.v4.ConnectionEnum + (*SMIncomingMessages)(nil), // 1: servicemanager.v4.SMIncomingMessages + (*GetUnitConfigStatus)(nil), // 2: servicemanager.v4.GetUnitConfigStatus + (*CheckUnitConfig)(nil), // 3: servicemanager.v4.CheckUnitConfig + (*SetUnitConfig)(nil), // 4: servicemanager.v4.SetUnitConfig + (*UpdateNetworks)(nil), // 5: servicemanager.v4.UpdateNetworks + (*ClockSync)(nil), // 6: servicemanager.v4.ClockSync + (*RunInstances)(nil), // 7: servicemanager.v4.RunInstances + (*ServiceInfo)(nil), // 8: servicemanager.v4.ServiceInfo + (*LayerInfo)(nil), // 9: servicemanager.v4.LayerInfo + (*FirewallRule)(nil), // 10: servicemanager.v4.FirewallRule + (*NetworkParameters)(nil), // 11: servicemanager.v4.NetworkParameters + (*InstanceInfo)(nil), // 12: servicemanager.v4.InstanceInfo + (*OverrideEnvVars)(nil), // 13: servicemanager.v4.OverrideEnvVars + (*OverrideInstanceEnvVar)(nil), // 14: servicemanager.v4.OverrideInstanceEnvVar + (*EnvVarInfo)(nil), // 15: servicemanager.v4.EnvVarInfo + (*SystemLogRequest)(nil), // 16: servicemanager.v4.SystemLogRequest + (*InstanceFilter)(nil), // 17: servicemanager.v4.InstanceFilter + (*InstanceLogRequest)(nil), // 18: servicemanager.v4.InstanceLogRequest + (*InstanceCrashLogRequest)(nil), // 19: servicemanager.v4.InstanceCrashLogRequest + (*GetAverageMonitoring)(nil), // 20: servicemanager.v4.GetAverageMonitoring + (*ConnectionStatus)(nil), // 21: servicemanager.v4.ConnectionStatus + (*ImageContentInfo)(nil), // 22: servicemanager.v4.ImageContentInfo + (*ImageFile)(nil), // 23: servicemanager.v4.ImageFile + (*ImageContent)(nil), // 24: servicemanager.v4.ImageContent + (*RegisterSM)(nil), // 25: servicemanager.v4.RegisterSM + (*SMOutgoingMessages)(nil), // 26: servicemanager.v4.SMOutgoingMessages + (*Partition)(nil), // 27: servicemanager.v4.Partition + (*UnitConfigStatus)(nil), // 28: servicemanager.v4.UnitConfigStatus + (*RunInstancesStatus)(nil), // 29: servicemanager.v4.RunInstancesStatus + (*UpdateInstancesStatus)(nil), // 30: servicemanager.v4.UpdateInstancesStatus + (*InstanceStatus)(nil), // 31: servicemanager.v4.InstanceStatus + (*OverrideEnvVarStatus)(nil), // 32: servicemanager.v4.OverrideEnvVarStatus + (*EnvVarInstanceStatus)(nil), // 33: servicemanager.v4.EnvVarInstanceStatus + (*EnvVarStatus)(nil), // 34: servicemanager.v4.EnvVarStatus + (*LogData)(nil), // 35: servicemanager.v4.LogData + (*InstantMonitoring)(nil), // 36: servicemanager.v4.InstantMonitoring + (*AverageMonitoring)(nil), // 37: servicemanager.v4.AverageMonitoring + (*MonitoringData)(nil), // 38: servicemanager.v4.MonitoringData + (*PartitionUsage)(nil), // 39: servicemanager.v4.PartitionUsage + (*InstanceMonitoring)(nil), // 40: servicemanager.v4.InstanceMonitoring + (*Alert)(nil), // 41: servicemanager.v4.Alert + (*ImageContentRequest)(nil), // 42: servicemanager.v4.ImageContentRequest + (*ClockSyncRequest)(nil), // 43: servicemanager.v4.ClockSyncRequest + (*SystemQuotaAlert)(nil), // 44: servicemanager.v4.SystemQuotaAlert + (*InstanceQuotaAlert)(nil), // 45: servicemanager.v4.InstanceQuotaAlert + (*DeviceAllocateAlert)(nil), // 46: servicemanager.v4.DeviceAllocateAlert + (*ResourceValidateAlert)(nil), // 47: servicemanager.v4.ResourceValidateAlert + (*SystemAlert)(nil), // 48: servicemanager.v4.SystemAlert + (*CoreAlert)(nil), // 49: servicemanager.v4.CoreAlert + (*InstanceAlert)(nil), // 50: servicemanager.v4.InstanceAlert + (*timestamppb.Timestamp)(nil), // 51: google.protobuf.Timestamp + (*common.InstanceIdent)(nil), // 52: common.v1.InstanceIdent + (*common.ErrorInfo)(nil), // 53: common.v1.ErrorInfo +} +var file_servicemanager_v4_servicemanager_proto_depIdxs = []int32{ + 2, // 0: servicemanager.v4.SMIncomingMessages.get_unit_config_status:type_name -> servicemanager.v4.GetUnitConfigStatus + 3, // 1: servicemanager.v4.SMIncomingMessages.check_unit_config:type_name -> servicemanager.v4.CheckUnitConfig + 4, // 2: servicemanager.v4.SMIncomingMessages.set_unit_config:type_name -> servicemanager.v4.SetUnitConfig + 7, // 3: servicemanager.v4.SMIncomingMessages.run_instances:type_name -> servicemanager.v4.RunInstances + 13, // 4: servicemanager.v4.SMIncomingMessages.override_env_vars:type_name -> servicemanager.v4.OverrideEnvVars + 16, // 5: servicemanager.v4.SMIncomingMessages.system_log_request:type_name -> servicemanager.v4.SystemLogRequest + 18, // 6: servicemanager.v4.SMIncomingMessages.instance_log_request:type_name -> servicemanager.v4.InstanceLogRequest + 19, // 7: servicemanager.v4.SMIncomingMessages.instance_crash_log_request:type_name -> servicemanager.v4.InstanceCrashLogRequest + 20, // 8: servicemanager.v4.SMIncomingMessages.get_average_monitoring:type_name -> servicemanager.v4.GetAverageMonitoring + 21, // 9: servicemanager.v4.SMIncomingMessages.connection_status:type_name -> servicemanager.v4.ConnectionStatus + 22, // 10: servicemanager.v4.SMIncomingMessages.image_content_info:type_name -> servicemanager.v4.ImageContentInfo + 24, // 11: servicemanager.v4.SMIncomingMessages.image_content:type_name -> servicemanager.v4.ImageContent + 5, // 12: servicemanager.v4.SMIncomingMessages.update_networks:type_name -> servicemanager.v4.UpdateNetworks + 6, // 13: servicemanager.v4.SMIncomingMessages.clock_sync:type_name -> servicemanager.v4.ClockSync + 11, // 14: servicemanager.v4.UpdateNetworks.networks:type_name -> servicemanager.v4.NetworkParameters + 51, // 15: servicemanager.v4.ClockSync.current_time:type_name -> google.protobuf.Timestamp + 8, // 16: servicemanager.v4.RunInstances.services:type_name -> servicemanager.v4.ServiceInfo + 9, // 17: servicemanager.v4.RunInstances.layers:type_name -> servicemanager.v4.LayerInfo + 12, // 18: servicemanager.v4.RunInstances.instances:type_name -> servicemanager.v4.InstanceInfo + 10, // 19: servicemanager.v4.NetworkParameters.rules:type_name -> servicemanager.v4.FirewallRule + 52, // 20: servicemanager.v4.InstanceInfo.instance:type_name -> common.v1.InstanceIdent + 11, // 21: servicemanager.v4.InstanceInfo.network_parameters:type_name -> servicemanager.v4.NetworkParameters + 14, // 22: servicemanager.v4.OverrideEnvVars.env_vars:type_name -> servicemanager.v4.OverrideInstanceEnvVar + 17, // 23: servicemanager.v4.OverrideInstanceEnvVar.instance_filter:type_name -> servicemanager.v4.InstanceFilter + 15, // 24: servicemanager.v4.OverrideInstanceEnvVar.vars:type_name -> servicemanager.v4.EnvVarInfo + 51, // 25: servicemanager.v4.EnvVarInfo.ttl:type_name -> google.protobuf.Timestamp + 51, // 26: servicemanager.v4.SystemLogRequest.from:type_name -> google.protobuf.Timestamp + 51, // 27: servicemanager.v4.SystemLogRequest.till:type_name -> google.protobuf.Timestamp + 17, // 28: servicemanager.v4.InstanceLogRequest.instance_filter:type_name -> servicemanager.v4.InstanceFilter + 51, // 29: servicemanager.v4.InstanceLogRequest.from:type_name -> google.protobuf.Timestamp + 51, // 30: servicemanager.v4.InstanceLogRequest.till:type_name -> google.protobuf.Timestamp + 17, // 31: servicemanager.v4.InstanceCrashLogRequest.instance_filter:type_name -> servicemanager.v4.InstanceFilter + 51, // 32: servicemanager.v4.InstanceCrashLogRequest.from:type_name -> google.protobuf.Timestamp + 51, // 33: servicemanager.v4.InstanceCrashLogRequest.till:type_name -> google.protobuf.Timestamp + 0, // 34: servicemanager.v4.ConnectionStatus.cloud_status:type_name -> servicemanager.v4.ConnectionEnum + 23, // 35: servicemanager.v4.ImageContentInfo.image_files:type_name -> servicemanager.v4.ImageFile + 53, // 36: servicemanager.v4.ImageContentInfo.error:type_name -> common.v1.ErrorInfo + 25, // 37: servicemanager.v4.SMOutgoingMessages.register_sm:type_name -> servicemanager.v4.RegisterSM + 28, // 38: servicemanager.v4.SMOutgoingMessages.unit_config_status:type_name -> servicemanager.v4.UnitConfigStatus + 29, // 39: servicemanager.v4.SMOutgoingMessages.run_instances_status:type_name -> servicemanager.v4.RunInstancesStatus + 30, // 40: servicemanager.v4.SMOutgoingMessages.update_instances_status:type_name -> servicemanager.v4.UpdateInstancesStatus + 32, // 41: servicemanager.v4.SMOutgoingMessages.override_env_var_status:type_name -> servicemanager.v4.OverrideEnvVarStatus + 35, // 42: servicemanager.v4.SMOutgoingMessages.log:type_name -> servicemanager.v4.LogData + 36, // 43: servicemanager.v4.SMOutgoingMessages.instant_monitoring:type_name -> servicemanager.v4.InstantMonitoring + 37, // 44: servicemanager.v4.SMOutgoingMessages.average_monitoring:type_name -> servicemanager.v4.AverageMonitoring + 41, // 45: servicemanager.v4.SMOutgoingMessages.alert:type_name -> servicemanager.v4.Alert + 42, // 46: servicemanager.v4.SMOutgoingMessages.image_content_request:type_name -> servicemanager.v4.ImageContentRequest + 43, // 47: servicemanager.v4.SMOutgoingMessages.clock_sync_request:type_name -> servicemanager.v4.ClockSyncRequest + 53, // 48: servicemanager.v4.UnitConfigStatus.error:type_name -> common.v1.ErrorInfo + 31, // 49: servicemanager.v4.RunInstancesStatus.instances:type_name -> servicemanager.v4.InstanceStatus + 31, // 50: servicemanager.v4.UpdateInstancesStatus.instances:type_name -> servicemanager.v4.InstanceStatus + 52, // 51: servicemanager.v4.InstanceStatus.instance:type_name -> common.v1.InstanceIdent + 53, // 52: servicemanager.v4.InstanceStatus.error_info:type_name -> common.v1.ErrorInfo + 33, // 53: servicemanager.v4.OverrideEnvVarStatus.env_vars_status:type_name -> servicemanager.v4.EnvVarInstanceStatus + 53, // 54: servicemanager.v4.OverrideEnvVarStatus.error:type_name -> common.v1.ErrorInfo + 17, // 55: servicemanager.v4.EnvVarInstanceStatus.instance_filter:type_name -> servicemanager.v4.InstanceFilter + 34, // 56: servicemanager.v4.EnvVarInstanceStatus.vars_status:type_name -> servicemanager.v4.EnvVarStatus + 53, // 57: servicemanager.v4.EnvVarStatus.error:type_name -> common.v1.ErrorInfo + 53, // 58: servicemanager.v4.LogData.error:type_name -> common.v1.ErrorInfo + 51, // 59: servicemanager.v4.InstantMonitoring.timestamp:type_name -> google.protobuf.Timestamp + 38, // 60: servicemanager.v4.InstantMonitoring.node_monitoring:type_name -> servicemanager.v4.MonitoringData + 40, // 61: servicemanager.v4.InstantMonitoring.instance_monitoring:type_name -> servicemanager.v4.InstanceMonitoring + 51, // 62: servicemanager.v4.AverageMonitoring.timestamp:type_name -> google.protobuf.Timestamp + 38, // 63: servicemanager.v4.AverageMonitoring.node_monitoring:type_name -> servicemanager.v4.MonitoringData + 40, // 64: servicemanager.v4.AverageMonitoring.instance_monitoring:type_name -> servicemanager.v4.InstanceMonitoring + 39, // 65: servicemanager.v4.MonitoringData.disk:type_name -> servicemanager.v4.PartitionUsage + 52, // 66: servicemanager.v4.InstanceMonitoring.instance:type_name -> common.v1.InstanceIdent + 38, // 67: servicemanager.v4.InstanceMonitoring.monitoring_data:type_name -> servicemanager.v4.MonitoringData + 51, // 68: servicemanager.v4.Alert.timestamp:type_name -> google.protobuf.Timestamp + 44, // 69: servicemanager.v4.Alert.system_quota_alert:type_name -> servicemanager.v4.SystemQuotaAlert + 45, // 70: servicemanager.v4.Alert.instance_quota_alert:type_name -> servicemanager.v4.InstanceQuotaAlert + 47, // 71: servicemanager.v4.Alert.resource_validate_alert:type_name -> servicemanager.v4.ResourceValidateAlert + 46, // 72: servicemanager.v4.Alert.device_allocate_alert:type_name -> servicemanager.v4.DeviceAllocateAlert + 48, // 73: servicemanager.v4.Alert.system_alert:type_name -> servicemanager.v4.SystemAlert + 49, // 74: servicemanager.v4.Alert.core_alert:type_name -> servicemanager.v4.CoreAlert + 50, // 75: servicemanager.v4.Alert.instance_alert:type_name -> servicemanager.v4.InstanceAlert + 52, // 76: servicemanager.v4.InstanceQuotaAlert.instance:type_name -> common.v1.InstanceIdent + 52, // 77: servicemanager.v4.DeviceAllocateAlert.instance:type_name -> common.v1.InstanceIdent + 53, // 78: servicemanager.v4.ResourceValidateAlert.errors:type_name -> common.v1.ErrorInfo + 52, // 79: servicemanager.v4.InstanceAlert.instance:type_name -> common.v1.InstanceIdent + 26, // 80: servicemanager.v4.SMService.RegisterSM:input_type -> servicemanager.v4.SMOutgoingMessages + 1, // 81: servicemanager.v4.SMService.RegisterSM:output_type -> servicemanager.v4.SMIncomingMessages + 81, // [81:82] is the sub-list for method output_type + 80, // [80:81] is the sub-list for method input_type + 80, // [80:80] is the sub-list for extension type_name + 80, // [80:80] is the sub-list for extension extendee + 0, // [0:80] is the sub-list for field type_name +} + +func init() { file_servicemanager_v4_servicemanager_proto_init() } +func file_servicemanager_v4_servicemanager_proto_init() { + if File_servicemanager_v4_servicemanager_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_servicemanager_v3_servicemanager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SMIncomingMessages); i { case 0: return &v.state @@ -4456,7 +4309,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetUnitConfigStatus); i { case 0: return &v.state @@ -4468,7 +4321,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CheckUnitConfig); i { case 0: return &v.state @@ -4480,7 +4333,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SetUnitConfig); i { case 0: return &v.state @@ -4492,7 +4345,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateNetworks); i { case 0: return &v.state @@ -4504,7 +4357,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ClockSync); i { case 0: return &v.state @@ -4516,7 +4369,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RunInstances); i { case 0: return &v.state @@ -4528,7 +4381,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ServiceInfo); i { case 0: return &v.state @@ -4540,7 +4393,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LayerInfo); i { case 0: return &v.state @@ -4552,8 +4405,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VersionInfo); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FirewallRule); i { case 0: return &v.state case 1: @@ -4564,8 +4417,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FirewallRule); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NetworkParameters); i { case 0: return &v.state case 1: @@ -4576,8 +4429,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NetworkParameters); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InstanceInfo); i { case 0: return &v.state case 1: @@ -4588,8 +4441,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InstanceInfo); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OverrideEnvVars); i { case 0: return &v.state case 1: @@ -4600,8 +4453,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OverrideEnvVars); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OverrideInstanceEnvVar); i { case 0: return &v.state case 1: @@ -4612,8 +4465,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OverrideInstanceEnvVar); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EnvVarInfo); i { case 0: return &v.state case 1: @@ -4624,8 +4477,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EnvVarInfo); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SystemLogRequest); i { case 0: return &v.state case 1: @@ -4636,8 +4489,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SystemLogRequest); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InstanceFilter); i { case 0: return &v.state case 1: @@ -4648,7 +4501,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceLogRequest); i { case 0: return &v.state @@ -4660,7 +4513,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceCrashLogRequest); i { case 0: return &v.state @@ -4672,8 +4525,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetNodeMonitoring); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetAverageMonitoring); i { case 0: return &v.state case 1: @@ -4684,7 +4537,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ConnectionStatus); i { case 0: return &v.state @@ -4696,7 +4549,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ImageContentInfo); i { case 0: return &v.state @@ -4708,7 +4561,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ImageFile); i { case 0: return &v.state @@ -4720,7 +4573,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ImageContent); i { case 0: return &v.state @@ -4732,8 +4585,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SMOutgoingMessages); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RegisterSM); i { case 0: return &v.state case 1: @@ -4744,8 +4597,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodeConfiguration); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SMOutgoingMessages); i { case 0: return &v.state case 1: @@ -4756,7 +4609,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Partition); i { case 0: return &v.state @@ -4768,7 +4621,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UnitConfigStatus); i { case 0: return &v.state @@ -4780,7 +4633,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RunInstancesStatus); i { case 0: return &v.state @@ -4792,7 +4645,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateInstancesStatus); i { case 0: return &v.state @@ -4804,7 +4657,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceStatus); i { case 0: return &v.state @@ -4816,20 +4669,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InstanceIdent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_servicemanager_v3_servicemanager_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ErrorInfo); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OverrideEnvVarStatus); i { case 0: return &v.state case 1: @@ -4840,8 +4681,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OverrideEnvVarStatus); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EnvVarInstanceStatus); i { case 0: return &v.state case 1: @@ -4852,8 +4693,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EnvVarInstanceStatus); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EnvVarStatus); i { case 0: return &v.state case 1: @@ -4864,8 +4705,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EnvVarStatus); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LogData); i { case 0: return &v.state case 1: @@ -4876,8 +4717,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LogData); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InstantMonitoring); i { case 0: return &v.state case 1: @@ -4888,8 +4729,8 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NodeMonitoring); i { + file_servicemanager_v4_servicemanager_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AverageMonitoring); i { case 0: return &v.state case 1: @@ -4900,7 +4741,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MonitoringData); i { case 0: return &v.state @@ -4912,7 +4753,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PartitionUsage); i { case 0: return &v.state @@ -4924,7 +4765,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceMonitoring); i { case 0: return &v.state @@ -4936,7 +4777,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Alert); i { case 0: return &v.state @@ -4948,7 +4789,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ImageContentRequest); i { case 0: return &v.state @@ -4960,7 +4801,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ClockSyncRequest); i { case 0: return &v.state @@ -4972,7 +4813,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SystemQuotaAlert); i { case 0: return &v.state @@ -4984,7 +4825,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceQuotaAlert); i { case 0: return &v.state @@ -4996,7 +4837,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeviceAllocateAlert); i { case 0: return &v.state @@ -5008,7 +4849,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceValidateAlert); i { case 0: return &v.state @@ -5020,19 +4861,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResourceValidateErrors); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_servicemanager_v3_servicemanager_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SystemAlert); i { case 0: return &v.state @@ -5044,7 +4873,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CoreAlert); i { case 0: return &v.state @@ -5056,7 +4885,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { return nil } } - file_servicemanager_v3_servicemanager_proto_msgTypes[51].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceAlert); i { case 0: return &v.state @@ -5069,7 +4898,7 @@ func file_servicemanager_v3_servicemanager_proto_init() { } } } - file_servicemanager_v3_servicemanager_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_servicemanager_v4_servicemanager_proto_msgTypes[0].OneofWrappers = []interface{}{ (*SMIncomingMessages_GetUnitConfigStatus)(nil), (*SMIncomingMessages_CheckUnitConfig)(nil), (*SMIncomingMessages_SetUnitConfig)(nil), @@ -5078,26 +4907,27 @@ func file_servicemanager_v3_servicemanager_proto_init() { (*SMIncomingMessages_SystemLogRequest)(nil), (*SMIncomingMessages_InstanceLogRequest)(nil), (*SMIncomingMessages_InstanceCrashLogRequest)(nil), - (*SMIncomingMessages_GetNodeMonitoring)(nil), + (*SMIncomingMessages_GetAverageMonitoring)(nil), (*SMIncomingMessages_ConnectionStatus)(nil), (*SMIncomingMessages_ImageContentInfo)(nil), (*SMIncomingMessages_ImageContent)(nil), (*SMIncomingMessages_UpdateNetworks)(nil), (*SMIncomingMessages_ClockSync)(nil), } - file_servicemanager_v3_servicemanager_proto_msgTypes[24].OneofWrappers = []interface{}{ - (*SMOutgoingMessages_NodeConfiguration)(nil), + file_servicemanager_v4_servicemanager_proto_msgTypes[25].OneofWrappers = []interface{}{ + (*SMOutgoingMessages_RegisterSm)(nil), (*SMOutgoingMessages_UnitConfigStatus)(nil), (*SMOutgoingMessages_RunInstancesStatus)(nil), (*SMOutgoingMessages_UpdateInstancesStatus)(nil), (*SMOutgoingMessages_OverrideEnvVarStatus)(nil), (*SMOutgoingMessages_Log)(nil), - (*SMOutgoingMessages_NodeMonitoring)(nil), + (*SMOutgoingMessages_InstantMonitoring)(nil), + (*SMOutgoingMessages_AverageMonitoring)(nil), (*SMOutgoingMessages_Alert)(nil), (*SMOutgoingMessages_ImageContentRequest)(nil), (*SMOutgoingMessages_ClockSyncRequest)(nil), } - file_servicemanager_v3_servicemanager_proto_msgTypes[41].OneofWrappers = []interface{}{ + file_servicemanager_v4_servicemanager_proto_msgTypes[40].OneofWrappers = []interface{}{ (*Alert_SystemQuotaAlert)(nil), (*Alert_InstanceQuotaAlert)(nil), (*Alert_ResourceValidateAlert)(nil), @@ -5110,19 +4940,19 @@ func file_servicemanager_v3_servicemanager_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_servicemanager_v3_servicemanager_proto_rawDesc, + RawDescriptor: file_servicemanager_v4_servicemanager_proto_rawDesc, NumEnums: 1, - NumMessages: 52, + NumMessages: 50, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_servicemanager_v3_servicemanager_proto_goTypes, - DependencyIndexes: file_servicemanager_v3_servicemanager_proto_depIdxs, - EnumInfos: file_servicemanager_v3_servicemanager_proto_enumTypes, - MessageInfos: file_servicemanager_v3_servicemanager_proto_msgTypes, + GoTypes: file_servicemanager_v4_servicemanager_proto_goTypes, + DependencyIndexes: file_servicemanager_v4_servicemanager_proto_depIdxs, + EnumInfos: file_servicemanager_v4_servicemanager_proto_enumTypes, + MessageInfos: file_servicemanager_v4_servicemanager_proto_msgTypes, }.Build() - File_servicemanager_v3_servicemanager_proto = out.File - file_servicemanager_v3_servicemanager_proto_rawDesc = nil - file_servicemanager_v3_servicemanager_proto_goTypes = nil - file_servicemanager_v3_servicemanager_proto_depIdxs = nil + File_servicemanager_v4_servicemanager_proto = out.File + file_servicemanager_v4_servicemanager_proto_rawDesc = nil + file_servicemanager_v4_servicemanager_proto_goTypes = nil + file_servicemanager_v4_servicemanager_proto_depIdxs = nil } diff --git a/vendor/github.com/aosedge/aos_common/api/servicemanager/v3/servicemanager_grpc.pb.go b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager_grpc.pb.go similarity index 94% rename from vendor/github.com/aosedge/aos_common/api/servicemanager/v3/servicemanager_grpc.pb.go rename to vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager_grpc.pb.go index 7c608828..69011712 100644 --- a/vendor/github.com/aosedge/aos_common/api/servicemanager/v3/servicemanager_grpc.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager_grpc.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v4.25.0 -// source: servicemanager/v3/servicemanager.proto +// - protoc v5.26.0 +// source: servicemanager/v4/servicemanager.proto package servicemanager @@ -34,7 +34,7 @@ func NewSMServiceClient(cc grpc.ClientConnInterface) SMServiceClient { } func (c *sMServiceClient) RegisterSM(ctx context.Context, opts ...grpc.CallOption) (SMService_RegisterSMClient, error) { - stream, err := c.cc.NewStream(ctx, &SMService_ServiceDesc.Streams[0], "/servicemanager.v3.SMService/RegisterSM", opts...) + stream, err := c.cc.NewStream(ctx, &SMService_ServiceDesc.Streams[0], "/servicemanager.v4.SMService/RegisterSM", opts...) if err != nil { return nil, err } @@ -122,7 +122,7 @@ func (x *sMServiceRegisterSMServer) Recv() (*SMOutgoingMessages, error) { // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var SMService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "servicemanager.v3.SMService", + ServiceName: "servicemanager.v4.SMService", HandlerType: (*SMServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ @@ -133,5 +133,5 @@ var SMService_ServiceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "servicemanager/v3/servicemanager.proto", + Metadata: "servicemanager/v4/servicemanager.proto", } diff --git a/vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager.pb.go b/vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager.pb.go new file mode 100644 index 00000000..8abefab0 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager.pb.go @@ -0,0 +1,918 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.26.0 +// source: updatemanager/v2/updatemanager.proto + +package updatemanager + +import ( + common "github.com/aosedge/aos_common/api/common" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdateState int32 + +const ( + UpdateState_IDLE UpdateState = 0 + UpdateState_PREPARED UpdateState = 1 + UpdateState_UPDATED UpdateState = 2 + UpdateState_FAILED UpdateState = 3 +) + +// Enum value maps for UpdateState. +var ( + UpdateState_name = map[int32]string{ + 0: "IDLE", + 1: "PREPARED", + 2: "UPDATED", + 3: "FAILED", + } + UpdateState_value = map[string]int32{ + "IDLE": 0, + "PREPARED": 1, + "UPDATED": 2, + "FAILED": 3, + } +) + +func (x UpdateState) Enum() *UpdateState { + p := new(UpdateState) + *p = x + return p +} + +func (x UpdateState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (UpdateState) Descriptor() protoreflect.EnumDescriptor { + return file_updatemanager_v2_updatemanager_proto_enumTypes[0].Descriptor() +} + +func (UpdateState) Type() protoreflect.EnumType { + return &file_updatemanager_v2_updatemanager_proto_enumTypes[0] +} + +func (x UpdateState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use UpdateState.Descriptor instead. +func (UpdateState) EnumDescriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{0} +} + +type ComponentState int32 + +const ( + ComponentState_INSTALLED ComponentState = 0 + ComponentState_INSTALLING ComponentState = 1 + ComponentState_ERROR ComponentState = 2 +) + +// Enum value maps for ComponentState. +var ( + ComponentState_name = map[int32]string{ + 0: "INSTALLED", + 1: "INSTALLING", + 2: "ERROR", + } + ComponentState_value = map[string]int32{ + "INSTALLED": 0, + "INSTALLING": 1, + "ERROR": 2, + } +) + +func (x ComponentState) Enum() *ComponentState { + p := new(ComponentState) + *p = x + return p +} + +func (x ComponentState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ComponentState) Descriptor() protoreflect.EnumDescriptor { + return file_updatemanager_v2_updatemanager_proto_enumTypes[1].Descriptor() +} + +func (ComponentState) Type() protoreflect.EnumType { + return &file_updatemanager_v2_updatemanager_proto_enumTypes[1] +} + +func (x ComponentState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ComponentState.Descriptor instead. +func (ComponentState) EnumDescriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{1} +} + +type CMMessages struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to CMMessage: + // + // *CMMessages_PrepareUpdate + // *CMMessages_StartUpdate + // *CMMessages_ApplyUpdate + // *CMMessages_RevertUpdate + CMMessage isCMMessages_CMMessage `protobuf_oneof:"CMMessage"` +} + +func (x *CMMessages) Reset() { + *x = CMMessages{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CMMessages) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CMMessages) ProtoMessage() {} + +func (x *CMMessages) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CMMessages.ProtoReflect.Descriptor instead. +func (*CMMessages) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{0} +} + +func (m *CMMessages) GetCMMessage() isCMMessages_CMMessage { + if m != nil { + return m.CMMessage + } + return nil +} + +func (x *CMMessages) GetPrepareUpdate() *PrepareUpdate { + if x, ok := x.GetCMMessage().(*CMMessages_PrepareUpdate); ok { + return x.PrepareUpdate + } + return nil +} + +func (x *CMMessages) GetStartUpdate() *StartUpdate { + if x, ok := x.GetCMMessage().(*CMMessages_StartUpdate); ok { + return x.StartUpdate + } + return nil +} + +func (x *CMMessages) GetApplyUpdate() *ApplyUpdate { + if x, ok := x.GetCMMessage().(*CMMessages_ApplyUpdate); ok { + return x.ApplyUpdate + } + return nil +} + +func (x *CMMessages) GetRevertUpdate() *RevertUpdate { + if x, ok := x.GetCMMessage().(*CMMessages_RevertUpdate); ok { + return x.RevertUpdate + } + return nil +} + +type isCMMessages_CMMessage interface { + isCMMessages_CMMessage() +} + +type CMMessages_PrepareUpdate struct { + PrepareUpdate *PrepareUpdate `protobuf:"bytes,1,opt,name=prepare_update,json=prepareUpdate,proto3,oneof"` +} + +type CMMessages_StartUpdate struct { + StartUpdate *StartUpdate `protobuf:"bytes,2,opt,name=start_update,json=startUpdate,proto3,oneof"` +} + +type CMMessages_ApplyUpdate struct { + ApplyUpdate *ApplyUpdate `protobuf:"bytes,3,opt,name=apply_update,json=applyUpdate,proto3,oneof"` +} + +type CMMessages_RevertUpdate struct { + RevertUpdate *RevertUpdate `protobuf:"bytes,4,opt,name=revert_update,json=revertUpdate,proto3,oneof"` +} + +func (*CMMessages_PrepareUpdate) isCMMessages_CMMessage() {} + +func (*CMMessages_StartUpdate) isCMMessages_CMMessage() {} + +func (*CMMessages_ApplyUpdate) isCMMessages_CMMessage() {} + +func (*CMMessages_RevertUpdate) isCMMessages_CMMessage() {} + +type PrepareComponentInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ComponentId string `protobuf:"bytes,1,opt,name=component_id,json=componentId,proto3" json:"component_id,omitempty"` + ComponentType string `protobuf:"bytes,2,opt,name=component_type,json=componentType,proto3" json:"component_type,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + Annotations string `protobuf:"bytes,4,opt,name=annotations,proto3" json:"annotations,omitempty"` + Url string `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"` + Sha256 []byte `protobuf:"bytes,6,opt,name=sha256,proto3" json:"sha256,omitempty"` + Size uint64 `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"` +} + +func (x *PrepareComponentInfo) Reset() { + *x = PrepareComponentInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PrepareComponentInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PrepareComponentInfo) ProtoMessage() {} + +func (x *PrepareComponentInfo) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PrepareComponentInfo.ProtoReflect.Descriptor instead. +func (*PrepareComponentInfo) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{1} +} + +func (x *PrepareComponentInfo) GetComponentId() string { + if x != nil { + return x.ComponentId + } + return "" +} + +func (x *PrepareComponentInfo) GetComponentType() string { + if x != nil { + return x.ComponentType + } + return "" +} + +func (x *PrepareComponentInfo) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *PrepareComponentInfo) GetAnnotations() string { + if x != nil { + return x.Annotations + } + return "" +} + +func (x *PrepareComponentInfo) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *PrepareComponentInfo) GetSha256() []byte { + if x != nil { + return x.Sha256 + } + return nil +} + +func (x *PrepareComponentInfo) GetSize() uint64 { + if x != nil { + return x.Size + } + return 0 +} + +type PrepareUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Components []*PrepareComponentInfo `protobuf:"bytes,1,rep,name=components,proto3" json:"components,omitempty"` +} + +func (x *PrepareUpdate) Reset() { + *x = PrepareUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PrepareUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PrepareUpdate) ProtoMessage() {} + +func (x *PrepareUpdate) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PrepareUpdate.ProtoReflect.Descriptor instead. +func (*PrepareUpdate) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{2} +} + +func (x *PrepareUpdate) GetComponents() []*PrepareComponentInfo { + if x != nil { + return x.Components + } + return nil +} + +type StartUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *StartUpdate) Reset() { + *x = StartUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartUpdate) ProtoMessage() {} + +func (x *StartUpdate) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartUpdate.ProtoReflect.Descriptor instead. +func (*StartUpdate) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{3} +} + +type ApplyUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ApplyUpdate) Reset() { + *x = ApplyUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplyUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplyUpdate) ProtoMessage() {} + +func (x *ApplyUpdate) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApplyUpdate.ProtoReflect.Descriptor instead. +func (*ApplyUpdate) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{4} +} + +type RevertUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RevertUpdate) Reset() { + *x = RevertUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RevertUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RevertUpdate) ProtoMessage() {} + +func (x *RevertUpdate) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RevertUpdate.ProtoReflect.Descriptor instead. +func (*RevertUpdate) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{5} +} + +type ComponentStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ComponentId string `protobuf:"bytes,1,opt,name=component_id,json=componentId,proto3" json:"component_id,omitempty"` + ComponentType string `protobuf:"bytes,2,opt,name=component_type,json=componentType,proto3" json:"component_type,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + State ComponentState `protobuf:"varint,4,opt,name=state,proto3,enum=updatemanager.v2.ComponentState" json:"state,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *ComponentStatus) Reset() { + *x = ComponentStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComponentStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComponentStatus) ProtoMessage() {} + +func (x *ComponentStatus) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ComponentStatus.ProtoReflect.Descriptor instead. +func (*ComponentStatus) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{6} +} + +func (x *ComponentStatus) GetComponentId() string { + if x != nil { + return x.ComponentId + } + return "" +} + +func (x *ComponentStatus) GetComponentType() string { + if x != nil { + return x.ComponentType + } + return "" +} + +func (x *ComponentStatus) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *ComponentStatus) GetState() ComponentState { + if x != nil { + return x.State + } + return ComponentState_INSTALLED +} + +func (x *ComponentStatus) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +type UpdateStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + Priority uint32 `protobuf:"varint,2,opt,name=priority,proto3" json:"priority,omitempty"` + UpdateState UpdateState `protobuf:"varint,3,opt,name=update_state,json=updateState,proto3,enum=updatemanager.v2.UpdateState" json:"update_state,omitempty"` + Components []*ComponentStatus `protobuf:"bytes,4,rep,name=components,proto3" json:"components,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *UpdateStatus) Reset() { + *x = UpdateStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateStatus) ProtoMessage() {} + +func (x *UpdateStatus) ProtoReflect() protoreflect.Message { + mi := &file_updatemanager_v2_updatemanager_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateStatus.ProtoReflect.Descriptor instead. +func (*UpdateStatus) Descriptor() ([]byte, []int) { + return file_updatemanager_v2_updatemanager_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateStatus) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *UpdateStatus) GetPriority() uint32 { + if x != nil { + return x.Priority + } + return 0 +} + +func (x *UpdateStatus) GetUpdateState() UpdateState { + if x != nil { + return x.UpdateState + } + return UpdateState_IDLE +} + +func (x *UpdateStatus) GetComponents() []*ComponentStatus { + if x != nil { + return x.Components + } + return nil +} + +func (x *UpdateStatus) GetError() *common.ErrorInfo { + if x != nil { + return x.Error + } + return nil +} + +var File_updatemanager_v2_updatemanager_proto protoreflect.FileDescriptor + +var file_updatemanager_v2_updatemanager_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, + 0x76, 0x32, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x1a, 0x16, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0xb2, 0x02, 0x0a, 0x0a, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, + 0x48, 0x0a, 0x0e, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x65, 0x70, 0x61, + 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x70, 0x72, 0x65, 0x70, + 0x61, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x42, 0x0a, 0x0c, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1d, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, + 0x52, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x42, 0x0a, + 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x12, 0x45, 0x0a, 0x0d, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x76, 0x65, + 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x72, 0x65, 0x76, 0x65, + 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x43, 0x4d, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xda, 0x01, 0x0a, 0x14, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, + 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x21, + 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x12, + 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, + 0x7a, 0x65, 0x22, 0x57, 0x0a, 0x0d, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x12, 0x46, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x65, 0x70, 0x61, + 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x0d, 0x0a, 0x0b, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x41, 0x70, + 0x70, 0x6c, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x76, + 0x65, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x0f, 0x43, 0x6f, + 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, + 0x0c, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, + 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x36, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x20, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xf4, 0x01, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x40, 0x0a, 0x0c, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x1d, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x41, 0x0a, + 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, + 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2a, 0x3e, 0x0a, 0x0b, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x49, + 0x44, 0x4c, 0x45, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, + 0x44, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x44, 0x10, 0x02, + 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x3a, 0x0a, 0x0e, + 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0d, + 0x0a, 0x09, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, + 0x0a, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, + 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x02, 0x32, 0x5d, 0x0a, 0x09, 0x55, 0x4d, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x55, 0x4d, 0x12, 0x1e, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x1a, 0x1c, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_updatemanager_v2_updatemanager_proto_rawDescOnce sync.Once + file_updatemanager_v2_updatemanager_proto_rawDescData = file_updatemanager_v2_updatemanager_proto_rawDesc +) + +func file_updatemanager_v2_updatemanager_proto_rawDescGZIP() []byte { + file_updatemanager_v2_updatemanager_proto_rawDescOnce.Do(func() { + file_updatemanager_v2_updatemanager_proto_rawDescData = protoimpl.X.CompressGZIP(file_updatemanager_v2_updatemanager_proto_rawDescData) + }) + return file_updatemanager_v2_updatemanager_proto_rawDescData +} + +var file_updatemanager_v2_updatemanager_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_updatemanager_v2_updatemanager_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_updatemanager_v2_updatemanager_proto_goTypes = []interface{}{ + (UpdateState)(0), // 0: updatemanager.v2.UpdateState + (ComponentState)(0), // 1: updatemanager.v2.ComponentState + (*CMMessages)(nil), // 2: updatemanager.v2.CMMessages + (*PrepareComponentInfo)(nil), // 3: updatemanager.v2.PrepareComponentInfo + (*PrepareUpdate)(nil), // 4: updatemanager.v2.PrepareUpdate + (*StartUpdate)(nil), // 5: updatemanager.v2.StartUpdate + (*ApplyUpdate)(nil), // 6: updatemanager.v2.ApplyUpdate + (*RevertUpdate)(nil), // 7: updatemanager.v2.RevertUpdate + (*ComponentStatus)(nil), // 8: updatemanager.v2.ComponentStatus + (*UpdateStatus)(nil), // 9: updatemanager.v2.UpdateStatus + (*common.ErrorInfo)(nil), // 10: common.v1.ErrorInfo +} +var file_updatemanager_v2_updatemanager_proto_depIdxs = []int32{ + 4, // 0: updatemanager.v2.CMMessages.prepare_update:type_name -> updatemanager.v2.PrepareUpdate + 5, // 1: updatemanager.v2.CMMessages.start_update:type_name -> updatemanager.v2.StartUpdate + 6, // 2: updatemanager.v2.CMMessages.apply_update:type_name -> updatemanager.v2.ApplyUpdate + 7, // 3: updatemanager.v2.CMMessages.revert_update:type_name -> updatemanager.v2.RevertUpdate + 3, // 4: updatemanager.v2.PrepareUpdate.components:type_name -> updatemanager.v2.PrepareComponentInfo + 1, // 5: updatemanager.v2.ComponentStatus.state:type_name -> updatemanager.v2.ComponentState + 10, // 6: updatemanager.v2.ComponentStatus.error:type_name -> common.v1.ErrorInfo + 0, // 7: updatemanager.v2.UpdateStatus.update_state:type_name -> updatemanager.v2.UpdateState + 8, // 8: updatemanager.v2.UpdateStatus.components:type_name -> updatemanager.v2.ComponentStatus + 10, // 9: updatemanager.v2.UpdateStatus.error:type_name -> common.v1.ErrorInfo + 9, // 10: updatemanager.v2.UMService.RegisterUM:input_type -> updatemanager.v2.UpdateStatus + 2, // 11: updatemanager.v2.UMService.RegisterUM:output_type -> updatemanager.v2.CMMessages + 11, // [11:12] is the sub-list for method output_type + 10, // [10:11] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name +} + +func init() { file_updatemanager_v2_updatemanager_proto_init() } +func file_updatemanager_v2_updatemanager_proto_init() { + if File_updatemanager_v2_updatemanager_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_updatemanager_v2_updatemanager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CMMessages); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PrepareComponentInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PrepareUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplyUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RevertUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComponentStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_updatemanager_v2_updatemanager_proto_msgTypes[0].OneofWrappers = []interface{}{ + (*CMMessages_PrepareUpdate)(nil), + (*CMMessages_StartUpdate)(nil), + (*CMMessages_ApplyUpdate)(nil), + (*CMMessages_RevertUpdate)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_updatemanager_v2_updatemanager_proto_rawDesc, + NumEnums: 2, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_updatemanager_v2_updatemanager_proto_goTypes, + DependencyIndexes: file_updatemanager_v2_updatemanager_proto_depIdxs, + EnumInfos: file_updatemanager_v2_updatemanager_proto_enumTypes, + MessageInfos: file_updatemanager_v2_updatemanager_proto_msgTypes, + }.Build() + File_updatemanager_v2_updatemanager_proto = out.File + file_updatemanager_v2_updatemanager_proto_rawDesc = nil + file_updatemanager_v2_updatemanager_proto_goTypes = nil + file_updatemanager_v2_updatemanager_proto_depIdxs = nil +} diff --git a/vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager_grpc.pb.go b/vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager_grpc.pb.go similarity index 93% rename from vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager_grpc.pb.go rename to vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager_grpc.pb.go index 7c586083..9ec4aa52 100644 --- a/vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager_grpc.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/updatemanager/updatemanager_grpc.pb.go @@ -1,4 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v5.26.0 +// source: updatemanager/v2/updatemanager.proto package updatemanager @@ -30,7 +34,7 @@ func NewUMServiceClient(cc grpc.ClientConnInterface) UMServiceClient { } func (c *uMServiceClient) RegisterUM(ctx context.Context, opts ...grpc.CallOption) (UMService_RegisterUMClient, error) { - stream, err := c.cc.NewStream(ctx, &UMService_ServiceDesc.Streams[0], "/updatemanager.v1.UMService/RegisterUM", opts...) + stream, err := c.cc.NewStream(ctx, &UMService_ServiceDesc.Streams[0], "/updatemanager.v2.UMService/RegisterUM", opts...) if err != nil { return nil, err } @@ -118,7 +122,7 @@ func (x *uMServiceRegisterUMServer) Recv() (*UpdateStatus, error) { // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var UMService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "updatemanager.v1.UMService", + ServiceName: "updatemanager.v2.UMService", HandlerType: (*UMServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ @@ -129,5 +133,5 @@ var UMService_ServiceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "updatemanager/v1/updatemanager.proto", + Metadata: "updatemanager/v2/updatemanager.proto", } diff --git a/vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager.pb.go b/vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager.pb.go deleted file mode 100644 index 7e4ed44f..00000000 --- a/vendor/github.com/aosedge/aos_common/api/updatemanager/v1/updatemanager.pb.go +++ /dev/null @@ -1,906 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.1 -// protoc v3.6.1 -// source: updatemanager/v1/updatemanager.proto - -package updatemanager - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UmState int32 - -const ( - UmState_IDLE UmState = 0 - UmState_PREPARED UmState = 1 - UmState_UPDATED UmState = 2 - UmState_FAILED UmState = 3 -) - -// Enum value maps for UmState. -var ( - UmState_name = map[int32]string{ - 0: "IDLE", - 1: "PREPARED", - 2: "UPDATED", - 3: "FAILED", - } - UmState_value = map[string]int32{ - "IDLE": 0, - "PREPARED": 1, - "UPDATED": 2, - "FAILED": 3, - } -) - -func (x UmState) Enum() *UmState { - p := new(UmState) - *p = x - return p -} - -func (x UmState) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (UmState) Descriptor() protoreflect.EnumDescriptor { - return file_updatemanager_v1_updatemanager_proto_enumTypes[0].Descriptor() -} - -func (UmState) Type() protoreflect.EnumType { - return &file_updatemanager_v1_updatemanager_proto_enumTypes[0] -} - -func (x UmState) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use UmState.Descriptor instead. -func (UmState) EnumDescriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{0} -} - -type ComponentStatus int32 - -const ( - ComponentStatus_INSTALLED ComponentStatus = 0 - ComponentStatus_INSTALLING ComponentStatus = 1 - ComponentStatus_ERROR ComponentStatus = 2 -) - -// Enum value maps for ComponentStatus. -var ( - ComponentStatus_name = map[int32]string{ - 0: "INSTALLED", - 1: "INSTALLING", - 2: "ERROR", - } - ComponentStatus_value = map[string]int32{ - "INSTALLED": 0, - "INSTALLING": 1, - "ERROR": 2, - } -) - -func (x ComponentStatus) Enum() *ComponentStatus { - p := new(ComponentStatus) - *p = x - return p -} - -func (x ComponentStatus) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ComponentStatus) Descriptor() protoreflect.EnumDescriptor { - return file_updatemanager_v1_updatemanager_proto_enumTypes[1].Descriptor() -} - -func (ComponentStatus) Type() protoreflect.EnumType { - return &file_updatemanager_v1_updatemanager_proto_enumTypes[1] -} - -func (x ComponentStatus) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ComponentStatus.Descriptor instead. -func (ComponentStatus) EnumDescriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{1} -} - -type CMMessages struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to CMMessage: - // *CMMessages_PrepareUpdate - // *CMMessages_StartUpdate - // *CMMessages_ApplyUpdate - // *CMMessages_RevertUpdate - CMMessage isCMMessages_CMMessage `protobuf_oneof:"CMMessage"` -} - -func (x *CMMessages) Reset() { - *x = CMMessages{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CMMessages) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CMMessages) ProtoMessage() {} - -func (x *CMMessages) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CMMessages.ProtoReflect.Descriptor instead. -func (*CMMessages) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{0} -} - -func (m *CMMessages) GetCMMessage() isCMMessages_CMMessage { - if m != nil { - return m.CMMessage - } - return nil -} - -func (x *CMMessages) GetPrepareUpdate() *PrepareUpdate { - if x, ok := x.GetCMMessage().(*CMMessages_PrepareUpdate); ok { - return x.PrepareUpdate - } - return nil -} - -func (x *CMMessages) GetStartUpdate() *StartUpdate { - if x, ok := x.GetCMMessage().(*CMMessages_StartUpdate); ok { - return x.StartUpdate - } - return nil -} - -func (x *CMMessages) GetApplyUpdate() *ApplyUpdate { - if x, ok := x.GetCMMessage().(*CMMessages_ApplyUpdate); ok { - return x.ApplyUpdate - } - return nil -} - -func (x *CMMessages) GetRevertUpdate() *RevertUpdate { - if x, ok := x.GetCMMessage().(*CMMessages_RevertUpdate); ok { - return x.RevertUpdate - } - return nil -} - -type isCMMessages_CMMessage interface { - isCMMessages_CMMessage() -} - -type CMMessages_PrepareUpdate struct { - PrepareUpdate *PrepareUpdate `protobuf:"bytes,1,opt,name=prepare_update,json=prepareUpdate,proto3,oneof"` -} - -type CMMessages_StartUpdate struct { - StartUpdate *StartUpdate `protobuf:"bytes,2,opt,name=start_update,json=startUpdate,proto3,oneof"` -} - -type CMMessages_ApplyUpdate struct { - ApplyUpdate *ApplyUpdate `protobuf:"bytes,3,opt,name=apply_update,json=applyUpdate,proto3,oneof"` -} - -type CMMessages_RevertUpdate struct { - RevertUpdate *RevertUpdate `protobuf:"bytes,4,opt,name=revert_update,json=revertUpdate,proto3,oneof"` -} - -func (*CMMessages_PrepareUpdate) isCMMessages_CMMessage() {} - -func (*CMMessages_StartUpdate) isCMMessages_CMMessage() {} - -func (*CMMessages_ApplyUpdate) isCMMessages_CMMessage() {} - -func (*CMMessages_RevertUpdate) isCMMessages_CMMessage() {} - -type PrepareComponentInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - VendorVersion string `protobuf:"bytes,2,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` - AosVersion uint64 `protobuf:"varint,3,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - Annotations string `protobuf:"bytes,4,opt,name=annotations,proto3" json:"annotations,omitempty"` - Url string `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"` - Sha256 []byte `protobuf:"bytes,6,opt,name=sha256,proto3" json:"sha256,omitempty"` - Sha512 []byte `protobuf:"bytes,7,opt,name=sha512,proto3" json:"sha512,omitempty"` - Size uint64 `protobuf:"varint,8,opt,name=size,proto3" json:"size,omitempty"` -} - -func (x *PrepareComponentInfo) Reset() { - *x = PrepareComponentInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PrepareComponentInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PrepareComponentInfo) ProtoMessage() {} - -func (x *PrepareComponentInfo) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PrepareComponentInfo.ProtoReflect.Descriptor instead. -func (*PrepareComponentInfo) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{1} -} - -func (x *PrepareComponentInfo) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *PrepareComponentInfo) GetVendorVersion() string { - if x != nil { - return x.VendorVersion - } - return "" -} - -func (x *PrepareComponentInfo) GetAosVersion() uint64 { - if x != nil { - return x.AosVersion - } - return 0 -} - -func (x *PrepareComponentInfo) GetAnnotations() string { - if x != nil { - return x.Annotations - } - return "" -} - -func (x *PrepareComponentInfo) GetUrl() string { - if x != nil { - return x.Url - } - return "" -} - -func (x *PrepareComponentInfo) GetSha256() []byte { - if x != nil { - return x.Sha256 - } - return nil -} - -func (x *PrepareComponentInfo) GetSha512() []byte { - if x != nil { - return x.Sha512 - } - return nil -} - -func (x *PrepareComponentInfo) GetSize() uint64 { - if x != nil { - return x.Size - } - return 0 -} - -type PrepareUpdate struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Components []*PrepareComponentInfo `protobuf:"bytes,1,rep,name=components,proto3" json:"components,omitempty"` -} - -func (x *PrepareUpdate) Reset() { - *x = PrepareUpdate{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PrepareUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PrepareUpdate) ProtoMessage() {} - -func (x *PrepareUpdate) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PrepareUpdate.ProtoReflect.Descriptor instead. -func (*PrepareUpdate) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{2} -} - -func (x *PrepareUpdate) GetComponents() []*PrepareComponentInfo { - if x != nil { - return x.Components - } - return nil -} - -type StartUpdate struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *StartUpdate) Reset() { - *x = StartUpdate{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StartUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StartUpdate) ProtoMessage() {} - -func (x *StartUpdate) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StartUpdate.ProtoReflect.Descriptor instead. -func (*StartUpdate) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{3} -} - -type ApplyUpdate struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ApplyUpdate) Reset() { - *x = ApplyUpdate{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyUpdate) ProtoMessage() {} - -func (x *ApplyUpdate) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyUpdate.ProtoReflect.Descriptor instead. -func (*ApplyUpdate) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{4} -} - -type RevertUpdate struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *RevertUpdate) Reset() { - *x = RevertUpdate{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RevertUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RevertUpdate) ProtoMessage() {} - -func (x *RevertUpdate) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RevertUpdate.ProtoReflect.Descriptor instead. -func (*RevertUpdate) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{5} -} - -type SystemComponent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - VendorVersion string `protobuf:"bytes,2,opt,name=vendor_version,json=vendorVersion,proto3" json:"vendor_version,omitempty"` - AosVersion uint64 `protobuf:"varint,3,opt,name=aos_version,json=aosVersion,proto3" json:"aos_version,omitempty"` - Status ComponentStatus `protobuf:"varint,4,opt,name=status,proto3,enum=updatemanager.v1.ComponentStatus" json:"status,omitempty"` - Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` -} - -func (x *SystemComponent) Reset() { - *x = SystemComponent{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SystemComponent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SystemComponent) ProtoMessage() {} - -func (x *SystemComponent) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SystemComponent.ProtoReflect.Descriptor instead. -func (*SystemComponent) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{6} -} - -func (x *SystemComponent) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *SystemComponent) GetVendorVersion() string { - if x != nil { - return x.VendorVersion - } - return "" -} - -func (x *SystemComponent) GetAosVersion() uint64 { - if x != nil { - return x.AosVersion - } - return 0 -} - -func (x *SystemComponent) GetStatus() ComponentStatus { - if x != nil { - return x.Status - } - return ComponentStatus_INSTALLED -} - -func (x *SystemComponent) GetError() string { - if x != nil { - return x.Error - } - return "" -} - -type UpdateStatus struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UmId string `protobuf:"bytes,1,opt,name=um_id,json=umId,proto3" json:"um_id,omitempty"` - UmState UmState `protobuf:"varint,2,opt,name=um_state,json=umState,proto3,enum=updatemanager.v1.UmState" json:"um_state,omitempty"` - Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` - Components []*SystemComponent `protobuf:"bytes,4,rep,name=components,proto3" json:"components,omitempty"` -} - -func (x *UpdateStatus) Reset() { - *x = UpdateStatus{} - if protoimpl.UnsafeEnabled { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateStatus) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateStatus) ProtoMessage() {} - -func (x *UpdateStatus) ProtoReflect() protoreflect.Message { - mi := &file_updatemanager_v1_updatemanager_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateStatus.ProtoReflect.Descriptor instead. -func (*UpdateStatus) Descriptor() ([]byte, []int) { - return file_updatemanager_v1_updatemanager_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateStatus) GetUmId() string { - if x != nil { - return x.UmId - } - return "" -} - -func (x *UpdateStatus) GetUmState() UmState { - if x != nil { - return x.UmState - } - return UmState_IDLE -} - -func (x *UpdateStatus) GetError() string { - if x != nil { - return x.Error - } - return "" -} - -func (x *UpdateStatus) GetComponents() []*SystemComponent { - if x != nil { - return x.Components - } - return nil -} - -var File_updatemanager_v1_updatemanager_proto protoreflect.FileDescriptor - -var file_updatemanager_v1_updatemanager_proto_rawDesc = []byte{ - 0x0a, 0x24, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, - 0x76, 0x31, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x22, 0xb2, 0x02, 0x0a, 0x0a, 0x43, 0x4d, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x48, 0x0a, 0x0e, 0x70, 0x72, 0x65, 0x70, 0x61, - 0x72, 0x65, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1f, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x31, 0x2e, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x48, 0x00, 0x52, 0x0d, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x12, 0x42, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x42, 0x0a, 0x0c, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x5f, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x41, - 0x70, 0x70, 0x6c, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x70, - 0x70, 0x6c, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x45, 0x0a, 0x0d, 0x72, 0x65, 0x76, - 0x65, 0x72, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1e, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x48, 0x00, 0x52, 0x0c, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x42, 0x0b, 0x0a, 0x09, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xe6, 0x01, - 0x0a, 0x14, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, - 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, - 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, - 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, - 0x0b, 0x61, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x0a, 0x61, 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, - 0x0a, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, - 0x61, 0x35, 0x31, 0x32, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, 0x35, - 0x31, 0x32, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x57, 0x0a, 0x0d, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, - 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x46, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, - 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, - 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x22, - 0x0d, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x0d, - 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x0e, 0x0a, - 0x0c, 0x52, 0x65, 0x76, 0x65, 0x72, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0xba, 0x01, - 0x0a, 0x0f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, - 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x76, 0x65, 0x6e, 0x64, 0x6f, - 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6f, 0x73, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x61, - 0x6f, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xb2, 0x01, 0x0a, 0x0c, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x13, 0x0a, 0x05, 0x75, - 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x6d, 0x49, 0x64, - 0x12, 0x34, 0x0a, 0x08, 0x75, 0x6d, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x07, 0x75, - 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x41, 0x0a, 0x0a, - 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x21, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x2a, - 0x3a, 0x0a, 0x07, 0x55, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x44, - 0x4c, 0x45, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x50, 0x41, 0x52, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, - 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x3b, 0x0a, 0x0f, 0x43, - 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0d, - 0x0a, 0x09, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, - 0x0a, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, - 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x02, 0x32, 0x5d, 0x0a, 0x09, 0x55, 0x4d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x55, 0x4d, 0x12, 0x1e, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x1a, 0x1c, 0x2e, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_updatemanager_v1_updatemanager_proto_rawDescOnce sync.Once - file_updatemanager_v1_updatemanager_proto_rawDescData = file_updatemanager_v1_updatemanager_proto_rawDesc -) - -func file_updatemanager_v1_updatemanager_proto_rawDescGZIP() []byte { - file_updatemanager_v1_updatemanager_proto_rawDescOnce.Do(func() { - file_updatemanager_v1_updatemanager_proto_rawDescData = protoimpl.X.CompressGZIP(file_updatemanager_v1_updatemanager_proto_rawDescData) - }) - return file_updatemanager_v1_updatemanager_proto_rawDescData -} - -var file_updatemanager_v1_updatemanager_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_updatemanager_v1_updatemanager_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_updatemanager_v1_updatemanager_proto_goTypes = []interface{}{ - (UmState)(0), // 0: updatemanager.v1.UmState - (ComponentStatus)(0), // 1: updatemanager.v1.ComponentStatus - (*CMMessages)(nil), // 2: updatemanager.v1.CMMessages - (*PrepareComponentInfo)(nil), // 3: updatemanager.v1.PrepareComponentInfo - (*PrepareUpdate)(nil), // 4: updatemanager.v1.PrepareUpdate - (*StartUpdate)(nil), // 5: updatemanager.v1.StartUpdate - (*ApplyUpdate)(nil), // 6: updatemanager.v1.ApplyUpdate - (*RevertUpdate)(nil), // 7: updatemanager.v1.RevertUpdate - (*SystemComponent)(nil), // 8: updatemanager.v1.SystemComponent - (*UpdateStatus)(nil), // 9: updatemanager.v1.UpdateStatus -} -var file_updatemanager_v1_updatemanager_proto_depIdxs = []int32{ - 4, // 0: updatemanager.v1.CMMessages.prepare_update:type_name -> updatemanager.v1.PrepareUpdate - 5, // 1: updatemanager.v1.CMMessages.start_update:type_name -> updatemanager.v1.StartUpdate - 6, // 2: updatemanager.v1.CMMessages.apply_update:type_name -> updatemanager.v1.ApplyUpdate - 7, // 3: updatemanager.v1.CMMessages.revert_update:type_name -> updatemanager.v1.RevertUpdate - 3, // 4: updatemanager.v1.PrepareUpdate.components:type_name -> updatemanager.v1.PrepareComponentInfo - 1, // 5: updatemanager.v1.SystemComponent.status:type_name -> updatemanager.v1.ComponentStatus - 0, // 6: updatemanager.v1.UpdateStatus.um_state:type_name -> updatemanager.v1.UmState - 8, // 7: updatemanager.v1.UpdateStatus.components:type_name -> updatemanager.v1.SystemComponent - 9, // 8: updatemanager.v1.UMService.RegisterUM:input_type -> updatemanager.v1.UpdateStatus - 2, // 9: updatemanager.v1.UMService.RegisterUM:output_type -> updatemanager.v1.CMMessages - 9, // [9:10] is the sub-list for method output_type - 8, // [8:9] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_updatemanager_v1_updatemanager_proto_init() } -func file_updatemanager_v1_updatemanager_proto_init() { - if File_updatemanager_v1_updatemanager_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_updatemanager_v1_updatemanager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CMMessages); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PrepareComponentInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PrepareUpdate); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StartUpdate); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyUpdate); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RevertUpdate); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SystemComponent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateStatus); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_updatemanager_v1_updatemanager_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*CMMessages_PrepareUpdate)(nil), - (*CMMessages_StartUpdate)(nil), - (*CMMessages_ApplyUpdate)(nil), - (*CMMessages_RevertUpdate)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_updatemanager_v1_updatemanager_proto_rawDesc, - NumEnums: 2, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_updatemanager_v1_updatemanager_proto_goTypes, - DependencyIndexes: file_updatemanager_v1_updatemanager_proto_depIdxs, - EnumInfos: file_updatemanager_v1_updatemanager_proto_enumTypes, - MessageInfos: file_updatemanager_v1_updatemanager_proto_msgTypes, - }.Build() - File_updatemanager_v1_updatemanager_proto = out.File - file_updatemanager_v1_updatemanager_proto_rawDesc = nil - file_updatemanager_v1_updatemanager_proto_goTypes = nil - file_updatemanager_v1_updatemanager_proto_depIdxs = nil -} diff --git a/vendor/github.com/aosedge/aos_common/image/image.go b/vendor/github.com/aosedge/aos_common/image/image.go index 12319ef6..d3f9061a 100644 --- a/vendor/github.com/aosedge/aos_common/image/image.go +++ b/vendor/github.com/aosedge/aos_common/image/image.go @@ -76,7 +76,6 @@ const ( // FileInfo file info. type FileInfo struct { Sha256 []byte - Sha512 []byte Size uint64 } @@ -152,20 +151,6 @@ func CheckFileInfo(ctx context.Context, fileName string, fileInfo FileInfo) (err return aoserrors.New("checksum sha256 mismatch") } - hash512 := sha3.New512() - - if _, err = file.Seek(0, io.SeekStart); err != nil { - return aoserrors.Wrap(err) - } - - if _, err := io.Copy(hash512, contextRead); err != nil { - return aoserrors.Wrap(err) - } - - if !reflect.DeepEqual(hash512.Sum(nil), fileInfo.Sha512) { - return aoserrors.New("checksum sha512 mismatch") - } - return nil } @@ -194,18 +179,6 @@ func CreateFileInfo(ctx context.Context, fileName string) (fileInfo FileInfo, er fileInfo.Sha256 = hash256.Sum(nil) - hash512 := sha3.New512() - - if _, err = file.Seek(0, io.SeekStart); err != nil { - return fileInfo, aoserrors.Wrap(err) - } - - if _, err := io.Copy(hash512, contextRead); err != nil { - return fileInfo, aoserrors.Wrap(err) - } - - fileInfo.Sha512 = hash512.Sum(nil) - return fileInfo, nil } diff --git a/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go b/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go index 5eefbd57..52110efa 100644 --- a/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go +++ b/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go @@ -60,7 +60,7 @@ type AlertSender interface { // InstanceInfoProvider provides instance info. type InstanceInfoProvider interface { - GetInstanceInfoByID(instanceID string) (ident aostypes.InstanceIdent, aosVersion uint64, err error) + GetInstanceInfoByID(instanceID string) (ident aostypes.InstanceIdent, version string, err error) } // CursorStorage provides API to set and get journal cursor. @@ -352,7 +352,7 @@ func (instance *JournalAlerts) getServiceInstanceAlert( instanceID = strings.TrimPrefix(instanceID, aosServicePrefix) instanceID = strings.TrimSuffix(instanceID, ".service") - instanceIdent, aosVersion, err := instance.instanceProvider.GetInstanceInfoByID(instanceID) + instanceIdent, version, err := instance.instanceProvider.GetInstanceInfoByID(instanceID) if err != nil { log.Errorf("Can't get instance info: %s", err) @@ -360,9 +360,9 @@ func (instance *JournalAlerts) getServiceInstanceAlert( } return &cloudprotocol.ServiceInstanceAlert{ - Message: entry.Fields[sdjournal.SD_JOURNAL_FIELD_MESSAGE], - InstanceIdent: instanceIdent, - AosVersion: aosVersion, + Message: entry.Fields[sdjournal.SD_JOURNAL_FIELD_MESSAGE], + InstanceIdent: instanceIdent, + ServiceVersion: version, } } diff --git a/vendor/github.com/aosedge/aos_common/migration/migration.go b/vendor/github.com/aosedge/aos_common/migration/migration.go index cfa51f95..3a87c53e 100644 --- a/vendor/github.com/aosedge/aos_common/migration/migration.go +++ b/vendor/github.com/aosedge/aos_common/migration/migration.go @@ -181,6 +181,7 @@ func copyFile(src string, dst string) (err error) { return aoserrors.Wrap(err) } defer destination.Close() + _, err = io.Copy(destination, source) return aoserrors.Wrap(err) diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go index 62a0e217..d2543d35 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go @@ -24,7 +24,21 @@ import ( log "github.com/sirupsen/logrus" ) -type alertCallback func(time time.Time, value uint64) +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +const ( + AlertStatusRaise = "raise" + AlertStatusContinue = "continue" + AlertStatusFall = "fall" +) + +/*********************************************************************************************************************** + * Private + **********************************************************************************************************************/ + +type alertCallback func(time time.Time, value uint64, status string) // alertProcessor object for detection alerts. type alertProcessor struct { @@ -32,8 +46,9 @@ type alertProcessor struct { source *uint64 callback alertCallback rule aostypes.AlertRuleParam - thresholdTime time.Time - thresholdDetected bool + highThresholdTime time.Time + lowThresholdTime time.Time + alertCondition bool } // createAlertProcessor creates alert processor based on configuration. @@ -49,34 +64,85 @@ func createAlertProcessor(name string, source *uint64, func (alert *alertProcessor) checkAlertDetection(currentTime time.Time) { value := *alert.source - if value >= alert.rule.MaxThreshold && alert.thresholdTime.IsZero() { + if !alert.alertCondition { + alert.handleHighThreshold(currentTime, value) + } else { + alert.handleLowThreshold(currentTime, value) + } +} + +func (alert *alertProcessor) handleHighThreshold(currentTime time.Time, value uint64) { + if value >= alert.rule.High && alert.highThresholdTime.IsZero() { log.WithFields(log.Fields{ - "name": alert.name, "maxThreshold": alert.rule.MaxThreshold, "value": value, - }).Debugf("Max threshold crossed") + "name": alert.name, + "highThreshold": alert.rule.High, + "value": value, + "currentTime": currentTime.Format("Jan 2 15:04:05.000"), + }).Debugf("High threshold crossed") + + alert.highThresholdTime = currentTime + } + + if value >= alert.rule.High && !alert.highThresholdTime.IsZero() && + currentTime.Sub(alert.highThresholdTime) >= alert.rule.Timeout.Duration && !alert.alertCondition { + alert.alertCondition = true + alert.highThresholdTime = currentTime + alert.lowThresholdTime = time.Time{} + + log.WithFields(log.Fields{ + "name": alert.name, + "value": value, + "status": AlertStatusRaise, + "currentTime": currentTime.Format("Jan 2 15:04:05.000"), + }).Debugf("Resource alert") + + alert.callback(currentTime, value, AlertStatusRaise) + } - alert.thresholdTime = currentTime + if value < alert.rule.High && !alert.highThresholdTime.IsZero() { + alert.highThresholdTime = time.Time{} } +} + +func (alert *alertProcessor) handleLowThreshold(currentTime time.Time, value uint64) { + if value <= alert.rule.Low && !alert.lowThresholdTime.IsZero() && + currentTime.Sub(alert.lowThresholdTime) >= alert.rule.Timeout.Duration { + alert.alertCondition = false + alert.lowThresholdTime = currentTime + alert.highThresholdTime = time.Time{} - if value < alert.rule.MinThreshold && !alert.thresholdTime.IsZero() { log.WithFields(log.Fields{ - "name": alert.name, "minThreshold": alert.rule.MinThreshold, "value": value, - }).Debugf("Min threshold crossed") + "name": alert.name, + "value": value, + "status": AlertStatusFall, + "currentTime": currentTime.Format("Jan 2 15:04:05.000"), + }).Debugf("Resource alert") - alert.thresholdTime = time.Time{} - alert.thresholdDetected = false + alert.callback(currentTime, value, AlertStatusFall) } - if !alert.thresholdTime.IsZero() && - currentTime.Sub(alert.thresholdTime) >= alert.rule.MinTimeout.Duration && - !alert.thresholdDetected { + if currentTime.Sub(alert.highThresholdTime) >= alert.rule.Timeout.Duration && alert.alertCondition { + alert.highThresholdTime = currentTime + log.WithFields(log.Fields{ "name": alert.name, "value": value, - "currentTime": currentTime.Format("Jan 2 15:04:05"), + "status": AlertStatusContinue, + "currentTime": currentTime.Format("Jan 2 15:04:05.000"), }).Debugf("Resource alert") - alert.thresholdDetected = true + alert.callback(currentTime, value, AlertStatusContinue) + } + + if value <= alert.rule.Low && alert.lowThresholdTime.IsZero() { + log.WithFields(log.Fields{ + "name": alert.name, "lowThreshold": alert.rule.Low, "value": value, + }).Debugf("Low threshold crossed") + + alert.lowThresholdTime = currentTime + } - alert.callback(currentTime, value) + if value > alert.rule.Low && !alert.lowThresholdTime.IsZero() { + alert.lowThresholdTime = time.Time{} } } diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/averagecalc.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/averagecalc.go new file mode 100644 index 00000000..08cde759 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/averagecalc.go @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2024 Renesas Electronics Corporation. +// Copyright (C) 2024 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package resourcemonitor + +import ( + "math" +) + +/*********************************************************************************************************************** + * Structs + **********************************************************************************************************************/ + +type averageCalc struct { + sum float64 + count uint64 + windowCount uint64 +} + +/*********************************************************************************************************************** + * Private + **********************************************************************************************************************/ + +func newAverageCalc(windowCount uint64) *averageCalc { + return &averageCalc{windowCount: windowCount} +} + +func (calc *averageCalc) calculate(value float64) float64 { + if calc.count < calc.windowCount { + calc.sum += value + calc.count++ + } else { + calc.sum -= calc.sum / float64(calc.count) + calc.sum += value + } + + return calc.getValue() +} + +func (calc *averageCalc) getValue() float64 { + if calc.count == 0 { + return 0 + } + + return calc.sum / float64(calc.count) +} + +func (calc *averageCalc) getIntValue() uint64 { + return uint64(math.Round(calc.getValue())) +} diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index 54e0fa07..af3cc57a 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -49,10 +49,6 @@ const ( YearPeriod ) -// For optimization capacity should be equals numbers of measurement values -// 5 - RAM, CPU, UsedDisk, InTraffic, OutTraffic. -const capacityAlertProcessorElements = 5 - /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -62,11 +58,30 @@ type SystemUsageProvider interface { FillSystemInfo(instanceID string, instance *instanceMonitoring) error } +// QuotaAlert quota alert structure. +type QuotaAlert struct { + Timestamp time.Time + Parameter string + Value uint64 + Status string +} + // AlertSender interface to send resource alerts. type AlertSender interface { SendAlert(alert cloudprotocol.AlertItem) } +// NodeInfoProvider interface to get node information. +type NodeInfoProvider interface { + GetNodeInfo() (cloudprotocol.NodeInfo, error) +} + +// NodeConfigProvider interface to get node config. +type NodeConfigProvider interface { + GetNodeConfig() (cloudprotocol.NodeConfig, error) + NodeConfigChangedChannel() <-chan cloudprotocol.NodeConfig +} + // MonitoringSender sends monitoring data. type MonitoringSender interface { SendMonitoringData(monitoringData cloudprotocol.NodeMonitoringData) @@ -78,43 +93,31 @@ type TrafficMonitoring interface { GetInstanceTraffic(instanceID string) (inputTraffic, outputTraffic uint64, err error) } -// PartitionConfig partition information. -type PartitionConfig struct { - Name string `json:"name"` - Types []string `json:"types"` - Path string `json:"path"` -} - // Config configuration for resource monitoring. type Config struct { - aostypes.AlertRules - SendPeriod aostypes.Duration `json:"sendPeriod"` - PollPeriod aostypes.Duration `json:"pollPeriod"` - Partitions []PartitionConfig `json:"partitions"` - Source string `json:"source"` + PollPeriod aostypes.Duration `json:"pollPeriod"` + AverageWindow aostypes.Duration `json:"averageWindow"` + Source string `json:"source"` } // ResourceMonitor instance. type ResourceMonitor struct { sync.Mutex - alertSender AlertSender - monitoringSender MonitoringSender - - config Config - nodeID string - - sendTimer *time.Ticker - pollTimer *time.Ticker - - nodeMonitoringData cloudprotocol.MonitoringData - systemInfo cloudprotocol.SystemInfo - - alertProcessors *list.List - + nodeInfoProvider NodeInfoProvider + nodeConfigProvider NodeConfigProvider + alertSender AlertSender + monitoringSender MonitoringSender + trafficMonitoring TrafficMonitoring + sourceSystemUsage SystemUsageProvider + + pollTimer *time.Ticker + averageWindowCount uint64 + nodeInfo cloudprotocol.NodeInfo + nodeMonitoringData cloudprotocol.MonitoringData + nodeAverageData averageMonitoring instanceMonitoringMap map[string]*instanceMonitoring - trafficMonitoring TrafficMonitoring - sourceSystemUsage SystemUsageProvider + alertProcessors *list.List cancelFunction context.CancelFunc } @@ -139,11 +142,20 @@ type instanceMonitoring struct { gid uint32 partitions []PartitionParam monitoringData cloudprotocol.InstanceMonitoringData + averageData averageMonitoring alertProcessorElements []*list.Element prevCPU uint64 prevTime time.Time } +type averageMonitoring struct { + ram *averageCalc + cpu *averageCalc + inTraffic *averageCalc + outTraffic *averageCalc + disks map[string]*averageCalc +} + /*********************************************************************************************************************** * Variable **********************************************************************************************************************/ @@ -152,12 +164,12 @@ type instanceMonitoring struct { // //nolint:gochecknoglobals var ( - systemCPUPercent = cpu.Percent - systemVirtualMemory = mem.VirtualMemory - systemDiskUsage = disk.Usage - getUserFSQuotaUsage = fs.GetUserFSQuotaUsage - cpuCount = runtime.NumCPU() - hostSystemUsageInstance SystemUsageProvider = nil + systemCPUPercent = cpu.Percent + systemVirtualMemory = mem.VirtualMemory + systemDiskUsage = disk.Usage + getUserFSQuotaUsage = fs.GetUserFSQuotaUsage + cpuCount = runtime.NumCPU() + instanceUsage SystemUsageProvider = nil ) /*********************************************************************************************************************** @@ -166,88 +178,43 @@ var ( // New creates new resource monitor instance. func New( - nodeID string, config Config, alertsSender AlertSender, monitoringSender MonitoringSender, - trafficMonitoring TrafficMonitoring) ( - monitor *ResourceMonitor, err error, + config Config, nodeInfoProvider NodeInfoProvider, nodeConfigProvider NodeConfigProvider, + trafficMonitoring TrafficMonitoring, alertsSender AlertSender, monitoringSender MonitoringSender) ( + *ResourceMonitor, error, ) { log.Debug("Create monitor") - monitor = &ResourceMonitor{ - alertSender: alertsSender, - monitoringSender: monitoringSender, - trafficMonitoring: trafficMonitoring, - config: config, - nodeID: nodeID, - sourceSystemUsage: getSourceSystemUsage(config.Source), - } - - monitor.alertProcessors = list.New() - - if monitor.config.CPU != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( - "System CPU", - &monitor.nodeMonitoringData.CPU, - func(time time.Time, value uint64) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("cpu", time, value)) - }, - *monitor.config.CPU)) + monitor := &ResourceMonitor{ + nodeInfoProvider: nodeInfoProvider, + nodeConfigProvider: nodeConfigProvider, + alertSender: alertsSender, + monitoringSender: monitoringSender, + trafficMonitoring: trafficMonitoring, + sourceSystemUsage: getSourceSystemUsage(config.Source), } - if monitor.config.RAM != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( - "System RAM", - &monitor.nodeMonitoringData.RAM, - func(time time.Time, value uint64) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("ram", time, value)) - }, - *monitor.config.RAM)) + nodeInfo, err := nodeInfoProvider.GetNodeInfo() + if err != nil { + return nil, aoserrors.Wrap(err) } - monitor.nodeMonitoringData.Disk = make([]cloudprotocol.PartitionUsage, len(config.Partitions)) - - for i, partitionParam := range config.Partitions { - monitor.nodeMonitoringData.Disk[i].Name = partitionParam.Name + monitor.averageWindowCount = uint64(config.AverageWindow.Duration.Nanoseconds()) / + uint64(config.PollPeriod.Duration.Nanoseconds()) + if monitor.averageWindowCount == 0 { + monitor.averageWindowCount = 1 } - if len(monitor.config.UsedDisks) > 0 { - for _, diskRule := range monitor.config.UsedDisks { - for i := 0; i < len(monitor.nodeMonitoringData.Disk); i++ { - if diskRule.Name != monitor.nodeMonitoringData.Disk[i].Name { - continue - } - - monitor.alertProcessors.PushBack(createAlertProcessor( - "Partition "+monitor.nodeMonitoringData.Disk[i].Name, - &monitor.nodeMonitoringData.Disk[i].UsedSize, - func(time time.Time, value uint64) { - monitor.alertSender.SendAlert(prepareSystemAlertItem( - monitor.nodeMonitoringData.Disk[i].Name, time, value)) - }, - diskRule.AlertRuleParam)) - - break - } - } + if err := monitor.setupNodeMonitoring(nodeInfo); err != nil { + return nil, aoserrors.Wrap(err) } - if monitor.config.InTraffic != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( - "IN Traffic", - &monitor.nodeMonitoringData.InTraffic, - func(time time.Time, value uint64) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("inTraffic", time, value)) - }, - *monitor.config.InTraffic)) + nodeConfig, err := nodeConfigProvider.GetNodeConfig() + if err != nil { + log.Errorf("Can't get node config: %v", err) } - if monitor.config.OutTraffic != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( - "OUT Traffic", - &monitor.nodeMonitoringData.OutTraffic, - func(time time.Time, value uint64) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("outTraffic", time, value)) - }, - *monitor.config.OutTraffic)) + if err := monitor.setupSystemAlerts(nodeConfig); err != nil { + log.Errorf("Can't setup system alerts: %v", err) } monitor.instanceMonitoringMap = make(map[string]*instanceMonitoring) @@ -255,12 +222,7 @@ func New( ctx, cancelFunc := context.WithCancel(context.Background()) monitor.cancelFunction = cancelFunc - monitor.pollTimer = time.NewTicker(monitor.config.PollPeriod.Duration) - monitor.sendTimer = time.NewTicker(monitor.config.SendPeriod.Duration) - - if err = monitor.gatheringSystemInfo(); err != nil { - return nil, err - } + monitor.pollTimer = time.NewTicker(config.PollPeriod.Duration) go monitor.run(ctx) @@ -271,10 +233,6 @@ func New( func (monitor *ResourceMonitor) Close() { log.Debug("Close monitor") - if monitor.sendTimer != nil { - monitor.sendTimer.Stop() - } - if monitor.pollTimer != nil { monitor.pollTimer.Stop() } @@ -284,10 +242,6 @@ func (monitor *ResourceMonitor) Close() { } } -func (monitor *ResourceMonitor) GetSystemInfo() cloudprotocol.SystemInfo { - return monitor.systemInfo -} - // StartInstanceMonitor starts monitoring service. func (monitor *ResourceMonitor) StartInstanceMonitor( instanceID string, monitoringConfig ResourceMonitorParams, @@ -303,8 +257,31 @@ func (monitor *ResourceMonitor) StartInstanceMonitor( log.WithFields(log.Fields{"id": instanceID}).Debug("Start instance monitoring") - monitor.instanceMonitoringMap[instanceID] = monitor.createInstanceMonitoring( - instanceID, monitoringConfig.AlertRules, monitoringConfig) + instanceMonitoring := &instanceMonitoring{ + uid: uint32(monitoringConfig.UID), + gid: uint32(monitoringConfig.GID), + partitions: monitoringConfig.Partitions, + monitoringData: cloudprotocol.InstanceMonitoringData{InstanceIdent: monitoringConfig.InstanceIdent}, + } + + monitor.instanceMonitoringMap[instanceID] = instanceMonitoring + + instanceMonitoring.monitoringData.Disk = make( + []cloudprotocol.PartitionUsage, len(monitoringConfig.Partitions)) + + for i, partitionParam := range monitoringConfig.Partitions { + instanceMonitoring.monitoringData.Disk[i].Name = partitionParam.Name + } + + instanceMonitoring.averageData = *newAverageMonitoring( + monitor.averageWindowCount, instanceMonitoring.monitoringData.Disk) + + if monitoringConfig.AlertRules != nil && monitor.alertSender != nil { + if err := monitor.setupInstanceAlerts( + instanceID, instanceMonitoring, *monitoringConfig.AlertRules); err != nil { + log.Errorf("Can't setup instance alerts: %v", err) + } + } return nil } @@ -329,21 +306,165 @@ func (monitor *ResourceMonitor) StopInstanceMonitor(instanceID string) error { return nil } +// GetAverageMonitoring returns average monitoring data. +func (monitor *ResourceMonitor) GetAverageMonitoring() (cloudprotocol.NodeMonitoringData, error) { + monitor.Lock() + defer monitor.Unlock() + + log.Debug("Get average monitoring data") + + averageMonitoringData := cloudprotocol.NodeMonitoringData{ + NodeID: monitor.nodeInfo.NodeID, + Timestamp: time.Now(), + MonitoringData: monitor.nodeAverageData.toMonitoringData(), + ServiceInstances: make([]cloudprotocol.InstanceMonitoringData, 0, len(monitor.instanceMonitoringMap)), + } + + for _, instanceMonitoring := range monitor.instanceMonitoringMap { + averageMonitoringData.ServiceInstances = append(averageMonitoringData.ServiceInstances, + cloudprotocol.InstanceMonitoringData{ + InstanceIdent: instanceMonitoring.monitoringData.InstanceIdent, + NodeID: monitor.nodeInfo.NodeID, + MonitoringData: instanceMonitoring.averageData.toMonitoringData(), + }) + } + + return averageMonitoringData, nil +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ +func (monitor *ResourceMonitor) setupNodeMonitoring(nodeInfo cloudprotocol.NodeInfo) error { + monitor.Lock() + defer monitor.Unlock() + + if nodeInfo.MaxDMIPs == 0 { + return aoserrors.Errorf("max DMIPs is 0") + } + + monitor.nodeInfo = nodeInfo + + monitor.nodeMonitoringData = cloudprotocol.MonitoringData{ + Disk: make([]cloudprotocol.PartitionUsage, len(nodeInfo.Partitions)), + } + + for i, partitionParam := range nodeInfo.Partitions { + monitor.nodeMonitoringData.Disk[i].Name = partitionParam.Name + } + + monitor.nodeAverageData = *newAverageMonitoring(monitor.averageWindowCount, monitor.nodeMonitoringData.Disk) + + return nil +} + +func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeConfig) (err error) { + monitor.Lock() + defer monitor.Unlock() + + monitor.alertProcessors = list.New() + + if nodeConfig.AlertRules == nil || monitor.alertSender == nil { + return nil + } + + if nodeConfig.AlertRules.CPU != nil { + rules := *nodeConfig.AlertRules.CPU + rules.High = monitor.cpuToDMIPs(float64(rules.High)) + rules.Low = monitor.cpuToDMIPs(float64(rules.Low)) + + monitor.alertProcessors.PushBack(createAlertProcessor( + "System CPU", + &monitor.nodeMonitoringData.CPU, + func(time time.Time, value uint64, status string) { + monitor.alertSender.SendAlert(prepareSystemAlertItem("cpu", time, value, status)) + }, + rules)) + } + + if nodeConfig.AlertRules.RAM != nil { + monitor.alertProcessors.PushBack(createAlertProcessor( + "System RAM", + &monitor.nodeMonitoringData.RAM, + func(time time.Time, value uint64, status string) { + monitor.alertSender.SendAlert(prepareSystemAlertItem("ram", time, value, status)) + }, + *nodeConfig.AlertRules.RAM)) + } + + for _, diskRule := range nodeConfig.AlertRules.UsedDisks { + diskUsageValue, findErr := getDiskUsageValue(monitor.nodeMonitoringData.Disk, diskRule.Name) + if findErr != nil && err == nil { + err = findErr + + log.Errorf("Can't find disk: %s", diskRule.Name) + + continue + } + + monitor.alertProcessors.PushBack(createAlertProcessor( + "Partition "+diskRule.Name, + diskUsageValue, + func(time time.Time, value uint64, status string) { + monitor.alertSender.SendAlert(prepareSystemAlertItem(diskRule.Name, time, value, status)) + }, + diskRule.AlertRuleParam)) + } + + if nodeConfig.AlertRules.InTraffic != nil { + monitor.alertProcessors.PushBack(createAlertProcessor( + "IN Traffic", + &monitor.nodeMonitoringData.InTraffic, + func(time time.Time, value uint64, status string) { + monitor.alertSender.SendAlert(prepareSystemAlertItem("inTraffic", time, value, status)) + }, + *nodeConfig.AlertRules.InTraffic)) + } + + if nodeConfig.AlertRules.OutTraffic != nil { + monitor.alertProcessors.PushBack(createAlertProcessor( + "OUT Traffic", + &monitor.nodeMonitoringData.OutTraffic, + func(time time.Time, value uint64, status string) { + monitor.alertSender.SendAlert(prepareSystemAlertItem("outTraffic", time, value, status)) + }, + *nodeConfig.AlertRules.OutTraffic)) + } + + return err +} + +func getDiskUsageValue(disks []cloudprotocol.PartitionUsage, name string) (*uint64, error) { + for i, disk := range disks { + if disk.Name == name { + return &disks[i].UsedSize, nil + } + } + + return nil, aoserrors.Errorf("can't find disk %s", name) +} + +func getDiskPath(disks []cloudprotocol.PartitionInfo, name string) (string, error) { + for _, disk := range disks { + if disk.Name == name { + return disk.Path, nil + } + } + + return "", aoserrors.Errorf("can't find disk %s", name) +} + func (monitor *ResourceMonitor) run(ctx context.Context) { for { select { case <-ctx.Done(): return - case <-monitor.sendTimer.C: - monitor.Lock() - monitoringData := monitor.prepareMonitoringData() - monitor.sendMonitoringData(monitoringData) - monitor.Unlock() + case nodeConfig := <-monitor.nodeConfigProvider.NodeConfigChangedChannel(): + if err := monitor.setupSystemAlerts(nodeConfig); err != nil { + log.Errorf("Can't setup system alerts: %v", err) + } case <-monitor.pollTimer.C: monitor.Lock() @@ -351,155 +472,111 @@ func (monitor *ResourceMonitor) run(ctx context.Context) { monitor.getCurrentSystemData() monitor.getCurrentInstanceData() monitor.processAlerts() + monitor.sendMonitoringData() monitor.Unlock() } } } -func (monitor *ResourceMonitor) createInstanceMonitoring( - instanceID string, rules *aostypes.AlertRules, monitoringConfig ResourceMonitorParams, -) *instanceMonitoring { - serviceMonitoring := &instanceMonitoring{ - uid: uint32(monitoringConfig.UID), - gid: uint32(monitoringConfig.GID), - partitions: monitoringConfig.Partitions, - monitoringData: cloudprotocol.InstanceMonitoringData{InstanceIdent: monitoringConfig.InstanceIdent}, - } - - if monitor.alertSender == nil { - return serviceMonitoring - } - - serviceMonitoring.monitoringData.Disk = make( - []cloudprotocol.PartitionUsage, len(monitoringConfig.Partitions)) - - for i, partitionParam := range monitoringConfig.Partitions { - serviceMonitoring.monitoringData.Disk[i].Name = partitionParam.Name - } - - if rules == nil { - return serviceMonitoring - } - - serviceMonitoring.alertProcessorElements = make([]*list.Element, 0, capacityAlertProcessorElements) +func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceMonitoring *instanceMonitoring, + rules aostypes.AlertRules, +) (err error) { + instanceMonitoring.alertProcessorElements = make([]*list.Element, 0) if rules.CPU != nil { + rules := *rules.CPU + rules.High = monitor.cpuToDMIPs(float64(rules.High)) + rules.Low = monitor.cpuToDMIPs(float64(rules.Low)) + e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" CPU", - &serviceMonitoring.monitoringData.CPU, - func(time time.Time, value uint64) { + &instanceMonitoring.monitoringData.CPU, + func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( - prepareInstanceAlertItem(monitoringConfig.InstanceIdent, "cpu", time, value)) - }, *rules.CPU)) + prepareInstanceAlertItem( + instanceMonitoring.monitoringData.InstanceIdent, "cpu", time, value, status)) + }, rules)) - serviceMonitoring.alertProcessorElements = append(serviceMonitoring.alertProcessorElements, e) + instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } if rules.RAM != nil { e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" RAM", - &serviceMonitoring.monitoringData.RAM, - func(time time.Time, value uint64) { + &instanceMonitoring.monitoringData.RAM, + func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( - prepareInstanceAlertItem(monitoringConfig.InstanceIdent, "ram", time, value)) + prepareInstanceAlertItem( + instanceMonitoring.monitoringData.InstanceIdent, "ram", time, value, status)) }, *rules.RAM)) - serviceMonitoring.alertProcessorElements = append(serviceMonitoring.alertProcessorElements, e) + instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } - if len(rules.UsedDisks) > 0 { - for _, diskRule := range rules.UsedDisks { - for i := 0; i < len(serviceMonitoring.monitoringData.Disk); i++ { - if diskRule.Name != serviceMonitoring.monitoringData.Disk[i].Name { - continue - } - - e := monitor.alertProcessors.PushBack(createAlertProcessor( - instanceID+" Partition "+serviceMonitoring.monitoringData.Disk[i].Name, - &serviceMonitoring.monitoringData.Disk[i].UsedSize, - func(time time.Time, value uint64) { - monitor.alertSender.SendAlert( - prepareInstanceAlertItem( - monitoringConfig.InstanceIdent, serviceMonitoring.monitoringData.Disk[i].Name, - time, value)) - }, diskRule.AlertRuleParam)) + for _, diskRule := range rules.UsedDisks { + diskUsageValue, findErr := getDiskUsageValue(instanceMonitoring.monitoringData.Disk, diskRule.Name) + if findErr != nil && err == nil { + log.Errorf("Can't find disk: %s", diskRule.Name) - serviceMonitoring.alertProcessorElements = append(serviceMonitoring.alertProcessorElements, e) + err = findErr - break - } + continue } + + e := monitor.alertProcessors.PushBack(createAlertProcessor( + instanceID+" Partition "+diskRule.Name, + diskUsageValue, + func(time time.Time, value uint64, status string) { + monitor.alertSender.SendAlert( + prepareInstanceAlertItem( + instanceMonitoring.monitoringData.InstanceIdent, diskRule.Name, time, value, status)) + }, diskRule.AlertRuleParam)) + + instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } if rules.InTraffic != nil { e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" Traffic IN", - &serviceMonitoring.monitoringData.InTraffic, - func(time time.Time, value uint64) { + &instanceMonitoring.monitoringData.InTraffic, + func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( - prepareInstanceAlertItem(monitoringConfig.InstanceIdent, "inTraffic", time, value)) + prepareInstanceAlertItem( + instanceMonitoring.monitoringData.InstanceIdent, "inTraffic", time, value, status)) }, *rules.InTraffic)) - serviceMonitoring.alertProcessorElements = append(serviceMonitoring.alertProcessorElements, e) + instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } if rules.OutTraffic != nil { e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" Traffic OUT", - &serviceMonitoring.monitoringData.OutTraffic, - func(time time.Time, value uint64) { + &instanceMonitoring.monitoringData.OutTraffic, + func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( - prepareInstanceAlertItem(monitoringConfig.InstanceIdent, "outTraffic", time, value)) + prepareInstanceAlertItem( + instanceMonitoring.monitoringData.InstanceIdent, "outTraffic", time, value, status)) }, *rules.OutTraffic)) - serviceMonitoring.alertProcessorElements = append(serviceMonitoring.alertProcessorElements, e) - } - - return serviceMonitoring -} - -func (monitor *ResourceMonitor) gatheringSystemInfo() (err error) { - monitor.systemInfo.NumCPUs = uint64(cpuCount) - - memStat, err := systemVirtualMemory() - if err != nil { - return aoserrors.Wrap(err) - } - - monitor.systemInfo.TotalRAM = memStat.Total - - monitor.systemInfo.Partitions = make([]cloudprotocol.PartitionInfo, len(monitor.config.Partitions)) - for i, partition := range monitor.config.Partitions { - monitor.systemInfo.Partitions[i].Name = partition.Name - monitor.systemInfo.Partitions[i].Types = append(monitor.systemInfo.Partitions[i].Types, partition.Types...) - - usageStat, err := systemDiskUsage(partition.Path) - if err != nil { - return aoserrors.Wrap(err) - } - - monitor.systemInfo.Partitions[i].TotalSize = usageStat.Total + instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } - return nil + return err } -func (monitor *ResourceMonitor) prepareMonitoringData() cloudprotocol.NodeMonitoringData { - monitoringData := cloudprotocol.NodeMonitoringData{ +func (monitor *ResourceMonitor) sendMonitoringData() { + nodeMonitoringData := cloudprotocol.NodeMonitoringData{ MonitoringData: monitor.nodeMonitoringData, - NodeID: monitor.nodeID, + NodeID: monitor.nodeInfo.NodeID, Timestamp: time.Now(), ServiceInstances: make([]cloudprotocol.InstanceMonitoringData, 0, len(monitor.instanceMonitoringMap)), } - for _, instance := range monitor.instanceMonitoringMap { - monitoringData.ServiceInstances = append(monitoringData.ServiceInstances, instance.monitoringData) + for _, instanceMonitoring := range monitor.instanceMonitoringMap { + nodeMonitoringData.ServiceInstances = append(nodeMonitoringData.ServiceInstances, + instanceMonitoring.monitoringData) } - return monitoringData -} - -func (monitor *ResourceMonitor) sendMonitoringData(nodeMonitoringData cloudprotocol.NodeMonitoringData) { monitor.monitoringSender.SendMonitoringData(nodeMonitoringData) } @@ -509,19 +586,24 @@ func (monitor *ResourceMonitor) getCurrentSystemData() { log.Errorf("Can't get system CPU: %s", err) } - monitor.nodeMonitoringData.CPU = uint64(math.Round(cpu)) + monitor.nodeMonitoringData.CPU = monitor.cpuToDMIPs(cpu) monitor.nodeMonitoringData.RAM, err = getSystemRAMUsage() if err != nil { log.Errorf("Can't get system RAM: %s", err) } - if len(monitor.nodeMonitoringData.Disk) > 0 { - for i, partitionParam := range monitor.config.Partitions { - monitor.nodeMonitoringData.Disk[i].UsedSize, err = getSystemDiskUsage(partitionParam.Path) - if err != nil { - log.Errorf("Can't get system Disk usage: %v", err) - } + for i, disk := range monitor.nodeMonitoringData.Disk { + mountPoint, err := getDiskPath(monitor.nodeInfo.Partitions, disk.Name) + if err != nil { + log.Errorf("Can't get disk path: %v", err) + + continue + } + + monitor.nodeMonitoringData.Disk[i].UsedSize, err = getSystemDiskUsage(mountPoint) + if err != nil { + log.Errorf("Can't get system Disk usage: %v", err) } } @@ -535,6 +617,8 @@ func (monitor *ResourceMonitor) getCurrentSystemData() { monitor.nodeMonitoringData.OutTraffic = outTraffic } + monitor.nodeAverageData.updateMonitoringData(monitor.nodeMonitoringData) + log.WithFields(log.Fields{ "CPU": monitor.nodeMonitoringData.CPU, "RAM": monitor.nodeMonitoringData.RAM, @@ -551,10 +635,12 @@ func (monitor *ResourceMonitor) getCurrentInstanceData() { log.Errorf("Can't fill system usage info: %v", err) } + value.monitoringData.CPU = monitor.cpuToDMIPs(float64(value.monitoringData.CPU)) + for i, partitionParam := range value.partitions { value.monitoringData.Disk[i].UsedSize, err = getInstanceDiskUsage(partitionParam.Path, value.uid, value.gid) if err != nil { - log.Errorf("Can't get service Disc usage: %v", err) + log.Errorf("Can't get service disk usage: %v", err) } } @@ -568,6 +654,8 @@ func (monitor *ResourceMonitor) getCurrentInstanceData() { value.monitoringData.OutTraffic = outTraffic } + value.averageData.updateMonitoringData(value.monitoringData.MonitoringData) + log.WithFields(log.Fields{ "id": instanceID, "CPU": value.monitoringData.CPU, @@ -584,7 +672,6 @@ func (monitor *ResourceMonitor) processAlerts() { for e := monitor.alertProcessors.Front(); e != nil; e = e.Next() { alertProcessor, ok := e.Value.(*alertProcessor) - if !ok { log.Error("Unexpected alert processors type") return @@ -601,7 +688,7 @@ func getSystemCPUUsage() (cpuUse float64, err error) { return 0, aoserrors.Wrap(err) } - cpuUse = v[0] + cpuUse = v[0] / float64(cpuCount) return cpuUse, nil } @@ -616,11 +703,11 @@ func getSystemRAMUsage() (ram uint64, err error) { return v.Used, nil } -// getSystemDiskUsage returns disc usage in bytes. -func getSystemDiskUsage(path string) (discUse uint64, err error) { +// getSystemDiskUsage returns disk usage in bytes. +func getSystemDiskUsage(path string) (diskUse uint64, err error) { v, err := systemDiskUsage(path) if err != nil { - return discUse, aoserrors.Wrap(err) + return diskUse, aoserrors.Wrap(err) } return v.Used, nil @@ -635,19 +722,22 @@ func getInstanceDiskUsage(path string, uid, gid uint32) (diskUse uint64, err err return diskUse, nil } -func prepareSystemAlertItem(parameter string, timestamp time.Time, value uint64) cloudprotocol.AlertItem { +func prepareSystemAlertItem( + parameter string, timestamp time.Time, value uint64, status string, +) cloudprotocol.AlertItem { return cloudprotocol.AlertItem{ Timestamp: timestamp, Tag: cloudprotocol.AlertTagSystemQuota, Payload: cloudprotocol.SystemQuotaAlert{ Parameter: parameter, Value: value, + Status: status, }, } } func prepareInstanceAlertItem( - instanceIndent aostypes.InstanceIdent, parameter string, timestamp time.Time, value uint64, + instanceIndent aostypes.InstanceIdent, parameter string, timestamp time.Time, value uint64, status string, ) cloudprotocol.AlertItem { return cloudprotocol.AlertItem{ Timestamp: timestamp, @@ -656,6 +746,7 @@ func prepareInstanceAlertItem( InstanceIdent: instanceIndent, Parameter: parameter, Value: value, + Status: status, }, } } @@ -665,9 +756,65 @@ func getSourceSystemUsage(source string) SystemUsageProvider { return &xenSystemUsage{} } - if hostSystemUsageInstance != nil { - return hostSystemUsageInstance + if instanceUsage != nil { + return instanceUsage } return &cgroupsSystemUsage{} } + +func (monitor *ResourceMonitor) cpuToDMIPs(cpu float64) uint64 { + return uint64(math.Round(float64(cpu) * float64(monitor.nodeInfo.MaxDMIPs) / 100.0)) +} + +func newAverageMonitoring(windowCount uint64, partitions []cloudprotocol.PartitionUsage) *averageMonitoring { + averageMonitoring := &averageMonitoring{ + ram: newAverageCalc(windowCount), + cpu: newAverageCalc(windowCount), + inTraffic: newAverageCalc(windowCount), + outTraffic: newAverageCalc(windowCount), + disks: make(map[string]*averageCalc), + } + + for _, partition := range partitions { + averageMonitoring.disks[partition.Name] = newAverageCalc(windowCount) + } + + return averageMonitoring +} + +func (average *averageMonitoring) toMonitoringData() cloudprotocol.MonitoringData { + monitoringData := cloudprotocol.MonitoringData{ + CPU: average.cpu.getIntValue(), + RAM: average.ram.getIntValue(), + InTraffic: average.inTraffic.getIntValue(), + OutTraffic: average.outTraffic.getIntValue(), + Disk: make([]cloudprotocol.PartitionUsage, 0, len(average.disks)), + } + + for name, diskUsage := range average.disks { + monitoringData.Disk = append(monitoringData.Disk, cloudprotocol.PartitionUsage{ + Name: name, UsedSize: diskUsage.getIntValue(), + }) + } + + return monitoringData +} + +func (average *averageMonitoring) updateMonitoringData(data cloudprotocol.MonitoringData) { + average.cpu.calculate(float64(data.CPU)) + average.ram.calculate(float64(data.RAM)) + average.inTraffic.calculate(float64(data.InTraffic)) + average.outTraffic.calculate(float64(data.OutTraffic)) + + for _, disk := range data.Disk { + averageCalc, ok := average.disks[disk.Name] + if !ok { + log.Errorf("Can't find disk: %s", disk.Name) + + continue + } + + averageCalc.calculate(float64(disk.UsedSize)) + } +} diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go index 4e636644..0be2b3b7 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go @@ -49,7 +49,7 @@ func (xen *xenSystemUsage) FillSystemInfo(instanceID string, instance *instanceM systemInfo, ok := xen.systemInfos[instanceID] if ok { instance.monitoringData.CPU = uint64(systemInfo.CPUFraction) - instance.monitoringData.RAM = uint64(systemInfo.Memory) * 1024 //nolint:gomnd + instance.monitoringData.RAM = uint64(systemInfo.Memory) * 1024 //nolint:mnd } return nil diff --git a/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go b/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go index 79cc6f08..1848754c 100644 --- a/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go +++ b/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go @@ -20,15 +20,39 @@ package pbconvert import ( "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/servicemanager/v3" + pbcommon "github.com/aosedge/aos_common/api/common" + pbiam "github.com/aosedge/aos_common/api/iamanager" + pbsm "github.com/aosedge/aos_common/api/servicemanager" ) /*********************************************************************************************************************** * Public **********************************************************************************************************************/ -func InstanceFilterToPB(filter cloudprotocol.InstanceFilter) *pb.InstanceIdent { - ident := &pb.InstanceIdent{ServiceId: "", SubjectId: "", Instance: -1} +// InstanceFilterFromPB converts InstanceFilter from protobuf to AOS type. +func InstanceFilterFromPB(filter *pbsm.InstanceFilter) cloudprotocol.InstanceFilter { + aosFilter := cloudprotocol.InstanceFilter{} + + if filter.GetServiceId() != "" { + aosFilter.ServiceID = &filter.ServiceId + } + + if filter.GetSubjectId() != "" { + aosFilter.SubjectID = &filter.SubjectId + } + + if filter.GetInstance() != -1 { + instance := (uint64)(filter.GetInstance()) + + aosFilter.Instance = &instance + } + + return aosFilter +} + +// InstanceFilterToPB converts InstanceFilter from AOS type to protobuf. +func InstanceFilterToPB(filter cloudprotocol.InstanceFilter) *pbsm.InstanceFilter { + ident := &pbsm.InstanceFilter{ServiceId: "", SubjectId: "", Instance: -1} if filter.ServiceID != nil { ident.ServiceId = *filter.ServiceID @@ -45,42 +69,48 @@ func InstanceFilterToPB(filter cloudprotocol.InstanceFilter) *pb.InstanceIdent { return ident } -func InstanceIdentToPB(ident aostypes.InstanceIdent) *pb.InstanceIdent { - return &pb.InstanceIdent{ServiceId: ident.ServiceID, SubjectId: ident.SubjectID, Instance: int64(ident.Instance)} -} - -func NetworkParametersToPB(params aostypes.NetworkParameters) *pb.NetworkParameters { - networkParams := &pb.NetworkParameters{ - Ip: params.IP, - Subnet: params.Subnet, - VlanId: params.VlanID, - DnsServers: make([]string, len(params.DNSServers)), - Rules: make([]*pb.FirewallRule, len(params.FirewallRules)), +// InstanceIdentFromPB converts InstanceIdent from protobuf to AOS type. +func InstanceIdentFromPB(ident *pbcommon.InstanceIdent) aostypes.InstanceIdent { + return aostypes.InstanceIdent{ + ServiceID: ident.GetServiceId(), + SubjectID: ident.GetSubjectId(), + Instance: ident.GetInstance(), } +} - copy(networkParams.GetDnsServers(), params.DNSServers) +// InstanceIdentToPB converts InstanceIdent from AOS type to protobuf. +func InstanceIdentToPB(ident aostypes.InstanceIdent) *pbcommon.InstanceIdent { + return &pbcommon.InstanceIdent{ServiceId: ident.ServiceID, SubjectId: ident.SubjectID, Instance: ident.Instance} +} - for i, rule := range params.FirewallRules { - networkParams.Rules[i] = &pb.FirewallRule{ - DstIp: rule.DstIP, - SrcIp: rule.SrcIP, - DstPort: rule.DstPort, - Proto: rule.Proto, - } +// ErrorInfoFromPB converts ErrorInfo from protobuf to AOS type. +func ErrorInfoFromPB(errorInfo *pbcommon.ErrorInfo) *cloudprotocol.ErrorInfo { + if errorInfo == nil { + return nil } - return networkParams + return &cloudprotocol.ErrorInfo{ + AosCode: int(errorInfo.GetAosCode()), + ExitCode: int(errorInfo.GetExitCode()), + Message: errorInfo.GetMessage(), + } } -func NewInstanceIdentFromPB(ident *pb.InstanceIdent) aostypes.InstanceIdent { - return aostypes.InstanceIdent{ - ServiceID: ident.GetServiceId(), - SubjectID: ident.GetSubjectId(), - Instance: uint64(ident.GetInstance()), +// ErrorInfoToPB converts ErrorInfo from AOS type to protobuf. +func ErrorInfoToPB(errorInfo *cloudprotocol.ErrorInfo) *pbcommon.ErrorInfo { + if errorInfo == nil { + return nil + } + + return &pbcommon.ErrorInfo{ + AosCode: int32(errorInfo.AosCode), + ExitCode: int32(errorInfo.ExitCode), + Message: errorInfo.Message, } } -func NewNetworkParametersFromPB(params *pb.NetworkParameters) aostypes.NetworkParameters { +// NetworkParametersFromPB converts NetworkParameters from protobuf to AOS type. +func NewNetworkParametersFromPB(params *pbsm.NetworkParameters) aostypes.NetworkParameters { networkParams := aostypes.NetworkParameters{ IP: params.GetIp(), Subnet: params.GetSubnet(), @@ -102,3 +132,81 @@ func NewNetworkParametersFromPB(params *pb.NetworkParameters) aostypes.NetworkPa return networkParams } + +// NetworkParametersToPB converts NetworkParameters from AOS type to protobuf. +func NetworkParametersToPB(params aostypes.NetworkParameters) *pbsm.NetworkParameters { + networkParams := &pbsm.NetworkParameters{ + Ip: params.IP, + Subnet: params.Subnet, + VlanId: params.VlanID, + DnsServers: make([]string, len(params.DNSServers)), + Rules: make([]*pbsm.FirewallRule, len(params.FirewallRules)), + } + + copy(networkParams.GetDnsServers(), params.DNSServers) + + for i, rule := range params.FirewallRules { + networkParams.Rules[i] = &pbsm.FirewallRule{ + DstIp: rule.DstIP, + SrcIp: rule.SrcIP, + DstPort: rule.DstPort, + Proto: rule.Proto, + } + } + + return networkParams +} + +// NodeInfoFromPB converts NodeInfo from protobuf to Aos type. +func NewNodeInfoFromPB(pbNodeInfo *pbiam.NodeInfo) cloudprotocol.NodeInfo { + nodeInfo := cloudprotocol.NodeInfo{ + NodeID: pbNodeInfo.GetNodeId(), + NodeType: pbNodeInfo.GetNodeType(), + Name: pbNodeInfo.GetName(), + Status: pbNodeInfo.GetStatus(), + OSType: pbNodeInfo.GetOsType(), + MaxDMIPs: pbNodeInfo.GetMaxDmips(), + TotalRAM: pbNodeInfo.GetTotalRam(), + ErrorInfo: ErrorInfoFromPB(pbNodeInfo.GetError()), + } + + if pbNodeInfo.GetCpus() != nil { + nodeInfo.CPUs = make([]cloudprotocol.CPUInfo, 0, len(pbNodeInfo.GetCpus())) + + for _, cpu := range pbNodeInfo.GetCpus() { + nodeInfo.CPUs = append(nodeInfo.CPUs, cloudprotocol.CPUInfo{ + ModelName: cpu.GetModelName(), + NumCores: cpu.GetNumCores(), + NumThreads: cpu.GetNumThreads(), + Arch: cpu.GetArch(), + ArchFamily: cpu.GetArchFamily(), + MaxDMIPs: cpu.GetMaxDmips(), + }) + } + } + + if pbNodeInfo.GetAttrs() != nil { + nodeInfo.Attrs = make(map[string]interface{}) + + for _, attr := range pbNodeInfo.GetAttrs() { + nodeInfo.Attrs[attr.GetName()] = attr.GetValue() + } + } + + if pbNodeInfo.GetPartitions() != nil { + nodeInfo.Partitions = make([]cloudprotocol.PartitionInfo, 0, len(pbNodeInfo.GetPartitions())) + + for _, partition := range pbNodeInfo.GetPartitions() { + partitionInfo := cloudprotocol.PartitionInfo{ + Name: partition.GetName(), + Types: partition.GetTypes(), + TotalSize: partition.GetTotalSize(), + Path: partition.GetPath(), + } + + nodeInfo.Partitions = append(nodeInfo.Partitions, partitionInfo) + } + } + + return nodeInfo +} diff --git a/vendor/github.com/aosedge/aos_common/utils/testtools/crypto.go b/vendor/github.com/aosedge/aos_common/utils/testtools/crypto.go index 96a90829..92a9923c 100644 --- a/vendor/github.com/aosedge/aos_common/utils/testtools/crypto.go +++ b/vendor/github.com/aosedge/aos_common/utils/testtools/crypto.go @@ -40,7 +40,7 @@ import ( // DefaultCertificateTemplate default certificate template. var DefaultCertificateTemplate = x509.Certificate{ //nolint:gochecknoglobals SerialNumber: big.NewInt(1), - Version: 3, //nolint:gomnd + Version: 3, //nolint:mnd NotBefore: time.Now().Add(-10 * time.Second), NotAfter: time.Now().AddDate(10, 0, 0), KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | @@ -59,7 +59,7 @@ var DefaultCertificateTemplate = x509.Certificate{ //nolint:gochecknoglobals "*.aos-dev.test", }, BasicConstraintsValid: true, - IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1).To4(), net.IPv6loopback}, //nolint:gomnd + IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1).To4(), net.IPv6loopback}, //nolint:mnd } /*********************************************************************************************************************** @@ -107,7 +107,7 @@ func GenerateCert( func GenerateCertAndKey( template, parent *x509.Certificate, parentPrivateKey crypto.PrivateKey, ) (cert *x509.Certificate, privateKey crypto.PrivateKey, err error) { - key, err := rsa.GenerateKey(rand.Reader, 2048) //nolint:gomnd + key, err := rsa.GenerateKey(rand.Reader, 2048) //nolint:mnd if err != nil { return nil, nil, aoserrors.Wrap(err) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 728977d1..0417e195 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,15 +7,16 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240701123742-84e62a5773fc +# github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes github.com/aosedge/aos_common/api/cloudprotocol -github.com/aosedge/aos_common/api/communicationmanager/v2 -github.com/aosedge/aos_common/api/iamanager/v4 -github.com/aosedge/aos_common/api/servicemanager/v3 -github.com/aosedge/aos_common/api/updatemanager/v1 +github.com/aosedge/aos_common/api/common +github.com/aosedge/aos_common/api/communicationmanager +github.com/aosedge/aos_common/api/iamanager +github.com/aosedge/aos_common/api/servicemanager +github.com/aosedge/aos_common/api/updatemanager github.com/aosedge/aos_common/image github.com/aosedge/aos_common/journalalerts github.com/aosedge/aos_common/migration From b815fe569323e79e95a54291969ca9bcfa39f753 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 26 Jun 2024 12:09:38 +0300 Subject: [PATCH 002/146] [umcontroller] Rename UmState to UpdateState Signed-off-by: Mykola Kobets --- umcontroller/umcontroller.go | 34 +++--- umcontroller/umcontroller_internal_test.go | 78 ++++++------ umcontroller/umcontroller_test.go | 132 ++++++++++----------- umcontroller/umctrlserver.go | 6 +- umcontroller/umhandler.go | 36 +++--- 5 files changed, 143 insertions(+), 143 deletions(-) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 02244ffd..81e80368 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -100,7 +100,7 @@ type umCtrlInternalMsg struct { } type umStatus struct { - umState string + updateStatus string componsStatus []systemComponentStatus } @@ -167,7 +167,7 @@ const ( evUpdateRequest = "updateRequest" evContinue = "continue" evUpdatePrepared = "updatePrepared" - evUmStateUpdated = "umStateUpdated" + evUpdateStatusUpdated = "updateStatusUpdated" evSystemUpdated = "systemUpdated" evApplyComplete = "applyComplete" @@ -411,7 +411,7 @@ func (umCtrl *Controller) processInternalMessages() { umCtrl.handleCloseConnection(internalMsg.umID) case umStatusUpdate: - umCtrl.generateFSMEvent(evUmStateUpdated, internalMsg.umID, internalMsg.status) + umCtrl.generateFSMEvent(evUpdateStatusUpdated, internalMsg.umID, internalMsg.status) default: log.Error("Unsupported internal message ", internalMsg.requestType) @@ -733,22 +733,22 @@ func (umCtrl *Controller) createStateMachine() (string, []fsm.EventDesc, map[str {Name: evContinueApply, Src: []string{stateIdle}, Dst: stateStartApply}, {Name: evContinueRevert, Src: []string{stateIdle}, Dst: stateStartRevert}, // process prepare - {Name: evUmStateUpdated, Src: []string{statePrepareUpdate}, Dst: stateUpdateUmStatusOnPrepareUpdate}, + {Name: evUpdateStatusUpdated, Src: []string{statePrepareUpdate}, Dst: stateUpdateUmStatusOnPrepareUpdate}, {Name: evContinue, Src: []string{stateUpdateUmStatusOnPrepareUpdate}, Dst: statePrepareUpdate}, // process start update {Name: evUpdatePrepared, Src: []string{statePrepareUpdate}, Dst: stateStartUpdate}, - {Name: evUmStateUpdated, Src: []string{stateStartUpdate}, Dst: stateUpdateUmStatusOnStartUpdate}, + {Name: evUpdateStatusUpdated, Src: []string{stateStartUpdate}, Dst: stateUpdateUmStatusOnStartUpdate}, {Name: evContinue, Src: []string{stateUpdateUmStatusOnStartUpdate}, Dst: stateStartUpdate}, // process start apply {Name: evSystemUpdated, Src: []string{stateStartUpdate}, Dst: stateStartApply}, - {Name: evUmStateUpdated, Src: []string{stateStartApply}, Dst: stateUpdateUmStatusOnStartApply}, + {Name: evUpdateStatusUpdated, Src: []string{stateStartApply}, Dst: stateUpdateUmStatusOnStartApply}, {Name: evContinue, Src: []string{stateUpdateUmStatusOnStartApply}, Dst: stateStartApply}, {Name: evApplyComplete, Src: []string{stateStartApply}, Dst: stateIdle}, // process revert {Name: evUpdateFailed, Src: []string{statePrepareUpdate}, Dst: stateStartRevert}, {Name: evUpdateFailed, Src: []string{stateStartUpdate}, Dst: stateStartRevert}, {Name: evUpdateFailed, Src: []string{stateStartApply}, Dst: stateStartRevert}, - {Name: evUmStateUpdated, Src: []string{stateStartRevert}, Dst: stateUpdateUmStatusOnRevert}, + {Name: evUpdateStatusUpdated, Src: []string{stateStartRevert}, Dst: stateUpdateUmStatusOnRevert}, {Name: evContinue, Src: []string{stateUpdateUmStatusOnRevert}, Dst: stateStartRevert}, {Name: evSystemReverted, Src: []string{stateStartRevert}, Dst: stateIdle}, @@ -757,13 +757,13 @@ func (umCtrl *Controller) createStateMachine() (string, []fsm.EventDesc, map[str fsm.Callbacks{ enterPrefix + stateIdle: umCtrl.processIdleState, enterPrefix + statePrepareUpdate: umCtrl.processPrepareState, - enterPrefix + stateUpdateUmStatusOnPrepareUpdate: umCtrl.processUpdateUmState, + enterPrefix + stateUpdateUmStatusOnPrepareUpdate: umCtrl.processUpdateUpdateStatus, enterPrefix + stateStartUpdate: umCtrl.processStartUpdateState, - enterPrefix + stateUpdateUmStatusOnStartUpdate: umCtrl.processUpdateUmState, + enterPrefix + stateUpdateUmStatusOnStartUpdate: umCtrl.processUpdateUpdateStatus, enterPrefix + stateStartApply: umCtrl.processStartApplyState, - enterPrefix + stateUpdateUmStatusOnStartApply: umCtrl.processUpdateUmState, + enterPrefix + stateUpdateUmStatusOnStartApply: umCtrl.processUpdateUpdateStatus, enterPrefix + stateStartRevert: umCtrl.processStartRevertState, - enterPrefix + stateUpdateUmStatusOnRevert: umCtrl.processUpdateUmState, + enterPrefix + stateUpdateUmStatusOnRevert: umCtrl.processUpdateUpdateStatus, enterPrefix + stateFaultState: umCtrl.processFaultState, beforePrefix + "event": umCtrl.onEvent, @@ -842,9 +842,9 @@ func (umCtrl *Controller) onEvent(ctx context.Context, e *fsm.Event) { } func (umCtrl *Controller) processIdleState(ctx context.Context, e *fsm.Event) { - umState := umCtrl.getCurrentUpdateState() + updateStatus := umCtrl.getCurrentUpdateState() - switch umState { + switch updateStatus { case stateFaultState: go umCtrl.generateFSMEvent(evContinueRevert) return @@ -968,8 +968,8 @@ func (umCtrl *Controller) processStartApplyState(ctx context.Context, e *fsm.Eve go umCtrl.generateFSMEvent(evApplyComplete) } -func (umCtrl *Controller) processUpdateUmState(ctx context.Context, e *fsm.Event) { - log.Debug("processUpdateUmState") +func (umCtrl *Controller) processUpdateUpdateStatus(ctx context.Context, e *fsm.Event) { + log.Debug("processUpdateUpdateStatus") umID, ok := e.Args[0].(string) if !ok { @@ -985,8 +985,8 @@ func (umCtrl *Controller) processUpdateUmState(ctx context.Context, e *fsm.Event for i, v := range umCtrl.connections { if v.umID == umID { - umCtrl.connections[i].state = status.umState - log.Debugf("UMid = %s state= %s", umID, status.umState) + umCtrl.connections[i].state = status.updateStatus + log.Debugf("UMid = %s state= %s", umID, status.updateStatus) break } diff --git a/umcontroller/umcontroller_internal_test.go b/umcontroller/umcontroller_internal_test.go index 3568dbb9..b75be80e 100644 --- a/umcontroller/umcontroller_internal_test.go +++ b/umcontroller/umcontroller_internal_test.go @@ -89,7 +89,7 @@ func TestNormalUpdate(t *testing.T) { stream := normalUpdateStream{test: t, continueCh: make(chan bool)} - handler, stopCh, err := newUmHandler("testUM", &stream, eventChannel, pb.UmState_IDLE) + handler, stopCh, err := newUmHandler("testUM", &stream, eventChannel, pb.UpdateState_IDLE) if err != nil { t.Errorf("erro create handler %s", err) } @@ -111,9 +111,9 @@ func TestNormalUpdate(t *testing.T) { break } - if internalEvent.status.umState != pb.UmState_PREPARED.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_PREPARED.String()) + if internalEvent.status.updateStatus != pb.UpdateState_PREPARED.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_PREPARED.String()) break } @@ -129,9 +129,9 @@ func TestNormalUpdate(t *testing.T) { break } - if internalEvent.status.umState != pb.UmState_UPDATED.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_UPDATED.String()) + if internalEvent.status.updateStatus != pb.UpdateState_UPDATED.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_UPDATED.String()) break } @@ -147,9 +147,9 @@ func TestNormalUpdate(t *testing.T) { break } - if internalEvent.status.umState != pb.UmState_IDLE.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_IDLE.String()) + if internalEvent.status.updateStatus != pb.UpdateState_IDLE.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_IDLE.String()) break } @@ -171,7 +171,7 @@ func TestNormalUpdateWithReboot(t *testing.T) { stream := normalUpdateStream{test: t, continueCh: make(chan bool)} - handler, stopCh, err := newUmHandler("testUM2", &stream, eventChannel, pb.UmState_IDLE) + handler, stopCh, err := newUmHandler("testUM2", &stream, eventChannel, pb.UpdateState_IDLE) if err != nil { t.Errorf("error create handler %s", err) } @@ -188,9 +188,9 @@ func TestNormalUpdateWithReboot(t *testing.T) { case internalEvent := <-eventChannel: switch stream.step { case StepPrepare: - if internalEvent.status.umState != pb.UmState_PREPARED.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_PREPARED.String()) + if internalEvent.status.updateStatus != pb.UpdateState_PREPARED.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_PREPARED.String()) break } @@ -201,12 +201,12 @@ func TestNormalUpdateWithReboot(t *testing.T) { } default: - log.Warn("Receive ", internalEvent.status.umState) + log.Warn("Receive ", internalEvent.status.updateStatus) } case <-stopCh: if stream.step == StepRebootOnUpdate { - handler, stopCh, err = newUmHandler("testUM2", &stream, eventChannel, pb.UmState_UPDATED) + handler, stopCh, err = newUmHandler("testUM2", &stream, eventChannel, pb.UpdateState_UPDATED) if err != nil { t.Errorf("Can't create UM handler: %s", err) } @@ -221,7 +221,7 @@ func TestNormalUpdateWithReboot(t *testing.T) { } if stream.step == StepRebootOnApply { - handler, stopCh, err = newUmHandler("testUM2", &stream, eventChannel, pb.UmState_IDLE) + handler, stopCh, err = newUmHandler("testUM2", &stream, eventChannel, pb.UpdateState_IDLE) if err != nil { t.Errorf("Can't create UM handler: %s", err) } @@ -246,7 +246,7 @@ func TestRevert(t *testing.T) { stream := failureUpdateStream{test: t, continueCh: make(chan bool)} - handler, stopCh, err := newUmHandler("testUM3", &stream, eventChannel, pb.UmState_IDLE) + handler, stopCh, err := newUmHandler("testUM3", &stream, eventChannel, pb.UpdateState_IDLE) if err != nil { t.Errorf("error create handler %s", err) } @@ -263,9 +263,9 @@ func TestRevert(t *testing.T) { case internalEvent := <-eventChannel: switch stream.step { case StepPrepare: - if internalEvent.status.umState != pb.UmState_PREPARED.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_PREPARED.String()) + if internalEvent.status.updateStatus != pb.UpdateState_PREPARED.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_PREPARED.String()) break } @@ -276,9 +276,9 @@ func TestRevert(t *testing.T) { } case StepUpdate: - if internalEvent.status.umState != pb.UmState_FAILED.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_FAILED.String()) + if internalEvent.status.updateStatus != pb.UpdateState_FAILED.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_FAILED.String()) break } @@ -289,9 +289,9 @@ func TestRevert(t *testing.T) { } case StepRevertUpdate: - if internalEvent.status.umState != pb.UmState_IDLE.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_IDLE.String()) + if internalEvent.status.updateStatus != pb.UpdateState_IDLE.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_IDLE.String()) break } @@ -313,7 +313,7 @@ func TestRevertWithReboot(t *testing.T) { stream := failureUpdateStream{test: t, continueCh: make(chan bool)} - handler, stopCh, err := newUmHandler("testUM4", &stream, eventChannel, pb.UmState_IDLE) + handler, stopCh, err := newUmHandler("testUM4", &stream, eventChannel, pb.UpdateState_IDLE) if err != nil { t.Errorf("error create handler %s", err) } @@ -330,9 +330,9 @@ func TestRevertWithReboot(t *testing.T) { case internalEvent := <-eventChannel: switch stream.step { case StepPrepare: - if internalEvent.status.umState != pb.UmState_PREPARED.String() { - t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.umState, - pb.UmState_PREPARED.String()) + if internalEvent.status.updateStatus != pb.UpdateState_PREPARED.String() { + t.Errorf("Unexpected UM update State %s != %s", internalEvent.status.updateStatus, + pb.UpdateState_PREPARED.String()) break } @@ -343,12 +343,12 @@ func TestRevertWithReboot(t *testing.T) { } default: - log.Warn("Receive ", internalEvent.status.umState) + log.Warn("Receive ", internalEvent.status.updateStatus) } case <-stopCh: if stream.step == StepRebootOnUpdate { - handler, stopCh, err = newUmHandler("testUM4", &stream, eventChannel, pb.UmState_FAILED) + handler, stopCh, err = newUmHandler("testUM4", &stream, eventChannel, pb.UpdateState_FAILED) if err != nil { t.Errorf("Can't create um handler: %s", err) } @@ -363,7 +363,7 @@ func TestRevertWithReboot(t *testing.T) { } if stream.step == StepRebootOnRevert { - handler, stopCh, err = newUmHandler("testUM2", &stream, eventChannel, pb.UmState_IDLE) + handler, stopCh, err = newUmHandler("testUM2", &stream, eventChannel, pb.UpdateState_IDLE) if err != nil { t.Errorf("Can't create um handler: %s", err) } @@ -422,7 +422,7 @@ func (stream *normalUpdateStream) Recv() (*pb.UpdateStatus, error) { switch stream.step { case StepPrepare: - messageToSend = &pb.UpdateStatus{UmState: pb.UmState_PREPARED} + messageToSend = &pb.UpdateStatus{UpdateState: pb.UpdateState_PREPARED} case StepRebootOnUpdate: return nil, io.EOF @@ -431,10 +431,10 @@ func (stream *normalUpdateStream) Recv() (*pb.UpdateStatus, error) { return nil, io.EOF case StepUpdate: - messageToSend = &pb.UpdateStatus{UmState: pb.UmState_UPDATED} + messageToSend = &pb.UpdateStatus{UpdateState: pb.UpdateState_UPDATED} case StepApplyUpdate: - messageToSend = &pb.UpdateStatus{UmState: pb.UmState_IDLE} + messageToSend = &pb.UpdateStatus{UpdateState: pb.UpdateState_IDLE} case StepFinish: return nil, io.EOF @@ -478,13 +478,13 @@ func (stream *failureUpdateStream) Recv() (*pb.UpdateStatus, error) { switch stream.step { case StepPrepare: - messageToSend = &pb.UpdateStatus{UmState: pb.UmState_PREPARED} + messageToSend = &pb.UpdateStatus{UpdateState: pb.UpdateState_PREPARED} case StepRebootOnUpdate: return nil, io.EOF case StepUpdate: - messageToSend = &pb.UpdateStatus{UmState: pb.UmState_FAILED} + messageToSend = &pb.UpdateStatus{UpdateState: pb.UpdateState_FAILED} case StepRebootOnRevert: return nil, io.EOF diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 55a35282..5ed0a35f 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -160,7 +160,7 @@ func TestConnection(t *testing.T) { {Id: "component2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - streamUM1, connUM1, err := createClientConnection("umID1", pb.UmState_IDLE, components) + streamUM1, connUM1, err := createClientConnection("umID1", pb.UpdateState_IDLE, components) if err != nil { t.Errorf("Error connect %s", err) } @@ -170,12 +170,12 @@ func TestConnection(t *testing.T) { {Id: "component4", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - streamUM2, connUM2, err := createClientConnection("umID2", pb.UmState_IDLE, components2) + streamUM2, connUM2, err := createClientConnection("umID2", pb.UpdateState_IDLE, components2) if err != nil { t.Errorf("Error connect %s", err) } - streamUM1Copy, connUM1Copy, err := createClientConnection("umID1", pb.UmState_IDLE, components) + streamUM1Copy, connUM1Copy, err := createClientConnection("umID1", pb.UpdateState_IDLE, components) if err != nil { t.Errorf("Error connect %s", err) } @@ -211,7 +211,7 @@ func TestConnection(t *testing.T) { **********************************************************************************************************************/ func createClientConnection( - clientID string, state pb.UmState, components []*pb.SystemComponent, + clientID string, state pb.UpdateState, components []*pb.SystemComponent, ) (stream pb.UMService_RegisterUMClient, conn *grpc.ClientConn, err error) { var opts []grpc.DialOption opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -230,7 +230,7 @@ func createClientConnection( return stream, nil, aoserrors.Wrap(err) } - umMsg := &pb.UpdateStatus{UmId: clientID, UmState: state, Components: components} + umMsg := &pb.UpdateStatus{UmId: clientID, UpdateState: state, Components: components} if err = stream.Send(umMsg); err != nil { log.Errorf("Fail send update status message %s", err) @@ -266,7 +266,7 @@ func TestFullUpdate(t *testing.T) { {Id: "um1C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um1 := newTestUM(t, "testUM1", pb.UmState_IDLE, "init", um1Components) + um1 := newTestUM(t, "testUM1", pb.UpdateState_IDLE, "init", um1Components) go um1.processMessages() um2Components := []*pb.SystemComponent{ @@ -274,7 +274,7 @@ func TestFullUpdate(t *testing.T) { {Id: "um2C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um2 := newTestUM(t, "testUM2", pb.UmState_IDLE, "init", um2Components) + um2 := newTestUM(t, "testUM2", pb.UpdateState_IDLE, "init", um2Components) go um2.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -316,7 +316,7 @@ func TestFullUpdate(t *testing.T) { um1.step = prepareStep um1.continueChan <- true <-um1.notifyTestChan // receive prepare - um1.sendState(pb.UmState_PREPARED) + um1.sendState(pb.UpdateState_PREPARED) um2Components = append(um2Components, &pb.SystemComponent{Id: "um2C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) @@ -327,17 +327,17 @@ func TestFullUpdate(t *testing.T) { um2.step = prepareStep um2.continueChan <- true <-um2.notifyTestChan - um2.sendState(pb.UmState_PREPARED) + um2.sendState(pb.UpdateState_PREPARED) um1.step = updateStep um1.continueChan <- true <-um1.notifyTestChan // um1 updated - um1.sendState(pb.UmState_UPDATED) + um1.sendState(pb.UpdateState_UPDATED) um2.step = updateStep um2.continueChan <- true <-um2.notifyTestChan // um2 updated - um2.sendState(pb.UmState_UPDATED) + um2.sendState(pb.UpdateState_UPDATED) um1Components = []*pb.SystemComponent{ {Id: "um1C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, @@ -348,7 +348,7 @@ func TestFullUpdate(t *testing.T) { um1.step = applyStep um1.continueChan <- true <-um1.notifyTestChan // um1 apply - um1.sendState(pb.UmState_IDLE) + um1.sendState(pb.UpdateState_IDLE) um2Components = []*pb.SystemComponent{ {Id: "um2C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, @@ -359,7 +359,7 @@ func TestFullUpdate(t *testing.T) { um2.step = applyStep um2.continueChan <- true <-um2.notifyTestChan // um1 apply - um2.sendState(pb.UmState_IDLE) + um2.sendState(pb.UpdateState_IDLE) time.Sleep(1 * time.Second) @@ -426,7 +426,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { {Id: "um3C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um3 := newTestUM(t, "testUM3", pb.UmState_IDLE, "init", um3Components) + um3 := newTestUM(t, "testUM3", pb.UpdateState_IDLE, "init", um3Components) go um3.processMessages() um4Components := []*pb.SystemComponent{ @@ -434,7 +434,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { {Id: "um4C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um4 := newTestUM(t, "testUM4", pb.UmState_IDLE, "init", um4Components) + um4 := newTestUM(t, "testUM4", pb.UpdateState_IDLE, "init", um4Components) go um4.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -477,7 +477,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { um3.step = prepareStep um3.continueChan <- true <-um3.notifyTestChan // receive prepare - um3.sendState(pb.UmState_PREPARED) + um3.sendState(pb.UpdateState_PREPARED) // prepare UM4 um4Components = append(um4Components, @@ -489,7 +489,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { um4.step = prepareStep um4.continueChan <- true <-um4.notifyTestChan - um4.sendState(pb.UmState_PREPARED) + um4.sendState(pb.UpdateState_PREPARED) um3.step = updateStep um3.continueChan <- true @@ -500,7 +500,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { um3.closeConnection() <-um3.notifyTestChan - um3 = newTestUM(t, "testUM3", pb.UmState_UPDATED, applyStep, um3Components) + um3 = newTestUM(t, "testUM3", pb.UpdateState_UPDATED, applyStep, um3Components) go um3.processMessages() um4.step = updateStep @@ -512,7 +512,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { <-um4.notifyTestChan - um4 = newTestUM(t, "testUM4", pb.UmState_UPDATED, applyStep, um4Components) + um4 = newTestUM(t, "testUM4", pb.UpdateState_UPDATED, applyStep, um4Components) go um4.processMessages() um3.step = applyStep @@ -529,7 +529,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { {Id: "um3C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, } - um3 = newTestUM(t, "testUM3", pb.UmState_IDLE, "init", um3Components) + um3 = newTestUM(t, "testUM3", pb.UpdateState_IDLE, "init", um3Components) go um3.processMessages() // um4 reboot @@ -542,7 +542,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { {Id: "um4C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, } - um4 = newTestUM(t, "testUM4", pb.UmState_IDLE, "init", um4Components) + um4 = newTestUM(t, "testUM4", pb.UpdateState_IDLE, "init", um4Components) go um4.processMessages() um3.step = finishStep @@ -603,7 +603,7 @@ func TestFullUpdateWithReboot(t *testing.T) { {Id: "um5C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um5 := newTestUM(t, "testUM5", pb.UmState_IDLE, "init", um5Components) + um5 := newTestUM(t, "testUM5", pb.UpdateState_IDLE, "init", um5Components) go um5.processMessages() um6Components := []*pb.SystemComponent{ @@ -611,7 +611,7 @@ func TestFullUpdateWithReboot(t *testing.T) { {Id: "um6C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um6 := newTestUM(t, "testUM6", pb.UmState_IDLE, "init", um6Components) + um6 := newTestUM(t, "testUM6", pb.UpdateState_IDLE, "init", um6Components) go um6.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -654,7 +654,7 @@ func TestFullUpdateWithReboot(t *testing.T) { um5.step = prepareStep um5.continueChan <- true <-um5.notifyTestChan // receive prepare - um5.sendState(pb.UmState_PREPARED) + um5.sendState(pb.UpdateState_PREPARED) // prepare UM6 um6Components = append(um6Components, @@ -666,7 +666,7 @@ func TestFullUpdateWithReboot(t *testing.T) { um6.step = prepareStep um6.continueChan <- true <-um6.notifyTestChan - um6.sendState(pb.UmState_PREPARED) + um6.sendState(pb.UpdateState_PREPARED) um5.step = updateStep um5.continueChan <- true @@ -690,10 +690,10 @@ func TestFullUpdateWithReboot(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um5 = newTestUM(t, "testUM5", pb.UmState_UPDATED, applyStep, um5Components) + um5 = newTestUM(t, "testUM5", pb.UpdateState_UPDATED, applyStep, um5Components) go um5.processMessages() - um6 = newTestUM(t, "testUM6", pb.UmState_PREPARED, updateStep, um6Components) + um6 = newTestUM(t, "testUM6", pb.UpdateState_PREPARED, updateStep, um6Components) go um6.processMessages() um6.continueChan <- true @@ -702,7 +702,7 @@ func TestFullUpdateWithReboot(t *testing.T) { um6.step = rebootStep um6.closeConnection() - um6 = newTestUM(t, "testUM6", pb.UmState_UPDATED, applyStep, um6Components) + um6 = newTestUM(t, "testUM6", pb.UpdateState_UPDATED, applyStep, um6Components) go um6.processMessages() // um5 apply and full reboot @@ -731,10 +731,10 @@ func TestFullUpdateWithReboot(t *testing.T) { {Id: "um5C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, } - um5 = newTestUM(t, "testUM5", pb.UmState_IDLE, "init", um5Components) + um5 = newTestUM(t, "testUM5", pb.UpdateState_IDLE, "init", um5Components) go um5.processMessages() - um6 = newTestUM(t, "testUM6", pb.UmState_UPDATED, applyStep, um6Components) + um6 = newTestUM(t, "testUM6", pb.UpdateState_UPDATED, applyStep, um6Components) go um6.processMessages() um6.step = rebootStep @@ -746,7 +746,7 @@ func TestFullUpdateWithReboot(t *testing.T) { {Id: "um6C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, } - um6 = newTestUM(t, "testUM6", pb.UmState_IDLE, "init", um6Components) + um6 = newTestUM(t, "testUM6", pb.UpdateState_IDLE, "init", um6Components) go um6.processMessages() um5.step = finishStep @@ -805,7 +805,7 @@ func TestRevertOnPrepare(t *testing.T) { {Id: "um7C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um7 := newTestUM(t, "testUM7", pb.UmState_IDLE, "init", um7Components) + um7 := newTestUM(t, "testUM7", pb.UpdateState_IDLE, "init", um7Components) go um7.processMessages() um8Components := []*pb.SystemComponent{ @@ -813,7 +813,7 @@ func TestRevertOnPrepare(t *testing.T) { {Id: "um8C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um8 := newTestUM(t, "testUM8", pb.UmState_IDLE, "init", um8Components) + um8 := newTestUM(t, "testUM8", pb.UpdateState_IDLE, "init", um8Components) go um8.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -855,7 +855,7 @@ func TestRevertOnPrepare(t *testing.T) { um7.step = prepareStep um7.continueChan <- true <-um7.notifyTestChan // receive prepare - um7.sendState(pb.UmState_PREPARED) + um7.sendState(pb.UpdateState_PREPARED) um8Components = append(um8Components, &pb.SystemComponent{Id: "um8C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) @@ -866,17 +866,17 @@ func TestRevertOnPrepare(t *testing.T) { um8.step = prepareStep um8.continueChan <- true <-um8.notifyTestChan - um8.sendState(pb.UmState_FAILED) + um8.sendState(pb.UpdateState_FAILED) um7.step = revertStep um7.continueChan <- true <-um7.notifyTestChan // um7 revert received - um7.sendState(pb.UmState_IDLE) + um7.sendState(pb.UpdateState_IDLE) um8.step = revertStep um8.continueChan <- true <-um8.notifyTestChan // um8 revert received - um8.sendState(pb.UmState_IDLE) + um8.sendState(pb.UpdateState_IDLE) um7.step = finishStep um8.step = finishStep @@ -938,7 +938,7 @@ func TestRevertOnUpdate(t *testing.T) { {Id: "um9C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um9 := newTestUM(t, "testUM9", pb.UmState_IDLE, "init", um9Components) + um9 := newTestUM(t, "testUM9", pb.UpdateState_IDLE, "init", um9Components) go um9.processMessages() um10Components := []*pb.SystemComponent{ @@ -946,7 +946,7 @@ func TestRevertOnUpdate(t *testing.T) { {Id: "um10C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um10 := newTestUM(t, "testUM10", pb.UmState_IDLE, "init", um10Components) + um10 := newTestUM(t, "testUM10", pb.UpdateState_IDLE, "init", um10Components) go um10.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -988,7 +988,7 @@ func TestRevertOnUpdate(t *testing.T) { um9.step = prepareStep um9.continueChan <- true <-um9.notifyTestChan // receive prepare - um9.sendState(pb.UmState_PREPARED) + um9.sendState(pb.UpdateState_PREPARED) um10Components = append(um10Components, &pb.SystemComponent{Id: "um10C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) @@ -999,12 +999,12 @@ func TestRevertOnUpdate(t *testing.T) { um10.step = prepareStep um10.continueChan <- true <-um10.notifyTestChan - um10.sendState(pb.UmState_PREPARED) + um10.sendState(pb.UpdateState_PREPARED) um9.step = updateStep um9.continueChan <- true <-um9.notifyTestChan // um9 updated - um9.sendState(pb.UmState_UPDATED) + um9.sendState(pb.UpdateState_UPDATED) um10Components = []*pb.SystemComponent{ {Id: "um10C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, @@ -1017,7 +1017,7 @@ func TestRevertOnUpdate(t *testing.T) { um10.step = updateStep um10.continueChan <- true <-um10.notifyTestChan // um10 updated - um10.sendState(pb.UmState_FAILED) + um10.sendState(pb.UpdateState_FAILED) um9Components = []*pb.SystemComponent{ {Id: "um9C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, @@ -1028,12 +1028,12 @@ func TestRevertOnUpdate(t *testing.T) { um9.step = revertStep um9.continueChan <- true <-um9.notifyTestChan // um9 revert received - um9.sendState(pb.UmState_IDLE) + um9.sendState(pb.UpdateState_IDLE) um10.step = revertStep um10.continueChan <- true <-um10.notifyTestChan // um10 revert received - um10.sendState(pb.UmState_IDLE) + um10.sendState(pb.UpdateState_IDLE) um9.step = finishStep um10.step = finishStep @@ -1095,7 +1095,7 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { {Id: "um11C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um11 := newTestUM(t, "testUM11", pb.UmState_IDLE, "init", um11Components) + um11 := newTestUM(t, "testUM11", pb.UpdateState_IDLE, "init", um11Components) go um11.processMessages() um12Components := []*pb.SystemComponent{ @@ -1103,7 +1103,7 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { {Id: "um12C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um12 := newTestUM(t, "testUM12", pb.UmState_IDLE, "init", um12Components) + um12 := newTestUM(t, "testUM12", pb.UpdateState_IDLE, "init", um12Components) go um12.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -1145,7 +1145,7 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um11.step = prepareStep um11.continueChan <- true <-um11.notifyTestChan // receive prepare - um11.sendState(pb.UmState_PREPARED) + um11.sendState(pb.UpdateState_PREPARED) um12Components = append(um12Components, &pb.SystemComponent{Id: "um12C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) @@ -1156,12 +1156,12 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um12.step = prepareStep um12.continueChan <- true <-um12.notifyTestChan - um12.sendState(pb.UmState_PREPARED) + um12.sendState(pb.UpdateState_PREPARED) um11.step = updateStep um11.continueChan <- true <-um11.notifyTestChan // um11 updated - um11.sendState(pb.UmState_UPDATED) + um11.sendState(pb.UpdateState_UPDATED) um12Components = []*pb.SystemComponent{ {Id: "um12C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, @@ -1178,7 +1178,7 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um12.closeConnection() <-um12.notifyTestChan - um12 = newTestUM(t, "testUM12", pb.UmState_FAILED, revertStep, um12Components) + um12 = newTestUM(t, "testUM12", pb.UpdateState_FAILED, revertStep, um12Components) go um12.processMessages() um11Components = []*pb.SystemComponent{ @@ -1190,12 +1190,12 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um11.step = revertStep um11.continueChan <- true <-um11.notifyTestChan // um11 revert received - um11.sendState(pb.UmState_IDLE) + um11.sendState(pb.UpdateState_IDLE) um12.step = revertStep um12.continueChan <- true <-um12.notifyTestChan // um12 revert received - um12.sendState(pb.UmState_IDLE) + um12.sendState(pb.UpdateState_IDLE) um11.step = finishStep um12.step = finishStep @@ -1257,7 +1257,7 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { {Id: "um13C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um13 := newTestUM(t, "testUM13", pb.UmState_IDLE, "init", um13Components) + um13 := newTestUM(t, "testUM13", pb.UpdateState_IDLE, "init", um13Components) go um13.processMessages() um14Components := []*pb.SystemComponent{ @@ -1265,7 +1265,7 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { {Id: "um14C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, } - um14 := newTestUM(t, "testUM14", pb.UmState_IDLE, "init", um14Components) + um14 := newTestUM(t, "testUM14", pb.UpdateState_IDLE, "init", um14Components) go um14.processMessages() componentDir, err := os.MkdirTemp("", "aosComponent_") @@ -1307,7 +1307,7 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um13.step = prepareStep um13.continueChan <- true <-um13.notifyTestChan // receive prepare - um13.sendState(pb.UmState_PREPARED) + um13.sendState(pb.UpdateState_PREPARED) um14Components = append(um14Components, &pb.SystemComponent{Id: "um14C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) @@ -1318,12 +1318,12 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um14.step = prepareStep um14.continueChan <- true <-um14.notifyTestChan - um14.sendState(pb.UmState_PREPARED) + um14.sendState(pb.UpdateState_PREPARED) um13.step = updateStep um13.continueChan <- true <-um13.notifyTestChan // um13 updated - um13.sendState(pb.UmState_UPDATED) + um13.sendState(pb.UpdateState_UPDATED) um14Components = []*pb.SystemComponent{ {Id: "um14C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, @@ -1355,10 +1355,10 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um13 = newTestUM(t, "testUM13", pb.UmState_UPDATED, revertStep, um13Components) + um13 = newTestUM(t, "testUM13", pb.UpdateState_UPDATED, revertStep, um13Components) go um13.processMessages() - um14 = newTestUM(t, "testUM14", pb.UmState_FAILED, revertStep, um14Components) + um14 = newTestUM(t, "testUM14", pb.UpdateState_FAILED, revertStep, um14Components) go um14.processMessages() um13Components = []*pb.SystemComponent{ @@ -1370,12 +1370,12 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um13.step = revertStep um13.continueChan <- true <-um13.notifyTestChan // um13 revert received - um13.sendState(pb.UmState_IDLE) + um13.sendState(pb.UpdateState_IDLE) um14.step = revertStep um14.continueChan <- true <-um14.notifyTestChan // um14 revert received - um14.sendState(pb.UmState_IDLE) + um14.sendState(pb.UpdateState_IDLE) um13.step = finishStep um14.step = finishStep @@ -1504,12 +1504,12 @@ func (context *testCryptoContext) DecryptAndValidate( * Private **********************************************************************************************************************/ -func newTestUM(t *testing.T, id string, umState pb.UmState, testState string, components []*pb.SystemComponent) ( +func newTestUM(t *testing.T, id string, updateStatus pb.UpdateState, testState string, components []*pb.SystemComponent) ( umTest *testUmConnection, ) { t.Helper() - stream, conn, err := createClientConnection(id, umState, components) + stream, conn, err := createClientConnection(id, updateStatus, components) if err != nil { t.Errorf("Error connect %s", err) return umTest @@ -1533,8 +1533,8 @@ func (um *testUmConnection) setComponents(components []*pb.SystemComponent) { um.components = components } -func (um *testUmConnection) sendState(state pb.UmState) { - umMsg := &pb.UpdateStatus{UmId: um.umID, UmState: state, Components: um.components} +func (um *testUmConnection) sendState(state pb.UpdateState) { + umMsg := &pb.UpdateStatus{UmId: um.umID, UpdateState: state, Components: um.components} if err := um.stream.Send(umMsg); err != nil { um.test.Errorf("Fail send update status message %s", err) diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index 004fd769..5c30a72a 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -126,9 +126,9 @@ func (server *umCtrlServer) RegisterUM(stream pb.UMService_RegisterUMServer) (er return aoserrors.Wrap(err) } - log.Debugf("Register UM id %s status %s", statusMsg.GetUmId(), statusMsg.GetUmState().String()) + log.Debugf("Register UM id %s status %s", statusMsg.GetUmId(), statusMsg.GetUpdateState().String()) - handler, ch, err := newUmHandler(statusMsg.GetUmId(), stream, server.controllerCh, statusMsg.GetUmState()) + handler, ch, err := newUmHandler(statusMsg.GetUmId(), stream, server.controllerCh, statusMsg.GetUpdateState()) if err != nil { return aoserrors.Wrap(err) } @@ -155,7 +155,7 @@ func (server *umCtrlServer) RegisterUM(stream pb.UMService_RegisterUMServer) (er } func getUmStatusFromUmMessage(msg *pb.UpdateStatus) (status umStatus) { - status.umState = msg.GetUmState().String() + status.updateStatus = msg.GetUpdateState().String() for _, component := range msg.GetComponents() { if component.GetId() == "" { diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index 4d968202..14547884 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -34,12 +34,12 @@ import ( **********************************************************************************************************************/ type umHandler struct { - umID string - stream pb.UMService_RegisterUMServer - messageChannel chan umCtrlInternalMsg - closeChannel chan bool - FSM *fsm.FSM - initialUmState string + umID string + stream pb.UMService_RegisterUMServer + messageChannel chan umCtrlInternalMsg + closeChannel chan bool + FSM *fsm.FSM + initialUpdateStatus string } type prepareRequest struct { @@ -78,22 +78,22 @@ const ( // NewUmHandler create update manager connection handler. func newUmHandler(id string, umStream pb.UMService_RegisterUMServer, - messageChannel chan umCtrlInternalMsg, state pb.UmState) (handler *umHandler, closeChannel chan bool, err error, + messageChannel chan umCtrlInternalMsg, state pb.UpdateState) (handler *umHandler, closeChannel chan bool, err error, ) { handler = &umHandler{umID: id, stream: umStream, messageChannel: messageChannel} handler.closeChannel = make(chan bool) - handler.initialUmState = state.String() + handler.initialUpdateStatus = state.String() initFsmState := hStateIdle switch state { - case pb.UmState_IDLE: + case pb.UpdateState_IDLE: initFsmState = hStateIdle - case pb.UmState_PREPARED: + case pb.UpdateState_PREPARED: initFsmState = hStateWaitForStartUpdate - case pb.UmState_UPDATED: + case pb.UpdateState_UPDATED: initFsmState = hStateWaitForApply - case pb.UmState_FAILED: + case pb.UpdateState_FAILED: log.Error("UM in failure state") initFsmState = hStateWaitForRevert @@ -147,7 +147,7 @@ func (handler *umHandler) Close() { } func (handler *umHandler) GetInitialState() (state string) { - return handler.initialUmState + return handler.initialUpdateStatus } // Close close connection. @@ -197,15 +197,15 @@ func (handler *umHandler) receiveData() { var evt string - state := statusMsg.GetUmState() + state := statusMsg.GetUpdateState() switch state { - case pb.UmState_IDLE: + case pb.UpdateState_IDLE: evt = eventIdleState - case pb.UmState_PREPARED: + case pb.UpdateState_PREPARED: evt = eventPrepareSuccess - case pb.UmState_UPDATED: + case pb.UpdateState_UPDATED: evt = eventUpdateSuccess - case pb.UmState_FAILED: + case pb.UpdateState_FAILED: log.Error("Update failure status: ", statusMsg.GetError()) evt = eventUpdateError From 6622bdbf3181b4a7cd677a100a9e89d8d02d72c1 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 26 Jun 2024 12:14:37 +0300 Subject: [PATCH 003/146] [umcontroller] Rename UmId to NodeId Signed-off-by: Mykola Kobets --- umcontroller/umcontroller_test.go | 4 ++-- umcontroller/umctrlserver.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 5ed0a35f..4b62f278 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -230,7 +230,7 @@ func createClientConnection( return stream, nil, aoserrors.Wrap(err) } - umMsg := &pb.UpdateStatus{UmId: clientID, UpdateState: state, Components: components} + umMsg := &pb.UpdateStatus{NodeId: clientID, UpdateState: state, Components: components} if err = stream.Send(umMsg); err != nil { log.Errorf("Fail send update status message %s", err) @@ -1534,7 +1534,7 @@ func (um *testUmConnection) setComponents(components []*pb.SystemComponent) { } func (um *testUmConnection) sendState(state pb.UpdateState) { - umMsg := &pb.UpdateStatus{UmId: um.umID, UpdateState: state, Components: um.components} + umMsg := &pb.UpdateStatus{NodeId: um.umID, UpdateState: state, Components: um.components} if err := um.stream.Send(umMsg); err != nil { um.test.Errorf("Fail send update status message %s", err) diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index 5c30a72a..e11090b9 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -126,15 +126,15 @@ func (server *umCtrlServer) RegisterUM(stream pb.UMService_RegisterUMServer) (er return aoserrors.Wrap(err) } - log.Debugf("Register UM id %s status %s", statusMsg.GetUmId(), statusMsg.GetUpdateState().String()) + log.Debugf("Register UM id %s status %s", statusMsg.GetNodeId(), statusMsg.GetUpdateState().String()) - handler, ch, err := newUmHandler(statusMsg.GetUmId(), stream, server.controllerCh, statusMsg.GetUpdateState()) + handler, ch, err := newUmHandler(statusMsg.GetNodeId(), stream, server.controllerCh, statusMsg.GetUpdateState()) if err != nil { return aoserrors.Wrap(err) } openConnectionMsg := umCtrlInternalMsg{ - umID: statusMsg.GetUmId(), + umID: statusMsg.GetNodeId(), handler: handler, requestType: openConnection, status: getUmStatusFromUmMessage(statusMsg), @@ -146,7 +146,7 @@ func (server *umCtrlServer) RegisterUM(stream pb.UMService_RegisterUMServer) (er <-ch closeConnectionMsg := umCtrlInternalMsg{ - umID: statusMsg.GetUmId(), + umID: statusMsg.GetNodeId(), requestType: closeConnection, } server.controllerCh <- closeConnectionMsg From 045018338a8f28a5948bb398a18b2ea356f660ee Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 26 Jun 2024 12:23:03 +0300 Subject: [PATCH 004/146] [all] Update ComponentInfo Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 8 +- amqphandler/amqphandler_test.go | 2 +- cmserver/cmserver.go | 4 +- umcontroller/umcontroller.go | 53 ++- umcontroller/umcontroller_test.go | 138 ++++--- umcontroller/umctrlserver.go | 11 +- umcontroller/umhandler.go | 14 +- unitstatushandler/firmwaremanager.go | 53 ++- .../unitstatushandler_internal_test.go | 366 +++++++++--------- unitstatushandler/unitstatushandler_test.go | 6 +- 10 files changed, 333 insertions(+), 322 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index ba8c9389..e0573798 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -660,11 +660,9 @@ func (handler *AmqpHandler) decodeData(data []byte, result interface{}) error { for _, component := range desiredStatus.Components { log.WithFields(log.Fields{ - "id": component.ID, - "annotations": string(component.Annotations), - "aosVersion": component.AosVersion, - "vendorVersion": component.VendorVersion, - "description": component.Description, + "id": component.ComponentID, + "annotations": string(component.Annotations), + "version": component.Version, }).Debug("Component") } diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index d0d0d649..4f59863c 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -313,7 +313,7 @@ func TestReceiveMessages(t *testing.T) { expectedData: &cloudprotocol.DesiredStatus{ UnitConfig: json.RawMessage([]byte("\"config\"")), Components: []cloudprotocol.ComponentInfo{ - {VersionInfo: aostypes.VersionInfo{AosVersion: 1}, ID: "rootfs"}, + {Version: "1.0.0", ComponentID: "rootfs"}, }, Layers: []cloudprotocol.LayerInfo{ {VersionInfo: aostypes.VersionInfo{AosVersion: 1}, ID: "l1", Digest: "digest"}, diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index 8ec1d913..7d689311 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -360,8 +360,8 @@ func (updateStatus *UpdateFOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateFO for _, component := range updateStatus.Components { pbStatus.Components = append(pbStatus.GetComponents(), &pb.ComponentInfo{ - Id: component.ID, - AosVersion: component.AosVersion, VendorVersion: component.VendorVersion, + ComponentId: component.ComponentID, + Version: component.Version, }) } diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 81e80368..31ebe5e6 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -72,14 +72,12 @@ type Controller struct { // SystemComponent information about system component update. type SystemComponent struct { - ID string `json:"id"` - VendorVersion string `json:"vendorVersion"` - AosVersion uint64 `json:"aosVersion"` - Annotations string `json:"annotations,omitempty"` - URL string `json:"url"` - Sha256 []byte `json:"sha256"` - Sha512 []byte `json:"sha512"` - Size uint64 `json:"size"` + ID string `json:"id"` + Version string `json:"version"` + Annotations string `json:"annotations,omitempty"` + URL string `json:"url"` + Sha256 []byte `json:"sha256"` + Size uint64 `json:"size"` } type umConnection struct { @@ -105,11 +103,10 @@ type umStatus struct { } type systemComponentStatus struct { - id string - vendorVersion string - aosVersion uint64 - status string - err string + id string + version string + status string + err string } type allConnectionMonitor struct { @@ -304,8 +301,8 @@ func (umCtrl *Controller) UpdateComponents( for _, component := range components { componentStatus := systemComponentStatus{ - id: component.ID, vendorVersion: component.VendorVersion, - aosVersion: component.AosVersion, status: cloudprotocol.DownloadedStatus, + id: component.ComponentID, version: component.Version, + status: cloudprotocol.DownloadedStatus, } encryptedFile, err := getFilePath(component.URLs[0]) @@ -336,8 +333,8 @@ func (umCtrl *Controller) UpdateComponents( fcrypt.DecryptParams{ Chains: chains, Certs: certs, - DecryptionInfo: component.DecryptionInfo, - Signs: component.Signs, + DecryptionInfo: &component.DecryptionInfo, + // Signs: component.Signs, }); err != nil { return umCtrl.currentComponents, aoserrors.Wrap(err) } @@ -353,9 +350,9 @@ func (umCtrl *Controller) UpdateComponents( } componentInfo := SystemComponent{ - ID: component.ID, VendorVersion: component.VendorVersion, - AosVersion: component.AosVersion, Annotations: string(component.Annotations), - Sha256: fileInfo.Sha256, Sha512: fileInfo.Sha512, Size: fileInfo.Size, + ID: component.ComponentID, Version: component.Version, + Annotations: string(component.Annotations), + Sha256: fileInfo.Sha256, Size: fileInfo.Size, URL: url.String(), } @@ -523,12 +520,12 @@ func (umCtrl *Controller) updateCurrentComponentsStatus(componsStatus []systemCo toRemove := []int{} for i, curStatus := range umCtrl.currentComponents { - if value.id == curStatus.ID { + if value.id == curStatus.ComponentID { if curStatus.Status != cloudprotocol.InstalledStatus { continue } - if value.vendorVersion != curStatus.VendorVersion { + if value.version != curStatus.Version { toRemove = append(toRemove, i) continue } @@ -549,7 +546,7 @@ func (umCtrl *Controller) updateCurrentComponentsStatus(componsStatus []systemCo func (umCtrl *Controller) updateComponentElement(component systemComponentStatus) { for i, curElement := range umCtrl.currentComponents { - if curElement.ID == component.id && curElement.VendorVersion == component.vendorVersion { + if curElement.ComponentID == component.id && curElement.Version == component.version { if curElement.Status == cloudprotocol.InstalledStatus && component.status != cloudprotocol.InstalledStatus { break } @@ -567,10 +564,9 @@ func (umCtrl *Controller) updateComponentElement(component systemComponentStatus } newComponentStatus := cloudprotocol.ComponentStatus{ - ID: component.id, - VendorVersion: component.vendorVersion, - AosVersion: component.aosVersion, - Status: component.status, + ComponentID: component.id, + Version: component.version, + Status: component.status, } if component.err != "" { @@ -1022,6 +1018,5 @@ func (umCtrl *Controller) updateComplete(ctx context.Context, e *fsm.Event) { } func (status systemComponentStatus) String() string { - return fmt.Sprintf("{id: %s, status: %s, vendorVersion: %s aosVersion: %d }", - status.id, status.status, status.vendorVersion, status.aosVersion) + return fmt.Sprintf("{id: %s, status: %s, version: %s }", status.id, status.status, status.version) } diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 4b62f278..6a60f886 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -286,16 +286,19 @@ func TestFullUpdate(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um1C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um1C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um2C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um2C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um2C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um2C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -446,16 +449,19 @@ func TestFullUpdateWithDisconnect(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um3C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um3C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um4C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um4C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um4C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um4C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -623,16 +629,19 @@ func TestFullUpdateWithReboot(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um5C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um5C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um6C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um6C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um6C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um6C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -825,16 +834,19 @@ func TestRevertOnPrepare(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um7C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um7C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um8C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um8C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um8C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um8C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -958,16 +970,19 @@ func TestRevertOnUpdate(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um9C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um9C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um10C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um10C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um10C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um10C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -1115,16 +1130,19 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um11C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um11C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um12C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um12C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um12C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um12C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -1277,16 +1295,19 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "um13C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile1"), kilobyte*2), + ComponentID: "um13C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um14C1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile2"), kilobyte*2), + ComponentID: "um14C1", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, { - ID: "um14C2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2"}, - DecryptDataStruct: prepareDecryptDataStruct(path.Join(componentDir, "someFile3"), kilobyte*2), + ComponentID: "um14C2", Version: "2.0.0", + DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), + DecryptionInfo: prepareDecryptionInfo(), }, } @@ -1547,14 +1568,14 @@ func (um *testUmConnection) closeConnection() { _ = um.stream.CloseSend() } -func prepareDecryptDataStruct(filePath string, size uint64) cloudprotocol.DecryptDataStruct { +func prepareDownloadInfo(filePath string, size uint64) cloudprotocol.DownloadInfo { if err := generateFile(filePath, size); err != nil { - return cloudprotocol.DecryptDataStruct{} + return cloudprotocol.DownloadInfo{} } imageFileInfo, err := image.CreateFileInfo(context.Background(), filePath) if err != nil { - return cloudprotocol.DecryptDataStruct{} + return cloudprotocol.DownloadInfo{} } url := url.URL{ @@ -1562,6 +1583,14 @@ func prepareDecryptDataStruct(filePath string, size uint64) cloudprotocol.Decryp Path: filePath, } + return cloudprotocol.DownloadInfo{ + URLs: []string{url.String()}, + Sha256: imageFileInfo.Sha256, + Size: imageFileInfo.Size, + } +} + +func prepareDecryptionInfo() cloudprotocol.DecryptionInfo { recInfo := struct { Serial string `json:"serial"` Issuer []byte `json:"issuer"` @@ -1570,19 +1599,12 @@ func prepareDecryptDataStruct(filePath string, size uint64) cloudprotocol.Decryp Issuer: []byte("issuer"), } - return cloudprotocol.DecryptDataStruct{ - URLs: []string{url.String()}, - Sha256: imageFileInfo.Sha256, - Sha512: imageFileInfo.Sha512, - Size: imageFileInfo.Size, - DecryptionInfo: &cloudprotocol.DecryptionInfo{ - BlockAlg: "AES256/CBC/pkcs7", - BlockIv: []byte{}, - BlockKey: []byte{}, - AsymAlg: "RSA/PKCS1v1_5", - ReceiverInfo: &recInfo, - }, - Signs: &cloudprotocol.Signs{}, + return cloudprotocol.DecryptionInfo{ + BlockAlg: "AES256/CBC/pkcs7", + BlockIv: []byte{}, + BlockKey: []byte{}, + AsymAlg: "RSA/PKCS1v1_5", + ReceiverInfo: &recInfo, } } diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index e11090b9..f5955fb5 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -158,16 +158,15 @@ func getUmStatusFromUmMessage(msg *pb.UpdateStatus) (status umStatus) { status.updateStatus = msg.GetUpdateState().String() for _, component := range msg.GetComponents() { - if component.GetId() == "" { + if component.GetComponentId() == "" { continue } status.componsStatus = append(status.componsStatus, systemComponentStatus{ - id: component.GetId(), - vendorVersion: component.GetVendorVersion(), - aosVersion: component.GetAosVersion(), - status: strings.ToLower(component.GetStatus().String()), - err: component.GetError(), + id: component.GetComponentId(), + version: component.GetVersion(), + status: strings.ToLower(component.GetState().String()), + err: component.GetError().GetMessage(), }) } diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index 14547884..863c94fe 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -233,14 +233,12 @@ func (handler *umHandler) sendPrepareUpdateRequest(ctx context.Context, e *fsm.E for _, value := range request.components { componetInfo := pb.PrepareComponentInfo{ - Id: value.ID, - VendorVersion: value.VendorVersion, - AosVersion: value.AosVersion, - Annotations: value.Annotations, - Url: value.URL, - Sha256: value.Sha256, - Sha512: value.Sha512, - Size: value.Size, + ComponentId: value.ID, + Version: value.Version, + Annotations: value.Annotations, + Url: value.URL, + Sha256: value.Sha256, + Size: value.Size, } componetForUpdate = append(componetForUpdate, &componetInfo) diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 3fed525c..73a9f518 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -160,7 +160,7 @@ func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTASt for _, component := range manager.CurrentUpdate.Components { status.Components = append(status.Components, cloudprotocol.ComponentStatus{ - ID: component.ID, AosVersion: component.AosVersion, VendorVersion: component.VendorVersion, + ComponentID: component.ComponentID, Version: component.Version, }) } @@ -192,8 +192,8 @@ func (manager *firmwareManager) processDesiredStatus(desiredStatus cloudprotocol desiredLoop: for _, desiredComponent := range desiredStatus.Components { for _, installedComponent := range installedComponents { - if desiredComponent.ID == installedComponent.ID { - if desiredComponent.VendorVersion == installedComponent.VendorVersion && + if desiredComponent.ComponentID == installedComponent.ComponentID { + if desiredComponent.Version == installedComponent.Version && installedComponent.Status == cloudprotocol.InstalledStatus { continue desiredLoop } else { @@ -204,8 +204,8 @@ desiredLoop: } log.WithFields(log.Fields{ - "id": desiredComponent.ID, - "vendorVersion": desiredComponent.VendorVersion, + "id": desiredComponent.ComponentID, + "version": desiredComponent.Version, }).Error("Desired component not found") } @@ -400,25 +400,24 @@ func (manager *firmwareManager) download(ctx context.Context) { for _, component := range manager.CurrentUpdate.Components { log.WithFields(log.Fields{ - "id": component.ID, - "version": component.VendorVersion, + "id": component.ComponentID, + "version": component.Version, }).Debug("Download component") - request[component.ID] = downloader.PackageInfo{ + request[component.ComponentID] = downloader.PackageInfo{ URLs: component.URLs, Sha256: component.Sha256, Sha512: component.Sha512, Size: component.Size, TargetType: cloudprotocol.DownloadTargetComponent, - TargetID: component.ID, + TargetID: component.ComponentID, TargetAosVersion: component.AosVersion, TargetVendorVersion: component.VendorVersion, } - manager.ComponentStatuses[component.ID] = &cloudprotocol.ComponentStatus{ - ID: component.ID, - AosVersion: component.AosVersion, - VendorVersion: component.VendorVersion, - Status: cloudprotocol.DownloadingStatus, + manager.ComponentStatuses[component.ComponentID] = &cloudprotocol.ComponentStatus{ + ComponentID: component.ComponentID, + Version: component.Version, + Status: cloudprotocol.DownloadingStatus, } } @@ -436,16 +435,16 @@ func (manager *firmwareManager) download(ctx context.Context) { for id, item := range manager.ComponentStatuses { if item.ErrorInfo != nil { log.WithFields(log.Fields{ - "id": item.ID, - "version": item.VendorVersion, + "id": item.ComponentID, + "version": item.Version, }).Errorf("Error downloading component: %s", item.ErrorInfo.Message) continue } log.WithFields(log.Fields{ - "id": item.ID, - "version": item.VendorVersion, + "id": item.ComponentID, + "version": item.Version, }).Debug("Component successfully downloaded") manager.updateComponentStatusByID(id, cloudprotocol.PendingStatus, "") @@ -572,8 +571,8 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component case componentsErr == "": for _, status := range manager.ComponentStatuses { log.WithFields(log.Fields{ - "id": status.ID, - "version": status.VendorVersion, + "id": status.ComponentID, + "version": status.Version, }).Info("Component successfully updated") } @@ -585,8 +584,8 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component } log.WithFields(log.Fields{ - "id": status.ID, - "version": status.VendorVersion, + "id": status.ComponentID, + "version": status.Version, }).Errorf("Error updating component: %v", status.ErrorInfo) } } @@ -595,15 +594,15 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component updateComponents := make([]cloudprotocol.ComponentInfo, 0, len(manager.CurrentUpdate.Components)) for _, component := range manager.CurrentUpdate.Components { - log.WithFields(log.Fields{"id": component.ID, "version": component.VendorVersion}).Debug("Update component") + log.WithFields(log.Fields{"id": component.ComponentID, "version": component.Version}).Debug("Update component") - manager.updateComponentStatusByID(component.ID, cloudprotocol.InstallingStatus, "") + manager.updateComponentStatusByID(component.ComponentID, cloudprotocol.InstallingStatus, "") - downloadInfo, ok := manager.DownloadResult[component.ID] + downloadInfo, ok := manager.DownloadResult[component.ComponentID] if !ok { err := aoserrors.New("update ID not found").Error() - manager.updateComponentStatusByID(component.ID, cloudprotocol.ErrorStatus, err) + manager.updateComponentStatusByID(component.ComponentID, cloudprotocol.ErrorStatus, err) return err } @@ -734,7 +733,7 @@ func (manager *firmwareManager) asyncUpdate( for id, status := range manager.ComponentStatuses { for _, item := range updateResult { - if item.ID == status.ID && item.VendorVersion == status.VendorVersion { + if item.ComponentID == status.ComponentID && item.Version == status.Version { if errorStr == "" { if item.ErrorInfo != nil { errorStr = item.ErrorInfo.Message diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 2e346be2..0d09e176 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -256,27 +256,27 @@ func TestFirmwareManager(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ID: "comp1", - VersionInfo: aostypes.VersionInfo{VendorVersion: "1.0"}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{1}}, + ComponentID: "comp1", + Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ID: "comp2", - VersionInfo: aostypes.VersionInfo{VendorVersion: "2.0"}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{2}}, + ComponentID: "comp2", + Version: "2.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, }, } otherUpdateComponents := []cloudprotocol.ComponentInfo{ { - ID: "comp3", - VersionInfo: aostypes.VersionInfo{VendorVersion: "3.0"}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{3}}, + ComponentID: "comp3", + Version: "3.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ID: "comp4", - VersionInfo: aostypes.VersionInfo{VendorVersion: "4.0"}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{4}}, + ComponentID: "comp4", + Version: "4.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, } @@ -300,17 +300,17 @@ func TestFirmwareManager(t *testing.T) { testID: "success update", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -323,17 +323,17 @@ func TestFirmwareManager(t *testing.T) { testID: "download error", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {Error: "download error"}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {Error: "download error"}, + updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, {State: cmserver.NoUpdate, Error: "download error"}, @@ -343,18 +343,18 @@ func TestFirmwareManager(t *testing.T) { testID: "update error", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, { - ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.ErrorStatus, + ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: "update error"}, }, }, @@ -373,17 +373,17 @@ func TestFirmwareManager(t *testing.T) { }, initStatus: &cmserver.UpdateStatus{State: cmserver.Downloading}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, {State: cmserver.NoUpdate}, @@ -395,28 +395,28 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateReadyToUpdate, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ID: { - ID: updateComponents[0].ID, - VendorVersion: updateComponents[0].VendorVersion, + updateComponents[0].ComponentID: { + ComponentID: updateComponents[0].ComponentID, + Version: updateComponents[0].Version, }, - updateComponents[1].ID: { - ID: updateComponents[1].ID, - VendorVersion: updateComponents[1].VendorVersion, + updateComponents[1].ComponentID: { + ComponentID: updateComponents[1].ComponentID, + Version: updateComponents[1].Version, }, }, }, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{{State: cmserver.Updating}, {State: cmserver.NoUpdate}}, }, @@ -426,27 +426,27 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateUpdating, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ID: { - ID: updateComponents[0].ID, - VendorVersion: updateComponents[0].VendorVersion, + updateComponents[0].ComponentID: { + ComponentID: updateComponents[0].ComponentID, + Version: updateComponents[0].Version, }, - updateComponents[1].ID: { - ID: updateComponents[1].ID, - VendorVersion: updateComponents[1].VendorVersion, + updateComponents[1].ComponentID: { + ComponentID: updateComponents[1].ComponentID, + Version: updateComponents[1].Version, }, }, }, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{{State: cmserver.NoUpdate}}, }, @@ -459,32 +459,32 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ID: { - ID: updateComponents[0].ID, - VendorVersion: updateComponents[0].VendorVersion, + updateComponents[0].ComponentID: { + ComponentID: updateComponents[0].ComponentID, + Version: updateComponents[0].Version, }, - updateComponents[1].ID: { - ID: updateComponents[1].ID, - VendorVersion: updateComponents[1].VendorVersion, + updateComponents[1].ComponentID: { + ComponentID: updateComponents[1].ComponentID, + Version: updateComponents[1].Version, }, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ Components: updateComponents, FOTASchedule: cloudprotocol.ScheduleRule{Type: cloudprotocol.TriggerUpdate}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, triggerUpdate: true, updateWaitStatuses: []cmserver.UpdateStatus{{State: cmserver.Updating}, {State: cmserver.NoUpdate}}, @@ -495,28 +495,28 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateDownloading, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.Downloading}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp3", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp4", VendorVersion: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", Version: "3.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: otherUpdateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, - otherUpdateComponents[0].ID: {}, - otherUpdateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, + otherUpdateComponents[0].ComponentID: {}, + otherUpdateComponents[1].ComponentID: {}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp3", VendorVersion: "3.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp4", VendorVersion: "4.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate, Error: context.Canceled.Error()}, @@ -537,22 +537,22 @@ func TestFirmwareManager(t *testing.T) { }, initStatus: &cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp3", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp4", VendorVersion: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", Version: "3.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ Components: otherUpdateComponents, FOTASchedule: cloudprotocol.ScheduleRule{Type: cloudprotocol.TriggerUpdate}, }, downloadResult: map[string]*downloadResult{ - otherUpdateComponents[0].ID: {}, - otherUpdateComponents[1].ID: {}, + otherUpdateComponents[0].ComponentID: {}, + otherUpdateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp3", VendorVersion: "3.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp4", VendorVersion: "4.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate, Error: context.Canceled.Error()}, @@ -568,41 +568,41 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ID: { - ID: updateComponents[0].ID, - VendorVersion: updateComponents[0].VendorVersion, - Status: cloudprotocol.InstallingStatus, + updateComponents[0].ComponentID: { + ComponentID: updateComponents[0].ComponentID, + Version: updateComponents[0].Version, + Status: cloudprotocol.InstallingStatus, }, - updateComponents[1].ID: { - ID: updateComponents[1].ID, - VendorVersion: updateComponents[1].VendorVersion, - Status: cloudprotocol.InstallingStatus, + updateComponents[1].ComponentID: { + ComponentID: updateComponents[1].ComponentID, + Version: updateComponents[1].Version, + Status: cloudprotocol.InstallingStatus, }, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.Updating}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp3", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp4", VendorVersion: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", Version: "3.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: otherUpdateComponents}, downloadResult: map[string]*downloadResult{ - otherUpdateComponents[0].ID: {}, - otherUpdateComponents[1].ID: {}, + otherUpdateComponents[0].ComponentID: {}, + otherUpdateComponents[1].ComponentID: {}, }, downloadTime: 1 * time.Second, updateTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp3", VendorVersion: "3.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp4", VendorVersion: "4.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate}, @@ -615,7 +615,7 @@ func TestFirmwareManager(t *testing.T) { { testID: "update unit config", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, - desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: json.RawMessage("{}")}, + desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, @@ -626,7 +626,7 @@ func TestFirmwareManager(t *testing.T) { { testID: "error unit config", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, - desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: json.RawMessage("{}")}, + desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}, unitConfigError: aoserrors.New("unit config error"), updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, {State: cmserver.NoUpdate, Error: "unit config error"}, @@ -636,8 +636,8 @@ func TestFirmwareManager(t *testing.T) { testID: "timetable update", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ FOTASchedule: cloudprotocol.ScheduleRule{ @@ -647,12 +647,12 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -665,8 +665,8 @@ func TestFirmwareManager(t *testing.T) { testID: "update TTL", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ID: "comp1", VendorVersion: "0.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ FOTASchedule: cloudprotocol.ScheduleRule{ @@ -676,8 +676,8 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, downloadResult: map[string]*downloadResult{ - updateComponents[0].ID: {}, - updateComponents[1].ID: {}, + updateComponents[0].ComponentID: {}, + updateComponents[1].ComponentID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -783,25 +783,25 @@ func TestSoftwareManager(t *testing.T) { updateLayers := []cloudprotocol.LayerInfo{ { - ID: "layer1", - Digest: "digest1", - VersionInfo: aostypes.VersionInfo{AosVersion: 1}, + LayerID: "layer1", + Digest: "digest1", + Version: "1.0", }, { - ID: "layer2", - Digest: "digest2", - VersionInfo: aostypes.VersionInfo{AosVersion: 2}, + LayerID: "layer2", + Digest: "digest2", + Version: "2.0", }, } updateServices := []cloudprotocol.ServiceInfo{ { - ID: "service1", - VersionInfo: aostypes.VersionInfo{AosVersion: 1}, + ServiceID: "service1", + Version: "1.0", }, { - ID: "service2", - VersionInfo: aostypes.VersionInfo{AosVersion: 2}, + ServiceID: "service2", + Version: "2.0", }, } @@ -829,7 +829,7 @@ func TestSoftwareManager(t *testing.T) { }, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -845,45 +845,45 @@ func TestSoftwareManager(t *testing.T) { initServices: []ServiceStatus{ { ServiceStatus: cloudprotocol.ServiceStatus{ - ID: updateServices[0].ID, - AosVersion: updateServices[0].AosVersion, - Status: cloudprotocol.InstalledStatus, + ServiceID: updateServices[0].ServiceID, + Version: updateServices[0].Version, + Status: cloudprotocol.InstalledStatus, }, }, { ServiceStatus: cloudprotocol.ServiceStatus{ - ID: updateServices[1].ID, - AosVersion: updateServices[1].AosVersion, - Status: cloudprotocol.InstalledStatus, + ServiceID: updateServices[1].ServiceID, + Version: updateServices[1].Version, + Status: cloudprotocol.InstalledStatus, }, }, }, initLayers: []LayerStatus{ { LayerStatus: cloudprotocol.LayerStatus{ - ID: updateLayers[0].ID, - AosVersion: updateLayers[0].AosVersion, - Digest: updateLayers[0].Digest, - Status: cloudprotocol.InstalledStatus, + LayerID: updateLayers[0].LayerID, + Version: updateLayers[0].Version, + Digest: updateLayers[0].Digest, + Status: cloudprotocol.InstalledStatus, }, }, { LayerStatus: cloudprotocol.LayerStatus{ - ID: updateLayers[1].ID, - AosVersion: updateLayers[1].AosVersion, - Digest: updateLayers[1].Digest, - Status: cloudprotocol.InstalledStatus, + LayerID: updateLayers[1].LayerID, + Version: updateLayers[1].Version, + Digest: updateLayers[1].Digest, + Status: cloudprotocol.InstalledStatus, }, }, }, desiredStatus: &cloudprotocol.DesiredStatus{ Layers: updateLayers, Services: append(updateServices, cloudprotocol.ServiceInfo{ - ID: "service3", - VersionInfo: aostypes.VersionInfo{AosVersion: 1}, + ServiceID: "service3", + Version: "1.0", }, cloudprotocol.ServiceInfo{ - ID: "service4", - VersionInfo: aostypes.VersionInfo{AosVersion: 1}, + ServiceID: "service4", + Version: "1.0", }), }, downloadResult: map[string]*downloadResult{ @@ -905,7 +905,7 @@ func TestSoftwareManager(t *testing.T) { }, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {Error: "download error"}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -922,7 +922,7 @@ func TestSoftwareManager(t *testing.T) { }, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {Error: "download error"}, updateLayers[1].Digest: {Error: "download error"}, - updateServices[0].ID: {Error: "download error"}, updateServices[1].ID: {Error: "download error"}, + updateServices[0].ServiceID: {Error: "download error"}, updateServices[1].ServiceID: {Error: "download error"}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, {State: cmserver.NoUpdate, Error: "download error"}, @@ -936,7 +936,7 @@ func TestSoftwareManager(t *testing.T) { }, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateError: aoserrors.New("update error"), updateWaitStatuses: []cmserver.UpdateStatus{ @@ -957,7 +957,7 @@ func TestSoftwareManager(t *testing.T) { initStatus: &cmserver.UpdateStatus{State: cmserver.Downloading}, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, {State: cmserver.NoUpdate}, @@ -972,32 +972,32 @@ func TestSoftwareManager(t *testing.T) { }, DownloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, LayerStatuses: map[string]*cloudprotocol.LayerStatus{ updateLayers[0].Digest: { - ID: updateLayers[0].ID, - Digest: updateLayers[0].Digest, - AosVersion: updateLayers[0].AosVersion, - Status: cloudprotocol.InstallingStatus, + LayerID: updateLayers[0].LayerID, + Digest: updateLayers[0].Digest, + Version: updateLayers[0].Version, + Status: cloudprotocol.InstallingStatus, }, updateLayers[1].Digest: { - ID: updateLayers[1].ID, - Digest: updateLayers[1].Digest, - AosVersion: updateLayers[1].AosVersion, - Status: cloudprotocol.InstallingStatus, + LayerID: updateLayers[1].LayerID, + Digest: updateLayers[1].Digest, + Version: updateLayers[1].Version, + Status: cloudprotocol.InstallingStatus, }, }, ServiceStatuses: map[string]*cloudprotocol.ServiceStatus{ - updateServices[0].ID: { - ID: updateServices[0].ID, - AosVersion: updateServices[0].AosVersion, - Status: cloudprotocol.InstallingStatus, + updateServices[0].ServiceID: { + ServiceID: updateServices[0].ServiceID, + Version: updateServices[0].Version, + Status: cloudprotocol.InstallingStatus, }, - updateServices[1].ID: { - ID: updateServices[1].ID, - AosVersion: updateServices[1].AosVersion, - Status: cloudprotocol.InstallingStatus, + updateServices[1].ServiceID: { + ServiceID: updateServices[1].ServiceID, + Version: updateServices[1].Version, + Status: cloudprotocol.InstallingStatus, }, }, }, @@ -1017,7 +1017,7 @@ func TestSoftwareManager(t *testing.T) { }, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -1038,7 +1038,7 @@ func TestSoftwareManager(t *testing.T) { }, downloadResult: map[string]*downloadResult{ updateLayers[0].Digest: {}, updateLayers[1].Digest: {}, - updateServices[0].ID: {}, updateServices[1].ID: {}, + updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -1687,8 +1687,8 @@ func newTestStatusHandler() *testStatusHandler { func (statusHandler *testStatusHandler) updateComponentStatus(componentInfo cloudprotocol.ComponentStatus) { log.WithFields(log.Fields{ - "id": componentInfo.ID, - "version": componentInfo.VendorVersion, + "id": componentInfo.ComponentID, + "version": componentInfo.Version, "status": componentInfo.Status, "error": componentInfo.ErrorInfo, }).Debug("Update component status") @@ -1696,7 +1696,7 @@ func (statusHandler *testStatusHandler) updateComponentStatus(componentInfo clou func (statusHandler *testStatusHandler) updateUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) { log.WithFields(log.Fields{ - "version": unitConfigInfo.VendorVersion, + "version": unitConfigInfo.Version, "status": unitConfigInfo.Status, "error": unitConfigInfo.ErrorInfo, }).Debug("Update unit config status") @@ -1704,9 +1704,9 @@ func (statusHandler *testStatusHandler) updateUnitConfigStatus(unitConfigInfo cl func (statusHandler *testStatusHandler) updateLayerStatus(layerInfo cloudprotocol.LayerStatus) { log.WithFields(log.Fields{ - "id": layerInfo.ID, + "id": layerInfo.LayerID, "digest": layerInfo.Digest, - "version": layerInfo.AosVersion, + "version": layerInfo.Version, "status": layerInfo.Status, "error": layerInfo.ErrorInfo, }).Debug("Update layer status") @@ -1714,8 +1714,8 @@ func (statusHandler *testStatusHandler) updateLayerStatus(layerInfo cloudprotoco func (statusHandler *testStatusHandler) updateServiceStatus(serviceInfo cloudprotocol.ServiceStatus) { log.WithFields(log.Fields{ - "id": serviceInfo.ID, - "version": serviceInfo.AosVersion, + "id": serviceInfo.ServiceID, + "version": serviceInfo.Version, "status": serviceInfo.Status, "error": serviceInfo.ErrorInfo, }).Debug("Update service status") diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index a6484a80..a9b59aac 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -275,8 +275,8 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ID: "comp0", VersionInfo: aostypes.VersionInfo{VendorVersion: "2.0"}}, - {ID: "comp2", VersionInfo: aostypes.VersionInfo{VendorVersion: "2.0"}}, + {ComponentID: "comp0", Version: "2.0"}, + {ComponentID: "comp2", Version: "2.0"}, }, }) @@ -312,7 +312,7 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ID: "comp1", VersionInfo: aostypes.VersionInfo{VendorVersion: "2.0"}}, + {ComponentID: "comp1", Version: "2.0"}, }, }) From cdb8a2d9c163942b118a4ef6c2a173daa52dc19e Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 22:03:59 +0300 Subject: [PATCH 005/146] [all] Update ComponentStatus Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 6 +- cmserver/cmserver_test.go | 12 +- database/database.go | 4 +- database/database_internal_test.go | 12 +- downloader/downloader_test.go | 1 - umcontroller/umcontroller.go | 22 +- umcontroller/umcontroller_internal_test.go | 8 +- umcontroller/umcontroller_test.go | 299 ++++++++++---------- umcontroller/umhandler.go | 4 +- unitstatushandler/unitstatushandler.go | 10 +- unitstatushandler/unitstatushandler_test.go | 26 +- 11 files changed, 199 insertions(+), 205 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 4f59863c..ab67e324 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -404,10 +404,10 @@ func TestSendMessages(t *testing.T) { } componentSetupData := []cloudprotocol.ComponentStatus{ - {ID: "rootfs", Status: "installed", VendorVersion: "1.0"}, - {ID: "firmware", Status: "installed", VendorVersion: "5", AosVersion: 6}, + {ComponentID: "rootfs", Status: "installed", Version: "1.0"}, + {ComponentID: "firmware", Status: "installed", Version: "5.6"}, { - ID: "bootloader", Status: "error", VendorVersion: "100", + ComponentID: "bootloader", Status: "error", Version: "100", ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 1, ExitCode: 100, Message: "install error"}, }, } diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index e710c16a..12a96f4c 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -126,7 +126,7 @@ func TestConnection(t *testing.T) { } statusFotaNotification := cmserver.UpdateFOTAStatus{ - Components: []cloudprotocol.ComponentStatus{{ID: "1234", AosVersion: 123, VendorVersion: "4321"}}, + Components: []cloudprotocol.ComponentStatus{{ComponentID: "1234", Version: "123.4321"}}, UnitConfig: &cloudprotocol.UnitConfigStatus{VendorVersion: "bc_version"}, UpdateStatus: cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, } @@ -151,16 +151,12 @@ func TestConnection(t *testing.T) { t.Fatal("Incorrect count of components") } - if status.GetComponents()[0].GetId() != "1234" { + if status.GetComponents()[0].GetComponentId() != "1234" { t.Error("Incorrect component id") } - if status.GetComponents()[0].GetVendorVersion() != "4321" { - t.Error("Incorrect vendor version") - } - - if status.GetComponents()[0].GetAosVersion() != 123 { - t.Error("Incorrect aos version") + if status.GetComponents()[0].GetVersion() != "123.4321" { + t.Error("Incorrect version") } if status.GetUnitConfig() == nil { diff --git a/database/database.go b/database/database.go index 62f339b8..f22de1e8 100644 --- a/database/database.go +++ b/database/database.go @@ -177,7 +177,7 @@ func (db *Database) GetJournalCursor() (cursor string, err error) { } // SetComponentsUpdateInfo store update data for update managers. -func (db *Database) SetComponentsUpdateInfo(updateInfo []umcontroller.SystemComponent) (err error) { +func (db *Database) SetComponentsUpdateInfo(updateInfo []umcontroller.ComponentStatus) (err error) { dataJSON, err := json.Marshal(&updateInfo) if err != nil { return aoserrors.Wrap(err) @@ -191,7 +191,7 @@ func (db *Database) SetComponentsUpdateInfo(updateInfo []umcontroller.SystemComp } // GetComponentsUpdateInfo returns update data for system components. -func (db *Database) GetComponentsUpdateInfo() (updateInfo []umcontroller.SystemComponent, err error) { +func (db *Database) GetComponentsUpdateInfo() (updateInfo []umcontroller.ComponentStatus, err error) { stmt, err := db.sql.Prepare("SELECT componentsUpdateInfo FROM config") if err != nil { return updateInfo, aoserrors.Wrap(err) diff --git a/database/database_internal_test.go b/database/database_internal_test.go index e4852fcc..5c0b53e9 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -133,12 +133,12 @@ func TestCursor(t *testing.T) { } func TestComponentsUpdateInfo(t *testing.T) { - testData := []umcontroller.SystemComponent{ + testData := []umcontroller.ComponentStatus{ { - ID: "component1", VendorVersion: "v1", AosVersion: 1, - Annotations: "Some annotation", URL: "url12", Sha512: []byte{1, 3, 90, 42}, + ID: "component1", Version: "v1", + Annotations: "Some annotation", URL: "url12", Sha256: []byte{1, 3, 90, 42}, }, - {ID: "component2", VendorVersion: "v1", AosVersion: 1, URL: "url12", Sha512: []byte{1, 3, 90, 42}}, + {ID: "component2", Version: "v1", URL: "url12", Sha256: []byte{1, 3, 90, 42}}, } if err := testDB.SetComponentsUpdateInfo(testData); err != nil { @@ -154,7 +154,7 @@ func TestComponentsUpdateInfo(t *testing.T) { t.Fatalf("Wrong update info value: %v", getUpdateInfo) } - testData = []umcontroller.SystemComponent{} + testData = []umcontroller.ComponentStatus{} if err := testDB.SetComponentsUpdateInfo(testData); err != nil { t.Fatal("Can't set update manager's update info ", err) @@ -246,7 +246,7 @@ func TestMultiThread(t *testing.T) { defer wg.Done() for i := 0; i < numIterations; i++ { - if err := testDB.SetComponentsUpdateInfo([]umcontroller.SystemComponent{{AosVersion: uint64(i)}}); err != nil { + if err := testDB.SetComponentsUpdateInfo([]umcontroller.ComponentStatus{{Version: strconv.Itoa(i)}}); err != nil { t.Errorf("Can't set journal cursor: %s", err) } } diff --git a/downloader/downloader_test.go b/downloader/downloader_test.go index 904e5fd1..4ec9183a 100644 --- a/downloader/downloader_test.go +++ b/downloader/downloader_test.go @@ -984,7 +984,6 @@ func preparePackageInfo(host, fileName, targetType string) (packageInfo download } packageInfo.Sha256 = imageFileInfo.Sha256 - packageInfo.Sha512 = imageFileInfo.Sha512 packageInfo.Size = imageFileInfo.Size packageInfo.TargetType = targetType packageInfo.TargetID = "targetID" diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 31ebe5e6..18cf4f10 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -70,8 +70,8 @@ type Controller struct { fileServer *fileserver.FileServer } -// SystemComponent information about system component update. -type SystemComponent struct { +// ComponentStatus information about system component update. +type ComponentStatus struct { ID string `json:"id"` Version string `json:"version"` Annotations string `json:"annotations,omitempty"` @@ -87,7 +87,7 @@ type umConnection struct { updatePriority uint32 state string components []string - updatePackages []SystemComponent + updatePackages []ComponentStatus } type umCtrlInternalMsg struct { @@ -118,8 +118,8 @@ type allConnectionMonitor struct { } type storage interface { - GetComponentsUpdateInfo() (updateInfo []SystemComponent, err error) - SetComponentsUpdateInfo(updateInfo []SystemComponent) (err error) + GetComponentsUpdateInfo() (updateInfo []ComponentStatus, err error) + SetComponentsUpdateInfo(updateInfo []ComponentStatus) (err error) } // CertificateProvider certificate and key provider interface. @@ -297,7 +297,7 @@ func (umCtrl *Controller) UpdateComponents( return umCtrl.currentComponents, nil } - componentsUpdateInfo := []SystemComponent{} + componentsUpdateInfo := []ComponentStatus{} for _, component := range components { componentStatus := systemComponentStatus{ @@ -349,7 +349,7 @@ func (umCtrl *Controller) UpdateComponents( Path: decryptedFile, } - componentInfo := SystemComponent{ + componentInfo := ComponentStatus{ ID: component.ComponentID, Version: component.Version, Annotations: string(component.Annotations), Sha256: fileInfo.Sha256, Size: fileInfo.Size, @@ -621,7 +621,7 @@ func (umCtrl *Controller) getCurrentUpdateState() (state string) { func (umCtrl *Controller) getUpdateComponentsFromStorage() (err error) { for i := range umCtrl.connections { - umCtrl.connections[i].updatePackages = []SystemComponent{} + umCtrl.connections[i].updatePackages = []ComponentStatus{} } updateComponents, err := umCtrl.storage.GetComponentsUpdateInfo() @@ -640,7 +640,7 @@ func (umCtrl *Controller) getUpdateComponentsFromStorage() (err error) { return aoserrors.Wrap(err) } -func (umCtrl *Controller) addComponentForUpdateToUm(componentInfo SystemComponent) (err error) { +func (umCtrl *Controller) addComponentForUpdateToUm(componentInfo ComponentStatus) (err error) { for i := range umCtrl.connections { for _, id := range umCtrl.connections[i].components { if id == componentInfo.ID { @@ -667,7 +667,7 @@ func (umCtrl *Controller) cleanupUpdateData() { umCtrl.allocator.FreeSpace(updatePackage.Size) } - umCtrl.connections[i].updatePackages = []SystemComponent{} + umCtrl.connections[i].updatePackages = []ComponentStatus{} } entries, err := os.ReadDir(umCtrl.componentDir) @@ -702,7 +702,7 @@ func (umCtrl *Controller) cleanupUpdateData() { return } - if err := umCtrl.storage.SetComponentsUpdateInfo([]SystemComponent{}); err != nil { + if err := umCtrl.storage.SetComponentsUpdateInfo([]ComponentStatus{}); err != nil { log.Error("Can't clean components update info ", err) } } diff --git a/umcontroller/umcontroller_internal_test.go b/umcontroller/umcontroller_internal_test.go index b75be80e..04cec9be 100644 --- a/umcontroller/umcontroller_internal_test.go +++ b/umcontroller/umcontroller_internal_test.go @@ -96,7 +96,7 @@ func TestNormalUpdate(t *testing.T) { stream.step = StepPrepare - components := []SystemComponent{{URL: "file:///path/to/update", VendorVersion: "vendorversion1", AosVersion: 1}} + components := []ComponentStatus{{URL: "file:///path/to/update", Version: "1.1.0"}} if err := handler.PrepareUpdate(components); err != nil { t.Errorf("Can't prepare components: %s", err) } @@ -178,7 +178,7 @@ func TestNormalUpdateWithReboot(t *testing.T) { stream.step = StepPrepare - components := []SystemComponent{{URL: "file:///path/to/update", VendorVersion: "vendorversion2", AosVersion: 1}} + components := []ComponentStatus{{URL: "file:///path/to/update", Version: "2.1.0"}} if err := handler.PrepareUpdate(components); err != nil { t.Errorf("Can't prepare components: %s", err) } @@ -253,7 +253,7 @@ func TestRevert(t *testing.T) { stream.step = StepPrepare - components := []SystemComponent{{URL: "file:///path/to/update", VendorVersion: "vendorversion3", AosVersion: 1}} + components := []ComponentStatus{{URL: "file:///path/to/update", Version: "2.1.0"}} if err := handler.PrepareUpdate(components); err != nil { t.Errorf("Can't prepare components: %s", err) } @@ -320,7 +320,7 @@ func TestRevertWithReboot(t *testing.T) { stream.step = StepPrepare - components := []SystemComponent{{URL: "file:///path/to/update", VendorVersion: "vendorversion4", AosVersion: 1}} + components := []ComponentStatus{{URL: "file:///path/to/update", Version: "2.1.0"}} if err := handler.PrepareUpdate(components); err != nil { t.Errorf("Can't prepare components: %s", err) } diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 6a60f886..b5bc048a 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -35,7 +35,6 @@ import ( "google.golang.org/grpc/credentials/insecure" "github.com/aosedge/aos_common/aoserrors" - "github.com/aosedge/aos_common/aostypes" pb "github.com/aosedge/aos_common/api/updatemanager" "github.com/aosedge/aos_common/image" @@ -65,7 +64,7 @@ const ( ) type testStorage struct { - updateInfo []umcontroller.SystemComponent + updateInfo []umcontroller.ComponentStatus } type testUmConnection struct { @@ -75,7 +74,7 @@ type testUmConnection struct { step string test *testing.T umID string - components []*pb.SystemComponent + components []*pb.ComponentStatus conn *grpc.ClientConn } @@ -155,9 +154,9 @@ func TestConnection(t *testing.T) { t.Fatalf("Can't create: UM controller %s", err) } - components := []*pb.SystemComponent{ - {Id: "component1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "component2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + components := []*pb.ComponentStatus{ + {ComponentId: "component1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } streamUM1, connUM1, err := createClientConnection("umID1", pb.UpdateState_IDLE, components) @@ -165,9 +164,9 @@ func TestConnection(t *testing.T) { t.Errorf("Error connect %s", err) } - components2 := []*pb.SystemComponent{ - {Id: "component3", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "component4", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + components2 := []*pb.ComponentStatus{ + {ComponentId: "component3", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component4", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } streamUM2, connUM2, err := createClientConnection("umID2", pb.UpdateState_IDLE, components2) @@ -211,7 +210,7 @@ func TestConnection(t *testing.T) { **********************************************************************************************************************/ func createClientConnection( - clientID string, state pb.UpdateState, components []*pb.SystemComponent, + clientID string, state pb.UpdateState, components []*pb.ComponentStatus, ) (stream pb.UMService_RegisterUMClient, conn *grpc.ClientConn, err error) { var opts []grpc.DialOption opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -261,17 +260,17 @@ func TestFullUpdate(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um1Components := []*pb.SystemComponent{ - {Id: "um1C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um1C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um1Components := []*pb.ComponentStatus{ + {ComponentId: "um1C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um1C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um1 := newTestUM(t, "testUM1", pb.UpdateState_IDLE, "init", um1Components) go um1.processMessages() - um2Components := []*pb.SystemComponent{ - {Id: "um2C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um2C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um2Components := []*pb.ComponentStatus{ + {ComponentId: "um2C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um2C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um2 := newTestUM(t, "testUM2", pb.UpdateState_IDLE, "init", um2Components) @@ -311,8 +310,8 @@ func TestFullUpdate(t *testing.T) { finChan <- true }(finishChannel) - um1Components = append(um1Components, &pb.SystemComponent{ - Id: "um1C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING, + um1Components = append(um1Components, &pb.ComponentStatus{ + ComponentId: "um1C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING, }) um1.setComponents(um1Components) @@ -322,9 +321,9 @@ func TestFullUpdate(t *testing.T) { um1.sendState(pb.UpdateState_PREPARED) um2Components = append(um2Components, - &pb.SystemComponent{Id: "um2C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um2C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um2Components = append(um2Components, - &pb.SystemComponent{Id: "um2C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um2C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um2.setComponents(um2Components) um2.step = prepareStep @@ -342,9 +341,9 @@ func TestFullUpdate(t *testing.T) { <-um2.notifyTestChan // um2 updated um2.sendState(pb.UpdateState_UPDATED) - um1Components = []*pb.SystemComponent{ - {Id: "um1C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um1C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, + um1Components = []*pb.ComponentStatus{ + {ComponentId: "um1C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um1C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um1.setComponents(um1Components) @@ -353,9 +352,9 @@ func TestFullUpdate(t *testing.T) { <-um1.notifyTestChan // um1 apply um1.sendState(pb.UpdateState_IDLE) - um2Components = []*pb.SystemComponent{ - {Id: "um2C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um2C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, + um2Components = []*pb.ComponentStatus{ + {ComponentId: "um2C1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um2C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um2.setComponents(um2Components) @@ -372,10 +371,10 @@ func TestFullUpdate(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um1C1", VendorVersion: "1", Status: "installed"}, - {ID: "um1C2", VendorVersion: "2", Status: "installed"}, - {ID: "um2C1", VendorVersion: "2", Status: "installed"}, - {ID: "um2C2", VendorVersion: "2", Status: "installed"}, + {ComponentID: "um1C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um1C2", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um2C1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um2C2", Version: "2.0.0", Status: "installed"}, } currentComponents, err := umCtrl.GetStatus() @@ -424,17 +423,17 @@ func TestFullUpdateWithDisconnect(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um3Components := []*pb.SystemComponent{ - {Id: "um3C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um3C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um3Components := []*pb.ComponentStatus{ + {ComponentId: "um3C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um3C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um3 := newTestUM(t, "testUM3", pb.UpdateState_IDLE, "init", um3Components) go um3.processMessages() - um4Components := []*pb.SystemComponent{ - {Id: "um4C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um4C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um4Components := []*pb.ComponentStatus{ + {ComponentId: "um4C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um4C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um4 := newTestUM(t, "testUM4", pb.UpdateState_IDLE, "init", um4Components) @@ -477,7 +476,7 @@ func TestFullUpdateWithDisconnect(t *testing.T) { // prepare UM3 um3Components = append(um3Components, - &pb.SystemComponent{Id: "um3C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um3C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um3.setComponents(um3Components) um3.step = prepareStep @@ -487,9 +486,9 @@ func TestFullUpdateWithDisconnect(t *testing.T) { // prepare UM4 um4Components = append(um4Components, - &pb.SystemComponent{Id: "um4C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um4C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um4Components = append(um4Components, - &pb.SystemComponent{Id: "um4C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um4C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um4.setComponents(um4Components) um4.step = prepareStep @@ -530,9 +529,9 @@ func TestFullUpdateWithDisconnect(t *testing.T) { um3.closeConnection() <-um3.notifyTestChan - um3Components = []*pb.SystemComponent{ - {Id: "um3C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um3C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, + um3Components = []*pb.ComponentStatus{ + {ComponentId: "um3C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um3C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um3 = newTestUM(t, "testUM3", pb.UpdateState_IDLE, "init", um3Components) @@ -543,9 +542,9 @@ func TestFullUpdateWithDisconnect(t *testing.T) { um4.closeConnection() <-um4.notifyTestChan - um4Components = []*pb.SystemComponent{ - {Id: "um4C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um4C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, + um4Components = []*pb.ComponentStatus{ + {ComponentId: "um4C1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um4C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um4 = newTestUM(t, "testUM4", pb.UpdateState_IDLE, "init", um4Components) @@ -557,10 +556,10 @@ func TestFullUpdateWithDisconnect(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um3C1", VendorVersion: "1", Status: "installed"}, - {ID: "um3C2", VendorVersion: "2", Status: "installed"}, - {ID: "um4C1", VendorVersion: "2", Status: "installed"}, - {ID: "um4C2", VendorVersion: "2", Status: "installed"}, + {ComponentID: "um3C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um3C2", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um4C1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um4C2", Version: "2.0.0", Status: "installed"}, } currentComponents, err := umCtrl.GetStatus() @@ -604,17 +603,17 @@ func TestFullUpdateWithReboot(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um5Components := []*pb.SystemComponent{ - {Id: "um5C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um5C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um5Components := []*pb.ComponentStatus{ + {ComponentId: "um5C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um5C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um5 := newTestUM(t, "testUM5", pb.UpdateState_IDLE, "init", um5Components) go um5.processMessages() - um6Components := []*pb.SystemComponent{ - {Id: "um6C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um6C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um6Components := []*pb.ComponentStatus{ + {ComponentId: "um6C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um6C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um6 := newTestUM(t, "testUM6", pb.UpdateState_IDLE, "init", um6Components) @@ -657,7 +656,7 @@ func TestFullUpdateWithReboot(t *testing.T) { // prepare UM5 um5Components = append(um5Components, - &pb.SystemComponent{Id: "um5C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um5C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um5.setComponents(um5Components) um5.step = prepareStep @@ -667,9 +666,9 @@ func TestFullUpdateWithReboot(t *testing.T) { // prepare UM6 um6Components = append(um6Components, - &pb.SystemComponent{Id: "um6C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um6C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um6Components = append(um6Components, - &pb.SystemComponent{Id: "um6C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um6C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um6.setComponents(um6Components) um6.step = prepareStep @@ -735,9 +734,9 @@ func TestFullUpdateWithReboot(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um5Components = []*pb.SystemComponent{ - {Id: "um5C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um5C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, + um5Components = []*pb.ComponentStatus{ + {ComponentId: "um5C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um5C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um5 = newTestUM(t, "testUM5", pb.UpdateState_IDLE, "init", um5Components) @@ -750,9 +749,9 @@ func TestFullUpdateWithReboot(t *testing.T) { um6.closeConnection() <-um6.notifyTestChan - um6Components = []*pb.SystemComponent{ - {Id: "um6C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um6C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLED}, + um6Components = []*pb.ComponentStatus{ + {ComponentId: "um6C1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um6C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um6 = newTestUM(t, "testUM6", pb.UpdateState_IDLE, "init", um6Components) @@ -762,10 +761,10 @@ func TestFullUpdateWithReboot(t *testing.T) { um6.step = finishStep etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um5C1", VendorVersion: "1", Status: "installed"}, - {ID: "um5C2", VendorVersion: "2", Status: "installed"}, - {ID: "um6C1", VendorVersion: "2", Status: "installed"}, - {ID: "um6C2", VendorVersion: "2", Status: "installed"}, + {ComponentID: "um5C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um5C2", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um6C1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um6C2", Version: "2.0.0", Status: "installed"}, } currentComponents, err := umCtrl.GetStatus() @@ -809,17 +808,17 @@ func TestRevertOnPrepare(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um7Components := []*pb.SystemComponent{ - {Id: "um7C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um7C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um7Components := []*pb.ComponentStatus{ + {ComponentId: "um7C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um7C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um7 := newTestUM(t, "testUM7", pb.UpdateState_IDLE, "init", um7Components) go um7.processMessages() - um8Components := []*pb.SystemComponent{ - {Id: "um8C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um8C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um8Components := []*pb.ComponentStatus{ + {ComponentId: "um8C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um8C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um8 := newTestUM(t, "testUM8", pb.UpdateState_IDLE, "init", um8Components) @@ -861,7 +860,7 @@ func TestRevertOnPrepare(t *testing.T) { }() um7Components = append(um7Components, - &pb.SystemComponent{Id: "um7C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um7C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um7.setComponents(um7Components) um7.step = prepareStep @@ -870,9 +869,9 @@ func TestRevertOnPrepare(t *testing.T) { um7.sendState(pb.UpdateState_PREPARED) um8Components = append(um8Components, - &pb.SystemComponent{Id: "um8C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um8C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um8Components = append(um8Components, - &pb.SystemComponent{Id: "um8C2", VendorVersion: "2", Status: pb.ComponentStatus_ERROR}) + &pb.ComponentStatus{ComponentId: "um8C2", Version: "2.0.0", State: pb.ComponentState_ERROR}) um8.setComponents(um8Components) um8.step = prepareStep @@ -896,11 +895,11 @@ func TestRevertOnPrepare(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um7C1", VendorVersion: "1", Status: "installed"}, - {ID: "um7C2", VendorVersion: "1", Status: "installed"}, - {ID: "um8C1", VendorVersion: "1", Status: "installed"}, - {ID: "um8C2", VendorVersion: "1", Status: "installed"}, - {ID: "um8C2", VendorVersion: "2", Status: "error"}, + {ComponentID: "um7C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um7C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um8C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um8C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um8C2", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -945,17 +944,17 @@ func TestRevertOnUpdate(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um9Components := []*pb.SystemComponent{ - {Id: "um9C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um9C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um9Components := []*pb.ComponentStatus{ + {ComponentId: "um9C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um9C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um9 := newTestUM(t, "testUM9", pb.UpdateState_IDLE, "init", um9Components) go um9.processMessages() - um10Components := []*pb.SystemComponent{ - {Id: "um10C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um10C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um10Components := []*pb.ComponentStatus{ + {ComponentId: "um10C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um10 := newTestUM(t, "testUM10", pb.UpdateState_IDLE, "init", um10Components) @@ -997,7 +996,7 @@ func TestRevertOnUpdate(t *testing.T) { }() um9Components = append(um9Components, - &pb.SystemComponent{Id: "um9C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um9C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um9.setComponents(um9Components) um9.step = prepareStep @@ -1006,9 +1005,9 @@ func TestRevertOnUpdate(t *testing.T) { um9.sendState(pb.UpdateState_PREPARED) um10Components = append(um10Components, - &pb.SystemComponent{Id: "um10C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um10C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um10Components = append(um10Components, - &pb.SystemComponent{Id: "um10C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um10C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um10.setComponents(um10Components) um10.step = prepareStep @@ -1021,11 +1020,11 @@ func TestRevertOnUpdate(t *testing.T) { <-um9.notifyTestChan // um9 updated um9.sendState(pb.UpdateState_UPDATED) - um10Components = []*pb.SystemComponent{ - {Id: "um10C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um10C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um10C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}, - {Id: "um10C2", VendorVersion: "2", Status: pb.ComponentStatus_ERROR}, + um10Components = []*pb.ComponentStatus{ + {ComponentId: "um10C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}, + {ComponentId: "um10C2", Version: "2.0.0", State: pb.ComponentState_ERROR}, } um10.setComponents(um10Components) @@ -1034,9 +1033,9 @@ func TestRevertOnUpdate(t *testing.T) { <-um10.notifyTestChan // um10 updated um10.sendState(pb.UpdateState_FAILED) - um9Components = []*pb.SystemComponent{ - {Id: "um9C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um9C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um9Components = []*pb.ComponentStatus{ + {ComponentId: "um9C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um9C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um9.setComponents(um9Components) @@ -1056,11 +1055,11 @@ func TestRevertOnUpdate(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um9C1", VendorVersion: "1", Status: "installed"}, - {ID: "um9C2", VendorVersion: "1", Status: "installed"}, - {ID: "um10C1", VendorVersion: "1", Status: "installed"}, - {ID: "um10C2", VendorVersion: "1", Status: "installed"}, - {ID: "um10C2", VendorVersion: "2", Status: "error"}, + {ComponentID: "um9C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um9C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um10C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um10C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um10C2", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1105,17 +1104,17 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um11Components := []*pb.SystemComponent{ - {Id: "um11C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um11C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um11Components := []*pb.ComponentStatus{ + {ComponentId: "um11C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um11C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um11 := newTestUM(t, "testUM11", pb.UpdateState_IDLE, "init", um11Components) go um11.processMessages() - um12Components := []*pb.SystemComponent{ - {Id: "um12C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um12C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um12Components := []*pb.ComponentStatus{ + {ComponentId: "um12C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um12 := newTestUM(t, "testUM12", pb.UpdateState_IDLE, "init", um12Components) @@ -1157,7 +1156,7 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { }() um11Components = append(um11Components, - &pb.SystemComponent{Id: "um11C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um11C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um11.setComponents(um11Components) um11.step = prepareStep @@ -1166,9 +1165,9 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um11.sendState(pb.UpdateState_PREPARED) um12Components = append(um12Components, - &pb.SystemComponent{Id: "um12C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um12C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um12Components = append(um12Components, - &pb.SystemComponent{Id: "um12C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um12C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um12.setComponents(um12Components) um12.step = prepareStep @@ -1181,10 +1180,10 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { <-um11.notifyTestChan // um11 updated um11.sendState(pb.UpdateState_UPDATED) - um12Components = []*pb.SystemComponent{ - {Id: "um12C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um12C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um12C2", VendorVersion: "2", Status: pb.ComponentStatus_ERROR}, + um12Components = []*pb.ComponentStatus{ + {ComponentId: "um12C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C2", Version: "2.0.0", State: pb.ComponentState_ERROR}, } um12.setComponents(um12Components) @@ -1199,9 +1198,9 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um12 = newTestUM(t, "testUM12", pb.UpdateState_FAILED, revertStep, um12Components) go um12.processMessages() - um11Components = []*pb.SystemComponent{ - {Id: "um11C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um11C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um11Components = []*pb.ComponentStatus{ + {ComponentId: "um11C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um11C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um11.setComponents(um11Components) @@ -1221,11 +1220,11 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um11C1", VendorVersion: "1", Status: "installed"}, - {ID: "um11C2", VendorVersion: "1", Status: "installed"}, - {ID: "um12C1", VendorVersion: "1", Status: "installed"}, - {ID: "um12C2", VendorVersion: "1", Status: "installed"}, - {ID: "um12C2", VendorVersion: "2", Status: "error"}, + {ComponentID: "um11C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um11C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um12C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um12C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um12C2", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1270,17 +1269,17 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { t.Errorf("Can't create: UM controller %s", err) } - um13Components := []*pb.SystemComponent{ - {Id: "um13C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um13C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um13Components := []*pb.ComponentStatus{ + {ComponentId: "um13C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um13C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um13 := newTestUM(t, "testUM13", pb.UpdateState_IDLE, "init", um13Components) go um13.processMessages() - um14Components := []*pb.SystemComponent{ - {Id: "um14C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um14C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um14Components := []*pb.ComponentStatus{ + {ComponentId: "um14C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um14 := newTestUM(t, "testUM14", pb.UpdateState_IDLE, "init", um14Components) @@ -1322,7 +1321,7 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { }() um13Components = append(um13Components, - &pb.SystemComponent{Id: "um13C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um13C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um13.setComponents(um13Components) um13.step = prepareStep @@ -1331,9 +1330,9 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um13.sendState(pb.UpdateState_PREPARED) um14Components = append(um14Components, - &pb.SystemComponent{Id: "um14C1", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um14C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um14Components = append(um14Components, - &pb.SystemComponent{Id: "um14C2", VendorVersion: "2", Status: pb.ComponentStatus_INSTALLING}) + &pb.ComponentStatus{ComponentId: "um14C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) um14.setComponents(um14Components) um14.step = prepareStep @@ -1346,10 +1345,10 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { <-um13.notifyTestChan // um13 updated um13.sendState(pb.UpdateState_UPDATED) - um14Components = []*pb.SystemComponent{ - {Id: "um14C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um14C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um14C2", VendorVersion: "2", Status: pb.ComponentStatus_ERROR}, + um14Components = []*pb.ComponentStatus{ + {ComponentId: "um14C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C2", Version: "2.0.0", State: pb.ComponentState_ERROR}, } um14.setComponents(um14Components) @@ -1382,9 +1381,9 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um14 = newTestUM(t, "testUM14", pb.UpdateState_FAILED, revertStep, um14Components) go um14.processMessages() - um13Components = []*pb.SystemComponent{ - {Id: "um13C1", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, - {Id: "um13C2", VendorVersion: "1", Status: pb.ComponentStatus_INSTALLED}, + um13Components = []*pb.ComponentStatus{ + {ComponentId: "um13C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um13C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um13.setComponents(um13Components) @@ -1404,11 +1403,11 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { time.Sleep(time.Second) etalonComponents := []cloudprotocol.ComponentStatus{ - {ID: "um13C1", VendorVersion: "1", Status: "installed"}, - {ID: "um13C2", VendorVersion: "1", Status: "installed"}, - {ID: "um14C1", VendorVersion: "1", Status: "installed"}, - {ID: "um14C2", VendorVersion: "1", Status: "installed"}, - {ID: "um14C2", VendorVersion: "2", Status: "error"}, + {ComponentID: "um13C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um13C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um14C1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um14C2", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um14C2", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1437,11 +1436,11 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { * Interfaces **********************************************************************************************************************/ -func (storage *testStorage) GetComponentsUpdateInfo() (updateInfo []umcontroller.SystemComponent, err error) { +func (storage *testStorage) GetComponentsUpdateInfo() (updateInfo []umcontroller.ComponentStatus, err error) { return storage.updateInfo, err } -func (storage *testStorage) SetComponentsUpdateInfo(updateInfo []umcontroller.SystemComponent) (err error) { +func (storage *testStorage) SetComponentsUpdateInfo(updateInfo []umcontroller.ComponentStatus) (err error) { storage.updateInfo = updateInfo return aoserrors.Wrap(err) } @@ -1525,7 +1524,7 @@ func (context *testCryptoContext) DecryptAndValidate( * Private **********************************************************************************************************************/ -func newTestUM(t *testing.T, id string, updateStatus pb.UpdateState, testState string, components []*pb.SystemComponent) ( +func newTestUM(t *testing.T, id string, updateStatus pb.UpdateState, testState string, components []*pb.ComponentStatus) ( umTest *testUmConnection, ) { t.Helper() @@ -1550,7 +1549,7 @@ func newTestUM(t *testing.T, id string, updateStatus pb.UpdateState, testState s return umTest } -func (um *testUmConnection) setComponents(components []*pb.SystemComponent) { +func (um *testUmConnection) setComponents(components []*pb.ComponentStatus) { um.components = components } diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index 863c94fe..0bdee93e 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -43,7 +43,7 @@ type umHandler struct { } type prepareRequest struct { - components []SystemComponent + components []ComponentStatus } /*********************************************************************************************************************** @@ -151,7 +151,7 @@ func (handler *umHandler) GetInitialState() (state string) { } // Close close connection. -func (handler *umHandler) PrepareUpdate(prepareComponents []SystemComponent) (err error) { +func (handler *umHandler) PrepareUpdate(prepareComponents []ComponentStatus) (err error) { log.Debug("PrepareUpdate for UMID ", handler.umID) request := prepareRequest{components: prepareComponents} diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 011f7179..e238cfe6 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -449,7 +449,7 @@ func (descriptor *statusDescriptor) getVersion() (version string) { return amqpStatus.VendorVersion case *cloudprotocol.ComponentStatus: - return amqpStatus.VendorVersion + return amqpStatus.Version case *cloudprotocol.LayerStatus: return strconv.FormatUint(amqpStatus.AosVersion, 10) @@ -485,9 +485,9 @@ func (instance *Instance) updateComponentStatus(componentInfo cloudprotocol.Comp defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "id": componentInfo.ID, + "id": componentInfo.ComponentID, "status": componentInfo.Status, - "vendorVersion": componentInfo.VendorVersion, + "vendorVersion": componentInfo.Version, "error": componentInfo.ErrorInfo, }).Debug("Update component status") @@ -496,10 +496,10 @@ func (instance *Instance) updateComponentStatus(componentInfo cloudprotocol.Comp } func (instance *Instance) processComponentStatus(componentInfo cloudprotocol.ComponentStatus) { - componentStatus, ok := instance.componentStatuses[componentInfo.ID] + componentStatus, ok := instance.componentStatuses[componentInfo.ComponentID] if !ok { componentStatus = &itemStatus{} - instance.componentStatuses[componentInfo.ID] = componentStatus + instance.componentStatuses[componentInfo.ComponentID] = componentStatus } instance.updateStatus(componentStatus, statusDescriptor{&componentInfo}) diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index a9b59aac..070a0758 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -57,9 +57,9 @@ func TestSendInitialStatus(t *testing.T) { {VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, }, Components: []cloudprotocol.ComponentStatus{ - {ID: "comp0", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp1", VendorVersion: "1.1", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.2", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.1", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.2", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{ {ID: "layer0", Digest: "digest0", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, @@ -230,9 +230,9 @@ func TestUpdateComponents(t *testing.T) { VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus, }) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater([]cloudprotocol.ComponentStatus{ - {ID: "comp0", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -263,9 +263,9 @@ func TestUpdateComponents(t *testing.T) { expectedUnitStatus := cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ID: "comp0", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{}, @@ -296,13 +296,13 @@ func TestUpdateComponents(t *testing.T) { expectedUnitStatus = cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ID: "comp0", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, - {ID: "comp1", VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, { - ID: "comp1", VendorVersion: "2.0", Status: cloudprotocol.ErrorStatus, + ComponentID: "comp1", Version: "2.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: firmwareUpdater.UpdateError.Error()}, }, - {ID: "comp2", VendorVersion: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{}, From 2e1f1e6453db2d52ebef446b6311efacf9a17283 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 23:01:37 +0300 Subject: [PATCH 006/146] [amqphandler] Rename MessageType consts Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 42 ++++++++++++++++----------------- amqphandler/amqphandler_test.go | 38 ++++++++++++++--------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index e0573798..92ad0cd8 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -102,25 +102,25 @@ type ConnectionEventsConsumer interface { **********************************************************************************************************************/ var messageMap = map[string]func() interface{}{ //nolint:gochecknoglobals - cloudprotocol.DesiredStatusType: func() interface{} { + cloudprotocol.DesiredStatusMessageType: func() interface{} { return &cloudprotocol.DesiredStatus{} }, - cloudprotocol.RequestLogType: func() interface{} { + cloudprotocol.RequestLogMessageType: func() interface{} { return &cloudprotocol.RequestLog{} }, - cloudprotocol.StateAcceptanceType: func() interface{} { + cloudprotocol.StateAcceptanceMessageType: func() interface{} { return &cloudprotocol.StateAcceptance{} }, - cloudprotocol.UpdateStateType: func() interface{} { + cloudprotocol.UpdateStateMessageType: func() interface{} { return &cloudprotocol.UpdateState{} }, - cloudprotocol.RenewCertsNotificationType: func() interface{} { + cloudprotocol.RenewCertsNotificationMessageType: func() interface{} { return &cloudprotocol.RenewCertsNotification{} }, - cloudprotocol.IssuedUnitCertsType: func() interface{} { + cloudprotocol.IssuedUnitCertsMessageType: func() interface{} { return &cloudprotocol.IssuedUnitCerts{} }, - cloudprotocol.OverrideEnvVarsType: func() interface{} { + cloudprotocol.OverrideEnvVarsMessageType: func() interface{} { return &cloudprotocol.OverrideEnvVars{} }, } @@ -133,11 +133,11 @@ var ( ) var importantMessages = []string{ //nolint:gochecknoglobals // used as const - cloudprotocol.DesiredStatusType, cloudprotocol.StateAcceptanceType, - cloudprotocol.RenewCertsNotificationType, cloudprotocol.IssuedUnitCertsType, cloudprotocol.OverrideEnvVarsType, - cloudprotocol.NewStateType, cloudprotocol.StateRequestType, cloudprotocol.UnitStatusType, - cloudprotocol.IssueUnitCertsType, cloudprotocol.InstallUnitCertsConfirmationType, - cloudprotocol.OverrideEnvVarsStatusType, + cloudprotocol.DesiredStatusMessageType, cloudprotocol.StateAcceptanceMessageType, + cloudprotocol.RenewCertsNotificationMessageType, cloudprotocol.IssuedUnitCertsMessageType, cloudprotocol.OverrideEnvVarsMessageType, + cloudprotocol.NewStateMessageType, cloudprotocol.StateRequestMessageType, cloudprotocol.UnitStatusMessageType, + cloudprotocol.IssueUnitCertsMessageType, cloudprotocol.InstallUnitCertsConfirmationMessageType, + cloudprotocol.OverrideEnvVarsStatusMessageType, } /*********************************************************************************************************************** @@ -234,7 +234,7 @@ func (handler *AmqpHandler) SendUnitStatus(unitStatus cloudprotocol.UnitStatus) handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.UnitStatusType, unitStatus, false) + return handler.scheduleMessage(cloudprotocol.UnitStatusMessageType, unitStatus, false) } // SendMonitoringData sends monitoring data. @@ -242,7 +242,7 @@ func (handler *AmqpHandler) SendMonitoringData(monitoringData cloudprotocol.Moni handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.MonitoringDataType, monitoringData, false) + return handler.scheduleMessage(cloudprotocol.MonitoringMessageType, monitoringData, false) } // SendServiceNewState sends new state message. @@ -250,7 +250,7 @@ func (handler *AmqpHandler) SendInstanceNewState(newState cloudprotocol.NewState handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.NewStateType, newState, false) + return handler.scheduleMessage(cloudprotocol.NewStateMessageType, newState, false) } // SendServiceStateRequest sends state request message. @@ -258,7 +258,7 @@ func (handler *AmqpHandler) SendInstanceStateRequest(request cloudprotocol.State handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.StateRequestType, request, true) + return handler.scheduleMessage(cloudprotocol.StateRequestMessageType, request, true) } // SendLog sends system or service logs. @@ -266,7 +266,7 @@ func (handler *AmqpHandler) SendLog(serviceLog cloudprotocol.PushLog) error { handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.PushLogType, serviceLog, true) + return handler.scheduleMessage(cloudprotocol.PushLogMessageType, serviceLog, true) } // SendAlerts sends alerts message. @@ -274,7 +274,7 @@ func (handler *AmqpHandler) SendAlerts(alerts cloudprotocol.Alerts) error { handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.AlertsType, alerts, true) + return handler.scheduleMessage(cloudprotocol.AlertsMessageType, alerts, true) } // SendIssueUnitCerts sends request to issue new certificates. @@ -283,7 +283,7 @@ func (handler *AmqpHandler) SendIssueUnitCerts(requests []cloudprotocol.IssueCer defer handler.Unlock() return handler.scheduleMessage( - cloudprotocol.IssueUnitCertsType, cloudprotocol.IssueUnitCerts{Requests: requests}, true) + cloudprotocol.IssueUnitCertsMessageType, cloudprotocol.IssueUnitCerts{Requests: requests}, true) } // SendInstallCertsConfirmation sends install certificates confirmation. @@ -292,7 +292,7 @@ func (handler *AmqpHandler) SendInstallCertsConfirmation(confirmations []cloudpr defer handler.Unlock() return handler.scheduleMessage( - cloudprotocol.InstallUnitCertsConfirmationType, + cloudprotocol.InstallUnitCertsConfirmationMessageType, cloudprotocol.InstallUnitCertsConfirmation{Certificates: confirmations}, true) } @@ -301,7 +301,7 @@ func (handler *AmqpHandler) SendOverrideEnvVarsStatus(envs cloudprotocol.Overrid handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.OverrideEnvVarsStatusType, envs, true) + return handler.scheduleMessage(cloudprotocol.OverrideEnvVarsStatusMessageType, envs, true) } // SubscribeForConnectionEvents subscribes for connection events. diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index ab67e324..c8f58e87 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -240,21 +240,21 @@ func TestReceiveMessages(t *testing.T) { testData := []testDataType{ { - messageType: cloudprotocol.StateAcceptanceType, + messageType: cloudprotocol.StateAcceptanceMessageType, expectedData: &cloudprotocol.StateAcceptance{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj0", Instance: 1}, Checksum: "0123456890", Result: "accepted", Reason: "just because", }, }, { - messageType: cloudprotocol.UpdateStateType, + messageType: cloudprotocol.UpdateStateMessageType, expectedData: &cloudprotocol.UpdateState{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "subj1", Instance: 1}, Checksum: "0993478847", State: "This is new state", }, }, { - messageType: cloudprotocol.RequestLogType, + messageType: cloudprotocol.RequestLogMessageType, expectedData: &cloudprotocol.RequestLog{ LogID: "someID", LogType: cloudprotocol.ServiceLog, @@ -265,7 +265,7 @@ func TestReceiveMessages(t *testing.T) { }, }, { - messageType: cloudprotocol.RequestLogType, + messageType: cloudprotocol.RequestLogMessageType, expectedData: &cloudprotocol.RequestLog{ LogID: "someID", LogType: cloudprotocol.CrashLog, @@ -276,7 +276,7 @@ func TestReceiveMessages(t *testing.T) { }, }, { - messageType: cloudprotocol.RequestLogType, + messageType: cloudprotocol.RequestLogMessageType, expectedData: &cloudprotocol.RequestLog{ LogID: "someID", LogType: cloudprotocol.SystemLog, @@ -286,7 +286,7 @@ func TestReceiveMessages(t *testing.T) { }, }, { - messageType: cloudprotocol.RenewCertsNotificationType, + messageType: cloudprotocol.RenewCertsNotificationMessageType, expectedData: &cloudprotocol.RenewCertsNotification{ Certificates: []cloudprotocol.RenewCertData{ {Type: "online", Serial: "1234", ValidTill: testTime}, @@ -297,7 +297,7 @@ func TestReceiveMessages(t *testing.T) { }, }, { - messageType: cloudprotocol.IssuedUnitCertsType, + messageType: cloudprotocol.IssuedUnitCertsMessageType, expectedData: &cloudprotocol.IssuedUnitCerts{ Certificates: []cloudprotocol.IssuedCertData{ {Type: "online", NodeID: "mainNode", CertificateChain: "123456"}, @@ -305,11 +305,11 @@ func TestReceiveMessages(t *testing.T) { }, }, { - messageType: cloudprotocol.OverrideEnvVarsType, + messageType: cloudprotocol.OverrideEnvVarsMessageType, expectedData: &cloudprotocol.OverrideEnvVars{OverrideEnvVars: []cloudprotocol.EnvVarsInstanceInfo{}}, }, { - messageType: cloudprotocol.DesiredStatusType, + messageType: cloudprotocol.DesiredStatusMessageType, expectedData: &cloudprotocol.DesiredStatus{ UnitConfig: json.RawMessage([]byte("\"config\"")), Components: []cloudprotocol.ComponentInfo{ @@ -536,7 +536,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.UnitStatusType, + MessageType: cloudprotocol.UnitStatusMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -560,7 +560,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.MonitoringDataType, + MessageType: cloudprotocol.MonitoringMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -581,7 +581,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.NewStateType, + MessageType: cloudprotocol.NewStateMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -604,7 +604,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.StateRequestType, + MessageType: cloudprotocol.StateRequestMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -623,7 +623,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.PushLogType, + MessageType: cloudprotocol.PushLogMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -645,7 +645,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.AlertsType, + MessageType: cloudprotocol.AlertsMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -661,7 +661,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.IssueUnitCertsType, + MessageType: cloudprotocol.IssueUnitCertsMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -677,7 +677,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.InstallUnitCertsConfirmationType, + MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -693,7 +693,7 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.OverrideEnvVarsStatusType, + MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType, SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, @@ -935,7 +935,7 @@ func TestSendDisconnectMessages(t *testing.T) { continue } - if message.Header.MessageType != cloudprotocol.AlertsType { + if message.Header.MessageType != cloudprotocol.AlertsMessageType { t.Errorf("Wrong message type: %s", message.Header.MessageType) } From 6137baa69b5b899e9f2c8372875c0d66b4e71e28 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 23:48:09 +0300 Subject: [PATCH 007/146] [all] Renam aostypes.UnitConfig to cloudprotocol.UnitConfig Signed-off-by: Mykola Kobets --- smcontroller/smcontroller.go | 4 ++-- smcontroller/smcontroller_test.go | 4 ++-- unitconfig/unitconfig.go | 16 ++++++++-------- unitconfig/unitconfig_test.go | 5 ++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 8c98ad83..ccb11da8 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -194,7 +194,7 @@ func (controller *Controller) GetUnitConfigStatus(nodeID string) (string, error) } // CheckUnitConfig checks unit config for the node. -func (controller *Controller) CheckUnitConfig(unitConfig aostypes.UnitConfig) error { +func (controller *Controller) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) error { for _, nodeConfig := range unitConfig.Nodes { for _, node := range controller.nodes { if node == nil { @@ -214,7 +214,7 @@ func (controller *Controller) CheckUnitConfig(unitConfig aostypes.UnitConfig) er } // SetUnitConfig sets unit config for the node. -func (controller *Controller) SetUnitConfig(unitConfig aostypes.UnitConfig) error { +func (controller *Controller) SetUnitConfig(unitConfig cloudprotocol.UnitConfig) error { for _, nodeConfig := range unitConfig.Nodes { for _, node := range controller.nodes { if node == nil { diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 5989de17..6f271e6a 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -290,7 +290,7 @@ func TestUnitConfigMessages(t *testing.T) { <-testWaitChan go func() { - if err := controller.CheckUnitConfig(aostypes.UnitConfig{ + if err := controller.CheckUnitConfig(cloudprotocol.UnitConfig{ VendorVersion: newVersion, Nodes: []aostypes.NodeUnitConfig{ { @@ -319,7 +319,7 @@ func TestUnitConfigMessages(t *testing.T) { <-testWaitChan go func() { - if err := controller.SetUnitConfig(aostypes.UnitConfig{ + if err := controller.SetUnitConfig(cloudprotocol.UnitConfig{ VendorVersion: newVersion, Nodes: []aostypes.NodeUnitConfig{ { diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 746e85cc..e3caedd3 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -40,14 +40,14 @@ type Instance struct { client Client unitConfigFile string - unitConfig aostypes.UnitConfig + unitConfig cloudprotocol.UnitConfig unitConfigError error } // Client client unit config interface. type Client interface { - CheckUnitConfig(unitConfig aostypes.UnitConfig) (err error) - SetUnitConfig(unitConfig aostypes.UnitConfig) (err error) + CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) + SetUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) } // ErrAlreadyInstalled error to detect that unit config with the same version already installed. @@ -74,7 +74,7 @@ func (instance *Instance) GetStatus() (unitConfigInfo cloudprotocol.UnitConfigSt instance.Lock() defer instance.Unlock() - unitConfigInfo.VendorVersion = instance.unitConfig.VendorVersion + unitConfigInfo.Version = instance.unitConfig.VendorVersion unitConfigInfo.Status = cloudprotocol.InstalledStatus if instance.unitConfigError != nil { @@ -87,7 +87,7 @@ func (instance *Instance) GetStatus() (unitConfigInfo cloudprotocol.UnitConfigSt // GetUnitConfigVersion returns unit config version. func (instance *Instance) GetUnitConfigVersion(configJSON json.RawMessage) (vendorVersion string, err error) { - unitConfig := aostypes.UnitConfig{VendorVersion: "unknown"} + unitConfig := cloudprotocol.UnitConfig{VendorVersion: "unknown"} if err = json.Unmarshal(configJSON, &unitConfig); err != nil { return unitConfig.VendorVersion, aoserrors.Wrap(err) @@ -101,7 +101,7 @@ func (instance *Instance) CheckUnitConfig(configJSON json.RawMessage) (vendorVer instance.Lock() defer instance.Unlock() - unitConfig := aostypes.UnitConfig{VendorVersion: "unknown"} + unitConfig := cloudprotocol.UnitConfig{VendorVersion: "unknown"} if err = json.Unmarshal(configJSON, &unitConfig); err != nil { return unitConfig.VendorVersion, aoserrors.Wrap(err) @@ -129,7 +129,7 @@ func (instance *Instance) UpdateUnitConfig(configJSON json.RawMessage) (err erro instance.Lock() defer instance.Unlock() - unitConfig := aostypes.UnitConfig{VendorVersion: "unknown"} + unitConfig := cloudprotocol.UnitConfig{VendorVersion: "unknown"} if err = json.Unmarshal(configJSON, &unitConfig); err != nil { return aoserrors.Wrap(err) @@ -177,7 +177,7 @@ func (instance *Instance) load() (err error) { return nil } -func (instance *Instance) checkUnitConfig(unitConfig aostypes.UnitConfig) (vendorVersion string, err error) { +func (instance *Instance) checkUnitConfig(unitConfig cloudprotocol.UnitConfig) (vendorVersion string, err error) { if unitConfig.VendorVersion == instance.unitConfig.VendorVersion { return unitConfig.VendorVersion, ErrAlreadyInstalled } diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index ea93de8d..12f52607 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -23,7 +23,6 @@ import ( "path" "testing" - "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/unitconfig" @@ -236,10 +235,10 @@ func TestUpdateUnitConfig(t *testing.T) { * testClient **********************************************************************************************************************/ -func (client *testClient) CheckUnitConfig(unitConfig aostypes.UnitConfig) (err error) { +func (client *testClient) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) { return nil } -func (client *testClient) SetUnitConfig(unitConfig aostypes.UnitConfig) (err error) { +func (client *testClient) SetUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) { return nil } From 9c51d441444d919a492c1b86fd21160a5a84c4dc Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 23:58:12 +0300 Subject: [PATCH 008/146] [all] Rename aostypes.NodeUnitConfig to cloudprotocol.NodeConfig Signed-off-by: Mykola Kobets --- launcher/launcher.go | 2 +- launcher/launcher_test.go | 50 +++++++++++++++---------------- smcontroller/smcontroller_test.go | 6 ++-- smcontroller/smhandler.go | 8 ++--- unitconfig/unitconfig.go | 5 ++-- 5 files changed, 35 insertions(+), 36 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 72bfad01..ecfec67d 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -146,7 +146,7 @@ type NodeManager interface { // ResourceManager provides node resources. type ResourceManager interface { - GetUnitConfiguration(nodeType string) aostypes.NodeUnitConfig + GetUnitConfiguration(nodeType string) cloudprotocol.NodeConfig } // StorageStateProvider instances storage state provider. diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 9e2ba4a8..1fc4f19b 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -107,7 +107,7 @@ type testImageProvider struct { } type testResourceManager struct { - nodeResources map[string]aostypes.NodeUnitConfig + nodeResources map[string]cloudprotocol.NodeConfig } type testStorage struct { @@ -445,7 +445,7 @@ func TestBalancing(t *testing.T) { } type testData struct { - nodeResources map[string]aostypes.NodeUnitConfig + nodeResources map[string]cloudprotocol.NodeConfig serviceConfigs map[string]aostypes.ServiceConfig desiredInstances []cloudprotocol.InstanceInfo expectedRunRequests map[string]runRequest @@ -456,7 +456,7 @@ func TestBalancing(t *testing.T) { // Check node priority and runner: all service instances should be start on higher priority node according to // supported runner { - nodeResources: map[string]aostypes.NodeUnitConfig{ + nodeResources: map[string]cloudprotocol.NodeConfig{ nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, @@ -544,7 +544,7 @@ func TestBalancing(t *testing.T) { }, // Check labels: label low priority service to run on high priority node { - nodeResources: map[string]aostypes.NodeUnitConfig{ + nodeResources: map[string]cloudprotocol.NodeConfig{ nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Labels: []string{"label1"}}, nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}}, nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, @@ -623,14 +623,14 @@ func TestBalancing(t *testing.T) { }, // Check available resources { - nodeResources: map[string]aostypes.NodeUnitConfig{ - nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Resources: []aostypes.ResourceInfo{ + nodeResources: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Resources: []cloudprotocol.ResourceInfo{ {Name: "resource1"}, {Name: "resource3"}, }}, nodeTypeRemoteSM: { NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}, - Resources: []aostypes.ResourceInfo{ + Resources: []cloudprotocol.ResourceInfo{ {Name: "resource1"}, {Name: "resource2"}, }, @@ -711,17 +711,17 @@ func TestBalancing(t *testing.T) { }, // Check available devices { - nodeResources: map[string]aostypes.NodeUnitConfig{ - nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Devices: []aostypes.DeviceInfo{ + nodeResources: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Devices: []cloudprotocol.DeviceInfo{ {Name: "dev1", SharedCount: 1}, {Name: "dev2", SharedCount: 2}, {Name: "dev3"}, }}, - nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Devices: []aostypes.DeviceInfo{ + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Devices: []cloudprotocol.DeviceInfo{ {Name: "dev1", SharedCount: 1}, {Name: "dev2", SharedCount: 3}, }, Labels: []string{"label2"}}, - nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0, Devices: []aostypes.DeviceInfo{ + nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0, Devices: []cloudprotocol.DeviceInfo{ {Name: "dev1", SharedCount: 1}, {Name: "dev2", SharedCount: 2}, }}, @@ -892,7 +892,7 @@ func TestServiceRevert(t *testing.T) { NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, RemoteNode: false, } - resourceManager.nodeResources[nodeTypeLocalSM] = aostypes.NodeUnitConfig{NodeType: nodeTypeLocalSM, Priority: 100} + resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{NodeType: nodeTypeLocalSM, Priority: 100} imageManager.services = map[string]imagemanager.ServiceInfo{ service1: { @@ -993,13 +993,13 @@ func TestStorageCleanup(t *testing.T) { RemoteNode: false, RunnerFeature: []string{runnerRunc}, } - resourceManager.nodeResources[nodeTypeLocalSM] = aostypes.NodeUnitConfig{Priority: 100} + resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{Priority: 100} nodeManager.nodeInformation[nodeIDRunxSM] = launcher.NodeInfo{ NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeRunxSM}, RemoteNode: true, RunnerFeature: []string{runnerRunx}, } - resourceManager.nodeResources[nodeTypeRunxSM] = aostypes.NodeUnitConfig{Priority: 0} + resourceManager.nodeResources[nodeTypeRunxSM] = cloudprotocol.NodeConfig{Priority: 0} imageManager.services = map[string]imagemanager.ServiceInfo{ service1: { @@ -1149,9 +1149,9 @@ func TestRebalancing(t *testing.T) { RemoteNode: false, RunnerFeature: []string{runnerRunc, "crun"}, } - resourceManager.nodeResources[nodeTypeLocalSM] = aostypes.NodeUnitConfig{ + resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ Priority: 100, - NodeType: nodeTypeLocalSM, Devices: []aostypes.DeviceInfo{ + NodeType: nodeTypeLocalSM, Devices: []cloudprotocol.DeviceInfo{ {Name: "dev1", SharedCount: 1}, }, } @@ -1166,13 +1166,13 @@ func TestRebalancing(t *testing.T) { RemoteNode: true, RunnerFeature: []string{runnerRunc}, } - resourceManager.nodeResources[nodeTypeRemoteSM] = aostypes.NodeUnitConfig{ + resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ Priority: 50, NodeType: nodeTypeRemoteSM, - Devices: []aostypes.DeviceInfo{ + Devices: []cloudprotocol.DeviceInfo{ {Name: "dev1", SharedCount: 2}, }, - Resources: []aostypes.ResourceInfo{{Name: "resource1"}}, + Resources: []cloudprotocol.ResourceInfo{{Name: "resource1"}}, } launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeManager, imageManager, resourceManager, @@ -1402,7 +1402,7 @@ func TestRebalancingSameNodePriority(t *testing.T) { NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, RemoteNode: false, } - resourceManager.nodeResources[nodeTypeLocalSM] = aostypes.NodeUnitConfig{ + resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeLocalSM, Labels: []string{"label1"}, } @@ -1411,7 +1411,7 @@ func TestRebalancingSameNodePriority(t *testing.T) { NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM}, RemoteNode: true, } - resourceManager.nodeResources[nodeTypeRemoteSM] = aostypes.NodeUnitConfig{ + resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeRemoteSM, Labels: []string{"label2"}, } @@ -1638,7 +1638,7 @@ func TestRebalancingAfterRestart(t *testing.T) { NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, RemoteNode: false, } - resourceManager.nodeResources[nodeTypeLocalSM] = aostypes.NodeUnitConfig{ + resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeLocalSM, Labels: []string{"label1"}, } @@ -1647,7 +1647,7 @@ func TestRebalancingAfterRestart(t *testing.T) { NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM}, RemoteNode: true, } - resourceManager.nodeResources[nodeTypeRemoteSM] = aostypes.NodeUnitConfig{ + resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeRemoteSM, Labels: []string{"label2"}, } @@ -1918,13 +1918,13 @@ func (nodeManager *testNodeManager) compareRunRequests(expectedRunRequests map[s func newTestResourceManager() *testResourceManager { resourceManager := &testResourceManager{ - nodeResources: make(map[string]aostypes.NodeUnitConfig), + nodeResources: make(map[string]cloudprotocol.NodeConfig), } return resourceManager } -func (resourceManager *testResourceManager) GetUnitConfiguration(nodeType string) aostypes.NodeUnitConfig { +func (resourceManager *testResourceManager) GetUnitConfiguration(nodeType string) cloudprotocol.NodeConfig { resource := resourceManager.nodeResources[nodeType] resource.NodeType = nodeType diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 6f271e6a..b74d0ea7 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -291,8 +291,8 @@ func TestUnitConfigMessages(t *testing.T) { go func() { if err := controller.CheckUnitConfig(cloudprotocol.UnitConfig{ - VendorVersion: newVersion, - Nodes: []aostypes.NodeUnitConfig{ + Version: newVersion, + Nodes: []cloudprotocol.NodeConfig{ { NodeType: nodeType, }, @@ -321,7 +321,7 @@ func TestUnitConfigMessages(t *testing.T) { go func() { if err := controller.SetUnitConfig(cloudprotocol.UnitConfig{ VendorVersion: newVersion, - Nodes: []aostypes.NodeUnitConfig{ + Nodes: []cloudprotocol.NodeConfig{ { NodeType: nodeType, }, diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index e12d228b..e423d960 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -108,7 +108,7 @@ func (handler *smHandler) getUnitConfigState() (vendorVersion string, err error) return pbStatus.UnitConfigStatus.GetVendorVersion(), nil } -func (handler *smHandler) checkUnitConfigState(cfg aostypes.NodeUnitConfig, vendorVersion string) error { +func (handler *smHandler) checkUnitConfigState(cfg cloudprotocol.NodeConfig, vendorVersion string) error { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() @@ -131,7 +131,7 @@ func (handler *smHandler) checkUnitConfigState(cfg aostypes.NodeUnitConfig, vend return nil } -func (handler *smHandler) setUnitConfig(cfg aostypes.NodeUnitConfig, vendorVersion string) error { +func (handler *smHandler) setUnitConfig(cfg cloudprotocol.NodeConfig, vendorVersion string) error { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() @@ -617,7 +617,7 @@ func (handler *smHandler) sendGetUnitConfigStatus() error { return nil } -func (handler *smHandler) sendCheckUnitConfig(cfg aostypes.NodeUnitConfig, vendorVersion string) error { +func (handler *smHandler) sendCheckUnitConfig(cfg cloudprotocol.NodeConfig, vendorVersion string) error { configJSON, err := json.Marshal(cfg) if err != nil { return aoserrors.Wrap(err) @@ -632,7 +632,7 @@ func (handler *smHandler) sendCheckUnitConfig(cfg aostypes.NodeUnitConfig, vendo return nil } -func (handler *smHandler) sendSetUnitConfig(cfg aostypes.NodeUnitConfig, vendorVersion string) error { +func (handler *smHandler) sendSetUnitConfig(cfg cloudprotocol.NodeConfig, vendorVersion string) error { configJSON, err := json.Marshal(cfg) if err != nil { return aoserrors.Wrap(err) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index e3caedd3..50b8696a 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -24,7 +24,6 @@ import ( "sync" "github.com/aosedge/aos_common/aoserrors" - "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_communicationmanager/config" @@ -114,14 +113,14 @@ func (instance *Instance) CheckUnitConfig(configJSON json.RawMessage) (vendorVer return vendorVersion, nil } -func (instance *Instance) GetUnitConfiguration(nodeType string) aostypes.NodeUnitConfig { +func (instance *Instance) GetUnitConfiguration(nodeType string) cloudprotocol.NodeConfig { for _, node := range instance.unitConfig.Nodes { if node.NodeType == nodeType { return node } } - return aostypes.NodeUnitConfig{} + return cloudprotocol.NodeConfig{} } // UpdateUnitConfig updates unit config. From f9b7dfafde95eb94972d56145988c79c4698d315 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 00:32:57 +0300 Subject: [PATCH 009/146] [all] Adapt UnitConfigStatus Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 2 +- cmserver/cmserver_test.go | 2 +- smcontroller/smcontroller_test.go | 12 ++++++------ smcontroller/smhandler.go | 14 +++++++------- unitconfig/unitconfig.go | 2 +- unitstatushandler/firmwaremanager.go | 6 +++--- unitstatushandler/unitstatushandler.go | 14 +++++++------- unitstatushandler/unitstatushandler_test.go | 20 ++++++++++---------- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index c8f58e87..d3a09007 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -373,7 +373,7 @@ func TestSendMessages(t *testing.T) { getDataType func() interface{} } - unitConfigData := []cloudprotocol.UnitConfigStatus{{VendorVersion: "1.0"}} + unitConfigData := []cloudprotocol.UnitConfigStatus{{Version: "1.0"}} serviceSetupData := []cloudprotocol.ServiceStatus{ {ID: "service0", AosVersion: 1, Status: "running", ErrorInfo: nil}, diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 12a96f4c..518f5c9a 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -127,7 +127,7 @@ func TestConnection(t *testing.T) { statusFotaNotification := cmserver.UpdateFOTAStatus{ Components: []cloudprotocol.ComponentStatus{{ComponentID: "1234", Version: "123.4321"}}, - UnitConfig: &cloudprotocol.UnitConfigStatus{VendorVersion: "bc_version"}, + UnitConfig: &cloudprotocol.UnitConfigStatus{Version: "bc_version"}, UpdateStatus: cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, } diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index b74d0ea7..9e05542b 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -233,7 +233,7 @@ func TestUnitConfigMessages(t *testing.T) { testWaitChan = make(chan struct{}) originalVersion = "version_1" configStatus = &pb.SMOutgoingMessages{SMOutgoingMessage: &pb.SMOutgoingMessages_UnitConfigStatus{ - UnitConfigStatus: &pb.UnitConfigStatus{VendorVersion: originalVersion}, + UnitConfigStatus: &pb.UnitConfigStatus{Version: originalVersion}, }} newVersion = "version_2" unitConfig = fmt.Sprintf(`{"nodeType":"%s"}`, nodeType) @@ -305,12 +305,12 @@ func TestUnitConfigMessages(t *testing.T) { }() if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_CheckUnitConfig{ - CheckUnitConfig: &pb.CheckUnitConfig{UnitConfig: unitConfig, VendorVersion: newVersion}, + CheckUnitConfig: &pb.CheckUnitConfig{UnitConfig: unitConfig, Version: newVersion}, }}, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - configStatus.GetUnitConfigStatus().VendorVersion = newVersion + configStatus.GetUnitConfigStatus().Version = newVersion if err := smClient.stream.Send(configStatus); err != nil { t.Errorf("Can't send unit config status") @@ -320,7 +320,7 @@ func TestUnitConfigMessages(t *testing.T) { go func() { if err := controller.SetUnitConfig(cloudprotocol.UnitConfig{ - VendorVersion: newVersion, + Version: newVersion, Nodes: []cloudprotocol.NodeConfig{ { NodeType: nodeType, @@ -334,12 +334,12 @@ func TestUnitConfigMessages(t *testing.T) { }() if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SetUnitConfig{ - SetUnitConfig: &pb.SetUnitConfig{UnitConfig: unitConfig, VendorVersion: newVersion}, + SetUnitConfig: &pb.SetUnitConfig{UnitConfig: unitConfig, Version: newVersion}, }}, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - configStatus.GetUnitConfigStatus().VendorVersion = newVersion + configStatus.GetUnitConfigStatus().Version = newVersion if err := smClient.stream.Send(configStatus); err != nil { t.Errorf("Can't send unit config status") diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index e423d960..2bd413ec 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -101,11 +101,11 @@ func (handler *smHandler) getUnitConfigState() (vendorVersion string, err error) return "", aoserrors.New("incorrect type") } - if pbStatus.UnitConfigStatus.GetError() != "" { - return vendorVersion, aoserrors.New(pbStatus.UnitConfigStatus.GetError()) + if pbStatus.UnitConfigStatus.GetError().GetMessage() != "" { + return vendorVersion, aoserrors.New(pbStatus.UnitConfigStatus.GetError().GetMessage()) } - return pbStatus.UnitConfigStatus.GetVendorVersion(), nil + return pbStatus.UnitConfigStatus.GetVersion(), nil } func (handler *smHandler) checkUnitConfigState(cfg cloudprotocol.NodeConfig, vendorVersion string) error { @@ -124,8 +124,8 @@ func (handler *smHandler) checkUnitConfigState(cfg cloudprotocol.NodeConfig, ven return aoserrors.New("incorrect type") } - if pbStatus.UnitConfigStatus.GetError() != "" { - return aoserrors.New(pbStatus.UnitConfigStatus.GetError()) + if pbStatus.UnitConfigStatus.GetError().GetMessage() != "" { + return aoserrors.New(pbStatus.UnitConfigStatus.GetError().GetMessage()) } return nil @@ -147,8 +147,8 @@ func (handler *smHandler) setUnitConfig(cfg cloudprotocol.NodeConfig, vendorVers return aoserrors.New("incorrect type") } - if pbStatus.UnitConfigStatus.GetError() != "" { - return aoserrors.New(pbStatus.UnitConfigStatus.GetError()) + if pbStatus.UnitConfigStatus.GetError().GetMessage() != "" { + return aoserrors.New(pbStatus.UnitConfigStatus.GetError().GetMessage()) } return nil diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 50b8696a..36e296be 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -73,7 +73,7 @@ func (instance *Instance) GetStatus() (unitConfigInfo cloudprotocol.UnitConfigSt instance.Lock() defer instance.Unlock() - unitConfigInfo.Version = instance.unitConfig.VendorVersion + unitConfigInfo.Version = instance.unitConfig.Version unitConfigInfo.Status = cloudprotocol.InstalledStatus if instance.unitConfigError != nil { diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 73a9f518..94fee072 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -166,7 +166,7 @@ func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTASt if len(manager.CurrentUpdate.UnitConfig) != 0 { version, _ := manager.unitConfigUpdater.GetUnitConfigVersion(manager.CurrentUpdate.UnitConfig) - status.UnitConfig = &cloudprotocol.UnitConfigStatus{VendorVersion: version} + status.UnitConfig = &cloudprotocol.UnitConfigStatus{Version: version} } return status @@ -373,11 +373,11 @@ func (manager *firmwareManager) download(ctx context.Context) { manager.DownloadResult = nil if len(manager.CurrentUpdate.UnitConfig) != 0 { - manager.UnitConfigStatus.VendorVersion = "" + manager.UnitConfigStatus.Version = "" version, err := manager.unitConfigUpdater.GetUnitConfigVersion(manager.CurrentUpdate.UnitConfig) - manager.UnitConfigStatus.VendorVersion = version + manager.UnitConfigStatus.Version = version if err != nil { log.Errorf("Error getting unit config version: %s", err) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index e238cfe6..2efd345c 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -350,9 +350,9 @@ func (instance *Instance) initCurrentStatus() error { for _, status := range unitConfigStatuses { log.WithFields(log.Fields{ - "status": status.Status, - "vendorVersion": status.VendorVersion, - "error": status.ErrorInfo, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Initial unit config status") instance.processUnitConfigStatus(status) @@ -446,7 +446,7 @@ func (descriptor *statusDescriptor) getStatus() (status string) { func (descriptor *statusDescriptor) getVersion() (version string) { switch amqpStatus := descriptor.amqpStatus.(type) { case *cloudprotocol.UnitConfigStatus: - return amqpStatus.VendorVersion + return amqpStatus.Version case *cloudprotocol.ComponentStatus: return amqpStatus.Version @@ -467,9 +467,9 @@ func (instance *Instance) updateUnitConfigStatus(unitConfigInfo cloudprotocol.Un defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "status": unitConfigInfo.Status, - "vendorVersion": unitConfigInfo.VendorVersion, - "error": unitConfigInfo.ErrorInfo, + "status": unitConfigInfo.Status, + "version": unitConfigInfo.Version, + "error": unitConfigInfo.ErrorInfo, }).Debug("Update unit config status") instance.processUnitConfigStatus(unitConfigInfo) diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 070a0758..5408d9f4 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -54,7 +54,7 @@ func TestSendInitialStatus(t *testing.T) { expectedUnitStatus := cloudprotocol.UnitStatus{ UnitSubjects: []string{"subject1"}, UnitConfig: []cloudprotocol.UnitConfigStatus{ - {VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}, + {Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, Components: []cloudprotocol.ComponentStatus{ {ComponentID: "comp0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -152,7 +152,7 @@ func TestSendInitialStatus(t *testing.T) { func TestUpdateUnitConfig(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) fotaUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) sotaUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -181,7 +181,7 @@ func TestUpdateUnitConfig(t *testing.T) { // success update unitConfigUpdater.UnitConfigStatus = cloudprotocol.UnitConfigStatus{ - VendorVersion: "1.1", Status: cloudprotocol.InstalledStatus, + Version: "1.1", Status: cloudprotocol.InstalledStatus, } expectedUnitStatus := cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, @@ -209,7 +209,7 @@ func TestUpdateUnitConfig(t *testing.T) { unitConfigUpdater.UpdateError = aoserrors.New("some error occurs") unitConfigUpdater.UnitConfigStatus = cloudprotocol.UnitConfigStatus{ - VendorVersion: "1.2", Status: cloudprotocol.ErrorStatus, + Version: "1.2", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: unitConfigUpdater.UpdateError.Error()}, } expectedUnitStatus.UnitConfig = append(expectedUnitStatus.UnitConfig, unitConfigUpdater.UnitConfigStatus) @@ -227,7 +227,7 @@ func TestUpdateUnitConfig(t *testing.T) { func TestUpdateComponents(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater(cloudprotocol.UnitConfigStatus{ - VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus, + Version: "1.0", Status: cloudprotocol.InstalledStatus, }) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater([]cloudprotocol.ComponentStatus{ {ComponentID: "comp0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -338,7 +338,7 @@ func TestUpdateLayers(t *testing.T) { }}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, layerStatuses) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -495,7 +495,7 @@ func TestUpdateServices(t *testing.T) { }}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(serviceStatuses, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -642,7 +642,7 @@ func TestUpdateServices(t *testing.T) { func TestRunInstances(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -758,7 +758,7 @@ func TestRunInstances(t *testing.T) { func TestUpdateInstancesStatus(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -866,7 +866,7 @@ func TestUpdateCachedSOTA(t *testing.T) { }, Cached: true}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{VendorVersion: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(serviceStatuses, layerStatuses) instanceRunner := unitstatushandler.NewTestInstanceRunner() From 1a7f0fa8b56572df806b8a87d25b9ecb8bddfdb7 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 02:02:03 +0300 Subject: [PATCH 010/146] [all] LayerInfo adaptation Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 2 +- cmserver/cmserver.go | 8 ++-- database/database.go | 19 ++++----- database/database_internal_test.go | 24 +++++------ imagemanager/imagemanager.go | 23 ++++++----- imagemanager/imagemanager_test.go | 26 ++++++------ launcher/launcher_test.go | 6 +-- smcontroller/smcontroller.go | 4 +- smcontroller/smcontroller_test.go | 12 +++--- smcontroller/smhandler.go | 9 +---- unitconfig/unitconfig.go | 22 +++++------ unitstatushandler/softwaremanager.go | 16 ++++---- unitstatushandler/unitstatushandler_test.go | 44 ++++++++++----------- 13 files changed, 99 insertions(+), 116 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index d3a09007..47de9d53 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -316,7 +316,7 @@ func TestReceiveMessages(t *testing.T) { {Version: "1.0.0", ComponentID: "rootfs"}, }, Layers: []cloudprotocol.LayerInfo{ - {VersionInfo: aostypes.VersionInfo{AosVersion: 1}, ID: "l1", Digest: "digest"}, + {Version: "1.0", LayerID: "l1", Digest: "digest"}, }, Services: []cloudprotocol.ServiceInfo{ {VersionInfo: aostypes.VersionInfo{AosVersion: 1}, ID: "serv1", ProviderID: "p1"}, diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index 7d689311..61842a00 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -324,15 +324,15 @@ func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSO for _, layer := range updateStatus.InstallLayers { pbStatus.InstallLayers = append(pbStatus.GetInstallLayers(), &pb.LayerInfo{ - Id: layer.ID, - AosVersion: layer.AosVersion, Digest: layer.Digest, + LayerId: layer.LayerID, + Version: layer.Version, Digest: layer.Digest, }) } for _, layer := range updateStatus.RemoveLayers { pbStatus.RemoveLayers = append(pbStatus.GetRemoveLayers(), &pb.LayerInfo{ - Id: layer.ID, - AosVersion: layer.AosVersion, Digest: layer.Digest, + LayerId: layer.LayerID, + Version: layer.Version, Digest: layer.Digest, }) } diff --git a/database/database.go b/database/database.go index f22de1e8..d0cc21aa 100644 --- a/database/database.go +++ b/database/database.go @@ -470,8 +470,8 @@ func (db *Database) GetLayersInfo() ([]imagemanager.LayerInfo, error) { // GetLayerInfo returns layer info by ID. func (db *Database) GetLayerInfo(digest string) (layer imagemanager.LayerInfo, err error) { if err = db.getDataFromQuery("SELECT * FROM layers WHERE digest = ?", - []any{digest}, &layer.Digest, &layer.ID, &layer.AosVersion, &layer.VendorVersion, &layer.Description, - &layer.URL, &layer.RemoteURL, &layer.Path, &layer.Size, &layer.Timestamp, &layer.Sha256, &layer.Sha512, + []any{digest}, &layer.Digest, &layer.LayerID, &layer.Version, + &layer.URL, &layer.RemoteURL, &layer.Path, &layer.Size, &layer.Timestamp, &layer.Sha256, &layer.Cached); err != nil { if errors.Is(err, errNotExist) { return layer, imagemanager.ErrNotExist @@ -485,9 +485,9 @@ func (db *Database) GetLayerInfo(digest string) (layer imagemanager.LayerInfo, e // AddLayer adds new layer. func (db *Database) AddLayer(layer imagemanager.LayerInfo) error { - return db.executeQuery("INSERT INTO layers values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - layer.Digest, layer.ID, layer.AosVersion, layer.VendorVersion, layer.Description, layer.URL, layer.RemoteURL, - layer.Path, layer.Size, layer.Timestamp, layer.Sha256, layer.Sha512, layer.Cached) + return db.executeQuery("INSERT INTO layers values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + layer.Digest, layer.LayerID, layer.Version, layer.URL, layer.RemoteURL, + layer.Path, layer.Size, layer.Timestamp, layer.Sha256, layer.Cached) } // SetLayerCached sets cached status for the layer. @@ -878,16 +878,13 @@ func (db *Database) createLayersTable() (err error) { _, err = db.sql.Exec(`CREATE TABLE IF NOT EXISTS layers (digest TEXT NOT NULL PRIMARY KEY, layerId TEXT, - aosVersion INTEGER, - vendorVersion TEXT, - description TEXT, + version TEXT, localURL TEXT, remoteURL TEXT, Path TEXT, Size INTEGER, Timestamp TIMESTAMP, sha256 BLOB, - sha512 BLOB, cached INTEGER)`) return aoserrors.Wrap(err) @@ -1057,8 +1054,8 @@ func (db *Database) getLayersFromQuery( var layer imagemanager.LayerInfo if err = rows.Scan( - &layer.Digest, &layer.ID, &layer.AosVersion, &layer.VendorVersion, &layer.Description, - &layer.URL, &layer.RemoteURL, &layer.Path, &layer.Size, &layer.Timestamp, &layer.Sha256, &layer.Sha512, + &layer.Digest, &layer.LayerID, &layer.Version, + &layer.URL, &layer.RemoteURL, &layer.Path, &layer.Size, &layer.Timestamp, &layer.Sha256, &layer.Cached); err != nil { return layers, aoserrors.Wrap(err) } diff --git a/database/database_internal_test.go b/database/database_internal_test.go index 5c0b53e9..301dee7b 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -410,13 +410,11 @@ func TestLayerStore(t *testing.T) { { layer: imagemanager.LayerInfo{ LayerInfo: aostypes.LayerInfo{ - VersionInfo: aostypes.VersionInfo{ - AosVersion: 1, - }, - ID: "layer1", - Digest: "digest1", - URL: "file:///path/layer1", - Size: 30, + Version: "1.0", + LayerID: "layer1", + Digest: "digest1", + URL: "file:///path/layer1", + Size: 30, }, RemoteURL: "http://path/layer1", Path: "/path/layer1", Timestamp: time.Now().UTC(), Cached: false, @@ -426,13 +424,11 @@ func TestLayerStore(t *testing.T) { { layer: imagemanager.LayerInfo{ LayerInfo: aostypes.LayerInfo{ - VersionInfo: aostypes.VersionInfo{ - AosVersion: 1, - }, - ID: "layer2", - Digest: "digest2", - URL: "file:///path/layer2", - Size: 60, + Version: "1.0", + LayerID: "layer2", + Digest: "digest2", + URL: "file:///path/layer2", + Size: 60, }, RemoteURL: "http://path/layer2", Path: "/path/layer2", Timestamp: time.Now().UTC(), Cached: true, diff --git a/imagemanager/imagemanager.go b/imagemanager/imagemanager.go index 3c531ed4..020f2b14 100644 --- a/imagemanager/imagemanager.go +++ b/imagemanager/imagemanager.go @@ -471,7 +471,7 @@ func (imagemanager *Imagemanager) RemoveService(serviceID string) error { func (imagemanager *Imagemanager) InstallLayer(layerInfo cloudprotocol.LayerInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate, ) error { - log.WithFields(log.Fields{"id": layerInfo.ID, "digest": layerInfo.Digest}).Debug("Install layer") + log.WithFields(log.Fields{"id": layerInfo.LayerID, "digest": layerInfo.Digest}).Debug("Install layer") if layerInfo, err := imagemanager.storage.GetLayerInfo(layerInfo.Digest); err == nil { if layerInfo.Cached { @@ -497,9 +497,9 @@ func (imagemanager *Imagemanager) InstallLayer(layerInfo cloudprotocol.LayerInfo releaseAllocatedSpace(decryptedFile, space) log.WithFields(log.Fields{ - "id": layerInfo.ID, - "aosVersion": layerInfo.AosVersion, - "imagePath": decryptedFile, + "id": layerInfo.LayerID, + "version": layerInfo.Version, + "imagePath": decryptedFile, }).Errorf("Can't install layer: %v", err) return @@ -519,7 +519,7 @@ func (imagemanager *Imagemanager) InstallLayer(layerInfo cloudprotocol.LayerInfo fcrypt.DecryptParams{ Chains: chains, Certs: certs, - DecryptionInfo: layerInfo.DecryptionInfo, + DecryptionInfo: &layerInfo.DecryptionInfo, Signs: layerInfo.Signs, }); err != nil { return aoserrors.Wrap(err) @@ -537,13 +537,12 @@ func (imagemanager *Imagemanager) InstallLayer(layerInfo cloudprotocol.LayerInfo if err := imagemanager.storage.AddLayer(LayerInfo{ LayerInfo: aostypes.LayerInfo{ - VersionInfo: layerInfo.VersionInfo, - ID: layerInfo.ID, - Digest: layerInfo.Digest, - URL: createLocalURL(decryptedFile), - Sha256: fileInfo.Sha256, - Sha512: fileInfo.Sha512, - Size: fileInfo.Size, + Version: layerInfo.Version, + LayerID: layerInfo.LayerID, + Digest: layerInfo.Digest, + URL: createLocalURL(decryptedFile), + Sha256: fileInfo.Sha256, + Size: fileInfo.Size, }, Path: decryptedFile, RemoteURL: remoteURL, diff --git a/imagemanager/imagemanager_test.go b/imagemanager/imagemanager_test.go index 2c29c7eb..f68208b0 100644 --- a/imagemanager/imagemanager_test.go +++ b/imagemanager/imagemanager_test.go @@ -1276,24 +1276,20 @@ func prepareLayerInfo(filePath, digest string, index int) (layerInfo cloudprotoc } installRequest := cloudprotocol.LayerInfo{ - VersionInfo: aostypes.VersionInfo{ - AosVersion: uint64(index), Description: "description" + strconv.Itoa(index), - }, - ID: "testLayer" + strconv.Itoa(index), - Digest: digest, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{ + Version: "v" + strconv.Itoa(index), + LayerID: "testLayer" + strconv.Itoa(index), + Digest: digest, + DownloadInfo: cloudprotocol.DownloadInfo{ URLs: []string{url.String()}, Sha256: imageFileInfo.Sha256, - Sha512: imageFileInfo.Sha512, Size: imageFileInfo.Size, - DecryptionInfo: &cloudprotocol.DecryptionInfo{ - BlockAlg: "AES256/CBC/pkcs7", - BlockIv: []byte{}, - BlockKey: []byte{}, - AsymAlg: "RSA/PKCS1v1_5", - ReceiverInfo: &recInfo, - }, - Signs: &cloudprotocol.Signs{}, + }, + DecryptionInfo: cloudprotocol.DecryptionInfo{ + BlockAlg: "AES256/CBC/pkcs7", + BlockIv: []byte{}, + BlockKey: []byte{}, + AsymAlg: "RSA/PKCS1v1_5", + ReceiverInfo: &recInfo, }, } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 1fc4f19b..b467fb6c 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -2169,9 +2169,9 @@ func createServiceInfo(id string, gid uint32, url string) aostypes.ServiceInfo { func createLayerInfo(digest string, url string) aostypes.LayerInfo { return aostypes.LayerInfo{ - Digest: digest, - VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - URL: url, + Digest: digest, + Version: "1.0", + URL: url, } } diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index ccb11da8..9ed2c849 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -202,7 +202,7 @@ func (controller *Controller) CheckUnitConfig(unitConfig cloudprotocol.UnitConfi } if node.config.NodeType == nodeConfig.NodeType { - err := node.checkUnitConfigState(nodeConfig, unitConfig.VendorVersion) + err := node.checkUnitConfigState(nodeConfig, unitConfig.Version) if err != nil { return err } @@ -222,7 +222,7 @@ func (controller *Controller) SetUnitConfig(unitConfig cloudprotocol.UnitConfig) } if node.config.NodeType == nodeConfig.NodeType { - err := node.setUnitConfig(nodeConfig, unitConfig.VendorVersion) + err := node.setUnitConfig(nodeConfig, unitConfig.Version) if err != nil { return err } diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 9e05542b..b4d971f6 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -964,9 +964,9 @@ func TestRunInstances(t *testing.T) { }}, Layers: []*pb.LayerInfo{ { - VersionInfo: &pb.VersionInfo{AosVersion: 2, VendorVersion: "3", Description: "desc2"}, - Url: "url2", LayerId: "l1", Digest: "digest1", Sha256: []byte{0, 0, 0, byte(100)}, - Sha512: []byte{byte(200), 0, 0, 0}, Size: uint64(500), + Version: "3", + Url: "url2", LayerId: "l1", Digest: "digest1", Sha256: []byte{0, 0, 0, byte(100)}, + Size: uint64(500), }, }, Instances: []*pb.InstanceInfo{ @@ -984,9 +984,9 @@ func TestRunInstances(t *testing.T) { Sha256: []byte{0, 0, 0, byte(100)}, Sha512: []byte{byte(200), 0, 0, 0}, Size: uint64(500), }} sendLayers = []aostypes.LayerInfo{{ - VersionInfo: aostypes.VersionInfo{AosVersion: 2, VendorVersion: "3", Description: "desc2"}, - URL: "url2", ID: "l1", Digest: "digest1", Sha256: []byte{0, 0, 0, byte(100)}, - Sha512: []byte{byte(200), 0, 0, 0}, Size: uint64(500), + Version: "3.0", + URL: "url2", LayerID: "l1", Digest: "digest1", Sha256: []byte{0, 0, 0, byte(100)}, + Size: uint64(500), }} sendInstances = []aostypes.InstanceInfo{{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "s1", SubjectID: "subj1", Instance: 1}, diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 2bd413ec..5e4778ef 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -214,16 +214,11 @@ func (handler *smHandler) runInstances( for i, layerInfo := range layers { pbRunInstances.Layers[i] = &pb.LayerInfo{ - VersionInfo: &pb.VersionInfo{ - AosVersion: layerInfo.AosVersion, - VendorVersion: layerInfo.VendorVersion, - Description: layerInfo.Description, - }, + Version: layerInfo.Version, Url: layerInfo.URL, - LayerId: layerInfo.ID, + LayerId: layerInfo.LayerID, Digest: layerInfo.Digest, Sha256: layerInfo.Sha256, - Sha512: layerInfo.Sha512, Size: layerInfo.Size, } } diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 36e296be..9b0a1227 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -86,13 +86,13 @@ func (instance *Instance) GetStatus() (unitConfigInfo cloudprotocol.UnitConfigSt // GetUnitConfigVersion returns unit config version. func (instance *Instance) GetUnitConfigVersion(configJSON json.RawMessage) (vendorVersion string, err error) { - unitConfig := cloudprotocol.UnitConfig{VendorVersion: "unknown"} + unitConfig := cloudprotocol.UnitConfig{Version: "unknown"} if err = json.Unmarshal(configJSON, &unitConfig); err != nil { - return unitConfig.VendorVersion, aoserrors.Wrap(err) + return unitConfig.Version, aoserrors.Wrap(err) } - return unitConfig.VendorVersion, nil + return unitConfig.Version, nil } // CheckUnitConfig checks unit config. @@ -100,10 +100,10 @@ func (instance *Instance) CheckUnitConfig(configJSON json.RawMessage) (vendorVer instance.Lock() defer instance.Unlock() - unitConfig := cloudprotocol.UnitConfig{VendorVersion: "unknown"} + unitConfig := cloudprotocol.UnitConfig{Version: "unknown"} if err = json.Unmarshal(configJSON, &unitConfig); err != nil { - return unitConfig.VendorVersion, aoserrors.Wrap(err) + return unitConfig.Version, aoserrors.Wrap(err) } if vendorVersion, err = instance.checkUnitConfig(unitConfig); err != nil { @@ -128,13 +128,13 @@ func (instance *Instance) UpdateUnitConfig(configJSON json.RawMessage) (err erro instance.Lock() defer instance.Unlock() - unitConfig := cloudprotocol.UnitConfig{VendorVersion: "unknown"} + unitConfig := cloudprotocol.UnitConfig{Version: "unknown"} if err = json.Unmarshal(configJSON, &unitConfig); err != nil { return aoserrors.Wrap(err) } - if unitConfig.VendorVersion == instance.unitConfig.VendorVersion { + if unitConfig.Version == instance.unitConfig.Version { return aoserrors.New("invalid vendor version") } @@ -177,13 +177,13 @@ func (instance *Instance) load() (err error) { } func (instance *Instance) checkUnitConfig(unitConfig cloudprotocol.UnitConfig) (vendorVersion string, err error) { - if unitConfig.VendorVersion == instance.unitConfig.VendorVersion { - return unitConfig.VendorVersion, ErrAlreadyInstalled + if unitConfig.Version == instance.unitConfig.Version { + return unitConfig.Version, ErrAlreadyInstalled } if err = instance.client.CheckUnitConfig(unitConfig); err != nil { - return unitConfig.VendorVersion, aoserrors.Wrap(err) + return unitConfig.Version, aoserrors.Wrap(err) } - return unitConfig.VendorVersion, nil + return unitConfig.Version, nil } diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 1c20d5cd..e49a4d97 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -878,9 +878,9 @@ func (manager *softwareManager) installLayers() (installErr string) { handleError := func(layer cloudprotocol.LayerInfo, layerErr string) { log.WithFields(log.Fields{ - "digest": layer.Digest, - "id": layer.ID, - "aosVersion": layer.AosVersion, + "digest": layer.Digest, + "id": layer.LayerID, + "version": layer.Version, }).Errorf("Can't install layer: %s", layerErr) if isCancelError(layerErr) { @@ -916,15 +916,15 @@ func (manager *softwareManager) installLayers() (installErr string) { Path: downloadInfo.FileName, } - layer.DecryptDataStruct.URLs = []string{url.String()} + layer.DownloadInfo.URLs = []string{url.String()} installLayers = append(installLayers, layer) } for _, layer := range installLayers { log.WithFields(log.Fields{ - "id": layer.ID, - "aosVersion": layer.AosVersion, + "id": layer.LayerID, + "aosVersion": layer.Version, "digest": layer.Digest, }).Debug("Install layer") @@ -941,8 +941,8 @@ func (manager *softwareManager) installLayers() (installErr string) { } log.WithFields(log.Fields{ - "id": layerInfo.ID, - "aosVersion": layerInfo.AosVersion, + "id": layerInfo.LayerID, + "aosVersion": layerInfo.Version, "digest": layerInfo.Digest, }).Info("Layer successfully installed") diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 5408d9f4..48c8db7f 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -382,16 +382,16 @@ func TestUpdateLayers(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Layers: []cloudprotocol.LayerInfo{ { - ID: "layer1", Digest: "digest1", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{1}}, + LayerID: "layer1", Digest: "digest1", Version: "0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ID: "layer3", Digest: "digest3", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{3}}, + LayerID: "layer3", Digest: "digest3", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ID: "layer4", Digest: "digest4", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{4}}, + LayerID: "layer4", Digest: "digest4", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, }, }) @@ -455,16 +455,16 @@ func TestUpdateLayers(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Layers: []cloudprotocol.LayerInfo{ { - ID: "layer3", Digest: "digest3", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{3}}, + LayerID: "layer3", Digest: "digest3", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ID: "layer4", Digest: "digest4", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{4}}, + LayerID: "layer4", Digest: "digest4", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, { - ID: "layer5", Digest: "digest5", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{5}}, + LayerID: "layer5", Digest: "digest5", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{5}}, }, }, }) @@ -937,24 +937,24 @@ func TestUpdateCachedSOTA(t *testing.T) { }, Layers: []cloudprotocol.LayerInfo{ { - ID: "layer0", Digest: "digest0", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"layer0"}, Sha256: []byte{0}}, + LayerID: "layer0", Digest: "digest0", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer0"}, Sha256: []byte{0}}, }, { - ID: "layer1", Digest: "digest1", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"layer1"}, Sha256: []byte{1}}, + LayerID: "layer1", Digest: "digest1", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer1"}, Sha256: []byte{1}}, }, { - ID: "layer2", Digest: "digest2", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"layer2"}, Sha256: []byte{2}}, + LayerID: "layer2", Digest: "digest2", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer2"}, Sha256: []byte{2}}, }, { - ID: "layer3", Digest: "digest3", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"layer3"}, Sha256: []byte{3}}, + LayerID: "layer3", Digest: "digest3", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer3"}, Sha256: []byte{3}}, }, { - ID: "layer5", Digest: "digest5", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"layer5"}, Sha256: []byte{3}}, + LayerID: "layer5", Digest: "digest5", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer5"}, Sha256: []byte{3}}, }, }, }) From fae3d215a19e43cd98cbd025fe2d9e7b8c022d49 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 12:19:33 +0300 Subject: [PATCH 011/146] [all] Update ServiceInfo Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 6 +- amqphandler/amqphandler_test.go | 2 +- cmserver/cmserver.go | 8 +- database/database_internal_test.go | 53 +++++------- imagemanager/imagemanager.go | 74 ++++++++++------- imagemanager/imagemanager_test.go | 92 ++++++++++----------- launcher/launcher.go | 12 +-- launcher/launcher_test.go | 14 ++-- smcontroller/smcontroller_test.go | 12 +-- smcontroller/smhandler.go | 9 +- unitstatushandler/softwaremanager.go | 66 +++++++-------- unitstatushandler/unitstatushandler_test.go | 44 +++++----- 12 files changed, 191 insertions(+), 201 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index 92ad0cd8..d3bfeb01 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -641,10 +641,8 @@ func (handler *AmqpHandler) decodeData(data []byte, result interface{}) error { for _, service := range desiredStatus.Services { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, - "vendorVersion": service.VendorVersion, - "description": service.Description, + "id": service.ServiceID, + "version": service.Version, }).Debug("Service") } diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 47de9d53..7562cd7d 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -319,7 +319,7 @@ func TestReceiveMessages(t *testing.T) { {Version: "1.0", LayerID: "l1", Digest: "digest"}, }, Services: []cloudprotocol.ServiceInfo{ - {VersionInfo: aostypes.VersionInfo{AosVersion: 1}, ID: "serv1", ProviderID: "p1"}, + {Version: "1.0", ServiceID: "serv1", ProviderID: "p1"}, }, Instances: []cloudprotocol.InstanceInfo{{ServiceID: "s1", SubjectID: "subj1", NumInstances: 1}}, FOTASchedule: cloudprotocol.ScheduleRule{TTL: uint64(100), Type: "type"}, diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index 61842a00..d383b329 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -338,15 +338,15 @@ func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSO for _, service := range updateStatus.InstallServices { pbStatus.InstallServices = append(pbStatus.GetInstallServices(), &pb.ServiceInfo{ - Id: service.ID, - AosVersion: service.AosVersion, + ServideId: service.ServiceID, + Version: service.Version, }) } for _, service := range updateStatus.RemoveServices { pbStatus.RemoveServices = append(pbStatus.GetRemoveServices(), &pb.ServiceInfo{ - Id: service.ID, - AosVersion: service.AosVersion, + ServideId: service.ServiceID, + Version: service.Version, }) } diff --git a/database/database_internal_test.go b/database/database_internal_test.go index 301dee7b..2d343f50 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -275,14 +275,11 @@ func TestServiceStore(t *testing.T) { { service: imagemanager.ServiceInfo{ ServiceInfo: aostypes.ServiceInfo{ - ID: "service1", - VersionInfo: aostypes.VersionInfo{ - AosVersion: 1, - VendorVersion: "1", - }, - URL: "file:///path/service1", - Size: 30, - GID: 1000, + ServiceID: "service1", + Version: "1.1", + URL: "file:///path/service1", + Size: 30, + GID: 1000, }, RemoteURL: "http://path/service1", Path: "/path/service1", Timestamp: time.Now().UTC(), Cached: false, Config: aostypes.ServiceConfig{ @@ -301,14 +298,11 @@ func TestServiceStore(t *testing.T) { { service: imagemanager.ServiceInfo{ ServiceInfo: aostypes.ServiceInfo{ - ID: "service2", - VersionInfo: aostypes.VersionInfo{ - AosVersion: 1, - VendorVersion: "1", - }, - URL: "file:///path/service2", - Size: 60, - GID: 2000, + ServiceID: "service2", + Version: "1.1", + URL: "file:///path/service2", + Size: 60, + GID: 2000, }, RemoteURL: "http://path/service2", Path: "/path/service2", Timestamp: time.Now().UTC(), Cached: true, Config: aostypes.ServiceConfig{ @@ -328,14 +322,11 @@ func TestServiceStore(t *testing.T) { { service: imagemanager.ServiceInfo{ ServiceInfo: aostypes.ServiceInfo{ - ID: "service2", - VersionInfo: aostypes.VersionInfo{ - AosVersion: 2, - VendorVersion: "1", - }, - URL: "file:///path/service2/new", - Size: 20, - GID: 1000, + ServiceID: "service2", + Version: "2.1", + URL: "file:///path/service2/new", + Size: 20, + GID: 1000, }, RemoteURL: "http://path/service2/new", Path: "/path/service2/new", Timestamp: time.Now().UTC(), @@ -351,16 +342,16 @@ func TestServiceStore(t *testing.T) { t.Errorf("Can't add service: %v", err) } - service, err := testDB.GetServiceInfo(tCase.service.ID) + service, err := testDB.GetServiceInfo(tCase.service.ServiceID) if err != nil { t.Errorf("Can't get service: %v", err) } if !reflect.DeepEqual(service, tCase.service) { - t.Errorf("service %s doesn't match stored one", tCase.service.ID) + t.Errorf("service %s doesn't match stored one", tCase.service.ServiceID) } - serviceVersions, err := testDB.GetServiceVersions(tCase.service.ID) + serviceVersions, err := testDB.GetServiceVersions(tCase.service.ServiceID) if err != nil { t.Errorf("Can't get service versions: %v", err) } @@ -378,11 +369,11 @@ func TestServiceStore(t *testing.T) { t.Errorf("Incorrect count of services: %v", len(services)) } - if err := testDB.SetServiceCached(tCase.service.ID, !tCase.service.Cached); err != nil { + if err := testDB.SetServiceCached(tCase.service.ServiceID, !tCase.service.Cached); err != nil { t.Errorf("Can't set service cached: %v", err) } - if service, err = testDB.GetServiceInfo(tCase.service.ID); err != nil { + if service, err = testDB.GetServiceInfo(tCase.service.ServiceID); err != nil { t.Errorf("Can't get service: %v", err) } @@ -392,11 +383,11 @@ func TestServiceStore(t *testing.T) { } for _, tCase := range cases { - if err := testDB.RemoveService(tCase.service.ID, tCase.service.AosVersion); err != nil { + if err := testDB.RemoveService(tCase.service.ServiceID, tCase.service.Version); err != nil { t.Errorf("Can't remove service: %v", err) } - if _, err := testDB.GetServiceInfo(tCase.service.ID); !errors.Is(err, tCase.serviceErrorAfterRemove) { + if _, err := testDB.GetServiceInfo(tCase.service.ServiceID); !errors.Is(err, tCase.serviceErrorAfterRemove) { t.Errorf("Unexpected error: %v", err) } } diff --git a/imagemanager/imagemanager.go b/imagemanager/imagemanager.go index 020f2b14..94a9792e 100644 --- a/imagemanager/imagemanager.go +++ b/imagemanager/imagemanager.go @@ -40,6 +40,7 @@ import ( "github.com/aosedge/aos_communicationmanager/fileserver" "github.com/aosedge/aos_communicationmanager/unitstatushandler" "github.com/aosedge/aos_communicationmanager/utils/uidgidpool" + semver "github.com/hashicorp/go-version" ) /*********************************************************************************************************************** @@ -71,7 +72,7 @@ type Storage interface { AddService(service ServiceInfo) error SetLayerCached(digest string, cached bool) error SetServiceCached(serviceID string, cached bool) error - RemoveService(serviceID string, aosVersion uint64) error + RemoveService(serviceID string, version string) error RemoveLayer(digest string) error } @@ -287,9 +288,9 @@ func (imagemanager *Imagemanager) GetRemoveServiceChannel() (channel <-chan stri func (imagemanager *Imagemanager) InstallService(serviceInfo cloudprotocol.ServiceInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate, ) error { - log.WithFields(log.Fields{"id": serviceInfo.ID}).Debug("Install service") + log.WithFields(log.Fields{"id": serviceInfo.ServiceID}).Debug("Install service") - serviceFromStorage, err := imagemanager.storage.GetServiceInfo(serviceInfo.ID) + serviceFromStorage, err := imagemanager.storage.GetServiceInfo(serviceInfo.ServiceID) if err != nil && !errors.Is(err, ErrNotExist) { return aoserrors.Wrap(err) } @@ -299,7 +300,17 @@ func (imagemanager *Imagemanager) InstallService(serviceInfo cloudprotocol.Servi if err == nil { isServiceExist = true - if serviceInfo.AosVersion <= serviceFromStorage.AosVersion { + version, err := semver.NewSemver(serviceInfo.Version) + if err != nil { + return aoserrors.Wrap(err) + } + + versionInStorage, err := semver.NewSemver(serviceFromStorage.Version) + if err != nil { + return aoserrors.Wrap(err) + } + + if version.LessThanOrEqual(versionInStorage) { return ErrVersionMismatch } } @@ -316,9 +327,9 @@ func (imagemanager *Imagemanager) InstallService(serviceInfo cloudprotocol.Servi releaseAllocatedSpace(decryptedFile, space) log.WithFields(log.Fields{ - "id": serviceInfo.ID, - "aosVersion": serviceInfo.AosVersion, - "imagePath": decryptedFile, + "id": serviceInfo.ServiceID, + "version": serviceInfo.Version, + "imagePath": decryptedFile, }).Errorf("Can't install service: %v", err) return @@ -385,14 +396,13 @@ func (imagemanager *Imagemanager) addService( if err = imagemanager.storage.AddService(ServiceInfo{ ServiceInfo: aostypes.ServiceInfo{ - VersionInfo: serviceInfo.VersionInfo, - ID: serviceInfo.ID, - ProviderID: serviceInfo.ProviderID, - URL: createLocalURL(decryptedFile), - Size: fileInfo.Size, - GID: uint32(gid), - Sha256: fileInfo.Sha256, - Sha512: fileInfo.Sha512, + Version: serviceInfo.Version, + ServiceID: serviceInfo.ServiceID, + ProviderID: serviceInfo.ProviderID, + URL: createLocalURL(decryptedFile), + Size: fileInfo.Size, + GID: uint32(gid), + Sha256: fileInfo.Sha256, }, RemoteURL: remoteURL, Path: decryptedFile, @@ -456,8 +466,8 @@ func (imagemanager *Imagemanager) RemoveService(serviceID string) error { if err = imagemanager.setServiceCached(ServiceInfo{ ServiceInfo: aostypes.ServiceInfo{ - ID: serviceID, - Size: serviceSize, + ServiceID: serviceID, + Size: serviceSize, }, Timestamp: services[len(services)-1].Timestamp, }, true); err != nil { @@ -643,20 +653,20 @@ func (imagemanager *Imagemanager) RevertService(serviceID string) error { **********************************************************************************************************************/ func (imagemanager *Imagemanager) setServiceCached(service ServiceInfo, cached bool) error { - if err := imagemanager.storage.SetServiceCached(service.ID, cached); err != nil { + if err := imagemanager.storage.SetServiceCached(service.ServiceID, cached); err != nil { return aoserrors.Wrap(err) } if cached { if err := imagemanager.serviceAllocator.AddOutdatedItem( - service.ID, service.Size, service.Timestamp); err != nil { + service.ServiceID, service.Size, service.Timestamp); err != nil { return aoserrors.Wrap(err) } return nil } - imagemanager.serviceAllocator.RestoreOutdatedItem(service.ID) + imagemanager.serviceAllocator.RestoreOutdatedItem(service.ServiceID) return nil } @@ -681,17 +691,17 @@ func (imagemanager *Imagemanager) setLayerCached(layer LayerInfo, cached bool) e } func (imagemanager *Imagemanager) removeObsoleteServiceVersions(service ServiceInfo) error { - services, err := imagemanager.storage.GetServiceVersions(service.ID) + services, err := imagemanager.storage.GetServiceVersions(service.ServiceID) if err != nil && !errors.Is(err, ErrNotExist) { return aoserrors.Wrap(err) } for _, storageService := range services { - if service.AosVersion != storageService.AosVersion { + if service.Version != storageService.Version { if removeErr := imagemanager.removeService(storageService); removeErr != nil { log.WithFields(log.Fields{ - "serviceID": storageService.ID, - "AosVersion": storageService.AosVersion, + "serviceID": storageService.ServiceID, + "version": storageService.Version, }).Errorf("Can't remove service: %v", removeErr) if err == nil { @@ -703,7 +713,7 @@ func (imagemanager *Imagemanager) removeObsoleteServiceVersions(service ServiceI if service.Cached { if cacheErr := imagemanager.setServiceCached(service, false); cacheErr != nil { - log.WithField("serviceID", service.ID).Errorf("Can't cached service: %v", cacheErr) + log.WithField("serviceID", service.ServiceID).Errorf("Can't cached service: %v", cacheErr) if err == nil { err = cacheErr @@ -789,7 +799,7 @@ func (imagemanager *Imagemanager) clearServiceResource(service ServiceInfo) erro } if service.Cached { - imagemanager.serviceAllocator.RestoreOutdatedItem(service.ID) + imagemanager.serviceAllocator.RestoreOutdatedItem(service.ServiceID) } imagemanager.serviceAllocator.FreeSpace(service.Size) @@ -816,11 +826,11 @@ func (imagemanager *Imagemanager) removeService(service ServiceInfo) error { return err } - if err := imagemanager.storage.RemoveService(service.ID, service.AosVersion); err != nil { + if err := imagemanager.storage.RemoveService(service.ServiceID, service.Version); err != nil { return aoserrors.Wrap(err) } - log.WithFields(log.Fields{"serviceID": service.ID}).Info("Service successfully removed") + log.WithFields(log.Fields{"serviceID": service.ServiceID}).Info("Service successfully removed") return nil } @@ -884,7 +894,7 @@ func (imagemanager *Imagemanager) removeOutdatedService(serviceID string) error err = errRem } - if errRem = imagemanager.storage.RemoveService(service.ID, service.AosVersion); errRem != nil && err == nil { + if errRem = imagemanager.storage.RemoveService(service.ServiceID, service.Version); errRem != nil && err == nil { err = errRem } } @@ -910,13 +920,13 @@ func (imagemanager *Imagemanager) setOutdatedServices() error { } if service.Cached { - size, err := imagemanager.getServiceSize(service.ID) + size, err := imagemanager.getServiceSize(service.ServiceID) if err != nil { return err } if err = imagemanager.serviceAllocator.AddOutdatedItem( - service.ID, size, service.Timestamp); err != nil { + service.ServiceID, size, service.Timestamp); err != nil { return aoserrors.Wrap(err) } } @@ -966,7 +976,7 @@ func (imagemanager *Imagemanager) removeOutdatedServices() error { if service.Cached && service.Timestamp.Add(time.Hour*24*time.Duration(imagemanager.serviceTTLDays)).Before(time.Now()) { if removeErr := imagemanager.removeService(service); removeErr != nil { - log.WithField("serviceID", service.ID).Errorf("Can't remove outdated service: %v", removeErr) + log.WithField("serviceID", service.ServiceID).Errorf("Can't remove outdated service: %v", removeErr) if err == nil { err = removeErr diff --git a/imagemanager/imagemanager_test.go b/imagemanager/imagemanager_test.go index f68208b0..a0a4cc74 100644 --- a/imagemanager/imagemanager_test.go +++ b/imagemanager/imagemanager_test.go @@ -161,7 +161,7 @@ func TestInstallService(t *testing.T) { cases := []struct { serviceID string - aosVersion uint64 + version string size uint64 expectedCountService int installErr error @@ -169,7 +169,7 @@ func TestInstallService(t *testing.T) { }{ { serviceID: "service1", - aosVersion: 1, + version: "1.0", size: 1 * megabyte, expectedCountService: 1, installErr: nil, @@ -184,7 +184,7 @@ func TestInstallService(t *testing.T) { }, { serviceID: "service2", - aosVersion: 1, + version: "1.0", size: 1 * megabyte, expectedCountService: 2, installErr: nil, @@ -199,7 +199,7 @@ func TestInstallService(t *testing.T) { }, { serviceID: "service3", - aosVersion: 1, + version: "1.0", size: 2 * megabyte, expectedCountService: 2, installErr: spaceallocator.ErrNoSpace, @@ -230,7 +230,7 @@ func TestInstallService(t *testing.T) { t.Errorf("Can't prepare service file: %v", err) } - serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.aosVersion) + serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.version) if err != nil { t.Errorf("Can't prepare service info: %v", err) } @@ -245,7 +245,7 @@ func TestInstallService(t *testing.T) { t.Errorf("Can't get service: %v", err) } - if service.ID != tCase.serviceID || service.AosVersion != tCase.aosVersion { + if service.ServiceID != tCase.serviceID || service.Version != tCase.version { t.Error("Unexpected service info") } @@ -295,14 +295,14 @@ func TestRevertService(t *testing.T) { cases := []struct { serviceID string - aosVersion uint64 + version string size uint64 serviceConfig aostypes.ServiceConfig }{ { - serviceID: "service1", - aosVersion: 1, - size: 1 * megabyte, + serviceID: "service1", + version: "1.0", + size: 1 * megabyte, serviceConfig: aostypes.ServiceConfig{ Hostname: allocateString("service1"), Quotas: aostypes.ServiceQuotas{ @@ -313,9 +313,9 @@ func TestRevertService(t *testing.T) { }, }, { - serviceID: "service1", - aosVersion: 2, - size: 1 * megabyte, + serviceID: "service1", + version: "2.0", + size: 1 * megabyte, serviceConfig: aostypes.ServiceConfig{ Hostname: allocateString("service1"), Quotas: aostypes.ServiceQuotas{ @@ -338,7 +338,7 @@ func TestRevertService(t *testing.T) { t.Errorf("Can't prepare service file: %v", err) } - serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.aosVersion) + serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.version) if err != nil { t.Errorf("Can't prepare service info: %v", err) } @@ -349,14 +349,14 @@ func TestRevertService(t *testing.T) { } casesRevert := []struct { - revertServiceID string - expectedAosVersion uint64 - err error + revertServiceID string + expectedVersion string + err error }{ { - revertServiceID: "service1", - expectedAosVersion: 1, - err: nil, + revertServiceID: "service1", + expectedVersion: "1.0", + err: nil, }, { revertServiceID: "service1", @@ -374,7 +374,7 @@ func TestRevertService(t *testing.T) { t.Errorf("Can't get service: %v", err) } - if service.AosVersion != tCase.expectedAosVersion { + if service.Version != tCase.expectedVersion { t.Error("Unexpected service version") } } @@ -410,7 +410,7 @@ func TestRemoveService(t *testing.T) { cases := []struct { serviceID string removeServiceID string - aosVersion uint64 + version string size uint64 expectedCountService int installErr error @@ -418,7 +418,7 @@ func TestRemoveService(t *testing.T) { }{ { serviceID: "service1", - aosVersion: 1, + version: "1.0", size: 1 * megabyte, expectedCountService: 1, installErr: nil, @@ -434,7 +434,7 @@ func TestRemoveService(t *testing.T) { { serviceID: "service2", removeServiceID: "service1", - aosVersion: 1, + version: "1.0", size: 1 * megabyte, expectedCountService: 1, installErr: spaceallocator.ErrNoSpace, @@ -460,7 +460,7 @@ func TestRemoveService(t *testing.T) { t.Errorf("Can't prepare service file: %v", err) } - serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.aosVersion) + serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.version) if err != nil { t.Errorf("Can't prepare service info: %v", err) } @@ -543,14 +543,14 @@ func TestRestoreService(t *testing.T) { cases := []struct { serviceID string removeServiceID string - aosVersion uint64 + version string size uint64 installErr error serviceConfig aostypes.ServiceConfig }{ { serviceID: "service1", - aosVersion: 1, + version: "1.0", size: 1 * megabyte, installErr: nil, serviceConfig: aostypes.ServiceConfig{ @@ -565,7 +565,7 @@ func TestRestoreService(t *testing.T) { { serviceID: "service2", removeServiceID: "service1", - aosVersion: 1, + version: "1.0", size: 1 * megabyte, installErr: spaceallocator.ErrNoSpace, serviceConfig: aostypes.ServiceConfig{ @@ -590,7 +590,7 @@ func TestRestoreService(t *testing.T) { t.Errorf("Can't prepare service file: %v", err) } - serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.aosVersion) + serviceInfo, err := prepareServiceInfo(servicePath, tCase.serviceID, tCase.version) if err != nil { t.Errorf("Can't prepare service info: %v", err) } @@ -1185,11 +1185,11 @@ func (storage *testStorageProvider) AddLayer(layer imagemanager.LayerInfo) error } func (storage *testStorageProvider) AddService(service imagemanager.ServiceInfo) error { - services := storage.services[service.ID] + services := storage.services[service.ServiceID] services = append(services, service) - storage.services[service.ID] = services + storage.services[service.ServiceID] = services return nil } @@ -1219,7 +1219,7 @@ func (storage *testStorageProvider) SetServiceCached(serviceID string, cached bo return nil } -func (storage *testStorageProvider) RemoveService(serviceID string, aosVersion uint64) error { +func (storage *testStorageProvider) RemoveService(serviceID string, version string) error { services, ok := storage.services[serviceID] if !ok { return nil @@ -1232,7 +1232,7 @@ func (storage *testStorageProvider) RemoveService(serviceID string, aosVersion u } for i := 0; i < len(services); i++ { - if services[i].AosVersion == aosVersion { + if services[i].Version == version { services = append(services[:i], services[i+1:]...) } } @@ -1297,7 +1297,7 @@ func prepareLayerInfo(filePath, digest string, index int) (layerInfo cloudprotoc } func prepareServiceInfo( - filePath, serviceID string, aosVersion uint64, + filePath, serviceID string, version string, ) (layerInfo cloudprotocol.ServiceInfo, err error) { imageFileInfo, err := image.CreateFileInfo(context.Background(), filePath) if err != nil { @@ -1318,24 +1318,20 @@ func prepareServiceInfo( } installRequest := cloudprotocol.ServiceInfo{ - VersionInfo: aostypes.VersionInfo{ - AosVersion: aosVersion, Description: "description", - }, - ID: serviceID, + Version: version, + ServiceID: serviceID, ProviderID: serviceID, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{ + DownloadInfo: cloudprotocol.DownloadInfo{ URLs: []string{url.String()}, Sha256: imageFileInfo.Sha256, - Sha512: imageFileInfo.Sha512, Size: imageFileInfo.Size, - DecryptionInfo: &cloudprotocol.DecryptionInfo{ - BlockAlg: "AES256/CBC/pkcs7", - BlockIv: []byte{}, - BlockKey: []byte{}, - AsymAlg: "RSA/PKCS1v1_5", - ReceiverInfo: &recInfo, - }, - Signs: &cloudprotocol.Signs{}, + }, + DecryptionInfo: cloudprotocol.DecryptionInfo{ + BlockAlg: "AES256/CBC/pkcs7", + BlockIv: []byte{}, + BlockKey: []byte{}, + AsymAlg: "RSA/PKCS1v1_5", + ReceiverInfo: &recInfo, }, } diff --git a/launcher/launcher.go b/launcher/launcher.go index ecfec67d..55a7ba51 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -813,7 +813,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (err instance.InstanceIdent, serviceInfo.ProviderID, prepareNetworkParameters(instance, serviceInfo)); err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instance.Instance, serviceInfo.AosVersion, cloudprotocol.InstanceStateFailed, err.Error())) + instance.Instance, serviceInfo, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } node.currentRunRequest.Instances[i] = instance @@ -1223,7 +1223,7 @@ func (launcher *Launcher) addRunRequest(instance aostypes.InstanceInfo, service } if isNewService { - log.WithFields(log.Fields{"serviceID": serviceInfo.ID, "node": node.NodeID}).Debug("Schedule service on node") + log.WithFields(log.Fields{"serviceID": serviceInfo.ServiceID, "node": node.NodeID}).Debug("Schedule service on node") node.currentRunRequest.Services = append(node.currentRunRequest.Services, serviceInfo) } @@ -1269,7 +1269,7 @@ func (launcher *Launcher) removeServiceFromNode(serviceID string, node *nodeStat i := 0 for _, service := range node.currentRunRequest.Services { - if service.ID != serviceID { + if service.ServiceID != serviceID { node.currentRunRequest.Services[i] = service i++ } @@ -1318,7 +1318,7 @@ func (launcher *Launcher) removeRunRequest(instance aostypes.InstanceInfo, node layerLoop: for _, currentDigest := range currentServiceInfo.Layers { for _, service := range node.currentRunRequest.Services { - serviceInfo, err := launcher.imageProvider.GetServiceInfo(service.ID) + serviceInfo, err := launcher.imageProvider.GetServiceInfo(service.ServiceID) if err != nil { log.Errorf("Can't get service info: %v", err) @@ -1338,7 +1338,7 @@ func (launcher *Launcher) removeRunRequest(instance aostypes.InstanceInfo, node } func createInstanceStatusFromInfo( - serviceID, subjectID string, instanceIndex, serviceVersion uint64, runState, errorMsg string, + serviceID, subjectID string, instanceIndex uint64, serviceVersion string, runState, errorMsg string, ) cloudprotocol.InstanceStatus { ident := aostypes.InstanceIdent{ ServiceID: serviceID, SubjectID: subjectID, Instance: instanceIndex, @@ -1346,7 +1346,7 @@ func createInstanceStatusFromInfo( instanceStatus := cloudprotocol.InstanceStatus{ InstanceIdent: ident, - AosVersion: serviceVersion, RunState: runState, + Version: serviceVersion, RunState: runState, } if errorMsg != "" { diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index b467fb6c..3b1fac7d 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -218,10 +218,10 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { // add a service to the storage testStorage.services[service1] = make([]imagemanager.ServiceInfo, 1) - testStorage.services[service1][0].ServiceInfo.ID = service1 + testStorage.services[service1][0].ServiceInfo.ServiceID = service1 testStorage.services[service2] = make([]imagemanager.ServiceInfo, 1) - testStorage.services[service2][0].ServiceInfo.ID = service2 + testStorage.services[service2][0].ServiceInfo.ServiceID = service2 launcherInstance, err := launcher.New(cfg, testStorage, nodeManager, imageManager, &testResourceManager{}, testStateStorage, newTestNetworkManager("")) @@ -277,7 +277,7 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { // add a service to the storage testStorage.services[service1] = make([]imagemanager.ServiceInfo, 1) - testStorage.services[service1][0].ServiceInfo.ID = service1 + testStorage.services[service1][0].ServiceInfo.ServiceID = service1 launcherInstance, err := launcher.New(cfg, testStorage, nodeManager, testImageManager, &testResourceManager{}, testStateStorage, newTestNetworkManager("")) @@ -2160,10 +2160,10 @@ func (network *testNetworkManager) RestartDNSServer() error { func createServiceInfo(id string, gid uint32, url string) aostypes.ServiceInfo { return aostypes.ServiceInfo{ - ID: id, - VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - URL: url, - GID: gid, + ServiceID: id, + Version: "1.0", + URL: url, + GID: gid, } } diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index b4d971f6..ed44f604 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -958,9 +958,9 @@ func TestRunInstances(t *testing.T) { expectedRunInstances = &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_RunInstances{ RunInstances: &pb.RunInstances{ Services: []*pb.ServiceInfo{{ - VersionInfo: &pb.VersionInfo{AosVersion: 1, VendorVersion: "1", Description: "desc"}, - Url: "url1", ServiceId: "s1", ProviderId: "p1", Gid: 600, - Sha256: []byte{0, 0, 0, byte(100)}, Sha512: []byte{byte(200), 0, 0, 0}, Size: uint64(500), + Version: "1.1", + Url: "url1", ServiceId: "s1", ProviderId: "p1", Gid: 600, + Sha256: []byte{0, 0, 0, byte(100)}, Size: uint64(500), }}, Layers: []*pb.LayerInfo{ { @@ -979,9 +979,9 @@ func TestRunInstances(t *testing.T) { }, }} sendServices = []aostypes.ServiceInfo{{ - VersionInfo: aostypes.VersionInfo{AosVersion: 1, VendorVersion: "1", Description: "desc"}, - ID: "s1", ProviderID: "p1", URL: "url1", GID: 600, - Sha256: []byte{0, 0, 0, byte(100)}, Sha512: []byte{byte(200), 0, 0, 0}, Size: uint64(500), + Version: "1.1", + ServiceID: "s1", ProviderID: "p1", URL: "url1", GID: 600, + Sha256: []byte{0, 0, 0, byte(100)}, Size: uint64(500), }} sendLayers = []aostypes.LayerInfo{{ Version: "3.0", diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 5e4778ef..bdeb1bc8 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -197,17 +197,12 @@ func (handler *smHandler) runInstances( for i, serviceInfo := range services { pbRunInstances.Services[i] = &pb.ServiceInfo{ - VersionInfo: &pb.VersionInfo{ - AosVersion: serviceInfo.AosVersion, - VendorVersion: serviceInfo.VendorVersion, - Description: serviceInfo.Description, - }, + Version: serviceInfo.Version, Url: serviceInfo.URL, - ServiceId: serviceInfo.ID, + ServiceId: serviceInfo.ServiceID, ProviderId: serviceInfo.ProviderID, Gid: serviceInfo.GID, Sha256: serviceInfo.Sha256, - Sha512: serviceInfo.Sha512, Size: serviceInfo.Size, } } diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index e49a4d97..dc1d93f0 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -262,7 +262,7 @@ func (manager *softwareManager) processDesiredServices( downloadServiceLoop: for _, desiredService := range desiredServices { for _, service := range allServices { - if desiredService.ID == service.ID && desiredService.AosVersion == service.AosVersion && + if desiredService.ServiceID == service.ServiceID && desiredService.Version == service.Version && service.Status != cloudprotocol.ErrorStatus { if service.Cached { update.RestoreServices = append(update.RestoreServices, desiredService) @@ -1039,15 +1039,15 @@ func (manager *softwareManager) installServices() (newServices []string, install handleError := func(service cloudprotocol.ServiceInfo, serviceErr string) { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, + "id": service.ServiceID, + "version": service.Version, }).Errorf("Can't install service: %s", serviceErr) if isCancelError(serviceErr) { return } - manager.updateStatusByID(service.ID, cloudprotocol.ErrorStatus, serviceErr) + manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, serviceErr) mutex.Lock() defer mutex.Unlock() @@ -1060,7 +1060,7 @@ func (manager *softwareManager) installServices() (newServices []string, install installServices := []cloudprotocol.ServiceInfo{} for _, service := range manager.CurrentUpdate.InstallServices { - downloadInfo, ok := manager.DownloadResult[service.ID] + downloadInfo, ok := manager.DownloadResult[service.ServiceID] if !ok { handleError(service, aoserrors.New("can't get download result").Error()) continue @@ -1076,23 +1076,23 @@ func (manager *softwareManager) installServices() (newServices []string, install Path: downloadInfo.FileName, } - service.DecryptDataStruct.URLs = []string{url.String()} + service.DownloadInfo.URLs = []string{url.String()} installServices = append(installServices, service) } for _, service := range installServices { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, + "id": service.ServiceID, + "version": service.Version, }).Debug("Install service") - manager.updateServiceStatusByID(service.ID, cloudprotocol.InstallingStatus, "") + manager.updateServiceStatusByID(service.ServiceID, cloudprotocol.InstallingStatus, "") // Create new variable to be captured by action function serviceInfo := service - manager.actionHandler.Execute(serviceInfo.ID, func(serviceID string) error { + manager.actionHandler.Execute(serviceInfo.ServiceID, func(serviceID string) error { err := manager.softwareUpdater.InstallService(serviceInfo, manager.CurrentUpdate.CertChains, manager.CurrentUpdate.Certs) if err != nil { @@ -1101,13 +1101,13 @@ func (manager *softwareManager) installServices() (newServices []string, install } log.WithFields(log.Fields{ - "id": serviceInfo.ID, - "aosVersion": serviceInfo.AosVersion, + "id": serviceInfo.ServiceID, + "aosVersion": serviceInfo.Version, }).Info("Service successfully installed") - newServices = append(newServices, serviceInfo.ID) + newServices = append(newServices, serviceInfo.ServiceID) - manager.updateServiceStatusByID(serviceInfo.ID, cloudprotocol.InstalledStatus, "") + manager.updateServiceStatusByID(serviceInfo.ServiceID, cloudprotocol.InstalledStatus, "") return nil }) @@ -1123,15 +1123,15 @@ func (manager *softwareManager) restoreServices() (restoreErr string) { handleError := func(service cloudprotocol.ServiceInfo, serviceErr string) { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, + "id": service.ServiceID, + "aosVersion": service.Version, }).Errorf("Can't restore service: %s", serviceErr) if isCancelError(serviceErr) { return } - manager.updateStatusByID(service.ID, cloudprotocol.ErrorStatus, serviceErr) + manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, serviceErr) mutex.Lock() defer mutex.Unlock() @@ -1143,32 +1143,32 @@ func (manager *softwareManager) restoreServices() (restoreErr string) { for _, service := range manager.CurrentUpdate.RestoreServices { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, + "id": service.ServiceID, + "aosVersion": service.Version, }).Debug("Restore service") - manager.ServiceStatuses[service.ID] = &cloudprotocol.ServiceStatus{ - ID: service.ID, - AosVersion: service.AosVersion, - Status: cloudprotocol.InstallingStatus, + manager.ServiceStatuses[service.ServiceID] = &cloudprotocol.ServiceStatus{ + ServiceID: service.ServiceID, + Version: service.Version, + Status: cloudprotocol.InstallingStatus, } // Create new variable to be captured by action function serviceInfo := service - manager.actionHandler.Execute(serviceInfo.ID, func(serviceID string) error { - if err := manager.softwareUpdater.RestoreService(serviceInfo.ID); err != nil { + manager.actionHandler.Execute(serviceInfo.ServiceID, func(serviceID string) error { + if err := manager.softwareUpdater.RestoreService(serviceInfo.ServiceID); err != nil { handleError(serviceInfo, aoserrors.Wrap(err).Error()) return aoserrors.Wrap(err) } log.WithFields(log.Fields{ - "id": serviceInfo.ID, - "aosVersion": serviceInfo.AosVersion, + "id": serviceInfo.ServiceID, + "version": serviceInfo.Version, }).Info("Service successfully restored") - manager.updateServiceStatusByID(serviceInfo.ID, cloudprotocol.InstalledStatus, "") + manager.updateServiceStatusByID(serviceInfo.ServiceID, cloudprotocol.InstalledStatus, "") return nil }) @@ -1223,7 +1223,7 @@ func (manager *softwareManager) removeServices() (removeErr string) { serviceStatus := service manager.actionHandler.Execute(serviceStatus.ID, func(serviceID string) error { - if err := manager.softwareUpdater.RemoveService(serviceStatus.ID); err != nil { + if err := manager.softwareUpdater.RemoveService(serviceStatus.ServiceID); err != nil { handleError(serviceStatus, err.Error()) return aoserrors.Wrap(err) } @@ -1248,11 +1248,11 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr strin manager.InstanceStatuses = []cloudprotocol.InstanceStatus{} for _, instance := range manager.CurrentUpdate.RunInstances { - var aosVersion uint64 + var version string for _, serviceInfo := range manager.CurrentUpdate.InstallServices { - if serviceInfo.ID == instance.ServiceID { - aosVersion = serviceInfo.AosVersion + if serviceInfo.ServiceID == instance.ServiceID { + version = serviceInfo.Version break } @@ -1267,7 +1267,7 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr strin manager.InstanceStatuses = append(manager.InstanceStatuses, cloudprotocol.InstanceStatus{ InstanceIdent: ident, - AosVersion: aosVersion, + Version: version, RunState: cloudprotocol.InstanceStateActivating, }) } diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 48c8db7f..785de575 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -538,16 +538,16 @@ func TestUpdateServices(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Services: []cloudprotocol.ServiceInfo{ { - ID: "service0", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{0}}, + ServiceID: "service0", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{0}}, }, { - ID: "service1", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{1}}, + ServiceID: "service1", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ID: "service3", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{3}}, + ServiceID: "service3", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, }, }) @@ -613,16 +613,16 @@ func TestUpdateServices(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Services: []cloudprotocol.ServiceInfo{ { - ID: "service1", VersionInfo: aostypes.VersionInfo{AosVersion: 1}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{1}}, + ServiceID: "service1", Version: "1.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ID: "service3", VersionInfo: aostypes.VersionInfo{AosVersion: 2}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{3}}, + ServiceID: "service3", Version: "2.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ID: "service4", VersionInfo: aostypes.VersionInfo{AosVersion: 2}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{Sha256: []byte{4}}, + ServiceID: "service4", Version: "2.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, }, }) @@ -915,24 +915,24 @@ func TestUpdateCachedSOTA(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Services: []cloudprotocol.ServiceInfo{ { - ID: "service0", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"service0"}, Sha256: []byte{0}}, + ServiceID: "service0", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service0"}, Sha256: []byte{0}}, }, { - ID: "service1", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"service1"}, Sha256: []byte{1}}, + ServiceID: "service1", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service1"}, Sha256: []byte{1}}, }, { - ID: "service2", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"service2"}, Sha256: []byte{2}}, + ServiceID: "service2", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service2"}, Sha256: []byte{2}}, }, { - ID: "service3", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"service3"}, Sha256: []byte{3}}, + ServiceID: "service3", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service3"}, Sha256: []byte{3}}, }, { - ID: "service4", VersionInfo: aostypes.VersionInfo{AosVersion: 0}, - DecryptDataStruct: cloudprotocol.DecryptDataStruct{URLs: []string{"service3"}, Sha256: []byte{3}}, + ServiceID: "service4", Version: "0.0", + DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service3"}, Sha256: []byte{3}}, }, }, Layers: []cloudprotocol.LayerInfo{ From 57a795a4b7023a80fc2dd82165fa593d3d4f31e0 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 12:50:08 +0300 Subject: [PATCH 012/146] [all] Update ServiceStatus Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 8 +-- cmserver/cmserver.go | 6 +- cmserver/cmserver_test.go | 14 ++--- imagemanager/imagemanager.go | 6 +- launcher/launcher.go | 4 +- launcher/launcher_test.go | 2 +- unitstatushandler/softwaremanager.go | 65 ++++++++++---------- unitstatushandler/unitstatushandler.go | 26 ++++---- unitstatushandler/unitstatushandler_test.go | 66 ++++++++++----------- 9 files changed, 98 insertions(+), 99 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 7562cd7d..d0ac8c4b 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -376,13 +376,13 @@ func TestSendMessages(t *testing.T) { unitConfigData := []cloudprotocol.UnitConfigStatus{{Version: "1.0"}} serviceSetupData := []cloudprotocol.ServiceStatus{ - {ID: "service0", AosVersion: 1, Status: "running", ErrorInfo: nil}, + {ServiceID: "service0", Version: "1.0", Status: "running", ErrorInfo: nil}, { - ID: "service1", AosVersion: 2, Status: "stopped", + ServiceID: "service1", Version: "2.0", Status: "stopped", ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 1, ExitCode: 100, Message: "crash"}, }, { - ID: "service2", AosVersion: 3, Status: "unknown", + ServiceID: "service2", Version: "3.0", Status: "unknown", ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 1, ExitCode: 100, Message: "unknown"}, }, } @@ -390,7 +390,7 @@ func TestSendMessages(t *testing.T) { instances := []cloudprotocol.InstanceStatus{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, - AosVersion: 1, StateChecksum: "12345", RunState: "running", NodeID: "mainNode", + Version: "1.0", StateChecksum: "12345", RunState: "running", NodeID: "mainNode", }, } diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index d383b329..cab2c6cf 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -318,7 +318,7 @@ func (server *CMServer) notifyAllClients(notification *pb.SchedulerNotifications func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSOTAStatus) { pbStatus = new(pb.UpdateSOTAStatus) - pbStatus.Error = updateStatus.Error + pbStatus.Error.Message = updateStatus.Error pbStatus.State = updateStatus.State.getPbState() @@ -355,7 +355,7 @@ func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSO func (updateStatus *UpdateFOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateFOTAStatus) { pbStatus = new(pb.UpdateFOTAStatus) - pbStatus.Error = updateStatus.Error + pbStatus.Error.Message = updateStatus.Error pbStatus.State = updateStatus.State.getPbState() for _, component := range updateStatus.Components { @@ -366,7 +366,7 @@ func (updateStatus *UpdateFOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateFO } if updateStatus.UnitConfig != nil { - pbStatus.UnitConfig = &pb.UnitConfigInfo{VendorVersion: updateStatus.UnitConfig.VendorVersion} + pbStatus.UnitConfig = &pb.UnitConfigInfo{Version: updateStatus.UnitConfig.Version} } return pbStatus diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 518f5c9a..55e8dcc5 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -168,8 +168,8 @@ func TestConnection(t *testing.T) { } statusNotification := cmserver.UpdateSOTAStatus{ - InstallServices: []cloudprotocol.ServiceStatus{{ID: "s1", AosVersion: 42}}, - RemoveServices: []cloudprotocol.ServiceStatus{{ID: "s2", AosVersion: 42}}, + InstallServices: []cloudprotocol.ServiceStatus{{ServiceID: "s1", Version: "42.0"}}, + RemoveServices: []cloudprotocol.ServiceStatus{{ServiceID: "s2", Version: "42.0"}}, InstallLayers: []cloudprotocol.LayerStatus{{ID: "l1", Digest: "someSha", AosVersion: 42}}, RemoveLayers: []cloudprotocol.LayerStatus{{ID: "l2", Digest: "someSha", AosVersion: 42}}, UpdateStatus: cmserver.UpdateStatus{State: cmserver.Downloading, Error: "SOTA error"}, @@ -191,7 +191,7 @@ func TestConnection(t *testing.T) { t.Error("Incorrect state: ", status.GetState().String()) } - if sotaStatus.GetError() != "SOTA error" { + if sotaStatus.GetError().GetMessage() != "SOTA error" { t.Error("Incorrect error message: ", status.GetError()) } @@ -199,11 +199,11 @@ func TestConnection(t *testing.T) { t.Fatal("Incorrect count of services") } - if sotaStatus.GetInstallServices()[0].GetId() != "s1" { + if sotaStatus.GetInstallServices()[0].GetServiceId() != "s1" { t.Error("Incorrect service id") } - if sotaStatus.GetInstallServices()[0].GetAosVersion() != 42 { + if sotaStatus.GetInstallServices()[0].GetVersion() != "42.0" { t.Error("Incorrect service aos version") } @@ -211,7 +211,7 @@ func TestConnection(t *testing.T) { t.Fatal("Incorrect count of layers") } - if sotaStatus.GetInstallLayers()[0].GetId() != "l1" { + if sotaStatus.GetInstallLayers()[0].GetLayerId() != "l1" { t.Error("Incorrect layer id") } @@ -219,7 +219,7 @@ func TestConnection(t *testing.T) { t.Error("Incorrect layer digest") } - if sotaStatus.GetInstallLayers()[0].GetAosVersion() != 42 { + if sotaStatus.GetInstallLayers()[0].GetVersion() != "42.0" { t.Error("Incorrect layer aos version") } diff --git a/imagemanager/imagemanager.go b/imagemanager/imagemanager.go index 94a9792e..747d4f5a 100644 --- a/imagemanager/imagemanager.go +++ b/imagemanager/imagemanager.go @@ -245,9 +245,9 @@ func (imagemanager *Imagemanager) GetServicesStatus() ([]unitstatushandler.Servi for i, service := range servicesInfo { servicesStatus[i] = unitstatushandler.ServiceStatus{ ServiceStatus: cloudprotocol.ServiceStatus{ - ID: service.ID, - AosVersion: service.AosVersion, - Status: cloudprotocol.InstalledStatus, + ServiceID: service.ServiceID, + Version: service.Version, + Status: cloudprotocol.InstalledStatus, }, Cached: service.Cached, } } diff --git a/launcher/launcher.go b/launcher/launcher.go index 55a7ba51..dd15c77c 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -608,14 +608,14 @@ newServicesLoop: } errorService := cloudprotocol.ServiceStatus{ - ID: newService, Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{}, + ServiceID: newService, Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{}, } service, err := launcher.imageProvider.GetServiceInfo(newService) if err != nil { errorService.ErrorInfo.Message = err.Error() } else { - errorService.AosVersion = service.AosVersion + errorService.Version = service.Version errorService.ErrorInfo.Message = "can't run any instances" } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 3b1fac7d..d8cbdf4e 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -960,7 +960,7 @@ func TestServiceRevert(t *testing.T) { }, "", errors.New("layer does't exist")), //nolint:goerr113 }, ErrorServices: []cloudprotocol.ServiceStatus{ - {ID: service2, AosVersion: 1, Status: cloudprotocol.ErrorStatus}, + {ServiceID: service2, Version: "1.0", Status: cloudprotocol.ErrorStatus}, }, } diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index dc1d93f0..add2fa38 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -179,13 +179,13 @@ func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTASt for _, service := range manager.CurrentUpdate.InstallServices { status.InstallServices = append(status.InstallServices, cloudprotocol.ServiceStatus{ - ID: service.ID, AosVersion: service.AosVersion, + ServiceID: service.ServiceID, Version: service.Version, }) } for _, service := range manager.CurrentUpdate.RemoveServices { status.RemoveServices = append(status.RemoveServices, cloudprotocol.ServiceStatus{ - ID: service.ID, AosVersion: service.AosVersion, + ServiceID: service.ServiceID, Version: service.Version, }) } @@ -205,12 +205,12 @@ func (manager *softwareManager) processRunStatus(status RunInstancesStatus) { errMsg = errStatus.ErrorInfo.Message } - if _, ok := manager.ServiceStatuses[errStatus.ID]; !ok { + if _, ok := manager.ServiceStatuses[errStatus.ServiceID]; !ok { status := errStatus - manager.ServiceStatuses[errStatus.ID] = &status + manager.ServiceStatuses[errStatus.ServiceID] = &status } - manager.updateServiceStatusByID(errStatus.ID, errStatus.Status, errMsg) + manager.updateServiceStatusByID(errStatus.ServiceID, errStatus.Status, errMsg) } manager.runCond.Broadcast() @@ -286,7 +286,7 @@ removeServiceLoop: } for _, desiredService := range desiredServices { - if service.ID == desiredService.ID { + if service.ServiceID == desiredService.ServiceID { continue removeServiceLoop } } @@ -551,15 +551,15 @@ func (manager *softwareManager) download(ctx context.Context) { } else if serviceStatus, ok := manager.ServiceStatuses[id]; ok { if serviceStatus.Status == cloudprotocol.ErrorStatus { log.WithFields(log.Fields{ - "id": serviceStatus.ID, - "version": serviceStatus.AosVersion, + "id": serviceStatus.ServiceID, + "version": serviceStatus.Version, }).Errorf("Error downloading service: %v", serviceStatus.ErrorInfo) continue } log.WithFields(log.Fields{ - "id": serviceStatus.ID, - "version": serviceStatus.AosVersion, + "id": serviceStatus.ServiceID, + "version": serviceStatus.Version, }).Debug("Service successfully downloaded") manager.updateServiceStatusByID(id, cloudprotocol.PendingStatus, "") @@ -592,24 +592,23 @@ func (manager *softwareManager) prepareDownloadRequest() (request map[string]dow for _, service := range manager.CurrentUpdate.InstallServices { log.WithFields(log.Fields{ - "id": service.ID, - "version": service.AosVersion, + "id": service.ServiceID, + "version": service.Version, }).Debug("Download service") - request[service.ID] = downloader.PackageInfo{ + request[service.ServiceID] = downloader.PackageInfo{ URLs: service.URLs, Sha256: service.Sha256, - Sha512: service.Sha512, Size: service.Size, TargetType: cloudprotocol.DownloadTargetService, - TargetID: service.ID, + TargetID: service.ServiceID, TargetAosVersion: service.AosVersion, TargetVendorVersion: service.VendorVersion, } - manager.ServiceStatuses[service.ID] = &cloudprotocol.ServiceStatus{ - ID: service.ID, - AosVersion: service.AosVersion, - Status: cloudprotocol.DownloadingStatus, + manager.ServiceStatuses[service.ServiceID] = &cloudprotocol.ServiceStatus{ + ServiceID: service.ServiceID, + Version: service.Version, + Status: cloudprotocol.DownloadingStatus, } } @@ -1184,15 +1183,15 @@ func (manager *softwareManager) removeServices() (removeErr string) { handleError := func(service cloudprotocol.ServiceStatus, serviceErr string) { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, + "id": service.ServiceID, + "version": service.Version, }).Errorf("Can't install service: %s", serviceErr) if isCancelError(serviceErr) { return } - manager.updateStatusByID(service.ID, cloudprotocol.ErrorStatus, serviceErr) + manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, serviceErr) mutex.Lock() defer mutex.Unlock() @@ -1204,36 +1203,36 @@ func (manager *softwareManager) removeServices() (removeErr string) { for _, service := range manager.CurrentUpdate.RemoveServices { log.WithFields(log.Fields{ - "id": service.ID, - "aosVersion": service.AosVersion, + "id": service.ServiceID, + "aosVersion": service.Version, }).Debug("Remove service") // Create status for remove layers. For install layer it is created in download function. manager.statusMutex.Lock() - manager.ServiceStatuses[service.ID] = &cloudprotocol.ServiceStatus{ - ID: service.ID, - AosVersion: service.AosVersion, - Status: cloudprotocol.RemovingStatus, + manager.ServiceStatuses[service.ServiceID] = &cloudprotocol.ServiceStatus{ + ServiceID: service.ServiceID, + Version: service.Version, + Status: cloudprotocol.RemovingStatus, } manager.statusMutex.Unlock() - manager.updateServiceStatusByID(service.ID, cloudprotocol.RemovingStatus, "") + manager.updateServiceStatusByID(service.ServiceID, cloudprotocol.RemovingStatus, "") // Create new variable to be captured by action function serviceStatus := service - manager.actionHandler.Execute(serviceStatus.ID, func(serviceID string) error { + manager.actionHandler.Execute(serviceStatus.ServiceID, func(serviceID string) error { if err := manager.softwareUpdater.RemoveService(serviceStatus.ServiceID); err != nil { handleError(serviceStatus, err.Error()) return aoserrors.Wrap(err) } log.WithFields(log.Fields{ - "id": serviceStatus.ID, - "aosVersion": serviceStatus.AosVersion, + "id": serviceStatus.ServiceID, + "aosVersion": serviceStatus.Version, }).Info("Service successfully removed") - manager.updateServiceStatusByID(serviceStatus.ID, cloudprotocol.RemovedStatus, "") + manager.updateServiceStatusByID(serviceStatus.ServiceID, cloudprotocol.RemovedStatus, "") return nil }) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 2efd345c..e11f370a 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -384,15 +384,15 @@ func (instance *Instance) initCurrentStatus() error { } for _, status := range serviceStatuses { - if _, ok := instance.serviceStatuses[status.ID]; !ok { - instance.serviceStatuses[status.ID] = &itemStatus{} + if _, ok := instance.serviceStatuses[status.ServiceID]; !ok { + instance.serviceStatuses[status.ServiceID] = &itemStatus{} } log.WithFields(log.Fields{ - "id": status.ID, - "status": status.Status, - "aosVersion": status.AosVersion, - "error": status.ErrorInfo, + "id": status.ServiceID, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Initial service status") instance.processServiceStatus(status) @@ -455,7 +455,7 @@ func (descriptor *statusDescriptor) getVersion() (version string) { return strconv.FormatUint(amqpStatus.AosVersion, 10) case *cloudprotocol.ServiceStatus: - return strconv.FormatUint(amqpStatus.AosVersion, 10) + return amqpStatus.Version default: return "" @@ -540,10 +540,10 @@ func (instance *Instance) updateServiceStatus(serviceInfo cloudprotocol.ServiceS defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "id": serviceInfo.ID, - "status": serviceInfo.Status, - "aosVersion": serviceInfo.AosVersion, - "error": serviceInfo.ErrorInfo, + "id": serviceInfo.ServiceID, + "status": serviceInfo.Status, + "version": serviceInfo.Version, + "error": serviceInfo.ErrorInfo, }).Debug("Update service status") instance.processServiceStatus(serviceInfo) @@ -551,10 +551,10 @@ func (instance *Instance) updateServiceStatus(serviceInfo cloudprotocol.ServiceS } func (instance *Instance) processServiceStatus(serviceInfo cloudprotocol.ServiceStatus) { - serviceStatus, ok := instance.serviceStatuses[serviceInfo.ID] + serviceStatus, ok := instance.serviceStatuses[serviceInfo.ServiceID] if !ok { serviceStatus = &itemStatus{} - instance.serviceStatuses[serviceInfo.ID] = serviceStatus + instance.serviceStatuses[serviceInfo.ServiceID] = serviceStatus } instance.updateStatus(serviceStatus, statusDescriptor{&serviceInfo}) diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 785de575..bbf590b5 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -67,26 +67,26 @@ func TestSendInitialStatus(t *testing.T) { {ID: "layer2", Digest: "digest2", AosVersion: 3, Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{ - {ID: "service0", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "service1", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "service2", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, } initialServices := []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service0", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service1", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service2", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + ServiceID: "service2", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, { ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service3", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus, }, Cached: true, }, @@ -485,13 +485,13 @@ func TestUpdateLayers(t *testing.T) { func TestUpdateServices(t *testing.T) { serviceStatuses := []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service0", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service1", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service2", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service2", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( @@ -528,10 +528,10 @@ func TestUpdateServices(t *testing.T) { Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{ - {ID: "service0", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "service1", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "service2", Status: cloudprotocol.RemovedStatus}, - {ID: "service3", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Status: cloudprotocol.RemovedStatus}, + {ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, } @@ -573,16 +573,16 @@ func TestUpdateServices(t *testing.T) { softwareUpdater.AllServices = []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service0", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service1", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service2", AosVersion: 0, Status: cloudprotocol.RemovedStatus, + ServiceID: "service2", Version: "0.0", Status: cloudprotocol.RemovedStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service3", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, } softwareUpdater.UpdateError = aoserrors.New("some error occurs") @@ -593,18 +593,18 @@ func TestUpdateServices(t *testing.T) { Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{ { - ID: "service0", AosVersion: 0, Status: cloudprotocol.ErrorStatus, + ServiceID: "service0", Version: "0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, - {ID: "service1", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "service2", Status: cloudprotocol.RemovedStatus}, - {ID: "service3", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Status: cloudprotocol.RemovedStatus}, + {ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, { - ID: "service3", AosVersion: 2, Status: cloudprotocol.ErrorStatus, + ServiceID: "service3", Version: "2.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, { - ID: "service4", AosVersion: 2, Status: cloudprotocol.ErrorStatus, + ServiceID: "service4", Version: "2.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, }, @@ -836,16 +836,16 @@ func TestUpdateInstancesStatus(t *testing.T) { func TestUpdateCachedSOTA(t *testing.T) { serviceStatuses := []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service0", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service1", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service2", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service2", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ID: "service4", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + ServiceID: "service4", Version: "0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true}, } layerStatuses := []unitstatushandler.LayerStatus{ @@ -904,11 +904,11 @@ func TestUpdateCachedSOTA(t *testing.T) { {ID: "layer5", Digest: "digest5", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{ - {ID: "service0", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "service1", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "service2", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "service3", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "service4", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service3", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service4", Version: "0.0", Status: cloudprotocol.InstalledStatus}, }, } From 4aef009cf20f3a1ef69f5b6ff20dee9e57e40095 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 13:59:32 +0300 Subject: [PATCH 013/146] [all] Update LayerStatus Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 8 +-- amqphandler/amqphandler_test.go | 6 +- cmserver/cmserver_test.go | 4 +- database/database_internal_test.go | 2 +- imagemanager/imagemanager.go | 8 +-- unitstatushandler/softwaremanager.go | 42 ++++++------- unitstatushandler/unitstatushandler.go | 23 ++++--- unitstatushandler/unitstatushandler_test.go | 70 ++++++++++----------- 8 files changed, 80 insertions(+), 83 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index d3bfeb01..a5ec7050 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -648,11 +648,9 @@ func (handler *AmqpHandler) decodeData(data []byte, result interface{}) error { for _, layer := range desiredStatus.Layers { log.WithFields(log.Fields{ - "id": layer.ID, - "digest": layer.Digest, - "aosVersion": layer.AosVersion, - "vendorVersion": layer.VendorVersion, - "description": layer.Description, + "id": layer.LayerID, + "digest": layer.Digest, + "version": layer.Version, }).Debug("Layer") } diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index d0ac8c4b..9b43ccf1 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -396,11 +396,11 @@ func TestSendMessages(t *testing.T) { layersSetupData := []cloudprotocol.LayerStatus{ { - ID: "layer0", Digest: "sha256:0", Status: "failed", AosVersion: 1, + LayerID: "layer0", Digest: "sha256:0", Status: "failed", Version: "1.0", ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 1, ExitCode: 100, Message: "bad layer"}, }, - {ID: "layer1", Digest: "sha256:1", Status: "installed", AosVersion: 2}, - {ID: "layer2", Digest: "sha256:2", Status: "installed", AosVersion: 3}, + {LayerID: "layer1", Digest: "sha256:1", Status: "installed", Version: "2.0"}, + {LayerID: "layer2", Digest: "sha256:2", Status: "installed", Version: "3.0"}, } componentSetupData := []cloudprotocol.ComponentStatus{ diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 55e8dcc5..0f44c57d 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -170,8 +170,8 @@ func TestConnection(t *testing.T) { statusNotification := cmserver.UpdateSOTAStatus{ InstallServices: []cloudprotocol.ServiceStatus{{ServiceID: "s1", Version: "42.0"}}, RemoveServices: []cloudprotocol.ServiceStatus{{ServiceID: "s2", Version: "42.0"}}, - InstallLayers: []cloudprotocol.LayerStatus{{ID: "l1", Digest: "someSha", AosVersion: 42}}, - RemoveLayers: []cloudprotocol.LayerStatus{{ID: "l2", Digest: "someSha", AosVersion: 42}}, + InstallLayers: []cloudprotocol.LayerStatus{{LayerID: "l1", Digest: "someSha", Version: "42.0"}}, + RemoveLayers: []cloudprotocol.LayerStatus{{LayerID: "l2", Digest: "someSha", Version: "42.0"}}, UpdateStatus: cmserver.UpdateStatus{State: cmserver.Downloading, Error: "SOTA error"}, } diff --git a/database/database_internal_test.go b/database/database_internal_test.go index 2d343f50..cc0ae5f8 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -439,7 +439,7 @@ func TestLayerStore(t *testing.T) { } if !reflect.DeepEqual(layer, tCase.layer) { - t.Errorf("layer %s doesn't match stored one", tCase.layer.ID) + t.Errorf("layer %s doesn't match stored one", tCase.layer.LayerID) } layers, err := testDB.GetLayersInfo() diff --git a/imagemanager/imagemanager.go b/imagemanager/imagemanager.go index 747d4f5a..9a0e4d80 100644 --- a/imagemanager/imagemanager.go +++ b/imagemanager/imagemanager.go @@ -269,10 +269,10 @@ func (imagemanager *Imagemanager) GetLayersStatus() ([]unitstatushandler.LayerSt for i, layer := range layersInfo { layersStatus[i] = unitstatushandler.LayerStatus{ LayerStatus: cloudprotocol.LayerStatus{ - ID: layer.ID, - AosVersion: layer.AosVersion, - Digest: layer.Digest, - Status: cloudprotocol.InstalledStatus, + LayerID: layer.LayerID, + Version: layer.Version, + Digest: layer.Digest, + Status: cloudprotocol.InstalledStatus, }, Cached: layer.Cached, } } diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index add2fa38..9b3234ed 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -167,13 +167,13 @@ func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTASt for _, layer := range manager.CurrentUpdate.InstallLayers { status.InstallLayers = append(status.InstallLayers, cloudprotocol.LayerStatus{ - ID: layer.ID, Digest: layer.Digest, AosVersion: layer.AosVersion, + LayerID: layer.LayerID, Digest: layer.Digest, Version: layer.Version, }) } for _, layer := range manager.CurrentUpdate.RemoveLayers { status.RemoveLayers = append(status.RemoveLayers, cloudprotocol.LayerStatus{ - ID: layer.ID, Digest: layer.Digest, AosVersion: layer.AosVersion, + LayerID: layer.LayerID, Digest: layer.Digest, Version: layer.Version, }) } @@ -533,18 +533,18 @@ func (manager *softwareManager) download(ctx context.Context) { if layerStatus, ok := manager.LayerStatuses[id]; ok { if layerStatus.Status == cloudprotocol.ErrorStatus { log.WithFields(log.Fields{ - "id": layerStatus.ID, + "id": layerStatus.LayerID, "digest": layerStatus.Digest, - "version": layerStatus.AosVersion, + "version": layerStatus.Version, }).Errorf("Error downloading layer: %v", layerStatus.ErrorInfo) continue } log.WithFields(log.Fields{ - "id": layerStatus.ID, + "id": layerStatus.LayerID, "digest": layerStatus.Digest, - "version": layerStatus.AosVersion, + "version": layerStatus.Version, }).Debug("Layer successfully downloaded") manager.updateLayerStatusByID(id, cloudprotocol.PendingStatus, "") @@ -614,9 +614,9 @@ func (manager *softwareManager) prepareDownloadRequest() (request map[string]dow for _, layer := range manager.CurrentUpdate.InstallLayers { log.WithFields(log.Fields{ - "id": layer.ID, + "id": layer.LayerID, "digest": layer.Digest, - "version": layer.AosVersion, + "version": layer.Version, }).Debug("Download layer") request[layer.Digest] = downloader.PackageInfo{ @@ -630,10 +630,10 @@ func (manager *softwareManager) prepareDownloadRequest() (request map[string]dow TargetVendorVersion: layer.VendorVersion, } manager.LayerStatuses[layer.Digest] = &cloudprotocol.LayerStatus{ - ID: layer.ID, - AosVersion: layer.AosVersion, - Digest: layer.Digest, - Status: cloudprotocol.DownloadingStatus, + LayerID: layer.LayerID, + Version: layer.Version, + Digest: layer.Digest, + Status: cloudprotocol.DownloadingStatus, } } @@ -974,8 +974,8 @@ func (manager *softwareManager) processRemoveRestorLayers( handleError := func(layer cloudprotocol.LayerStatus, layerErr string) { log.WithFields(log.Fields{ "digest": layer.Digest, - "id": layer.ID, - "aosVersion": layer.AosVersion, + "id": layer.LayerID, + "aosVersion": layer.Version, }).Errorf("Can't %s layer: %s", operationStr, layerErr) if isCancelError(layerErr) { @@ -994,16 +994,16 @@ func (manager *softwareManager) processRemoveRestorLayers( for _, layer := range layers { log.WithFields(log.Fields{ - "id": layer.ID, - "aosVersion": layer.AosVersion, + "id": layer.LayerID, + "aosVersion": layer.Version, "digest": layer.Digest, }).Debugf("%s layer", operationStr) manager.statusMutex.Lock() manager.LayerStatuses[layer.Digest] = &cloudprotocol.LayerStatus{ - ID: layer.ID, - AosVersion: layer.AosVersion, - Digest: layer.Digest, + LayerID: layer.LayerID, + Version: layer.Version, + Digest: layer.Digest, } manager.statusMutex.Unlock() @@ -1017,8 +1017,8 @@ func (manager *softwareManager) processRemoveRestorLayers( } log.WithFields(log.Fields{ - "id": layerInfo.ID, - "aosVersion": layerInfo.AosVersion, + "id": layerInfo.LayerID, + "aosVersion": layerInfo.Version, "digest": layerInfo.Digest, }).Infof("Layer successfully %sd", operationStr) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index e11f370a..84bf3af4 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -21,7 +21,6 @@ import ( "context" "encoding/json" "errors" - "strconv" "sync" "sync/atomic" "time" @@ -409,11 +408,11 @@ func (instance *Instance) initCurrentStatus() error { } log.WithFields(log.Fields{ - "id": status.ID, - "digest": status.Digest, - "status": status.Status, - "aosVersion": status.AosVersion, - "error": status.ErrorInfo, + "id": status.LayerID, + "digest": status.Digest, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Initial layer status") instance.processLayerStatus(status) @@ -452,7 +451,7 @@ func (descriptor *statusDescriptor) getVersion() (version string) { return amqpStatus.Version case *cloudprotocol.LayerStatus: - return strconv.FormatUint(amqpStatus.AosVersion, 10) + return amqpStatus.Version case *cloudprotocol.ServiceStatus: return amqpStatus.Version @@ -510,11 +509,11 @@ func (instance *Instance) updateLayerStatus(layerInfo cloudprotocol.LayerStatus) defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "id": layerInfo.ID, - "digest": layerInfo.Digest, - "status": layerInfo.Status, - "aosVersion": layerInfo.AosVersion, - "error": layerInfo.ErrorInfo, + "id": layerInfo.LayerID, + "digest": layerInfo.Digest, + "status": layerInfo.Status, + "version": layerInfo.Version, + "error": layerInfo.ErrorInfo, }).Debug("Update layer status") if _, ok := instance.layerStatuses[layerInfo.Digest]; !ok { diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index bbf590b5..1327af8d 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -62,9 +62,9 @@ func TestSendInitialStatus(t *testing.T) { {ComponentID: "comp2", Version: "1.2", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{ - {ID: "layer0", Digest: "digest0", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "layer1", Digest: "digest1", AosVersion: 2, Status: cloudprotocol.InstalledStatus}, - {ID: "layer2", Digest: "digest2", AosVersion: 3, Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "3.0", Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{ {ServiceID: "service0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -94,13 +94,13 @@ func TestSendInitialStatus(t *testing.T) { initialLayers := []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer0", Digest: "digest0", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + LayerID: "layer0", Digest: "digest0", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer1", Digest: "digest1", AosVersion: 2, Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "2.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer2", Digest: "digest2", AosVersion: 3, Status: cloudprotocol.InstalledStatus, + LayerID: "layer2", Digest: "digest2", Version: "3.0", Status: cloudprotocol.InstalledStatus, }}, } @@ -328,13 +328,13 @@ func TestUpdateComponents(t *testing.T) { func TestUpdateLayers(t *testing.T) { layerStatuses := []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer0", Digest: "digest0", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer1", Digest: "digest1", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer2", Digest: "digest2", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( @@ -370,11 +370,11 @@ func TestUpdateLayers(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {ID: "layer0", Digest: "digest0", AosVersion: 0, Status: cloudprotocol.RemovedStatus}, - {ID: "layer1", Digest: "digest1", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "layer2", Digest: "digest2", AosVersion: 0, Status: cloudprotocol.RemovedStatus}, - {ID: "layer3", Digest: "digest3", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "layer4", Digest: "digest4", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer3", Digest: "digest3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer4", Digest: "digest4", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{}, } @@ -415,19 +415,19 @@ func TestUpdateLayers(t *testing.T) { softwareUpdater.AllLayers = []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer0", Digest: "digest0", AosVersion: 0, Status: cloudprotocol.RemovedStatus, + LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.RemovedStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer1", Digest: "digest1", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer2", Digest: "digest2", AosVersion: 0, Status: cloudprotocol.RemovedStatus, + LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.RemovedStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer3", Digest: "digest3", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + LayerID: "layer3", Digest: "digest3", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer4", Digest: "digest4", AosVersion: 1, Status: cloudprotocol.InstalledStatus, + LayerID: "layer4", Digest: "digest4", Version: "1.0", Status: cloudprotocol.InstalledStatus, }}, } @@ -439,13 +439,13 @@ func TestUpdateLayers(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {ID: "layer0", Digest: "digest0", AosVersion: 0, Status: cloudprotocol.RemovedStatus}, - {ID: "layer1", Digest: "digest1", AosVersion: 0, Status: cloudprotocol.RemovedStatus}, - {ID: "layer2", Digest: "digest2", AosVersion: 0, Status: cloudprotocol.RemovedStatus}, - {ID: "layer3", Digest: "digest3", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, - {ID: "layer4", Digest: "digest4", AosVersion: 1, Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer3", Digest: "digest3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer4", Digest: "digest4", Version: "1.0", Status: cloudprotocol.InstalledStatus}, { - ID: "layer5", Digest: "digest5", AosVersion: 1, Status: cloudprotocol.ErrorStatus, + LayerID: "layer5", Digest: "digest5", Version: "1.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, }, @@ -850,19 +850,19 @@ func TestUpdateCachedSOTA(t *testing.T) { } layerStatuses := []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer0", Digest: "digest0", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer1", Digest: "digest1", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer2", Digest: "digest2", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer4", Digest: "digest4", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer4", Digest: "digest4", Version: "0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true}, {LayerStatus: cloudprotocol.LayerStatus{ - ID: "layer5", Digest: "digest5", AosVersion: 0, Status: cloudprotocol.InstalledStatus, + LayerID: "layer5", Digest: "digest5", Version: "0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( @@ -897,11 +897,11 @@ func TestUpdateCachedSOTA(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {ID: "layer0", Digest: "digest0", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "layer1", Digest: "digest1", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "layer2", Digest: "digest2", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "layer3", Digest: "digest3", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, - {ID: "layer5", Digest: "digest5", AosVersion: 0, Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer3", Digest: "digest3", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer5", Digest: "digest5", Version: "0.0", Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{ {ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, From a1e8deda5d9f1e32f0dfc516c5a653e0f9d126e7 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 14:21:57 +0300 Subject: [PATCH 014/146] [all] Initial UnitConfig adaptation Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 2 +- amqphandler/amqphandler_test.go | 2 +- cmserver/cmserver_test.go | 2 +- smcontroller/smhandler.go | 4 ++-- unitconfig/unitconfig_test.go | 4 ++-- unitstatushandler/unitstatushandler_test.go | 5 ++--- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index a5ec7050..151512c0 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -635,7 +635,7 @@ func (handler *AmqpHandler) decodeData(data []byte, result interface{}) error { log.Debug("Decrypted data:") - if len(desiredStatus.UnitConfig) != 0 { + if desiredStatus.UnitConfig != nil { log.Debugf("UnitConfig: %s", desiredStatus.UnitConfig) } diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 9b43ccf1..c64d6b8d 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -311,7 +311,7 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.DesiredStatusMessageType, expectedData: &cloudprotocol.DesiredStatus{ - UnitConfig: json.RawMessage([]byte("\"config\"")), + UnitConfig: &cloudprotocol.UnitConfig{}, Components: []cloudprotocol.ComponentInfo{ {Version: "1.0.0", ComponentID: "rootfs"}, }, diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 0f44c57d..b673f3f4 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -163,7 +163,7 @@ func TestConnection(t *testing.T) { t.Fatal("Unit Config is nil") } - if status.GetUnitConfig().GetVendorVersion() != "bc_version" { + if status.GetUnitConfig().GetVersion() != "bc_version" { t.Error("Incorrect unit config version") } diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index bdeb1bc8..b72d56bc 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -614,7 +614,7 @@ func (handler *smHandler) sendCheckUnitConfig(cfg cloudprotocol.NodeConfig, vend } if err := handler.stream.Send(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_CheckUnitConfig{ - CheckUnitConfig: &pb.CheckUnitConfig{UnitConfig: string(configJSON), VendorVersion: vendorVersion}, + CheckUnitConfig: &pb.CheckUnitConfig{UnitConfig: string(configJSON), Version: vendorVersion}, }}); err != nil { return aoserrors.Wrap(err) } @@ -629,7 +629,7 @@ func (handler *smHandler) sendSetUnitConfig(cfg cloudprotocol.NodeConfig, vendor } if err := handler.stream.Send(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SetUnitConfig{ - SetUnitConfig: &pb.SetUnitConfig{UnitConfig: string(configJSON), VendorVersion: vendorVersion}, + SetUnitConfig: &pb.SetUnitConfig{UnitConfig: string(configJSON), Version: vendorVersion}, }}); err != nil { return aoserrors.Wrap(err) } diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index 12f52607..f6bc1642 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -114,8 +114,8 @@ func TestValidGetStatus(t *testing.T) { t.Errorf("Wrong unit config status: %s", info.Status) } - if info.VendorVersion != "1.0.0" { - t.Errorf("Wrong unit config version: %s", info.VendorVersion) + if info.Version != "1.0.0" { + t.Errorf("Wrong unit config version: %s", info.Version) } nodeUnitConfig := unitConfig.GetUnitConfiguration("type1") diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 1327af8d..1cc0372b 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -18,7 +18,6 @@ package unitstatushandler_test import ( - "encoding/json" "reflect" "testing" "time" @@ -192,7 +191,7 @@ func TestUpdateUnitConfig(t *testing.T) { unitConfigUpdater.UpdateVersion = "1.1" - statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: json.RawMessage("{}")}) + statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}) receivedUnitStatus, err := sender.WaitForStatus(waitStatusTimeout) if err != nil { @@ -214,7 +213,7 @@ func TestUpdateUnitConfig(t *testing.T) { } expectedUnitStatus.UnitConfig = append(expectedUnitStatus.UnitConfig, unitConfigUpdater.UnitConfigStatus) - statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: json.RawMessage("{}")}) + statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}) if receivedUnitStatus, err = sender.WaitForStatus(waitStatusTimeout); err != nil { t.Fatalf("Can't receive unit status: %s", err) From d9901fa439139fb0144394fb313e4c657bf00001 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 14:23:22 +0300 Subject: [PATCH 015/146] [downloader] image.FileInfo adaptation Signed-off-by: Mykola Kobets --- downloader/downloader.go | 1 - 1 file changed, 1 deletion(-) diff --git a/downloader/downloader.go b/downloader/downloader.go index a3c82382..ab569b30 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -514,7 +514,6 @@ func (downloader *Downloader) downloadPackage(result *downloadResult) (err error if err = image.CheckFileInfo(result.ctx, result.downloadFileName, image.FileInfo{ Sha256: result.packageInfo.Sha256, - Sha512: result.packageInfo.Sha512, Size: result.packageInfo.Size, }); err != nil { if removeErr := os.RemoveAll(result.downloadFileName); removeErr != nil { From 0a388ecc579beac3062bff1ebccff619c8012766 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 14:41:38 +0300 Subject: [PATCH 016/146] [amqphandler, launcher] NodeInfo initial adaptation Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 12 +++++++----- launcher/launcher.go | 2 +- launcher/launcher_test.go | 12 +++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index c64d6b8d..25faafb5 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -413,12 +413,14 @@ func TestSendMessages(t *testing.T) { } nodeConfiguration := []cloudprotocol.NodeInfo{ - {NodeID: "main", NodeType: "mainType", SystemInfo: cloudprotocol.SystemInfo{ - NumCPUs: 2, TotalRAM: 200, - Partitions: []cloudprotocol.PartitionInfo{ - {Name: "p1", Types: []string{"t1"}, TotalSize: 200}, + { + NodeID: "main", NodeType: "mainType", TotalRAM: 200, + CPUs: []cloudprotocol.CPUInfo{ + {ModelName: "Intel(R) Core(TM) i7-1185G7"}, + {ModelName: "Intel(R) Core(TM) i7-1185G7"}, }, - }}, + Partitions: []cloudprotocol.PartitionInfo{{Name: "p1", Types: []string{"t1"}, TotalSize: 200}}, + }, } nodeMonitoring := cloudprotocol.NodeMonitoringData{ diff --git a/launcher/launcher.go b/launcher/launcher.go index dd15c77c..9ad8fa17 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -1032,7 +1032,7 @@ func (launcher *Launcher) getNodeByMonitoringData(nodes []*nodeStatus, alertType nodesResources = append(nodesResources, freeNodeResources{ node: node, freeRAM: node.TotalRAM - monitoringData.RAM, - freeCPU: node.NumCPUs*100 - monitoringData.CPU, + freeCPU: uint64(len(node.CPUs)*100) - monitoringData.CPU, }) } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index d8cbdf4e..4e787195 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -357,11 +357,13 @@ func TestInitialStatus(t *testing.T) { }} nodeInfo := cloudprotocol.NodeInfo{ - NodeID: id, NodeType: "nodeType", SystemInfo: cloudprotocol.SystemInfo{ - NumCPUs: 1, TotalRAM: 100, - Partitions: []cloudprotocol.PartitionInfo{ - {Name: "id", TotalSize: 200}, - }, + NodeID: id, NodeType: "nodeType", + TotalRAM: 100, + CPUs: []cloudprotocol.CPUInfo{ + {ModelName: "Intel(R) Core(TM) i7-1185G7"}, + }, + Partitions: []cloudprotocol.PartitionInfo{ + {Name: "id", TotalSize: 200}, }, } From f1cce359e7b85d9f2069bb88f10f68262969df0d Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 14:51:44 +0300 Subject: [PATCH 017/146] [all] Update Alerts Signed-off-by: Mykola Kobets --- alerts/alerts.go | 8 ++--- alerts/alerts_test.go | 10 +++--- amqphandler/amqphandler_test.go | 30 ++++++++-------- downloader/downloader.go | 17 ++++----- smcontroller/smhandler.go | 62 ++++++++++++++++++--------------- 5 files changed, 66 insertions(+), 61 deletions(-) diff --git a/alerts/alerts.go b/alerts/alerts.go index be487d4e..f666f2f8 100644 --- a/alerts/alerts.go +++ b/alerts/alerts.go @@ -194,8 +194,8 @@ func (instance *Alerts) addAlert(item cloudprotocol.AlertItem) (bufferIsFull boo instance.Lock() defer instance.Unlock() - if len(instance.currentAlerts) != 0 && - reflect.DeepEqual(instance.currentAlerts[len(instance.currentAlerts)-1].Payload, item.Payload) { + if len(instance.currentAlerts.Items) != 0 && + reflect.DeepEqual(instance.currentAlerts.Items[len(instance.currentAlerts.Items)-1].Payload, item.Payload) { instance.duplicatedAlerts++ return } @@ -206,7 +206,7 @@ func (instance *Alerts) addAlert(item cloudprotocol.AlertItem) (bufferIsFull boo } instance.alertsSize += len(data) - instance.currentAlerts = append(instance.currentAlerts, item) + instance.currentAlerts.Items = append(instance.currentAlerts.Items, item) return instance.alertsSize >= instance.config.MaxMessageSize } @@ -233,7 +233,7 @@ func (instance *Alerts) prepareAlertsPackage() { log.Warn("Skip sending alerts due to channel is full") } - instance.currentAlerts = []cloudprotocol.AlertItem{} + instance.currentAlerts.Items = []cloudprotocol.AlertItem{} instance.skippedAlerts = 0 instance.duplicatedAlerts = 0 instance.alertsSize = 0 diff --git a/alerts/alerts_test.go b/alerts/alerts_test.go index 8442c5bd..bb0556e5 100644 --- a/alerts/alerts_test.go +++ b/alerts/alerts_test.go @@ -97,7 +97,7 @@ func TestAlertsMaxMessageSize(t *testing.T) { alertsHandler.SendAlert(alertItem) - expectedAlerts = append(expectedAlerts, alertItem) + expectedAlerts.Items = append(expectedAlerts.Items, alertItem) } for i := 2; i < numMessages; i++ { @@ -145,7 +145,7 @@ func TestAlertsDuplicationMessages(t *testing.T) { Payload: cloudprotocol.SystemAlert{Message: randomString(32)}, } - expectedAlerts = append(expectedAlerts, alertItem) + expectedAlerts.Items = append(expectedAlerts.Items, alertItem) for i := 0; i < 2; i++ { alertsHandler.SendAlert(alertItem) @@ -189,7 +189,7 @@ func TestAlertsOfflineMessages(t *testing.T) { Payload: cloudprotocol.SystemAlert{Message: randomString(200)}, } - expectedAlerts = append(expectedAlerts, alertItem) + expectedAlerts.Items = append(expectedAlerts.Items, alertItem) alertsHandler.SendAlert(alertItem) } @@ -220,7 +220,7 @@ func TestAlertsOfflineMessages(t *testing.T) { t.Fatalf("Wait alerts error: %v", err) } - receivedAlerts = append(receivedAlerts, alerts...) + receivedAlerts.Items = append(receivedAlerts.Items, alerts.Items...) } if !reflect.DeepEqual(receivedAlerts, expectedAlerts) { @@ -267,7 +267,7 @@ func (sender *testSender) waitResult(timeout time.Duration) (cloudprotocol.Alert return alerts, nil case <-time.After(timeout): - return nil, errTimeout + return cloudprotocol.Alerts{}, errTimeout } } } diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 25faafb5..e2162efb 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -474,20 +474,22 @@ func TestSendMessages(t *testing.T) { } alertsData := cloudprotocol.Alerts{ - cloudprotocol.AlertItem{ - Timestamp: time.Now().UTC(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: map[string]interface{}{"Message": "System error", "nodeId": "mainNode"}, - }, - cloudprotocol.AlertItem{ - Timestamp: time.Now().UTC(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: map[string]interface{}{"Message": "Service crashed", "nodeId": "mainNode"}, - }, - cloudprotocol.AlertItem{ - Timestamp: time.Now().UTC(), - Tag: cloudprotocol.AlertTagResourceValidate, - Payload: map[string]interface{}{"Parameter": "cpu", "Value": float64(100), "nodeId": "mainNode"}, + Items: []cloudprotocol.AlertItem{ + { + Timestamp: time.Now().UTC(), + Tag: cloudprotocol.AlertTagSystemError, + Payload: map[string]interface{}{"Message": "System error", "nodeId": "mainNode"}, + }, + { + Timestamp: time.Now().UTC(), + Tag: cloudprotocol.AlertTagSystemError, + Payload: map[string]interface{}{"Message": "Service crashed", "nodeId": "mainNode"}, + }, + { + Timestamp: time.Now().UTC(), + Tag: cloudprotocol.AlertTagResourceValidate, + Payload: map[string]interface{}{"Parameter": "cpu", "Value": float64(100), "nodeId": "mainNode"}, + }, }, } diff --git a/downloader/downloader.go b/downloader/downloader.go index ab569b30..cda553eb 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -22,7 +22,6 @@ import ( "context" "encoding/base64" "errors" - "fmt" "os" "path" "path/filepath" @@ -648,15 +647,13 @@ func (downloader *Downloader) prepareDownloadAlert( return cloudprotocol.AlertItem{ Timestamp: time.Now(), Tag: cloudprotocol.AlertTagDownloadProgress, Payload: cloudprotocol.DownloadAlert{ - TargetType: result.packageInfo.TargetType, - TargetID: result.packageInfo.TargetID, - TargetAosVersion: result.packageInfo.TargetAosVersion, - TargetVendorVersion: result.packageInfo.TargetVendorVersion, - Progress: fmt.Sprintf("%.2f%%", resp.Progress()*100), - URL: resp.Request.HTTPRequest.URL.String(), - DownloadedBytes: bytefmt.ByteSize(uint64(resp.BytesComplete())), - TotalBytes: bytefmt.ByteSize(uint64(resp.Size())), - Message: msg, + TargetType: result.packageInfo.TargetType, + TargetID: result.packageInfo.TargetID, + Version: result.packageInfo.TargetVersion, + URL: resp.Request.HTTPRequest.URL.String(), + DownloadedBytes: bytefmt.ByteSize(uint64(resp.BytesComplete())), + TotalBytes: bytefmt.ByteSize(uint64(resp.Size())), + Message: msg, }, } } diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index b72d56bc..be568da8 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -28,6 +28,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" + "github.com/aosedge/aos_common/api/common" pb "github.com/aosedge/aos_common/api/servicemanager" "github.com/aosedge/aos_common/utils/pbconvert" "github.com/aosedge/aos_common/utils/syncstream" @@ -276,7 +277,7 @@ func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (e }).Debug("Get instance log") request := &pb.InstanceLogRequest{ - LogId: logRequest.LogID, Instance: pbconvert.InstanceFilterToPB(logRequest.Filter.InstanceFilter), + LogId: logRequest.LogID, InstanceFilter: pbconvert.InstanceFilterToPB(logRequest.Filter.InstanceFilter), } if logRequest.Filter.From != nil { @@ -307,7 +308,7 @@ func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLo }).Debug("Get instance crash log") request := &pb.InstanceCrashLogRequest{ - LogId: logRequest.LogID, Instance: pbconvert.InstanceFilterToPB(logRequest.Filter.InstanceFilter), + LogId: logRequest.LogID, InstanceFilter: pbconvert.InstanceFilterToPB(logRequest.Filter.InstanceFilter), } if logRequest.Filter.From != nil { @@ -336,8 +337,8 @@ func (handler *smHandler) overrideEnvVars(envVars cloudprotocol.OverrideEnvVars) for i, item := range envVars.OverrideEnvVars { requestItem := &pb.OverrideInstanceEnvVar{ - Instance: pbconvert.InstanceFilterToPB(item.InstanceFilter), - Vars: make([]*pb.EnvVarInfo, len(item.EnvVars)), + InstanceFilter: pbconvert.InstanceFilterToPB(item.InstanceFilter), + Vars: make([]*pb.EnvVarInfo, len(item.EnvVars)), } for j, envVar := range item.EnvVars { @@ -475,22 +476,20 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { case *pb.Alert_ResourceValidateAlert: resourceValidate := cloudprotocol.ResourceValidateAlert{ - ResourcesErrors: make([]cloudprotocol.ResourceValidateError, len(data.ResourceValidateAlert.GetErrors())), - NodeID: handler.config.NodeID, + Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), + NodeID: handler.config.NodeID, + Name: data.ResourceValidateAlert.Name, } - for i, resourceError := range data.ResourceValidateAlert.GetErrors() { - resourceValidate.ResourcesErrors[i] = cloudprotocol.ResourceValidateError{ - Name: resourceError.GetName(), - Errors: resourceError.GetErrorMsg(), - } + for i, error := range data.ResourceValidateAlert.GetErrors() { + resourceValidate.Errors[i] = *pbconvert.ErrorInfoFromPB(error) } alertItem.Payload = resourceValidate case *pb.Alert_DeviceAllocateAlert: alertItem.Payload = cloudprotocol.DeviceAllocateAlert{ - InstanceIdent: pbconvert.NewInstanceIdentFromPB(data.DeviceAllocateAlert.GetInstance()), + InstanceIdent: pbconvert.InstanceIdentFromPB(data.DeviceAllocateAlert.GetInstance()), Device: data.DeviceAllocateAlert.GetDevice(), Message: data.DeviceAllocateAlert.GetMessage(), NodeID: handler.config.NodeID, @@ -511,16 +510,16 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { case *pb.Alert_InstanceQuotaAlert: alertItem.Payload = cloudprotocol.InstanceQuotaAlert{ - InstanceIdent: pbconvert.NewInstanceIdentFromPB(data.InstanceQuotaAlert.GetInstance()), + InstanceIdent: pbconvert.InstanceIdentFromPB(data.InstanceQuotaAlert.GetInstance()), Parameter: data.InstanceQuotaAlert.GetParameter(), Value: data.InstanceQuotaAlert.GetValue(), } case *pb.Alert_InstanceAlert: alertItem.Payload = cloudprotocol.ServiceInstanceAlert{ - InstanceIdent: pbconvert.NewInstanceIdentFromPB(data.InstanceAlert.GetInstance()), - AosVersion: data.InstanceAlert.GetAosVersion(), - Message: data.InstanceAlert.GetMessage(), + InstanceIdent: pbconvert.InstanceIdentFromPB(data.InstanceAlert.GetInstance()), + ServiceVersion: data.InstanceAlert.GetServiceVersion(), + Message: data.InstanceAlert.GetMessage(), } default: @@ -545,7 +544,9 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { Part: data.GetPart(), Content: data.GetData(), ErrorInfo: &cloudprotocol.ErrorInfo{ - Message: data.GetError(), + AosCode: int(data.GetError().AosCode), + ExitCode: int(data.GetError().ExitCode), + Message: data.GetError().Message, }, }); err != nil { log.Errorf("Can't send log: %v", err) @@ -567,13 +568,19 @@ func (handler *smHandler) processOverrideEnvVarsStatus(envVarStatus *pb.Override for i, item := range envVarStatus.GetEnvVarsStatus() { responseItem := cloudprotocol.EnvVarsInstanceStatus{ - InstanceFilter: cloudprotocol.NewInstanceFilter(item.GetInstance().GetServiceId(), - item.GetInstance().GetSubjectId(), item.GetInstance().GetInstance()), + InstanceFilter: cloudprotocol.NewInstanceFilter(item.GetInstanceFilter().GetServiceId(), + item.GetInstanceFilter().GetSubjectId(), item.GetInstanceFilter().GetInstance()), Statuses: make([]cloudprotocol.EnvVarStatus, len(item.GetVarsStatus())), } for j, varStatus := range item.GetVarsStatus() { - responseItem.Statuses[j] = cloudprotocol.EnvVarStatus{ID: varStatus.GetVarId(), Error: varStatus.GetError()} + responseItem.Statuses[j] = cloudprotocol.EnvVarStatus{ + ID: varStatus.GetVarId(), + Error: &cloudprotocol.ErrorInfo{ + AosCode: int(varStatus.GetError().GetAosCode()), + ExitCode: int(varStatus.GetError().GetExitCode()), Message: varStatus.GetError().GetMessage(), + }, + } } response[i] = responseItem @@ -668,25 +675,24 @@ func instancesStatusFromPB(pbStatuses []*pb.InstanceStatus, nodeID string) []clo for i, status := range pbStatuses { instancesStatus[i] = cloudprotocol.InstanceStatus{ - InstanceIdent: pbconvert.NewInstanceIdentFromPB(status.GetInstance()), - NodeID: nodeID, - AosVersion: status.GetAosVersion(), - RunState: status.GetRunState(), - ErrorInfo: errorInfoFromPB(status.GetErrorInfo()), + InstanceIdent: pbconvert.InstanceIdentFromPB(status.GetInstance()), + NodeID: nodeID, + ServiceVersion: status.GetServiceVersion(), + RunState: status.GetRunState(), + ErrorInfo: errorInfoFromPB(status.GetErrorInfo()), } } return instancesStatus } -func errorInfoFromPB(pbError *pb.ErrorInfo) *cloudprotocol.ErrorInfo { +func errorInfoFromPB(pbError *common.ErrorInfo) *cloudprotocol.ErrorInfo { if pbError == nil { return nil } return &cloudprotocol.ErrorInfo{ - AosCode: int(pbError.GetAosCode()), - ExitCode: int(pbError.GetExitCode()), Message: pbError.GetMessage(), + AosCode: int(pbError.GetAosCode()), ExitCode: int(pbError.GetExitCode()), Message: pbError.GetMessage(), } } From b0fefb315016076fec7ff80610ee2c7ce89c3c67 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 14:55:37 +0300 Subject: [PATCH 018/146] [downloader, unitstatushandler] PackageInfo update Signed-off-by: Mykola Kobets --- downloader/downloader.go | 14 ++++++-------- downloader/downloader_test.go | 3 +-- unitstatushandler/firmwaremanager.go | 14 ++++++-------- unitstatushandler/softwaremanager.go | 27 ++++++++++++--------------- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/downloader/downloader.go b/downloader/downloader.go index cda553eb..b11cfba4 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -78,14 +78,12 @@ type DownloadInfo struct { // PackageInfo struct contains package info data. type PackageInfo struct { - URLs []string - Sha256 []byte - Sha512 []byte - Size uint64 - TargetType string - TargetID string - TargetAosVersion uint64 - TargetVendorVersion string + URLs []string + Sha256 []byte + Size uint64 + TargetType string + TargetID string + TargetVersion string } // Storage provides API to add, remove, update or access download info data. diff --git a/downloader/downloader_test.go b/downloader/downloader_test.go index 4ec9183a..52eeb8ea 100644 --- a/downloader/downloader_test.go +++ b/downloader/downloader_test.go @@ -987,8 +987,7 @@ func preparePackageInfo(host, fileName, targetType string) (packageInfo download packageInfo.Size = imageFileInfo.Size packageInfo.TargetType = targetType packageInfo.TargetID = "targetID" - packageInfo.TargetAosVersion = 1 - packageInfo.TargetVendorVersion = "vendorVersion1" + packageInfo.TargetVersion = "1.0" return packageInfo } diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 94fee072..68487d9a 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -405,14 +405,12 @@ func (manager *firmwareManager) download(ctx context.Context) { }).Debug("Download component") request[component.ComponentID] = downloader.PackageInfo{ - URLs: component.URLs, - Sha256: component.Sha256, - Sha512: component.Sha512, - Size: component.Size, - TargetType: cloudprotocol.DownloadTargetComponent, - TargetID: component.ComponentID, - TargetAosVersion: component.AosVersion, - TargetVendorVersion: component.VendorVersion, + URLs: component.URLs, + Sha256: component.Sha256, + Size: component.Size, + TargetType: cloudprotocol.DownloadTargetComponent, + TargetID: component.ComponentID, + TargetVersion: component.Version, } manager.ComponentStatuses[component.ComponentID] = &cloudprotocol.ComponentStatus{ ComponentID: component.ComponentID, diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 9b3234ed..74497ee6 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -597,13 +597,12 @@ func (manager *softwareManager) prepareDownloadRequest() (request map[string]dow }).Debug("Download service") request[service.ServiceID] = downloader.PackageInfo{ - URLs: service.URLs, - Sha256: service.Sha256, - Size: service.Size, - TargetType: cloudprotocol.DownloadTargetService, - TargetID: service.ServiceID, - TargetAosVersion: service.AosVersion, - TargetVendorVersion: service.VendorVersion, + URLs: service.URLs, + Sha256: service.Sha256, + Size: service.Size, + TargetType: cloudprotocol.DownloadTargetService, + TargetID: service.ServiceID, + TargetVersion: service.Version, } manager.ServiceStatuses[service.ServiceID] = &cloudprotocol.ServiceStatus{ ServiceID: service.ServiceID, @@ -620,14 +619,12 @@ func (manager *softwareManager) prepareDownloadRequest() (request map[string]dow }).Debug("Download layer") request[layer.Digest] = downloader.PackageInfo{ - URLs: layer.URLs, - Sha256: layer.Sha256, - Sha512: layer.Sha512, - Size: layer.Size, - TargetType: cloudprotocol.DownloadTargetLayer, - TargetID: layer.Digest, - TargetAosVersion: layer.AosVersion, - TargetVendorVersion: layer.VendorVersion, + URLs: layer.URLs, + Sha256: layer.Sha256, + Size: layer.Size, + TargetType: cloudprotocol.DownloadTargetLayer, + TargetID: layer.Digest, + TargetVersion: layer.Version, } manager.LayerStatuses[layer.Digest] = &cloudprotocol.LayerStatus{ LayerID: layer.LayerID, From 53a04846dfb9f610dbeabe1c2c57a601ea804278 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 15:17:24 +0300 Subject: [PATCH 019/146] [launcher, unitstatushandler] Update InstanceStatus Signed-off-by: Mykola Kobets --- launcher/launcher.go | 18 +++++------ launcher/launcher_test.go | 6 ++-- unitstatushandler/unitstatushandler.go | 22 +++++++------- .../unitstatushandler_internal_test.go | 2 +- unitstatushandler/unitstatushandler_test.go | 30 +++++++++---------- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 9ad8fa17..5f7960a2 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -720,14 +720,14 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, 0, + errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", cloudprotocol.InstanceStateFailed, err.Error())) continue } if serviceInfo.Cached { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, 0, + errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", cloudprotocol.InstanceStateFailed, "service deleted")) continue @@ -737,7 +737,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc if err != nil { for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.AosVersion, cloudprotocol.InstanceStateFailed, err.Error())) + instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } continue @@ -747,7 +747,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc if err != nil { for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.AosVersion, cloudprotocol.InstanceStateFailed, err.Error())) + instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } continue @@ -759,7 +759,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc nodeForInstance, err := launcher.getNodesByDevices(nodes, serviceInfo.Config.Devices) if err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.AosVersion, cloudprotocol.InstanceStateFailed, err.Error())) + instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) continue } @@ -767,14 +767,14 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc instanceInfo, err := launcher.prepareInstanceStartInfo(serviceInfo, instance, instanceIndex) if err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.AosVersion, cloudprotocol.InstanceStateFailed, err.Error())) + instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } node := launcher.getMostPriorityNode(nodeForInstance, serviceInfo) if err = launcher.allocateDevices(node, serviceInfo.Config.Devices); err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.AosVersion, cloudprotocol.InstanceStateFailed, err.Error())) + instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) continue } @@ -799,7 +799,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (err for i, instance := range node.currentRunRequest.Instances { serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, 0, + errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", cloudprotocol.InstanceStateFailed, err.Error())) continue @@ -813,7 +813,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (err instance.InstanceIdent, serviceInfo.ProviderID, prepareNetworkParameters(instance, serviceInfo)); err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instance.Instance, serviceInfo, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) + instance.Instance, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } node.currentRunRequest.Instances[i] = instance diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 4e787195..24ff4796 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -352,7 +352,7 @@ func TestInitialStatus(t *testing.T) { for i, id := range cfg.SMController.NodeIDs { instances := []cloudprotocol.InstanceStatus{{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "s1", SubjectID: "subj1", Instance: uint64(i)}, - AosVersion: 1, StateChecksum: magicSum, RunState: "running", + Version: "1.0", StateChecksum: magicSum, RunState: "running", NodeID: id, }} @@ -1868,7 +1868,7 @@ func (nodeManager *testNodeManager) RunInstances(nodeID string, for i, instance := range instances { successStatus.Instances[i] = cloudprotocol.InstanceStatus{ InstanceIdent: instance.InstanceIdent, - AosVersion: 1, + Version: "1.0", RunState: cloudprotocol.InstanceStateActive, NodeID: nodeID, } } @@ -2181,7 +2181,7 @@ func createInstanceStatus(ident aostypes.InstanceIdent, nodeID string, err error status := cloudprotocol.InstanceStatus{ InstanceIdent: ident, RunState: cloudprotocol.InstanceStateActive, - AosVersion: 1, + Version: "1.0", NodeID: nodeID, } diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 84bf3af4..65358c35 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -366,10 +366,10 @@ func (instance *Instance) initCurrentStatus() error { for _, status := range componentStatuses { log.WithFields(log.Fields{ - "id": status.ID, - "status": status.Status, - "vendorVersion": status.VendorVersion, - "error": status.ErrorInfo, + "id": status.ComponentID, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Initial component status") instance.processComponentStatus(status) @@ -569,14 +569,14 @@ foundloop: for _, instanceStatus := range status { for i := range instance.instanceStatuses { if instanceStatus.InstanceIdent == instance.instanceStatuses[i].InstanceIdent && - instanceStatus.AosVersion == instance.instanceStatuses[i].AosVersion { + instanceStatus.Version == instance.instanceStatuses[i].Version { log.WithFields(log.Fields{ - "serviceID": instanceStatus.InstanceIdent.ServiceID, - "subjectID": instanceStatus.InstanceIdent.SubjectID, - "instance": instanceStatus.InstanceIdent.Instance, - "aosVersion": instanceStatus.AosVersion, - "runState": instanceStatus.RunState, - "error": instanceStatus.ErrorInfo, + "serviceID": instanceStatus.InstanceIdent.ServiceID, + "subjectID": instanceStatus.InstanceIdent.SubjectID, + "instance": instanceStatus.InstanceIdent.Instance, + "version": instanceStatus.Version, + "runState": instanceStatus.RunState, + "error": instanceStatus.ErrorInfo, }).Debug("Update instance status") instance.instanceStatuses[i].StateChecksum = instanceStatus.StateChecksum diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 0d09e176..79949599 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -1727,7 +1727,7 @@ func (statusHandler *testStatusHandler) setInstanceStatus(status []cloudprotocol "serviceID": instanceStatus.ServiceID, "subjectID": instanceStatus.SubjectID, "instanceID": instanceStatus.Instance, - "aosVersion": instanceStatus.AosVersion, + "version": instanceStatus.Version, "error": instanceStatus.ErrorInfo, "nodeID": instanceStatus.NodeID, }).Debug("Update instance status") diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 1cc0372b..e803cd82 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -661,10 +661,10 @@ func TestRunInstances(t *testing.T) { initialInstancesStatus := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", }, } @@ -710,19 +710,19 @@ func TestRunInstances(t *testing.T) { updatedInstancesStatus := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 2}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 2}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj2", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj2", Instance: 0}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj1", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj1", Instance: 0}, Version: "1.0", }, } @@ -778,13 +778,13 @@ func TestUpdateInstancesStatus(t *testing.T) { if err := statusHandler.ProcessRunStatus( unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, Version: "1.0", }, }}); err != nil { t.Fatalf("Can't process run status: %v", err) @@ -798,14 +798,14 @@ func TestUpdateInstancesStatus(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, Version: "1.0", StateChecksum: "newState", }, }, @@ -813,11 +813,11 @@ func TestUpdateInstancesStatus(t *testing.T) { statusHandler.ProcessUpdateInstanceStatus([]cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, AosVersion: 1, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, Version: "1.0", StateChecksum: "newState", }, }) From 495c341ba6dfa291b02b81b9a7171cc06764c027 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 23:52:27 +0300 Subject: [PATCH 020/146] [amqphandler, smcontroller] Update cloudprotocol.EnvVarStatus Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 2 +- smcontroller/smhandler.go | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index e2162efb..2c67b98b 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -499,7 +499,7 @@ func TestSendMessages(t *testing.T) { InstanceFilter: cloudprotocol.NewInstanceFilter("service0", "subject0", -1), Statuses: []cloudprotocol.EnvVarStatus{ {ID: "1234"}, - {ID: "345", Error: "some error"}, + {ID: "345", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "some error"}}, }, }, { diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index be568da8..7920117a 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -575,11 +575,8 @@ func (handler *smHandler) processOverrideEnvVarsStatus(envVarStatus *pb.Override for j, varStatus := range item.GetVarsStatus() { responseItem.Statuses[j] = cloudprotocol.EnvVarStatus{ - ID: varStatus.GetVarId(), - Error: &cloudprotocol.ErrorInfo{ - AosCode: int(varStatus.GetError().GetAosCode()), - ExitCode: int(varStatus.GetError().GetExitCode()), Message: varStatus.GetError().GetMessage(), - }, + ID: varStatus.GetVarId(), + ErrorInfo: pbconvert.ErrorInfoFromPB(varStatus.GetError()), } } From 723dffa9971078a9aec482cd8ab7ecf30f2bdf21 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 3 Jul 2024 23:56:57 +0300 Subject: [PATCH 021/146] [iamclient] Fix iamclient test Signed-off-by: Mykola Kobets --- iamclient/iamclient_test.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index a8db2e1c..c2598d04 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -453,16 +453,6 @@ func (server *testProtectedServer) FinishProvisioning( return rsp, nil } -func (server *testProtectedServer) Clear(context context.Context, req *pb.ClearRequest) (rsp *empty.Empty, err error) { - return rsp, nil -} - -func (server *testProtectedServer) SetOwner( - context context.Context, req *pb.SetOwnerRequest, -) (rsp *empty.Empty, err error) { - return rsp, nil -} - func (server *testPublicServer) GetSystemInfo( context context.Context, req *empty.Empty, ) (rsp *pb.SystemInfo, err error) { From 02246b685ce4d884606c89be3c8e1031706fcdcc Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 4 Jul 2024 16:32:20 +0300 Subject: [PATCH 022/146] [all] Make ComponentInfo.ComponentID optional Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 3 +- cmserver/cmserver.go | 4 +- umcontroller/umcontroller.go | 8 +- umcontroller/umcontroller_test.go | 46 ++++---- unitstatushandler/firmwaremanager.go | 36 ++++-- .../unitstatushandler_internal_test.go | 104 +++++++++--------- unitstatushandler/unitstatushandler_test.go | 10 +- 7 files changed, 121 insertions(+), 90 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 2c67b98b..53db2f81 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -217,6 +217,7 @@ func TestMain(m *testing.M) { func TestReceiveMessages(t *testing.T) { cryptoContext := &testCryptoContext{} + rootfs := "rootfs" amqpHandler, err := amqphandler.New() if err != nil { @@ -313,7 +314,7 @@ func TestReceiveMessages(t *testing.T) { expectedData: &cloudprotocol.DesiredStatus{ UnitConfig: &cloudprotocol.UnitConfig{}, Components: []cloudprotocol.ComponentInfo{ - {Version: "1.0.0", ComponentID: "rootfs"}, + {Version: "1.0.0", ComponentID: &rootfs}, }, Layers: []cloudprotocol.LayerInfo{ {Version: "1.0", LayerID: "l1", Digest: "digest"}, diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index cab2c6cf..983155f7 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -338,14 +338,14 @@ func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSO for _, service := range updateStatus.InstallServices { pbStatus.InstallServices = append(pbStatus.GetInstallServices(), &pb.ServiceInfo{ - ServideId: service.ServiceID, + ServiceId: service.ServiceID, Version: service.Version, }) } for _, service := range updateStatus.RemoveServices { pbStatus.RemoveServices = append(pbStatus.GetRemoveServices(), &pb.ServiceInfo{ - ServideId: service.ServiceID, + ServiceId: service.ServiceID, Version: service.Version, }) } diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 18cf4f10..9cd0005a 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -300,8 +300,12 @@ func (umCtrl *Controller) UpdateComponents( componentsUpdateInfo := []ComponentStatus{} for _, component := range components { + if component.ComponentID == nil { + continue + } + componentStatus := systemComponentStatus{ - id: component.ComponentID, version: component.Version, + id: *component.ComponentID, version: component.Version, status: cloudprotocol.DownloadedStatus, } @@ -350,7 +354,7 @@ func (umCtrl *Controller) UpdateComponents( } componentInfo := ComponentStatus{ - ID: component.ComponentID, Version: component.Version, + ID: *component.ComponentID, Version: component.Version, Annotations: string(component.Annotations), Sha256: fileInfo.Sha256, Size: fileInfo.Size, URL: url.String(), diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index b5bc048a..404e7e74 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -285,17 +285,17 @@ func TestFullUpdate(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um1C2", Version: "2.0.0", + ComponentID: convertToComponentID("um1C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um2C1", Version: "2.0.0", + ComponentID: convertToComponentID("um2C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um2C2", Version: "2.0.0", + ComponentID: convertToComponentID("um2C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -448,17 +448,17 @@ func TestFullUpdateWithDisconnect(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um3C2", Version: "2.0.0", + ComponentID: convertToComponentID("um3C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um4C1", Version: "2.0.0", + ComponentID: convertToComponentID("um4C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um4C2", Version: "2.0.0", + ComponentID: convertToComponentID("um4C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -628,17 +628,17 @@ func TestFullUpdateWithReboot(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um5C2", Version: "2.0.0", + ComponentID: convertToComponentID("um5C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um6C1", Version: "2.0.0", + ComponentID: convertToComponentID("um6C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um6C2", Version: "2.0.0", + ComponentID: convertToComponentID("um6C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -833,17 +833,17 @@ func TestRevertOnPrepare(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um7C2", Version: "2.0.0", + ComponentID: convertToComponentID("um7C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um8C1", Version: "2.0.0", + ComponentID: convertToComponentID("um8C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um8C2", Version: "2.0.0", + ComponentID: convertToComponentID("um8C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -969,17 +969,17 @@ func TestRevertOnUpdate(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um9C2", Version: "2.0.0", + ComponentID: convertToComponentID("um9C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um10C1", Version: "2.0.0", + ComponentID: convertToComponentID("um10C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um10C2", Version: "2.0.0", + ComponentID: convertToComponentID("um10C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -1129,17 +1129,17 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um11C2", Version: "2.0.0", + ComponentID: convertToComponentID("um11C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um12C1", Version: "2.0.0", + ComponentID: convertToComponentID("um12C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um12C2", Version: "2.0.0", + ComponentID: convertToComponentID("um12C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -1294,17 +1294,17 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "um13C2", Version: "2.0.0", + ComponentID: convertToComponentID("um13C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um14C1", Version: "2.0.0", + ComponentID: convertToComponentID("um14C1"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: "um14C2", Version: "2.0.0", + ComponentID: convertToComponentID("um14C2"), Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -1615,3 +1615,7 @@ func generateFile(fileName string, size uint64) (err error) { return nil } + +func convertToComponentID(id string) *string { + return &id +} diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 68487d9a..8742afe0 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -159,9 +159,11 @@ func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTASt } for _, component := range manager.CurrentUpdate.Components { - status.Components = append(status.Components, cloudprotocol.ComponentStatus{ - ComponentID: component.ComponentID, Version: component.Version, - }) + if component.ComponentID != nil { + status.Components = append(status.Components, cloudprotocol.ComponentStatus{ + ComponentID: *component.ComponentID, Version: component.Version, + }) + } } if len(manager.CurrentUpdate.UnitConfig) != 0 { @@ -191,8 +193,12 @@ func (manager *firmwareManager) processDesiredStatus(desiredStatus cloudprotocol desiredLoop: for _, desiredComponent := range desiredStatus.Components { + if desiredComponent.ComponentID == nil { + continue + } + for _, installedComponent := range installedComponents { - if desiredComponent.ComponentID == installedComponent.ComponentID { + if *desiredComponent.ComponentID == installedComponent.ComponentID { if desiredComponent.Version == installedComponent.Version && installedComponent.Status == cloudprotocol.InstalledStatus { continue desiredLoop @@ -399,21 +405,25 @@ func (manager *firmwareManager) download(ctx context.Context) { request := make(map[string]downloader.PackageInfo) for _, component := range manager.CurrentUpdate.Components { + if component.ComponentID == nil { + continue + } + log.WithFields(log.Fields{ "id": component.ComponentID, "version": component.Version, }).Debug("Download component") - request[component.ComponentID] = downloader.PackageInfo{ + request[*component.ComponentID] = downloader.PackageInfo{ URLs: component.URLs, Sha256: component.Sha256, Size: component.Size, TargetType: cloudprotocol.DownloadTargetComponent, - TargetID: component.ComponentID, + TargetID: *component.ComponentID, TargetVersion: component.Version, } - manager.ComponentStatuses[component.ComponentID] = &cloudprotocol.ComponentStatus{ - ComponentID: component.ComponentID, + manager.ComponentStatuses[*component.ComponentID] = &cloudprotocol.ComponentStatus{ + ComponentID: *component.ComponentID, Version: component.Version, Status: cloudprotocol.DownloadingStatus, } @@ -592,15 +602,19 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component updateComponents := make([]cloudprotocol.ComponentInfo, 0, len(manager.CurrentUpdate.Components)) for _, component := range manager.CurrentUpdate.Components { + if component.ComponentID == nil { + continue + } + log.WithFields(log.Fields{"id": component.ComponentID, "version": component.Version}).Debug("Update component") - manager.updateComponentStatusByID(component.ComponentID, cloudprotocol.InstallingStatus, "") + manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.InstallingStatus, "") - downloadInfo, ok := manager.DownloadResult[component.ComponentID] + downloadInfo, ok := manager.DownloadResult[*component.ComponentID] if !ok { err := aoserrors.New("update ID not found").Error() - manager.updateComponentStatusByID(component.ComponentID, cloudprotocol.ErrorStatus, err) + manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.ErrorStatus, err) return err } diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 79949599..b0288f05 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -256,12 +256,12 @@ func TestFirmwareManager(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "comp1", + ComponentID: convertToComponentID("comp1"), Version: "1.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ComponentID: "comp2", + ComponentID: convertToComponentID("comp2"), Version: "2.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, }, @@ -269,12 +269,12 @@ func TestFirmwareManager(t *testing.T) { otherUpdateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: "comp3", + ComponentID: convertToComponentID("comp3"), Version: "3.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ComponentID: "comp4", + ComponentID: convertToComponentID("comp4"), Version: "4.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, @@ -305,8 +305,8 @@ func TestFirmwareManager(t *testing.T) { }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -328,8 +328,8 @@ func TestFirmwareManager(t *testing.T) { }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {Error: "download error"}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {Error: "download error"}, + *updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -348,8 +348,8 @@ func TestFirmwareManager(t *testing.T) { }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -377,8 +377,8 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, }, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ @@ -395,16 +395,16 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateReadyToUpdate, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ComponentID: { - ComponentID: updateComponents[0].ComponentID, + *updateComponents[0].ComponentID: { + ComponentID: *updateComponents[0].ComponentID, Version: updateComponents[0].Version, }, - updateComponents[1].ComponentID: { - ComponentID: updateComponents[1].ComponentID, + *updateComponents[1].ComponentID: { + ComponentID: *updateComponents[1].ComponentID, Version: updateComponents[1].Version, }, }, @@ -426,16 +426,16 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateUpdating, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ComponentID: { - ComponentID: updateComponents[0].ComponentID, + *updateComponents[0].ComponentID: { + ComponentID: *updateComponents[0].ComponentID, Version: updateComponents[0].Version, }, - updateComponents[1].ComponentID: { - ComponentID: updateComponents[1].ComponentID, + *updateComponents[1].ComponentID: { + ComponentID: *updateComponents[1].ComponentID, Version: updateComponents[1].Version, }, }, @@ -459,16 +459,16 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ComponentID: { - ComponentID: updateComponents[0].ComponentID, + *updateComponents[0].ComponentID: { + ComponentID: *updateComponents[0].ComponentID, Version: updateComponents[0].Version, }, - updateComponents[1].ComponentID: { - ComponentID: updateComponents[1].ComponentID, + *updateComponents[1].ComponentID: { + ComponentID: *updateComponents[1].ComponentID, Version: updateComponents[1].Version, }, }, @@ -495,8 +495,8 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateDownloading, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.Downloading}, @@ -508,10 +508,10 @@ func TestFirmwareManager(t *testing.T) { }, desiredStatus: &cloudprotocol.DesiredStatus{Components: otherUpdateComponents}, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, - otherUpdateComponents[0].ComponentID: {}, - otherUpdateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, + *otherUpdateComponents[0].ComponentID: {}, + *otherUpdateComponents[1].ComponentID: {}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ @@ -547,8 +547,8 @@ func TestFirmwareManager(t *testing.T) { FOTASchedule: cloudprotocol.ScheduleRule{Type: cloudprotocol.TriggerUpdate}, }, downloadResult: map[string]*downloadResult{ - otherUpdateComponents[0].ComponentID: {}, - otherUpdateComponents[1].ComponentID: {}, + *otherUpdateComponents[0].ComponentID: {}, + *otherUpdateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, @@ -568,17 +568,17 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, DownloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ - updateComponents[0].ComponentID: { - ComponentID: updateComponents[0].ComponentID, + *updateComponents[0].ComponentID: { + ComponentID: *updateComponents[0].ComponentID, Version: updateComponents[0].Version, Status: cloudprotocol.InstallingStatus, }, - updateComponents[1].ComponentID: { - ComponentID: updateComponents[1].ComponentID, + *updateComponents[1].ComponentID: { + ComponentID: *updateComponents[1].ComponentID, Version: updateComponents[1].Version, Status: cloudprotocol.InstallingStatus, }, @@ -593,8 +593,8 @@ func TestFirmwareManager(t *testing.T) { }, desiredStatus: &cloudprotocol.DesiredStatus{Components: otherUpdateComponents}, downloadResult: map[string]*downloadResult{ - otherUpdateComponents[0].ComponentID: {}, - otherUpdateComponents[1].ComponentID: {}, + *otherUpdateComponents[0].ComponentID: {}, + *otherUpdateComponents[1].ComponentID: {}, }, downloadTime: 1 * time.Second, updateTime: 1 * time.Second, @@ -647,8 +647,8 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, @@ -676,8 +676,8 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, downloadResult: map[string]*downloadResult{ - updateComponents[0].ComponentID: {}, - updateComponents[1].ComponentID: {}, + *updateComponents[0].ComponentID: {}, + *updateComponents[1].ComponentID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -1873,3 +1873,7 @@ func waitForSOTAUpdateStatus( return aoserrors.Errorf("wait for SOTA %s status timeout", expectedStatus.State) } } + +func convertToComponentID(id string) *string { + return &id +} diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index e803cd82..9d95a0bd 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -274,8 +274,8 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ComponentID: "comp0", Version: "2.0"}, - {ComponentID: "comp2", Version: "2.0"}, + {ComponentID: convertToComponentID("comp0"), Version: "2.0"}, + {ComponentID: convertToComponentID("comp2"), Version: "2.0"}, }, }) @@ -311,7 +311,7 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ComponentID: "comp1", Version: "2.0"}, + {ComponentID: convertToComponentID("comp1"), Version: "2.0"}, }, }) @@ -1067,3 +1067,7 @@ func handleUpdateStatus(handler *unitstatushandler.Instance) { } } } + +func convertToComponentID(id string) *string { + return &id +} From 41b5e0a963b1bf7ab8e614d3d477facaa96e86d0 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 4 Jul 2024 16:36:06 +0300 Subject: [PATCH 023/146] [all] Rename Version to ServiceVersion in InstanceStatus Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 4 +-- launcher/launcher.go | 3 +- launcher/launcher_test.go | 18 +++++------ unitstatushandler/softwaremanager.go | 6 ++-- unitstatushandler/unitstatushandler.go | 4 +-- .../unitstatushandler_internal_test.go | 2 +- unitstatushandler/unitstatushandler_test.go | 30 +++++++++---------- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 53db2f81..ccc55aea 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -390,8 +390,8 @@ func TestSendMessages(t *testing.T) { instances := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, - Version: "1.0", StateChecksum: "12345", RunState: "running", NodeID: "mainNode", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, + ServiceVersion: "1.0", StateChecksum: "12345", RunState: "running", NodeID: "mainNode", }, } diff --git a/launcher/launcher.go b/launcher/launcher.go index 5f7960a2..1a0247c1 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -1345,8 +1345,7 @@ func createInstanceStatusFromInfo( } instanceStatus := cloudprotocol.InstanceStatus{ - InstanceIdent: ident, - Version: serviceVersion, RunState: runState, + InstanceIdent: ident, ServiceVersion: serviceVersion, RunState: runState, } if errorMsg != "" { diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 24ff4796..30e52371 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -351,8 +351,8 @@ func TestInitialStatus(t *testing.T) { for i, id := range cfg.SMController.NodeIDs { instances := []cloudprotocol.InstanceStatus{{ - InstanceIdent: aostypes.InstanceIdent{ServiceID: "s1", SubjectID: "subj1", Instance: uint64(i)}, - Version: "1.0", StateChecksum: magicSum, RunState: "running", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "s1", SubjectID: "subj1", Instance: uint64(i)}, + ServiceVersion: "1.0", StateChecksum: magicSum, RunState: "running", NodeID: id, }} @@ -1867,9 +1867,9 @@ func (nodeManager *testNodeManager) RunInstances(nodeID string, for i, instance := range instances { successStatus.Instances[i] = cloudprotocol.InstanceStatus{ - InstanceIdent: instance.InstanceIdent, - Version: "1.0", - RunState: cloudprotocol.InstanceStateActive, NodeID: nodeID, + InstanceIdent: instance.InstanceIdent, + ServiceVersion: "1.0", + RunState: cloudprotocol.InstanceStateActive, NodeID: nodeID, } } @@ -2179,10 +2179,10 @@ func createLayerInfo(digest string, url string) aostypes.LayerInfo { func createInstanceStatus(ident aostypes.InstanceIdent, nodeID string, err error) cloudprotocol.InstanceStatus { status := cloudprotocol.InstanceStatus{ - InstanceIdent: ident, - RunState: cloudprotocol.InstanceStateActive, - Version: "1.0", - NodeID: nodeID, + InstanceIdent: ident, + RunState: cloudprotocol.InstanceStateActive, + ServiceVersion: "1.0", + NodeID: nodeID, } if err != nil { diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 74497ee6..1a5d4a95 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -1262,9 +1262,9 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr strin ident.Instance = i manager.InstanceStatuses = append(manager.InstanceStatuses, cloudprotocol.InstanceStatus{ - InstanceIdent: ident, - Version: version, - RunState: cloudprotocol.InstanceStateActivating, + InstanceIdent: ident, + ServiceVersion: version, + RunState: cloudprotocol.InstanceStateActivating, }) } } diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 65358c35..7c884562 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -569,12 +569,12 @@ foundloop: for _, instanceStatus := range status { for i := range instance.instanceStatuses { if instanceStatus.InstanceIdent == instance.instanceStatuses[i].InstanceIdent && - instanceStatus.Version == instance.instanceStatuses[i].Version { + instanceStatus.ServiceVersion == instance.instanceStatuses[i].ServiceVersion { log.WithFields(log.Fields{ "serviceID": instanceStatus.InstanceIdent.ServiceID, "subjectID": instanceStatus.InstanceIdent.SubjectID, "instance": instanceStatus.InstanceIdent.Instance, - "version": instanceStatus.Version, + "version": instanceStatus.ServiceVersion, "runState": instanceStatus.RunState, "error": instanceStatus.ErrorInfo, }).Debug("Update instance status") diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index b0288f05..bb60d2b6 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -1727,7 +1727,7 @@ func (statusHandler *testStatusHandler) setInstanceStatus(status []cloudprotocol "serviceID": instanceStatus.ServiceID, "subjectID": instanceStatus.SubjectID, "instanceID": instanceStatus.Instance, - "version": instanceStatus.Version, + "version": instanceStatus.ServiceVersion, "error": instanceStatus.ErrorInfo, "nodeID": instanceStatus.NodeID, }).Debug("Update instance status") diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 9d95a0bd..796c857f 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -661,10 +661,10 @@ func TestRunInstances(t *testing.T) { initialInstancesStatus := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", }, } @@ -710,19 +710,19 @@ func TestRunInstances(t *testing.T) { updatedInstancesStatus := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 2}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 2}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj2", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj2", Instance: 0}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj1", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", }, } @@ -778,13 +778,13 @@ func TestUpdateInstancesStatus(t *testing.T) { if err := statusHandler.ProcessRunStatus( unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0", }, }}); err != nil { t.Fatalf("Can't process run status: %v", err) @@ -798,14 +798,14 @@ func TestUpdateInstancesStatus(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0", StateChecksum: "newState", }, }, @@ -813,11 +813,11 @@ func TestUpdateInstancesStatus(t *testing.T) { statusHandler.ProcessUpdateInstanceStatus([]cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, Version: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0", StateChecksum: "newState", }, }) From 44c2667f3cee804afce72f82ebe77b1a477a3451 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 4 Jul 2024 18:41:47 +0300 Subject: [PATCH 024/146] [vendor] Update vendor to latest feature_dynamic_nodes branch Signed-off-by: Mykola Kobets --- go.mod | 2 +- go.sum | 4 ++-- .../aos_common/api/cloudprotocol/desiredstatus.go | 12 ++++++++++++ vendor/modules.txt | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index dce8f84c..2955b4c8 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b + github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index b397375b..702ee558 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b h1:+BLcX0YXKgbsBTouS4H855Ks6Ozb21GD2gdoR+jpQck= -github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab h1:vON8DvOduWA6mOm5xKibVp6MhPrLjHVvU6oqew2GUco= +github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go index a8bbbdb8..de277ce7 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go @@ -92,6 +92,15 @@ type UnitConfig struct { Nodes []NodeConfig `json:"nodes"` } +// Signs message signature. +type Signs struct { + ChainName string `json:"chainName"` + Alg string `json:"alg"` + Value []byte `json:"value"` + TrustedTimestamp string `json:"trustedTimestamp"` + OcspValues []string `json:"ocspValues"` +} + // DecryptionInfo update decryption info. type DecryptionInfo struct { BlockAlg string `json:"blockAlg"` @@ -124,6 +133,7 @@ type ServiceInfo struct { Version string `json:"version"` DownloadInfo DecryptionInfo DecryptionInfo `json:"decryptionInfo"` + Signs Signs `json:"signs"` } // LayerInfo decrypted layer info. @@ -133,6 +143,7 @@ type LayerInfo struct { Version string `json:"version"` DownloadInfo DecryptionInfo DecryptionInfo `json:"decryptionInfo"` + Signs Signs `json:"signs"` } // ComponentInfo decrypted component info. @@ -143,6 +154,7 @@ type ComponentInfo struct { Annotations json.RawMessage `json:"annotations,omitempty"` DownloadInfo DecryptionInfo DecryptionInfo `json:"decryptionInfo"` + Signs Signs `json:"signs"` } // InstanceInfo decrypted desired instance runtime info. diff --git a/vendor/modules.txt b/vendor/modules.txt index 0417e195..e9f00f9a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240704113917-4b7545c9918b +# github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From feb96735006b904d6f3f661be28372c6033d6876 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 4 Jul 2024 18:53:20 +0300 Subject: [PATCH 025/146] [imagemanager] Update DecryptParams Signed-off-by: Mykola Kobets --- fcrypt/fcrypt.go | 8 ++++---- fcrypt/fcrypt_internal_test.go | 4 ++-- imagemanager/imagemanager.go | 2 +- umcontroller/umcontroller.go | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fcrypt/fcrypt.go b/fcrypt/fcrypt.go index 984c2e49..e92d5b68 100644 --- a/fcrypt/fcrypt.go +++ b/fcrypt/fcrypt.go @@ -112,7 +112,7 @@ type SignContext struct { type SignContextInterface interface { AddCertificate(fingerprint string, asn1Bytes []byte) (err error) AddCertificateChain(name string, fingerprints []string) (err error) - VerifySign(ctx context.Context, f *os.File, sign *cloudprotocol.Signs) (err error) + VerifySign(ctx context.Context, f *os.File, sign cloudprotocol.Signs) (err error) } // CertificateProvider interface to get certificate. @@ -134,8 +134,8 @@ type certificateChainInfo struct { type DecryptParams struct { Chains []cloudprotocol.CertificateChain Certs []cloudprotocol.Certificate - DecryptionInfo *cloudprotocol.DecryptionInfo - Signs *cloudprotocol.Signs + DecryptionInfo cloudprotocol.DecryptionInfo + Signs cloudprotocol.Signs } /*********************************************************************************************************************** @@ -393,7 +393,7 @@ func (signContext *SignContext) AddCertificateChain(name string, fingerprints [] // VerifySign verifies signature. func (signContext *SignContext) VerifySign( - ctx context.Context, f *os.File, sign *cloudprotocol.Signs, + ctx context.Context, f *os.File, sign cloudprotocol.Signs, ) (err error) { if len(signContext.signCertificateChains) == 0 || len(signContext.signCertificates) == 0 { return aoserrors.New("sign context not initialized (no certificates)") diff --git a/fcrypt/fcrypt_internal_test.go b/fcrypt/fcrypt_internal_test.go index 87252093..a830f0a8 100644 --- a/fcrypt/fcrypt_internal_test.go +++ b/fcrypt/fcrypt_internal_test.go @@ -96,7 +96,7 @@ type testUpgradeCertificate struct { type testUpgradeFileInfo struct { FileData []byte - Signs *cloudprotocol.Signs + Signs cloudprotocol.Signs } // UpgradeMetadata upgrade metadata. @@ -842,7 +842,7 @@ func TestVerifySignOfComponent(t *testing.T) { Data: []testUpgradeFileInfo{ { FileData: []byte("test"), - Signs: &cloudprotocol.Signs{ + Signs: cloudprotocol.Signs{ ChainName: "8D28D60220B8D08826E283B531A0B1D75359C5EE", Alg: "RSA/SHA256", Value: signValue, diff --git a/imagemanager/imagemanager.go b/imagemanager/imagemanager.go index 9a0e4d80..dbc4bd8f 100644 --- a/imagemanager/imagemanager.go +++ b/imagemanager/imagemanager.go @@ -529,7 +529,7 @@ func (imagemanager *Imagemanager) InstallLayer(layerInfo cloudprotocol.LayerInfo fcrypt.DecryptParams{ Chains: chains, Certs: certs, - DecryptionInfo: &layerInfo.DecryptionInfo, + DecryptionInfo: layerInfo.DecryptionInfo, Signs: layerInfo.Signs, }); err != nil { return aoserrors.Wrap(err) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 9cd0005a..06512d47 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -337,8 +337,8 @@ func (umCtrl *Controller) UpdateComponents( fcrypt.DecryptParams{ Chains: chains, Certs: certs, - DecryptionInfo: &component.DecryptionInfo, - // Signs: component.Signs, + DecryptionInfo: component.DecryptionInfo, + Signs: component.Signs, }); err != nil { return umCtrl.currentComponents, aoserrors.Wrap(err) } From db7d2cdf3d84047488566d0484f46f273ebf489d Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 13:53:06 +0300 Subject: [PATCH 026/146] [iamclient] Implement GetNodeInfo interface Signed-off-by: Mykola Kobets --- iamclient/iamclient.go | 143 ++++++++++++++++++++++++++++++++++-- iamclient/iamclient_test.go | 99 +++++++++++++++++++++++++ 2 files changed, 235 insertions(+), 7 deletions(-) diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 734d2fbb..245026ca 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -20,6 +20,8 @@ package iamclient import ( "context" "encoding/base64" + "errors" + "io" "sync" "time" @@ -27,11 +29,15 @@ import ( "github.com/aosedge/aos_common/api/cloudprotocol" pb "github.com/aosedge/aos_common/api/iamanager" "github.com/aosedge/aos_common/utils/cryptutils" + pbconvert "github.com/aosedge/aos_common/utils/pbconvert" "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/emptypb" "github.com/aosedge/aos_communicationmanager/config" ) @@ -40,7 +46,10 @@ import ( * Consts **********************************************************************************************************************/ -const iamRequestTimeout = 30 * time.Second +const ( + iamRequestTimeout = 30 * time.Second + iamReconnectInterval = 10 * time.Second +) /*********************************************************************************************************************** * Types @@ -52,8 +61,7 @@ type Client struct { sender Sender - nodeID string - + nodeID string systemID string publicConnection *grpc.ClientConn @@ -62,7 +70,9 @@ type Client struct { identService pb.IAMPublicIdentityServiceClient certificateService pb.IAMCertificateServiceClient - closeChannel chan struct{} + closeChannel chan struct{} + nodeService pb.IAMPublicNodesServiceClient + nodeInfoListeners []chan cloudprotocol.NodeInfo } // Sender provides API to send messages to the cloud. @@ -91,8 +101,9 @@ func New( } localClient := &Client{ - sender: sender, - closeChannel: make(chan struct{}, 1), + sender: sender, + closeChannel: make(chan struct{}, 1), + nodeInfoListeners: make([]chan cloudprotocol.NodeInfo, 0), } defer func() { @@ -108,6 +119,7 @@ func New( localClient.publicService = pb.NewIAMPublicServiceClient(localClient.publicConnection) localClient.identService = pb.NewIAMPublicIdentityServiceClient(localClient.publicConnection) + localClient.nodeService = pb.NewIAMPublicNodesServiceClient(localClient.publicConnection) if localClient.protectedConnection, err = localClient.createProtectedConnection( config, cryptocontext, insecure); err != nil { @@ -119,13 +131,15 @@ func New( log.Debug("Connected to IAM") if localClient.nodeID, _, err = localClient.getNodeInfo(); err != nil { - return client, aoserrors.Wrap(err) + return nil, aoserrors.Wrap(err) } if localClient.systemID, err = localClient.getSystemID(); err != nil { return nil, aoserrors.Wrap(err) } + go localClient.connectPublicNodeService() + return localClient, nil } @@ -139,6 +153,51 @@ func (client *Client) GetSystemID() (systemID string) { return client.systemID } +// GetNodeInfo returns node info. +func (client *Client) GetNodeInfo(nodeID string) (nodeInfo cloudprotocol.NodeInfo, err error) { + log.WithField("nodeID", nodeID).Debug("Get node info") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + request := &pb.GetNodeInfoRequest{NodeId: nodeID} + + response, err := client.nodeService.GetNodeInfo(ctx, request) + if err != nil { + return cloudprotocol.NodeInfo{}, aoserrors.Wrap(err) + } + + return pbconvert.NewNodeInfoFromPB(response), nil +} + +// GetAllNodeIDs returns node ids. +func (client *Client) GetAllNodeIDs() (nodeIDs []string, err error) { + log.Debug("Get all node ids") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.nodeService.GetAllNodeIDs(ctx, &emptypb.Empty{}) + if err != nil { + return nil, aoserrors.Wrap(err) + } + + return response.Ids, err +} + +// SubscribeNodeInfoChange subscribes client on NodeInfoChange events +func (client *Client) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { + client.Lock() + defer client.Unlock() + + log.Debug("Subscribe on node info change event") + + ch := make(chan cloudprotocol.NodeInfo) + client.nodeInfoListeners = append(client.nodeInfoListeners, ch) + + return ch +} + // RenewCertificatesNotification renew certificates notification. func (client *Client) RenewCertificatesNotification(pwd string, certInfo []cloudprotocol.RenewCertData) (err error) { newCerts := make([]cloudprotocol.IssueCertData, 0, len(certInfo)) @@ -257,6 +316,8 @@ func (client *Client) Close() (err error) { client.protectedConnection.Close() } + client.nodeInfoListeners = nil + log.Debug("Disconnected from IAM") return nil @@ -356,3 +417,71 @@ func (client *Client) getSystemID() (systemID string, err error) { return response.GetSystemId(), nil } + +func (client *Client) processMessages(listener pb.IAMPublicNodesService_SubscribeNodeChangedClient) (err error) { + for { + nodeInfo, err := listener.Recv() + if err != nil { + if code, ok := status.FromError(err); ok { + if code.Code() == codes.Canceled { + log.Debug("IAM client connection closed") + return nil + } + } + + return aoserrors.Wrap(err) + } + + client.Lock() + for _, listener := range client.nodeInfoListeners { + listener <- pbconvert.NewNodeInfoFromPB(nodeInfo) + } + client.Unlock() + } +} + +func (client *Client) connectPublicNodeService() { + listener, err := client.subscribeNodeInfoChange() + + for { + if err != nil { + log.Errorf("Error register to IAM: %v", aoserrors.Wrap(err)) + } else { + if err = client.processMessages(listener); err != nil { + if errors.Is(err, io.EOF) { + log.Debug("Connection is closed") + } else { + log.Errorf("Connection error: %v", aoserrors.Wrap(err)) + } + } + } + + log.Debugf("Reconnect to IAM in %v...", iamReconnectInterval) + + select { + case <-client.closeChannel: + log.Debugf("Disconnected from IAM") + + return + + case <-time.After(iamReconnectInterval): + listener, err = client.subscribeNodeInfoChange() + } + } +} + +func (client *Client) subscribeNodeInfoChange() (listener pb.IAMPublicNodesService_SubscribeNodeChangedClient, err error) { + client.Lock() + defer client.Unlock() + + client.nodeService = pb.NewIAMPublicNodesServiceClient(client.publicConnection) + + listener, err = client.nodeService.SubscribeNodeChanged(context.Background(), &emptypb.Empty{}) + if err != nil { + log.WithField("error", err).Error("Can't subscribe on NodeChange event") + + return nil, aoserrors.Wrap(err) + } + + return listener, err +} diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index c2598d04..b037ee04 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -37,6 +37,7 @@ import ( "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/iamclient" @@ -55,9 +56,18 @@ const ( * Types **********************************************************************************************************************/ +type testIAMPublicNodesServiceServer struct { + pb.UnimplementedIAMPublicNodesServiceServer + nodeInfo chan *pb.NodeInfo + + currentID string + currentNodeName string +} + type testPublicServer struct { pb.UnimplementedIAMPublicServiceServer pb.UnimplementedIAMPublicIdentityServiceServer + testIAMPublicNodesServiceServer grpcServer *grpc.Server systemID string @@ -331,6 +341,73 @@ func TestGetCertificates(t *testing.T) { } } +func TestGetNodeInfo(t *testing.T) { + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, &testSender{}, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + nodeInfo, err := client.GetNodeInfo(publicServer.currentID) + if err != nil { + t.Errorf("Error is not expected: %s", err) + } + + if nodeInfo.NodeID != publicServer.currentID { + t.Errorf("Not expected NodeId: %s", nodeInfo.NodeID) + } + + if nodeInfo.Name != publicServer.currentNodeName { + t.Errorf("Not expected NodeId: %s", nodeInfo.Name) + } +} + +func TestSubscribeNodeInfoChange(t *testing.T) { + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, &testSender{}, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + + stream := client.SubscribeNodeInfoChange() + + secondaryNodeInfo := pb.NodeInfo{NodeId: "secondary", NodeType: "secondary"} + + publicServer.nodeInfo <- &secondaryNodeInfo + + receivedNodeInfo := <-stream + + defer client.Close() + + if secondaryNodeInfo.GetNodeId() != receivedNodeInfo.NodeID { + t.Errorf("NodeInfo with not expected Id: %s", receivedNodeInfo.NodeID) + } + if secondaryNodeInfo.GetName() != receivedNodeInfo.Name { + t.Errorf("NodeInfo with not expected Name: %s", receivedNodeInfo.Name) + } +} + /******************************************************************************* * Private ******************************************************************************/ @@ -346,9 +423,11 @@ func newTestServer( } publicServer.grpcServer = grpc.NewServer() + publicServer.nodeInfo = make(chan *pb.NodeInfo) pb.RegisterIAMPublicServiceServer(publicServer.grpcServer, publicServer) pb.RegisterIAMPublicIdentityServiceServer(publicServer.grpcServer, publicServer) + pb.RegisterIAMPublicNodesServiceServer(publicServer.grpcServer, &publicServer.testIAMPublicNodesServiceServer) go func() { if err := publicServer.grpcServer.Serve(publicListener); err != nil { @@ -465,6 +544,26 @@ func (server *testPublicServer) GetNodeInfo(context context.Context, req *empty. return &pb.NodeInfo{}, nil } +func (server *testIAMPublicNodesServiceServer) GetAllNodeIDs(context context.Context, req *emptypb.Empty) (*pb.NodesID, error) { + return &pb.NodesID{}, nil +} + +func (server *testIAMPublicNodesServiceServer) GetNodeInfo(context context.Context, req *pb.GetNodeInfoRequest) (*pb.NodeInfo, error) { + return &pb.NodeInfo{NodeId: server.currentID, Name: server.currentNodeName}, nil +} + +func (server *testIAMPublicNodesServiceServer) SubscribeNodeChanged(empty *emptypb.Empty, stream pb.IAMPublicNodesService_SubscribeNodeChangedServer) error { + log.Error("testIAMPublicNodesServiceServer SubscribeNodeChanged") + + nodeInfo := <-server.nodeInfo + + return stream.Send(nodeInfo) +} + +func (server *testIAMPublicNodesServiceServer) RegisterNode(pb.IAMPublicNodesService_RegisterNodeServer) error { + return nil +} + func (sender *testSender) SendIssueUnitCerts(requests []cloudprotocol.IssueCertData) (err error) { sender.csr = make(map[string]string) From 629da86c7d85fe23c5bf1a8d3b5091ebb65dde98 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 4 Jul 2024 16:36:23 +0300 Subject: [PATCH 027/146] [cmserver] Update to new protocol Signed-off-by: Oleksandr Grytsov --- cmserver/cmserver.go | 30 +++++++++++++++++------------- cmserver/cmserver_test.go | 34 +++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index 983155f7..c069403e 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -26,6 +26,7 @@ import ( "github.com/aosedge/aos_common/api/cloudprotocol" pb "github.com/aosedge/aos_common/api/communicationmanager" "github.com/aosedge/aos_common/utils/cryptutils" + "github.com/aosedge/aos_common/utils/pbconvert" "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" "google.golang.org/grpc" @@ -61,7 +62,7 @@ type UpdateState int // UpdateStatus represents SOTA/FOTA status. type UpdateStatus struct { State UpdateState - Error string + Error *cloudprotocol.ErrorInfo } // UpdateFOTAStatus FOTA update status for update scheduler service. @@ -316,23 +317,24 @@ func (server *CMServer) notifyAllClients(notification *pb.SchedulerNotifications } func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSOTAStatus) { - pbStatus = new(pb.UpdateSOTAStatus) - - pbStatus.Error.Message = updateStatus.Error - - pbStatus.State = updateStatus.State.getPbState() + pbStatus = &pb.UpdateSOTAStatus{ + Error: pbconvert.ErrorInfoToPB(updateStatus.Error), + State: updateStatus.State.getPbState(), + } for _, layer := range updateStatus.InstallLayers { pbStatus.InstallLayers = append(pbStatus.GetInstallLayers(), &pb.LayerInfo{ LayerId: layer.LayerID, - Version: layer.Version, Digest: layer.Digest, + Digest: layer.Digest, + Version: layer.Version, }) } for _, layer := range updateStatus.RemoveLayers { pbStatus.RemoveLayers = append(pbStatus.GetRemoveLayers(), &pb.LayerInfo{ LayerId: layer.LayerID, - Version: layer.Version, Digest: layer.Digest, + Digest: layer.Digest, + Version: layer.Version, }) } @@ -354,14 +356,16 @@ func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSO } func (updateStatus *UpdateFOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateFOTAStatus) { - pbStatus = new(pb.UpdateFOTAStatus) - pbStatus.Error.Message = updateStatus.Error - pbStatus.State = updateStatus.State.getPbState() + pbStatus = &pb.UpdateFOTAStatus{ + Error: pbconvert.ErrorInfoToPB(updateStatus.Error), + State: updateStatus.State.getPbState(), + } for _, component := range updateStatus.Components { pbStatus.Components = append(pbStatus.GetComponents(), &pb.ComponentInfo{ - ComponentId: component.ComponentID, - Version: component.Version, + ComponentId: component.ComponentID, + ComponentType: component.ComponentType, + Version: component.Version, }) } diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index b673f3f4..14432078 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -126,7 +126,13 @@ func TestConnection(t *testing.T) { } statusFotaNotification := cmserver.UpdateFOTAStatus{ - Components: []cloudprotocol.ComponentStatus{{ComponentID: "1234", Version: "123.4321"}}, + Components: []cloudprotocol.ComponentStatus{ + { + ComponentID: "testComponent", + ComponentType: "testType", + Version: "2.0.0", + }, + }, UnitConfig: &cloudprotocol.UnitConfigStatus{Version: "bc_version"}, UpdateStatus: cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, } @@ -151,11 +157,15 @@ func TestConnection(t *testing.T) { t.Fatal("Incorrect count of components") } - if status.GetComponents()[0].GetComponentId() != "1234" { + if status.GetComponents()[0].GetComponentId() != "testComponent" { t.Error("Incorrect component id") } - if status.GetComponents()[0].GetVersion() != "123.4321" { + if status.GetComponents()[0].GetComponentType() != "testType" { + t.Error("Incorrect component type") + } + + if status.GetComponents()[0].GetVersion() != "2.0.0" { t.Error("Incorrect version") } @@ -168,11 +178,13 @@ func TestConnection(t *testing.T) { } statusNotification := cmserver.UpdateSOTAStatus{ - InstallServices: []cloudprotocol.ServiceStatus{{ServiceID: "s1", Version: "42.0"}}, - RemoveServices: []cloudprotocol.ServiceStatus{{ServiceID: "s2", Version: "42.0"}}, - InstallLayers: []cloudprotocol.LayerStatus{{LayerID: "l1", Digest: "someSha", Version: "42.0"}}, - RemoveLayers: []cloudprotocol.LayerStatus{{LayerID: "l2", Digest: "someSha", Version: "42.0"}}, - UpdateStatus: cmserver.UpdateStatus{State: cmserver.Downloading, Error: "SOTA error"}, + InstallServices: []cloudprotocol.ServiceStatus{{ServiceID: "s1", Version: "1.0.0"}}, + RemoveServices: []cloudprotocol.ServiceStatus{{ServiceID: "s2", Version: "2.0.0"}}, + InstallLayers: []cloudprotocol.LayerStatus{{LayerID: "l1", Digest: "someSha", Version: "3.0.0"}}, + RemoveLayers: []cloudprotocol.LayerStatus{{LayerID: "l2", Digest: "someSha", Version: "4.0.0"}}, + UpdateStatus: cmserver.UpdateStatus{State: cmserver.Downloading, Error: &cloudprotocol.ErrorInfo{ + Message: "SOTA error", + }}, } unitStatusHandler.sotaChannel <- statusNotification @@ -191,7 +203,7 @@ func TestConnection(t *testing.T) { t.Error("Incorrect state: ", status.GetState().String()) } - if sotaStatus.GetError().GetMessage() != "SOTA error" { + if sotaStatus.GetError().Message != "SOTA error" { t.Error("Incorrect error message: ", status.GetError()) } @@ -203,7 +215,7 @@ func TestConnection(t *testing.T) { t.Error("Incorrect service id") } - if sotaStatus.GetInstallServices()[0].GetVersion() != "42.0" { + if sotaStatus.GetInstallServices()[0].GetVersion() != "1.0.0" { t.Error("Incorrect service aos version") } @@ -219,7 +231,7 @@ func TestConnection(t *testing.T) { t.Error("Incorrect layer digest") } - if sotaStatus.GetInstallLayers()[0].GetVersion() != "42.0" { + if sotaStatus.GetInstallLayers()[0].GetVersion() != "3.0.0" { t.Error("Incorrect layer aos version") } From 82ae41cb2b77a47af2413eaf1adb8c8bc370757e Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 4 Jul 2024 16:41:26 +0300 Subject: [PATCH 028/146] [cmserver] Move unit config status to SOTA Signed-off-by: Oleksandr Grytsov --- cmserver/cmserver.go | 12 ++++++------ cmserver/cmserver_test.go | 40 +++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index c069403e..73da6d18 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -68,12 +68,12 @@ type UpdateStatus struct { // UpdateFOTAStatus FOTA update status for update scheduler service. type UpdateFOTAStatus struct { Components []cloudprotocol.ComponentStatus - UnitConfig *cloudprotocol.UnitConfigStatus UpdateStatus } // UpdateSOTAStatus SOTA update status for update scheduler service. type UpdateSOTAStatus struct { + UnitConfig *cloudprotocol.UnitConfigStatus InstallServices []cloudprotocol.ServiceStatus RemoveServices []cloudprotocol.ServiceStatus InstallLayers []cloudprotocol.LayerStatus @@ -186,7 +186,7 @@ func (server *CMServer) Close() { server.stopChannel <- true } -// SubscribeNotifications sunscribes on SOTA FOTA packages status changes. +// SubscribeNotifications subscribes on SOTA FOTA packages status changes. func (server *CMServer) SubscribeNotifications( req *empty.Empty, stream pb.UpdateSchedulerService_SubscribeNotificationsServer, ) (err error) { @@ -322,6 +322,10 @@ func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSO State: updateStatus.State.getPbState(), } + if updateStatus.UnitConfig != nil { + pbStatus.UnitConfig = &pb.UnitConfigInfo{Version: updateStatus.UnitConfig.Version} + } + for _, layer := range updateStatus.InstallLayers { pbStatus.InstallLayers = append(pbStatus.GetInstallLayers(), &pb.LayerInfo{ LayerId: layer.LayerID, @@ -369,10 +373,6 @@ func (updateStatus *UpdateFOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateFO }) } - if updateStatus.UnitConfig != nil { - pbStatus.UnitConfig = &pb.UnitConfigInfo{Version: updateStatus.UnitConfig.Version} - } - return pbStatus } diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 14432078..6d7157a2 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -133,7 +133,6 @@ func TestConnection(t *testing.T) { Version: "2.0.0", }, }, - UnitConfig: &cloudprotocol.UnitConfigStatus{Version: "bc_version"}, UpdateStatus: cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, } @@ -144,40 +143,33 @@ func TestConnection(t *testing.T) { t.Fatalf("Can't receive notification: %s", err) } - status := notification.GetFotaStatus() - if status == nil { + fotaStatus := notification.GetFotaStatus() + if fotaStatus == nil { t.Fatalf("No FOTA status") } - if status.GetState() != pb.UpdateState_READY_TO_UPDATE { - t.Error("Incorrect state: ", status.GetState().String()) + if fotaStatus.GetState() != pb.UpdateState_READY_TO_UPDATE { + t.Error("Incorrect state: ", fotaStatus.GetState().String()) } - if len(status.GetComponents()) != 1 { + if len(fotaStatus.GetComponents()) != 1 { t.Fatal("Incorrect count of components") } - if status.GetComponents()[0].GetComponentId() != "testComponent" { + if fotaStatus.GetComponents()[0].GetComponentId() != "testComponent" { t.Error("Incorrect component id") } - if status.GetComponents()[0].GetComponentType() != "testType" { + if fotaStatus.GetComponents()[0].GetComponentType() != "testType" { t.Error("Incorrect component type") } - if status.GetComponents()[0].GetVersion() != "2.0.0" { + if fotaStatus.GetComponents()[0].GetVersion() != "2.0.0" { t.Error("Incorrect version") } - if status.GetUnitConfig() == nil { - t.Fatal("Unit Config is nil") - } - - if status.GetUnitConfig().GetVersion() != "bc_version" { - t.Error("Incorrect unit config version") - } - statusNotification := cmserver.UpdateSOTAStatus{ + UnitConfig: &cloudprotocol.UnitConfigStatus{Version: "bc_version"}, InstallServices: []cloudprotocol.ServiceStatus{{ServiceID: "s1", Version: "1.0.0"}}, RemoveServices: []cloudprotocol.ServiceStatus{{ServiceID: "s2", Version: "2.0.0"}}, InstallLayers: []cloudprotocol.LayerStatus{{LayerID: "l1", Digest: "someSha", Version: "3.0.0"}}, @@ -200,11 +192,19 @@ func TestConnection(t *testing.T) { } if sotaStatus.GetState() != pb.UpdateState_DOWNLOADING { - t.Error("Incorrect state: ", status.GetState().String()) + t.Error("Incorrect state: ", sotaStatus.GetState().String()) } - if sotaStatus.GetError().Message != "SOTA error" { - t.Error("Incorrect error message: ", status.GetError()) + if sotaStatus.GetError().GetMessage() != "SOTA error" { + t.Error("Incorrect error message: ", sotaStatus.GetError()) + } + + if sotaStatus.GetUnitConfig() == nil { + t.Fatal("Unit Config is nil") + } + + if sotaStatus.GetUnitConfig().GetVersion() != "bc_version" { + t.Error("Incorrect unit config version") } if len(sotaStatus.GetInstallServices()) != 1 { From 6eae29364547952f0c2195ee4c86cc21be304655 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sat, 6 Jul 2024 15:51:37 +0300 Subject: [PATCH 029/146] [unitstatushandler] Move updating unit config to software manager Signed-off-by: Oleksandr Grytsov --- unitstatushandler/firmwaremanager.go | 186 ++--------- unitstatushandler/softwaremanager.go | 156 +++++++-- unitstatushandler/timetable.go | 10 +- unitstatushandler/unitstatushandler.go | 17 +- .../unitstatushandler_internal_test.go | 228 +++++++------ unitstatushandler/unitstatushandler_test.go | 312 ++++++++++-------- 6 files changed, 463 insertions(+), 446 deletions(-) diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 8742afe0..08e889ba 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -20,8 +20,6 @@ package unitstatushandler import ( "context" "encoding/json" - "errors" - "fmt" "net/url" "reflect" "strings" @@ -35,7 +33,6 @@ import ( "github.com/aosedge/aos_communicationmanager/cmserver" "github.com/aosedge/aos_communicationmanager/downloader" - "github.com/aosedge/aos_communicationmanager/unitconfig" ) /*********************************************************************************************************************** @@ -54,12 +51,10 @@ type firmwareDownloader interface { type firmwareStatusHandler interface { updateComponentStatus(componentInfo cloudprotocol.ComponentStatus) - updateUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) } type firmwareUpdate struct { Schedule cloudprotocol.ScheduleRule `json:"schedule,omitempty"` - UnitConfig json.RawMessage `json:"unitConfig,omitempty"` Components []cloudprotocol.ComponentInfo `json:"components,omitempty"` CertChains []cloudprotocol.CertificateChain `json:"certChains,omitempty"` Certs []cloudprotocol.Certificate `json:"certs,omitempty"` @@ -70,19 +65,16 @@ type firmwareManager struct { statusChannel chan cmserver.UpdateFOTAStatus - downloader firmwareDownloader - statusHandler firmwareStatusHandler - firmwareUpdater FirmwareUpdater - unitConfigUpdater UnitConfigUpdater - storage Storage - runner InstanceRunner + downloader firmwareDownloader + statusHandler firmwareStatusHandler + firmwareUpdater FirmwareUpdater + storage Storage stateMachine *updateStateMachine statusMutex sync.RWMutex pendingUpdate *firmwareUpdate ComponentStatuses map[string]*cloudprotocol.ComponentStatus `json:"componentStatuses,omitempty"` - UnitConfigStatus cloudprotocol.UnitConfigStatus `json:"unitConfigStatus,omitempty"` CurrentUpdate *firmwareUpdate `json:"currentUpdate,omitempty"` DownloadResult map[string]*downloadResult `json:"downloadResult,omitempty"` CurrentState string `json:"currentState,omitempty"` @@ -95,18 +87,15 @@ type firmwareManager struct { **********************************************************************************************************************/ func newFirmwareManager(statusHandler firmwareStatusHandler, downloader firmwareDownloader, - firmwareUpdater FirmwareUpdater, unitConfigUpdater UnitConfigUpdater, - storage Storage, runner InstanceRunner, defaultTTL time.Duration, + firmwareUpdater FirmwareUpdater, storage Storage, defaultTTL time.Duration, ) (manager *firmwareManager, err error) { manager = &firmwareManager{ - statusChannel: make(chan cmserver.UpdateFOTAStatus, 1), - downloader: downloader, - statusHandler: statusHandler, - firmwareUpdater: firmwareUpdater, - unitConfigUpdater: unitConfigUpdater, - storage: storage, - runner: runner, - CurrentState: stateNoUpdate, + statusChannel: make(chan cmserver.UpdateFOTAStatus, 1), + downloader: downloader, + statusHandler: statusHandler, + firmwareUpdater: firmwareUpdater, + storage: storage, + CurrentState: stateNoUpdate, } if err = manager.loadState(); err != nil { @@ -152,7 +141,10 @@ func (manager *firmwareManager) close() (err error) { func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTAStatus) { status.State = convertState(manager.CurrentState) - status.Error = manager.UpdateErr + + if manager.UpdateErr != "" { + status.Error = &cloudprotocol.ErrorInfo{Message: manager.UpdateErr} + } if status.State == cmserver.NoUpdate || manager.CurrentUpdate == nil { return status @@ -166,11 +158,6 @@ func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTASt } } - if len(manager.CurrentUpdate.UnitConfig) != 0 { - version, _ := manager.unitConfigUpdater.GetUnitConfigVersion(manager.CurrentUpdate.UnitConfig) - status.UnitConfig = &cloudprotocol.UnitConfigStatus{Version: version} - } - return status } @@ -178,9 +165,10 @@ func (manager *firmwareManager) processDesiredStatus(desiredStatus cloudprotocol manager.Lock() defer manager.Unlock() + log.Debug("Process desired FOTA") + update := &firmwareUpdate{ Schedule: desiredStatus.FOTASchedule, - UnitConfig: desiredStatus.UnitConfig, Components: make([]cloudprotocol.ComponentInfo, 0), CertChains: desiredStatus.CertificateChains, Certs: desiredStatus.Certificates, @@ -215,10 +203,12 @@ desiredLoop: }).Error("Desired component not found") } - if len(update.UnitConfig) != 0 || len(update.Components) != 0 { + if len(update.Components) != 0 { if err = manager.newUpdate(update); err != nil { return aoserrors.Wrap(err) } + } else { + log.Debug("No FOTA update required") } return nil @@ -270,31 +260,6 @@ func (manager *firmwareManager) getComponentStatuses() (status []cloudprotocol.C return status, nil } -func (manager *firmwareManager) getUnitConfigStatuses() (status []cloudprotocol.UnitConfigStatus, err error) { - manager.Lock() - defer manager.Unlock() - - manager.statusMutex.RLock() - defer manager.statusMutex.RUnlock() - - info, err := manager.unitConfigUpdater.GetStatus() - if err != nil { - return nil, aoserrors.Wrap(err) - } - - status = append(status, info) - - // Append currently processing info - - if manager.CurrentState == stateNoUpdate || len(manager.CurrentUpdate.UnitConfig) == 0 { - return status, nil - } - - status = append(status, manager.UnitConfigStatus) - - return status, nil -} - /*********************************************************************************************************************** * Implementer **********************************************************************************************************************/ @@ -306,12 +271,6 @@ func (manager *firmwareManager) stateChanged(event, state string, updateErr stri manager.updateComponentStatusByID(id, cloudprotocol.ErrorStatus, updateErr) } } - - if len(manager.CurrentUpdate.UnitConfig) != 0 { - if manager.UnitConfigStatus.Status != cloudprotocol.ErrorStatus { - manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, updateErr) - } - } } manager.CurrentState = state @@ -378,27 +337,6 @@ func (manager *firmwareManager) download(ctx context.Context) { manager.DownloadResult = nil - if len(manager.CurrentUpdate.UnitConfig) != 0 { - manager.UnitConfigStatus.Version = "" - - version, err := manager.unitConfigUpdater.GetUnitConfigVersion(manager.CurrentUpdate.UnitConfig) - - manager.UnitConfigStatus.Version = version - - if err != nil { - log.Errorf("Error getting unit config version: %s", err) - - downloadErr = aoserrors.Wrap(err).Error() - manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, downloadErr) - - return - } - - log.WithFields(log.Fields{"version": version}).Debug("Get unit config version") - - manager.updateUnitConfigStatus(cloudprotocol.PendingStatus, "") - } - manager.statusMutex.Lock() manager.ComponentStatuses = make(map[string]*cloudprotocol.ComponentStatus) @@ -481,18 +419,6 @@ func (manager *firmwareManager) update(ctx context.Context) { return } } - - if len(manager.CurrentUpdate.UnitConfig) != 0 { - if err := manager.updateUnitConfig(ctx); err != "" { - updateErr = err - return - } - - if err := manager.runner.RestartInstances(); err != nil { - updateErr = err.Error() - return - } - } } func (manager *firmwareManager) updateTimeout() { @@ -539,8 +465,7 @@ func (manager *firmwareManager) newUpdate(update *firmwareUpdate) (err error) { } default: - if reflect.DeepEqual(update.Components, manager.CurrentUpdate.Components) && - unitConfigsEqual(update.UnitConfig, manager.CurrentUpdate.UnitConfig) { + if reflect.DeepEqual(update.Components, manager.CurrentUpdate.Components) { if reflect.DeepEqual(update.Schedule, manager.CurrentUpdate.Schedule) { return nil } @@ -588,7 +513,7 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component for id, status := range manager.ComponentStatuses { if status.Status != cloudprotocol.ErrorStatus { manager.updateComponentStatusByID(id, cloudprotocol.ErrorStatus, - fmt.Sprintf("update aborted due to error: %s", componentsErr)) + "update aborted due to error: "+componentsErr) } log.WithFields(log.Fields{ @@ -697,38 +622,6 @@ func (manager *firmwareManager) saveState() (err error) { return nil } -func (manager *firmwareManager) updateUnitConfig(ctx context.Context) (unitConfigErr string) { - log.Debug("Update unit config") - - defer func() { - if unitConfigErr != "" { - manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, unitConfigErr) - } - }() - - if _, err := manager.unitConfigUpdater.CheckUnitConfig(manager.CurrentUpdate.UnitConfig); err != nil { - if errors.Is(err, unitconfig.ErrAlreadyInstalled) { - log.Error("Unit config already installed") - - manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, "") - - return "" - } - - return aoserrors.Wrap(err).Error() - } - - manager.updateUnitConfigStatus(cloudprotocol.InstallingStatus, "") - - if err := manager.unitConfigUpdater.UpdateUnitConfig(manager.CurrentUpdate.UnitConfig); err != nil { - return aoserrors.Wrap(err).Error() - } - - manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, "") - - return "" -} - func (manager *firmwareManager) asyncUpdate( updateComponents []cloudprotocol.ComponentInfo, ) (channel <-chan string) { @@ -762,38 +655,3 @@ func (manager *firmwareManager) asyncUpdate( return finishChannel } - -func (manager *firmwareManager) updateUnitConfigStatus(status, errorStr string) { - manager.statusMutex.Lock() - defer manager.statusMutex.Unlock() - - manager.UnitConfigStatus.Status = status - - if errorStr != "" { - manager.UnitConfigStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: errorStr} - } - - manager.statusHandler.updateUnitConfigStatus(manager.UnitConfigStatus) -} - -func unitConfigsEqual(config1, config2 json.RawMessage) (equal bool) { - var configData1, configData2 interface{} - - if config1 == nil && config2 == nil { - return true - } - - if (config1 == nil && config2 != nil) || (config1 != nil && config2 == nil) { - return false - } - - if err := json.Unmarshal(config1, &configData1); err != nil { - log.Errorf("Can't marshal unit config: %s", err) - } - - if err := json.Unmarshal(config2, &configData2); err != nil { - log.Errorf("Can't marshal unit config: %s", err) - } - - return reflect.DeepEqual(configData1, configData2) -} diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 1a5d4a95..fbae2658 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -20,6 +20,7 @@ package unitstatushandler import ( "context" "encoding/json" + "errors" "net/url" "reflect" "sync" @@ -34,6 +35,7 @@ import ( "github.com/aosedge/aos_communicationmanager/cmserver" "github.com/aosedge/aos_communicationmanager/downloader" + "github.com/aosedge/aos_communicationmanager/unitconfig" ) /*********************************************************************************************************************** @@ -54,11 +56,13 @@ type softwareDownloader interface { type softwareStatusHandler interface { updateLayerStatus(layerInfo cloudprotocol.LayerStatus) updateServiceStatus(serviceInfo cloudprotocol.ServiceStatus) + updateUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) setInstanceStatus(status []cloudprotocol.InstanceStatus) } type softwareUpdate struct { Schedule cloudprotocol.ScheduleRule `json:"schedule,omitempty"` + UnitConfig *cloudprotocol.UnitConfig `json:"unitConfig,omitempty"` InstallServices []cloudprotocol.ServiceInfo `json:"installServices,omitempty"` RemoveServices []cloudprotocol.ServiceStatus `json:"removeServices,omitempty"` RestoreServices []cloudprotocol.ServiceInfo `json:"restoreServices,omitempty"` @@ -76,11 +80,12 @@ type softwareManager struct { statusChannel chan cmserver.UpdateSOTAStatus - downloader softwareDownloader - statusHandler softwareStatusHandler - softwareUpdater SoftwareUpdater - instanceRunner InstanceRunner - storage Storage + unitConfigUpdater UnitConfigUpdater + downloader softwareDownloader + statusHandler softwareStatusHandler + softwareUpdater SoftwareUpdater + instanceRunner InstanceRunner + storage Storage stateMachine *updateStateMachine actionHandler *action.Handler @@ -90,6 +95,7 @@ type softwareManager struct { LayerStatuses map[string]*cloudprotocol.LayerStatus `json:"layerStatuses,omitempty"` ServiceStatuses map[string]*cloudprotocol.ServiceStatus `json:"serviceStatuses,omitempty"` InstanceStatuses []cloudprotocol.InstanceStatus `json:"instanceStatuses,omitempty"` + UnitConfigStatus cloudprotocol.UnitConfigStatus `json:"unitConfigStatus,omitempty"` CurrentUpdate *softwareUpdate `json:"currentUpdate,omitempty"` DownloadResult map[string]*downloadResult `json:"downloadResult,omitempty"` CurrentState string `json:"currentState,omitempty"` @@ -102,17 +108,19 @@ type softwareManager struct { **********************************************************************************************************************/ func newSoftwareManager(statusHandler softwareStatusHandler, downloader softwareDownloader, - softwareUpdater SoftwareUpdater, instanceRunner InstanceRunner, storage Storage, defaultTTL time.Duration, + unitConfigUpdater UnitConfigUpdater, softwareUpdater SoftwareUpdater, instanceRunner InstanceRunner, + storage Storage, defaultTTL time.Duration, ) (manager *softwareManager, err error) { manager = &softwareManager{ - statusChannel: make(chan cmserver.UpdateSOTAStatus, 1), - downloader: downloader, - statusHandler: statusHandler, - softwareUpdater: softwareUpdater, - instanceRunner: instanceRunner, - actionHandler: action.New(maxConcurrentActions), - storage: storage, - CurrentState: stateNoUpdate, + statusChannel: make(chan cmserver.UpdateSOTAStatus, 1), + downloader: downloader, + statusHandler: statusHandler, + unitConfigUpdater: unitConfigUpdater, + softwareUpdater: softwareUpdater, + instanceRunner: instanceRunner, + actionHandler: action.New(maxConcurrentActions), + storage: storage, + CurrentState: stateNoUpdate, } manager.runCond = sync.NewCond(&manager.Mutex) @@ -145,9 +153,12 @@ func newSoftwareManager(statusHandler softwareStatusHandler, downloader software func (manager *softwareManager) close() (err error) { manager.Lock() + log.Debug("Close software manager") + manager.runCond.Broadcast() close(manager.statusChannel) + manager.Unlock() if err = manager.stateMachine.close(); err != nil { @@ -159,7 +170,10 @@ func (manager *softwareManager) close() (err error) { func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTAStatus) { status.State = convertState(manager.CurrentState) - status.Error = manager.UpdateErr + + if manager.UpdateErr != "" { + status.Error = &cloudprotocol.ErrorInfo{Message: manager.UpdateErr} + } if status.State == cmserver.NoUpdate || manager.CurrentUpdate == nil { return status @@ -189,6 +203,10 @@ func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTASt }) } + if manager.CurrentUpdate.UnitConfig != nil { + status.UnitConfig = &cloudprotocol.UnitConfigStatus{Version: manager.CurrentUpdate.UnitConfig.Version} + } + return status } @@ -220,8 +238,11 @@ func (manager *softwareManager) processDesiredStatus(desiredStatus cloudprotocol manager.Lock() defer manager.Unlock() + log.Debug("Process desired SOTA") + update := &softwareUpdate{ Schedule: desiredStatus.SOTASchedule, + UnitConfig: desiredStatus.UnitConfig, InstallServices: make([]cloudprotocol.ServiceInfo, 0), RemoveServices: make([]cloudprotocol.ServiceStatus, 0), InstallLayers: make([]cloudprotocol.LayerInfo, 0), @@ -245,12 +266,12 @@ func (manager *softwareManager) processDesiredStatus(desiredStatus cloudprotocol if len(update.InstallServices) != 0 || len(update.RemoveServices) != 0 || len(update.InstallLayers) != 0 || len(update.RemoveLayers) != 0 || len(update.RestoreServices) != 0 || - len(update.RestoreLayers) != 0 || manager.needRunInstances(desiredStatus.Instances) { + len(update.RestoreLayers) != 0 || manager.needRunInstances(desiredStatus.Instances) || update.UnitConfig != nil { if err := manager.newUpdate(update); err != nil { return aoserrors.Wrap(err) } } else { - log.Debug("No software update needed") + log.Debug("No SOTA update required") } return nil @@ -436,6 +457,31 @@ func (manager *softwareManager) getLayersStatus() (layerStatuses []cloudprotocol return layerStatuses, nil } +func (manager *softwareManager) getUnitConfigStatuses() (status []cloudprotocol.UnitConfigStatus, err error) { + manager.Lock() + defer manager.Unlock() + + manager.statusMutex.RLock() + defer manager.statusMutex.RUnlock() + + info, err := manager.unitConfigUpdater.GetStatus() + if err != nil { + return nil, aoserrors.Wrap(err) + } + + status = append(status, info) + + // Append currently processing info + + if manager.CurrentState == stateNoUpdate || manager.CurrentUpdate.UnitConfig == nil { + return status, nil + } + + status = append(status, manager.UnitConfigStatus) + + return status, nil +} + /*********************************************************************************************************************** * Implementer **********************************************************************************************************************/ @@ -453,6 +499,12 @@ func (manager *softwareManager) stateChanged(event, state string, updateErr stri manager.updateServiceStatusByID(id, cloudprotocol.ErrorStatus, updateErr) } } + + if manager.CurrentUpdate.UnitConfig != nil { + if manager.UnitConfigStatus.Status != cloudprotocol.ErrorStatus { + manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, updateErr) + } + } } manager.CurrentState = state @@ -518,6 +570,11 @@ func (manager *softwareManager) download(ctx context.Context) { manager.DownloadResult = nil + if manager.CurrentUpdate.UnitConfig != nil { + manager.UnitConfigStatus.Version = manager.CurrentUpdate.UnitConfig.Version + manager.updateUnitConfigStatus(cloudprotocol.PendingStatus, "") + } + request := manager.prepareDownloadRequest() // Nothing to download @@ -554,6 +611,7 @@ func (manager *softwareManager) download(ctx context.Context) { "id": serviceStatus.ServiceID, "version": serviceStatus.Version, }).Errorf("Error downloading service: %v", serviceStatus.ErrorInfo) + continue } @@ -666,6 +724,12 @@ func (manager *softwareManager) update(ctx context.Context) { }() }() + if manager.CurrentUpdate.UnitConfig != nil { + if err := manager.updateUnitConfig(ctx); err != "" { + updateErr = err + } + } + if errorStr := manager.removeServices(); errorStr != "" && updateErr == "" { updateErr = errorStr } @@ -695,10 +759,6 @@ func (manager *softwareManager) update(ctx context.Context) { updateErr = errorStr } - if updateErr != "" { - return - } - manager.runCond.Wait() } @@ -748,7 +808,8 @@ func (manager *softwareManager) newUpdate(update *softwareUpdate) (err error) { } default: - if reflect.DeepEqual(update.InstallLayers, manager.CurrentUpdate.InstallLayers) && + if reflect.DeepEqual(update.UnitConfig, manager.CurrentUpdate.UnitConfig) && + reflect.DeepEqual(update.InstallLayers, manager.CurrentUpdate.InstallLayers) && reflect.DeepEqual(update.RemoveLayers, manager.CurrentUpdate.RemoveLayers) && reflect.DeepEqual(update.InstallServices, manager.CurrentUpdate.InstallServices) && reflect.DeepEqual(update.RemoveServices, manager.CurrentUpdate.RemoveServices) && @@ -954,16 +1015,16 @@ func (manager *softwareManager) installLayers() (installErr string) { } func (manager *softwareManager) removeLayers() (removeErr string) { - return manager.processRemoveRestorLayers( + return manager.processRemoveRestoreLayers( manager.CurrentUpdate.RemoveLayers, "remove", cloudprotocol.RemovedStatus, manager.softwareUpdater.RemoveLayer) } func (manager *softwareManager) restoreLayers() (restoreErr string) { - return manager.processRemoveRestorLayers( + return manager.processRemoveRestoreLayers( manager.CurrentUpdate.RestoreLayers, "restore", cloudprotocol.InstalledStatus, manager.softwareUpdater.RestoreLayer) } -func (manager *softwareManager) processRemoveRestorLayers( +func (manager *softwareManager) processRemoveRestoreLayers( layers []cloudprotocol.LayerStatus, operationStr, successStatus string, operation func(digest string) error, ) (processError string) { var mutex sync.Mutex @@ -1277,3 +1338,48 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr strin return "" } + +func (manager *softwareManager) updateUnitConfig(ctx context.Context) (unitConfigErr string) { + log.Debug("Update unit config") + + defer func() { + if unitConfigErr != "" { + manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, unitConfigErr) + } + }() + + if err := manager.unitConfigUpdater.CheckUnitConfig(*manager.CurrentUpdate.UnitConfig); err != nil { + if errors.Is(err, unitconfig.ErrAlreadyInstalled) { + log.Error("Unit config already installed") + + manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, "") + + return "" + } + + return aoserrors.Wrap(err).Error() + } + + manager.updateUnitConfigStatus(cloudprotocol.InstallingStatus, "") + + if err := manager.unitConfigUpdater.UpdateUnitConfig(*manager.CurrentUpdate.UnitConfig); err != nil { + return aoserrors.Wrap(err).Error() + } + + manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, "") + + return "" +} + +func (manager *softwareManager) updateUnitConfigStatus(status, errorStr string) { + manager.statusMutex.Lock() + defer manager.statusMutex.Unlock() + + manager.UnitConfigStatus.Status = status + + if errorStr != "" { + manager.UnitConfigStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: errorStr} + } + + manager.statusHandler.updateUnitConfigStatus(manager.UnitConfigStatus) +} diff --git a/unitstatushandler/timetable.go b/unitstatushandler/timetable.go index e7d12738..5a3bc2d8 100644 --- a/unitstatushandler/timetable.go +++ b/unitstatushandler/timetable.go @@ -54,12 +54,12 @@ func validateTimetable(timetable []cloudprotocol.TimetableEntry) (err error) { return aoserrors.New("start value should contain only time") } - if year, month, day := slot.Finish.Date(); year != 0 || month != 1 || day != 1 { - return aoserrors.New("finish value should contain only time") + if year, month, day := slot.End.Date(); year != 0 || month != 1 || day != 1 { + return aoserrors.New("end value should contain only time") } - if slot.Start.After(slot.Finish.Time) { - return aoserrors.New("start value should be before finish value") + if slot.Start.After(slot.End.Time) { + return aoserrors.New("start value should be before end value") } } } @@ -103,7 +103,7 @@ func getAvailableTimetableTime( //nolint:gosmopolitan finishDate := time.Date(startEntry.Year(), startEntry.Month(), startEntry.Day(), - slot.Finish.Hour(), slot.Finish.Minute(), slot.Finish.Second(), slot.Finish.Nanosecond(), time.Local) + slot.End.Hour(), slot.End.Minute(), slot.End.Second(), slot.End.Nanosecond(), time.Local) duration := startDate.Sub(fromDate) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 7c884562..d99a4c6c 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -54,10 +54,9 @@ type StatusSender interface { // UnitConfigUpdater updates unit configuration. type UnitConfigUpdater interface { - GetStatus() (unitConfigInfo cloudprotocol.UnitConfigStatus, err error) - GetUnitConfigVersion(configJSON json.RawMessage) (vendorVersion string, err error) - CheckUnitConfig(configJSON json.RawMessage) (vendorVersion string, err error) - UpdateUnitConfig(configJSON json.RawMessage) (err error) + GetStatus() (cloudprotocol.UnitConfigStatus, error) + CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) error + UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) error } // FirmwareUpdater updates system components. @@ -175,13 +174,13 @@ func New( groupDownloader := newGroupDownloader(downloader) - if instance.firmwareManager, err = newFirmwareManager(instance, groupDownloader, firmwareUpdater, unitConfigUpdater, - storage, instanceRunner, cfg.UMController.UpdateTTL.Duration); err != nil { + if instance.firmwareManager, err = newFirmwareManager(instance, groupDownloader, firmwareUpdater, + storage, cfg.UMController.UpdateTTL.Duration); err != nil { return nil, aoserrors.Wrap(err) } - if instance.softwareManager, err = newSoftwareManager(instance, groupDownloader, softwareUpdater, instanceRunner, - storage, cfg.SMController.UpdateTTL.Duration); err != nil { + if instance.softwareManager, err = newSoftwareManager(instance, groupDownloader, unitConfigUpdater, softwareUpdater, + instanceRunner, storage, cfg.SMController.UpdateTTL.Duration); err != nil { return nil, aoserrors.Wrap(err) } @@ -342,7 +341,7 @@ func (instance *Instance) initCurrentStatus() error { // Get initial unit config info - unitConfigStatuses, err := instance.firmwareManager.getUnitConfigStatuses() + unitConfigStatuses, err := instance.softwareManager.getUnitConfigStatuses() if err != nil { return aoserrors.Wrap(err) } diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index bb60d2b6..e32b88cf 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -60,7 +60,6 @@ type TestSender struct { type TestUnitConfigUpdater struct { UnitConfigStatus cloudprotocol.UnitConfigStatus - UpdateVersion string UpdateError error } @@ -249,7 +248,6 @@ func TestFirmwareManager(t *testing.T) { downloadResult map[string]*downloadResult updateTime time.Duration updateComponentStatuses []cloudprotocol.ComponentStatus - unitConfigError error triggerUpdate bool updateWaitStatuses []cmserver.UpdateStatus } @@ -281,8 +279,8 @@ func TestFirmwareManager(t *testing.T) { } updateTimeSlots := []cloudprotocol.TimeSlot{{ - Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 23, 59, 59, 999999, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 23, 59, 59, 999999, time.Local)}, }} updateTimetable := []cloudprotocol.TimetableEntry{ @@ -336,7 +334,8 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Downloading}, {State: cmserver.NoUpdate, Error: "download error"}, + {State: cmserver.Downloading}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "download error"}}, }, }, { @@ -362,7 +361,7 @@ func TestFirmwareManager(t *testing.T) { {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, - {State: cmserver.NoUpdate, Error: "update error"}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "update error"}}, }, }, { @@ -386,7 +385,9 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, {State: cmserver.NoUpdate}, + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, }, }, { @@ -418,7 +419,10 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, - updateWaitStatuses: []cmserver.UpdateStatus{{State: cmserver.Updating}, {State: cmserver.NoUpdate}}, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, }, { testID: "continue update on updating state", @@ -448,7 +452,9 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, - updateWaitStatuses: []cmserver.UpdateStatus{{State: cmserver.NoUpdate}}, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.NoUpdate}, + }, }, { testID: "same update on ready to update state", @@ -486,8 +492,11 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, }, - triggerUpdate: true, - updateWaitStatuses: []cmserver.UpdateStatus{{State: cmserver.Updating}, {State: cmserver.NoUpdate}}, + triggerUpdate: true, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, }, { testID: "new update on downloading state", @@ -519,7 +528,7 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.NoUpdate, Error: context.Canceled.Error()}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: context.Canceled.Error()}}, {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, @@ -555,7 +564,7 @@ func TestFirmwareManager(t *testing.T) { {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.NoUpdate, Error: context.Canceled.Error()}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: context.Canceled.Error()}}, {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, }, @@ -612,26 +621,6 @@ func TestFirmwareManager(t *testing.T) { {State: cmserver.NoUpdate}, }, }, - { - testID: "update unit config", - initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, - desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}, - updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Downloading}, - {State: cmserver.ReadyToUpdate}, - {State: cmserver.Updating}, - {State: cmserver.NoUpdate}, - }, - }, - { - testID: "error unit config", - initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, - desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}, - unitConfigError: aoserrors.New("unit config error"), - updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Downloading}, {State: cmserver.NoUpdate, Error: "unit config error"}, - }, - }, { testID: "timetable update", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, @@ -682,13 +671,14 @@ func TestFirmwareManager(t *testing.T) { updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, - {State: cmserver.NoUpdate, Error: "update timeout"}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{ + Message: "update timeout", + }}, }, }, } firmwareUpdater := NewTestFirmwareUpdater(nil) - unitConfigUpdater := NewTestUnitConfigUpdater(cloudprotocol.UnitConfigStatus{}) firmwareDownloader := newTestGroupDownloader() testStorage := NewTestStorage() @@ -701,7 +691,6 @@ func TestFirmwareManager(t *testing.T) { firmwareUpdater.InitComponentsInfo = item.initComponentStatuses firmwareUpdater.UpdateComponentsInfo = item.updateComponentStatuses firmwareUpdater.UpdateTime = item.updateTime - unitConfigUpdater.UpdateError = item.unitConfigError if err := testStorage.saveFirmwareState(item.initState); err != nil { t.Errorf("Can't save init state: %s", err) @@ -710,8 +699,8 @@ func TestFirmwareManager(t *testing.T) { // Create firmware manager - firmwareManager, err := newFirmwareManager(newTestStatusHandler(), firmwareDownloader, - firmwareUpdater, unitConfigUpdater, testStorage, &TestInstanceRunner{}, 30*time.Second) + firmwareManager, err := newFirmwareManager(newTestStatusHandler(), firmwareDownloader, firmwareUpdater, + testStorage, 30*time.Second) if err != nil { t.Errorf("Can't create firmware manager: %s", err) continue @@ -806,8 +795,8 @@ func TestSoftwareManager(t *testing.T) { } updateTimeSlots := []cloudprotocol.TimeSlot{{ - Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 23, 59, 59, 999999, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 23, 59, 59, 999999, time.Local)}, }} updateTimetable := []cloudprotocol.TimetableEntry{ @@ -909,7 +898,7 @@ func TestSoftwareManager(t *testing.T) { }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, - {State: cmserver.ReadyToUpdate, Error: "download error"}, + {State: cmserver.ReadyToUpdate, Error: &cloudprotocol.ErrorInfo{Message: "download error"}}, {State: cmserver.Updating}, {State: cmserver.NoUpdate}, }, @@ -921,11 +910,16 @@ func TestSoftwareManager(t *testing.T) { Layers: updateLayers, Services: updateServices, }, downloadResult: map[string]*downloadResult{ - updateLayers[0].Digest: {Error: "download error"}, updateLayers[1].Digest: {Error: "download error"}, - updateServices[0].ServiceID: {Error: "download error"}, updateServices[1].ServiceID: {Error: "download error"}, + updateLayers[0].Digest: {Error: "download error"}, + updateLayers[1].Digest: {Error: "download error"}, + updateServices[0].ServiceID: {Error: "download error"}, + updateServices[1].ServiceID: {Error: "download error"}, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Downloading}, {State: cmserver.NoUpdate, Error: "download error"}, + {State: cmserver.Downloading}, { + State: cmserver.NoUpdate, + Error: &cloudprotocol.ErrorInfo{Message: "download error"}, + }, }, }, { @@ -943,7 +937,7 @@ func TestSoftwareManager(t *testing.T) { {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, - {State: cmserver.NoUpdate, Error: "update error"}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "update error"}}, }, }, { @@ -960,7 +954,9 @@ func TestSoftwareManager(t *testing.T) { updateServices[0].ServiceID: {}, updateServices[1].ServiceID: {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, {State: cmserver.NoUpdate}, + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, }, }, { @@ -1002,7 +998,35 @@ func TestSoftwareManager(t *testing.T) { }, }, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Updating}, {State: cmserver.NoUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, + }, + { + testID: "update unit config", + initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, + desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{ + Version: "1.0.0", + }}, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Downloading}, + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, + }, + { + testID: "error unit config", + initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, + desiredStatus: &cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{ + Version: "1.0.0", + }}, + updateError: aoserrors.New("unit config error"), + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Downloading}, + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "unit config error"}}, }, }, { @@ -1043,11 +1067,12 @@ func TestSoftwareManager(t *testing.T) { updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, - {State: cmserver.NoUpdate, Error: "update timeout"}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "update timeout"}}, }, }, } + unitConfigUpdater := NewTestUnitConfigUpdater(cloudprotocol.UnitConfigStatus{}) softwareUpdater := NewTestSoftwareUpdater(nil, nil) instanceRunner := NewTestInstanceRunner() softwareDownloader := newTestGroupDownloader() @@ -1062,6 +1087,7 @@ func TestSoftwareManager(t *testing.T) { softwareUpdater.AllServices = item.initServices softwareUpdater.AllLayers = item.initLayers softwareUpdater.UpdateError = item.updateError + unitConfigUpdater.UpdateError = item.updateError if err := testStorage.saveSoftwareState(item.initState); err != nil { t.Errorf("Can't save init state: %s", err) @@ -1070,8 +1096,8 @@ func TestSoftwareManager(t *testing.T) { // Create software manager - softwareManager, err := newSoftwareManager(newTestStatusHandler(), softwareDownloader, softwareUpdater, - instanceRunner, testStorage, 30*time.Second) + softwareManager, err := newSoftwareManager(newTestStatusHandler(), softwareDownloader, unitConfigUpdater, + softwareUpdater, instanceRunner, testStorage, 30*time.Second) if err != nil { t.Errorf("Can't create software manager: %s", err) continue @@ -1118,9 +1144,7 @@ func TestSoftwareManager(t *testing.T) { } } - if item.updateError == nil { - softwareManager.processRunStatus(RunInstancesStatus{}) - } + softwareManager.processRunStatus(RunInstancesStatus{}) } if err = waitForSOTAUpdateStatus(softwareManager.statusChannel, expectedStatus); err != nil { @@ -1171,8 +1195,8 @@ func TestTimeTable(t *testing.T) { { DayOfWeek: 1, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 2, 0, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 2, 0, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, }, }, }, @@ -1184,26 +1208,26 @@ func TestTimeTable(t *testing.T) { { DayOfWeek: 1, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 2, 0, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 2, 0, 0, 0, 0, time.Local)}, }, }, }, }, - err: "finish value should contain only time", + err: "end value should contain only time", }, { timetable: []cloudprotocol.TimetableEntry{ { DayOfWeek: 1, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 1, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 1, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, }, }, }, }, - err: "start value should be before finish value", + err: "start value should be before end value", }, { fromDate: time.Date(1, 1, 1, 0, 0, 0, 0, time.Local), @@ -1211,8 +1235,8 @@ func TestTimeTable(t *testing.T) { { DayOfWeek: 1, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 0, 0, 0, 0, time.Local)}, }, }, }, @@ -1225,32 +1249,32 @@ func TestTimeTable(t *testing.T) { { DayOfWeek: 2, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 8, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 8, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, }, { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 14, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 14, 0, 0, 0, time.Local)}, }, }, }, { DayOfWeek: 3, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 16, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 18, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 16, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 18, 0, 0, 0, time.Local)}, }, { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 20, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 22, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 20, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 22, 0, 0, 0, time.Local)}, }, }, }, { DayOfWeek: 1, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, }, }, }, @@ -1263,48 +1287,48 @@ func TestTimeTable(t *testing.T) { { DayOfWeek: 1, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 8, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 8, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, }, { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 14, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 14, 0, 0, 0, time.Local)}, }, }, }, { DayOfWeek: 2, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 16, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 18, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 16, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 18, 0, 0, 0, time.Local)}, }, { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 20, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 22, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 20, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 22, 0, 0, 0, time.Local)}, }, }, }, { DayOfWeek: 3, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, }, }, }, { DayOfWeek: 4, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 12, 0, 0, 0, time.Local)}, }, }, }, { DayOfWeek: 5, TimeSlots: []cloudprotocol.TimeSlot{ { - Start: aostypes.Time{Time: time.Date(0, 1, 1, 8, 0, 0, 0, time.Local)}, - Finish: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, + Start: aostypes.Time{Time: time.Date(0, 1, 1, 8, 0, 0, 0, time.Local)}, + End: aostypes.Time{Time: time.Date(0, 1, 1, 10, 0, 0, 0, time.Local)}, }, }, }, @@ -1433,23 +1457,19 @@ func (sender *TestSender) SubscribeForConnectionEvents(consumer amqphandler.Conn * TestUnitConfigUpdater **********************************************************************************************************************/ -func NewTestUnitConfigUpdater(unitConfigInfo cloudprotocol.UnitConfigStatus) (updater *TestUnitConfigUpdater) { - return &TestUnitConfigUpdater{UnitConfigStatus: unitConfigInfo} +func NewTestUnitConfigUpdater(unitConfigsStatus cloudprotocol.UnitConfigStatus) *TestUnitConfigUpdater { + return &TestUnitConfigUpdater{UnitConfigStatus: unitConfigsStatus} } -func (updater *TestUnitConfigUpdater) GetStatus() (info cloudprotocol.UnitConfigStatus, err error) { +func (updater *TestUnitConfigUpdater) GetStatus() (cloudprotocol.UnitConfigStatus, error) { return updater.UnitConfigStatus, nil } -func (updater *TestUnitConfigUpdater) GetUnitConfigVersion(configJSON json.RawMessage) (version string, err error) { - return updater.UpdateVersion, updater.UpdateError -} - -func (updater *TestUnitConfigUpdater) CheckUnitConfig(configJSON json.RawMessage) (version string, err error) { - return updater.UpdateVersion, updater.UpdateError +func (updater *TestUnitConfigUpdater) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) error { + return updater.UpdateError } -func (updater *TestUnitConfigUpdater) UpdateUnitConfig(configJSON json.RawMessage) (err error) { +func (updater *TestUnitConfigUpdater) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) { return updater.UpdateError } @@ -1830,13 +1850,17 @@ func compareStatuses(expectedStatus, comparedStatus cmserver.UpdateStatus) (err return aoserrors.Errorf("wrong state: %s", comparedStatus.State) } - if comparedStatus.Error == "" && expectedStatus.Error != "" || - comparedStatus.Error != "" && expectedStatus.Error == "" { - return aoserrors.Errorf("wrong error: %s", comparedStatus.Error) + if expectedStatus.Error == nil && comparedStatus.Error == nil { + return nil + } + + if comparedStatus.Error == nil && expectedStatus.Error != nil || + comparedStatus.Error != nil && expectedStatus.Error == nil { + return aoserrors.Errorf("wrong error: %s", comparedStatus.Error.Message) } - if !strings.Contains(comparedStatus.Error, expectedStatus.Error) { - return aoserrors.Errorf("wrong error: %s", comparedStatus.Error) + if !strings.Contains(comparedStatus.Error.Message, expectedStatus.Error.Message) { + return aoserrors.Errorf("wrong error: %s", comparedStatus.Error.Message) } return nil diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 796c857f..33a54a2f 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -53,39 +53,39 @@ func TestSendInitialStatus(t *testing.T) { expectedUnitStatus := cloudprotocol.UnitStatus{ UnitSubjects: []string{"subject1"}, UnitConfig: []cloudprotocol.UnitConfigStatus{ - {Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, Components: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.1", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.2", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.2.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{ - {LayerID: "layer0", Digest: "digest0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer1", Digest: "digest1", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer2", Digest: "digest2", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{ - {ServiceID: "service0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, } initialServices := []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service0", Version: "1.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service2", Version: "1.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service2", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, { ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true, }, @@ -93,13 +93,13 @@ func TestSendInitialStatus(t *testing.T) { initialLayers := []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer0", Digest: "digest0", Version: "1.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer0", Digest: "digest0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer1", Digest: "digest1", Version: "2.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer2", Digest: "digest2", Version: "3.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer2", Digest: "digest2", Version: "3.0.0", Status: cloudprotocol.InstalledStatus, }}, } @@ -151,7 +151,7 @@ func TestSendInitialStatus(t *testing.T) { func TestUpdateUnitConfig(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) fotaUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) sotaUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -180,7 +180,7 @@ func TestUpdateUnitConfig(t *testing.T) { // success update unitConfigUpdater.UnitConfigStatus = cloudprotocol.UnitConfigStatus{ - Version: "1.1", Status: cloudprotocol.InstalledStatus, + Version: "1.1.0", Status: cloudprotocol.InstalledStatus, } expectedUnitStatus := cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, @@ -189,9 +189,16 @@ func TestUpdateUnitConfig(t *testing.T) { Services: []cloudprotocol.ServiceStatus{}, } - unitConfigUpdater.UpdateVersion = "1.1" + statusHandler.ProcessDesiredStatus( + cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{Version: "1.1.0"}}) - statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}) + if _, err := instanceRunner.WaitForRunInstance(waitRunInstanceTimeout); err != nil { + t.Errorf("Wait run instances error: %v", err) + } + + if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + t.Fatalf("Can't process run status: %v", err) + } receivedUnitStatus, err := sender.WaitForStatus(waitStatusTimeout) if err != nil { @@ -204,16 +211,24 @@ func TestUpdateUnitConfig(t *testing.T) { // failed update - unitConfigUpdater.UpdateVersion = "1.2" unitConfigUpdater.UpdateError = aoserrors.New("some error occurs") - unitConfigUpdater.UnitConfigStatus = cloudprotocol.UnitConfigStatus{ - Version: "1.2", Status: cloudprotocol.ErrorStatus, + expectedUnitStatus.UnitConfig = append(expectedUnitStatus.UnitConfig, cloudprotocol.UnitConfigStatus{ + Version: "1.2.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: unitConfigUpdater.UpdateError.Error()}, + }) + + statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{ + Version: "1.2.0", + }}) + + if _, err := instanceRunner.WaitForRunInstance(waitRunInstanceTimeout); err != nil { + t.Errorf("Wait run instances error: %v", err) } - expectedUnitStatus.UnitConfig = append(expectedUnitStatus.UnitConfig, unitConfigUpdater.UnitConfigStatus) - statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{UnitConfig: &cloudprotocol.UnitConfig{}}) + if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + t.Fatalf("Can't process run status: %v", err) + } if receivedUnitStatus, err = sender.WaitForStatus(waitStatusTimeout); err != nil { t.Fatalf("Can't receive unit status: %s", err) @@ -226,12 +241,12 @@ func TestUpdateUnitConfig(t *testing.T) { func TestUpdateComponents(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater(cloudprotocol.UnitConfigStatus{ - Version: "1.0", Status: cloudprotocol.InstalledStatus, + Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater([]cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -262,9 +277,9 @@ func TestUpdateComponents(t *testing.T) { expectedUnitStatus := cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{}, @@ -274,8 +289,8 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ComponentID: convertToComponentID("comp0"), Version: "2.0"}, - {ComponentID: convertToComponentID("comp2"), Version: "2.0"}, + {ComponentID: convertToComponentID("comp0"), Version: "2.0.0"}, + {ComponentID: convertToComponentID("comp2"), Version: "2.0.0"}, }, }) @@ -295,13 +310,13 @@ func TestUpdateComponents(t *testing.T) { expectedUnitStatus = cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { - ComponentID: "comp1", Version: "2.0", Status: cloudprotocol.ErrorStatus, + ComponentID: "comp1", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: firmwareUpdater.UpdateError.Error()}, }, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{}, @@ -311,7 +326,7 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ComponentID: convertToComponentID("comp1"), Version: "2.0"}, + {ComponentID: convertToComponentID("comp1"), Version: "2.0.0"}, }, }) @@ -327,17 +342,17 @@ func TestUpdateComponents(t *testing.T) { func TestUpdateLayers(t *testing.T) { layerStatuses := []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, layerStatuses) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -369,11 +384,11 @@ func TestUpdateLayers(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.RemovedStatus}, - {LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.RemovedStatus}, - {LayerID: "layer3", Digest: "digest3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer4", Digest: "digest4", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{}, } @@ -381,15 +396,15 @@ func TestUpdateLayers(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Layers: []cloudprotocol.LayerInfo{ { - LayerID: "layer1", Digest: "digest1", Version: "0", + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - LayerID: "layer3", Digest: "digest3", Version: "1.0", + LayerID: "layer3", Digest: "digest3", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - LayerID: "layer4", Digest: "digest4", Version: "1.0", + LayerID: "layer4", Digest: "digest4", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, }, @@ -414,19 +429,19 @@ func TestUpdateLayers(t *testing.T) { softwareUpdater.AllLayers = []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.RemovedStatus, + LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.RemovedStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.RemovedStatus, + LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer3", Digest: "digest3", Version: "1.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer4", Digest: "digest4", Version: "1.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, } @@ -438,13 +453,13 @@ func TestUpdateLayers(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.RemovedStatus}, - {LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.RemovedStatus}, - {LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.RemovedStatus}, - {LayerID: "layer3", Digest: "digest3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer4", Digest: "digest4", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { - LayerID: "layer5", Digest: "digest5", Version: "1.0", Status: cloudprotocol.ErrorStatus, + LayerID: "layer5", Digest: "digest5", Version: "1.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, }, @@ -454,15 +469,15 @@ func TestUpdateLayers(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Layers: []cloudprotocol.LayerInfo{ { - LayerID: "layer3", Digest: "digest3", Version: "1.0", + LayerID: "layer3", Digest: "digest3", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - LayerID: "layer4", Digest: "digest4", Version: "1.0", + LayerID: "layer4", Digest: "digest4", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, { - LayerID: "layer5", Digest: "digest5", Version: "1.0", + LayerID: "layer5", Digest: "digest5", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{5}}, }, }, @@ -484,17 +499,17 @@ func TestUpdateLayers(t *testing.T) { func TestUpdateServices(t *testing.T) { serviceStatuses := []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service1", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service2", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(serviceStatuses, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -527,25 +542,25 @@ func TestUpdateServices(t *testing.T) { Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{ - {ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service2", Status: cloudprotocol.RemovedStatus}, - {ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, } statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Services: []cloudprotocol.ServiceInfo{ { - ServiceID: "service0", Version: "0.0", + ServiceID: "service0", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{0}}, }, { - ServiceID: "service1", Version: "1.0", + ServiceID: "service1", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ServiceID: "service3", Version: "1.0", + ServiceID: "service3", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, }, @@ -572,16 +587,16 @@ func TestUpdateServices(t *testing.T) { softwareUpdater.AllServices = []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service2", Version: "0.0", Status: cloudprotocol.RemovedStatus, + ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }}, } softwareUpdater.UpdateError = aoserrors.New("some error occurs") @@ -592,18 +607,18 @@ func TestUpdateServices(t *testing.T) { Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{ { - ServiceID: "service0", Version: "0.0", Status: cloudprotocol.ErrorStatus, + ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, - {ServiceID: "service1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service2", Status: cloudprotocol.RemovedStatus}, - {ServiceID: "service3", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, + {ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { - ServiceID: "service3", Version: "2.0", Status: cloudprotocol.ErrorStatus, + ServiceID: "service3", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, { - ServiceID: "service4", Version: "2.0", Status: cloudprotocol.ErrorStatus, + ServiceID: "service4", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, }, @@ -612,15 +627,15 @@ func TestUpdateServices(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Services: []cloudprotocol.ServiceInfo{ { - ServiceID: "service1", Version: "1.0", + ServiceID: "service1", Version: "1.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ServiceID: "service3", Version: "2.0", + ServiceID: "service3", Version: "2.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ServiceID: "service4", Version: "2.0", + ServiceID: "service4", Version: "2.0.0", DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, }, @@ -641,7 +656,7 @@ func TestUpdateServices(t *testing.T) { func TestRunInstances(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -661,10 +676,12 @@ func TestRunInstances(t *testing.T) { initialInstancesStatus := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, + ServiceVersion: "1.0.0", }, } @@ -710,19 +727,24 @@ func TestRunInstances(t *testing.T) { updatedInstancesStatus := []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 2}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 2}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj2", Instance: 0}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj2", Instance: 0}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", }, } @@ -757,7 +779,7 @@ func TestRunInstances(t *testing.T) { func TestUpdateInstancesStatus(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -778,13 +800,16 @@ func TestUpdateInstancesStatus(t *testing.T) { if err := statusHandler.ProcessRunStatus( unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, + ServiceVersion: "1.0.0", }, }}); err != nil { t.Fatalf("Can't process run status: %v", err) @@ -798,27 +823,32 @@ func TestUpdateInstancesStatus(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", - RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", + RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, ServiceVersion: "1.0", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, + ServiceVersion: "1.0.0", }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0", - StateChecksum: "newState", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, + ServiceVersion: "1.0.0", + StateChecksum: "newState", }, }, } statusHandler.ProcessUpdateInstanceStatus([]cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0", - RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", + RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0", - StateChecksum: "newState", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, + ServiceVersion: "1.0.0", + StateChecksum: "newState", }, }) @@ -835,37 +865,37 @@ func TestUpdateInstancesStatus(t *testing.T) { func TestUpdateCachedSOTA(t *testing.T) { serviceStatuses := []unitstatushandler.ServiceStatus{ {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service1", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service2", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service4", Version: "0.0", Status: cloudprotocol.InstalledStatus, + ServiceID: "service4", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true}, } layerStatuses := []unitstatushandler.LayerStatus{ {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer4", Digest: "digest4", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer4", Digest: "digest4", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true}, {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer5", Digest: "digest5", Version: "0.0", Status: cloudprotocol.InstalledStatus, + LayerID: "layer5", Digest: "digest5", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, }, Cached: true}, } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( - cloudprotocol.UnitConfigStatus{Version: "1.0", Status: cloudprotocol.InstalledStatus}) + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(serviceStatuses, layerStatuses) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -896,63 +926,63 @@ func TestUpdateCachedSOTA(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {LayerID: "layer0", Digest: "digest0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer1", Digest: "digest1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer2", Digest: "digest2", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer3", Digest: "digest3", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {LayerID: "layer5", Digest: "digest5", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer3", Digest: "digest3", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {LayerID: "layer5", Digest: "digest5", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, }, Services: []cloudprotocol.ServiceStatus{ - {ServiceID: "service0", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service2", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service3", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service4", Version: "0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service3", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ServiceID: "service4", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, }, } statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Services: []cloudprotocol.ServiceInfo{ { - ServiceID: "service0", Version: "0.0", + ServiceID: "service0", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service0"}, Sha256: []byte{0}}, }, { - ServiceID: "service1", Version: "0.0", + ServiceID: "service1", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service1"}, Sha256: []byte{1}}, }, { - ServiceID: "service2", Version: "0.0", + ServiceID: "service2", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service2"}, Sha256: []byte{2}}, }, { - ServiceID: "service3", Version: "0.0", + ServiceID: "service3", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service3"}, Sha256: []byte{3}}, }, { - ServiceID: "service4", Version: "0.0", + ServiceID: "service4", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"service3"}, Sha256: []byte{3}}, }, }, Layers: []cloudprotocol.LayerInfo{ { - LayerID: "layer0", Digest: "digest0", Version: "0.0", + LayerID: "layer0", Digest: "digest0", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer0"}, Sha256: []byte{0}}, }, { - LayerID: "layer1", Digest: "digest1", Version: "0.0", + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer1"}, Sha256: []byte{1}}, }, { - LayerID: "layer2", Digest: "digest2", Version: "0.0", + LayerID: "layer2", Digest: "digest2", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer2"}, Sha256: []byte{2}}, }, { - LayerID: "layer3", Digest: "digest3", Version: "0.0", + LayerID: "layer3", Digest: "digest3", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer3"}, Sha256: []byte{3}}, }, { - LayerID: "layer5", Digest: "digest5", Version: "0.0", + LayerID: "layer5", Digest: "digest5", Version: "0.0.0", DownloadInfo: cloudprotocol.DownloadInfo{URLs: []string{"layer5"}, Sha256: []byte{3}}, }, }, From 88327041e92d090f33e194b91cac39f423526333 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sun, 7 Jul 2024 23:04:26 +0300 Subject: [PATCH 030/146] [unitstatushandler] Use error and ErrorInfo instead of string error Signed-off-by: Oleksandr Grytsov --- unitstatushandler/firmwaremanager.go | 111 ++++---- unitstatushandler/groupdownloader.go | 16 +- unitstatushandler/softwaremanager.go | 244 +++++++++--------- .../unitstatushandler_internal_test.go | 13 +- unitstatushandler/updatestatemachine.go | 20 +- 5 files changed, 199 insertions(+), 205 deletions(-) diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 08e889ba..42a0be93 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -20,9 +20,9 @@ package unitstatushandler import ( "context" "encoding/json" + "errors" "net/url" "reflect" - "strings" "sync" "time" @@ -78,7 +78,7 @@ type firmwareManager struct { CurrentUpdate *firmwareUpdate `json:"currentUpdate,omitempty"` DownloadResult map[string]*downloadResult `json:"downloadResult,omitempty"` CurrentState string `json:"currentState,omitempty"` - UpdateErr string `json:"updateErr,omitempty"` + UpdateErr *cloudprotocol.ErrorInfo `json:"updateErr,omitempty"` TTLDate time.Time `json:"ttlDate,omitempty"` } @@ -141,10 +141,7 @@ func (manager *firmwareManager) close() (err error) { func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTAStatus) { status.State = convertState(manager.CurrentState) - - if manager.UpdateErr != "" { - status.Error = &cloudprotocol.ErrorInfo{Message: manager.UpdateErr} - } + status.Error = manager.UpdateErr if status.State == cmserver.NoUpdate || manager.CurrentUpdate == nil { return status @@ -220,7 +217,7 @@ func (manager *firmwareManager) startUpdate() (err error) { log.Debug("Start firmware update") - if err = manager.stateMachine.sendEvent(eventStartUpdate, ""); err != nil { + if err = manager.stateMachine.sendEvent(eventStartUpdate, nil); err != nil { return aoserrors.Wrap(err) } @@ -264,31 +261,37 @@ func (manager *firmwareManager) getComponentStatuses() (status []cloudprotocol.C * Implementer **********************************************************************************************************************/ -func (manager *firmwareManager) stateChanged(event, state string, updateErr string) { +func (manager *firmwareManager) stateChanged(event, state string, updateErr error) { + var errorInfo *cloudprotocol.ErrorInfo + + if updateErr != nil { + errorInfo = &cloudprotocol.ErrorInfo{Message: updateErr.Error()} + } + if event == eventCancel { for id, status := range manager.ComponentStatuses { if status.Status != cloudprotocol.ErrorStatus { - manager.updateComponentStatusByID(id, cloudprotocol.ErrorStatus, updateErr) + manager.updateComponentStatusByID(id, cloudprotocol.ErrorStatus, errorInfo) } } } manager.CurrentState = state - manager.UpdateErr = updateErr + manager.UpdateErr = errorInfo log.WithFields(log.Fields{ "state": state, "event": event, }).Debug("Firmware manager state changed") - if updateErr != "" { - log.Errorf("Firmware update error: %s", updateErr) + if updateErr != nil { + log.Errorf("Firmware update error: %v", updateErr) } manager.sendCurrentStatus() if err := manager.saveState(); err != nil { - log.Errorf("Can't save current firmware manager state: %s", err) + log.Errorf("Can't save current firmware manager state: %v", err) } } @@ -313,24 +316,24 @@ func (manager *firmwareManager) noUpdate() { if manager.TTLDate, err = manager.stateMachine.startNewUpdate( time.Duration(manager.CurrentUpdate.Schedule.TTL) * time.Second); err != nil { - log.Errorf("Can't start new firmware update: %s", err) + log.Errorf("Can't start new firmware update: %v", err) } }() } } func (manager *firmwareManager) download(ctx context.Context) { - var downloadErr string + var downloadErr error defer func() { go func() { manager.Lock() defer manager.Unlock() - if downloadErr != "" { + if downloadErr != nil { manager.stateMachine.finishOperation(ctx, eventCancel, downloadErr) } else { - manager.stateMachine.finishOperation(ctx, eventFinishDownload, "") + manager.stateMachine.finishOperation(ctx, eventFinishDownload, nil) } }() }() @@ -393,7 +396,7 @@ func (manager *firmwareManager) download(ctx context.Context) { "version": item.Version, }).Debug("Component successfully downloaded") - manager.updateComponentStatusByID(id, cloudprotocol.PendingStatus, "") + manager.updateComponentStatusByID(id, cloudprotocol.PendingStatus, nil) } } @@ -402,7 +405,7 @@ func (manager *firmwareManager) readyToUpdate() { } func (manager *firmwareManager) update(ctx context.Context) { - var updateErr string + var updateErr error defer func() { go func() { @@ -414,9 +417,8 @@ func (manager *firmwareManager) update(ctx context.Context) { }() if len(manager.CurrentUpdate.Components) != 0 { - if err := manager.updateComponents(ctx); err != "" { + if err := manager.updateComponents(ctx); err != nil { updateErr = err - return } } } @@ -426,8 +428,8 @@ func (manager *firmwareManager) updateTimeout() { defer manager.Unlock() if manager.stateMachine.canTransit(eventCancel) { - if err := manager.stateMachine.sendEvent(eventCancel, aoserrors.New("update timeout").Error()); err != nil { - log.Errorf("Can't cancel update: %s", err) + if err := manager.stateMachine.sendEvent(eventCancel, aoserrors.New("update timeout")); err != nil { + log.Errorf("Can't cancel update: %v", err) } } } @@ -488,7 +490,7 @@ func (manager *firmwareManager) newUpdate(update *firmwareUpdate) (err error) { return nil } - if err = manager.stateMachine.sendEvent(eventCancel, aoserrors.Wrap(context.Canceled).Error()); err != nil { + if err = manager.stateMachine.sendEvent(eventCancel, aoserrors.Wrap(context.Canceled)); err != nil { return aoserrors.Wrap(err) } } @@ -496,12 +498,12 @@ func (manager *firmwareManager) newUpdate(update *firmwareUpdate) (err error) { return nil } -func (manager *firmwareManager) updateComponents(ctx context.Context) (componentsErr string) { +func (manager *firmwareManager) updateComponents(ctx context.Context) (componentsErr error) { defer func() { switch { - case strings.Contains(componentsErr, context.Canceled.Error()): + case errors.Is(ctx.Err(), context.Canceled): - case componentsErr == "": + case componentsErr == nil: for _, status := range manager.ComponentStatuses { log.WithFields(log.Fields{ "id": status.ComponentID, @@ -512,14 +514,15 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component default: for id, status := range manager.ComponentStatuses { if status.Status != cloudprotocol.ErrorStatus { - manager.updateComponentStatusByID(id, cloudprotocol.ErrorStatus, - "update aborted due to error: "+componentsErr) + manager.updateComponentStatusByID(id, cloudprotocol.ErrorStatus, &cloudprotocol.ErrorInfo{ + Message: "update aborted due to error: " + componentsErr.Error(), + }) } log.WithFields(log.Fields{ "id": status.ComponentID, "version": status.Version, - }).Errorf("Error updating component: %v", status.ErrorInfo) + }).Errorf("Error updating component: %s", status.ErrorInfo.Message) } } }() @@ -533,13 +536,14 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component log.WithFields(log.Fields{"id": component.ComponentID, "version": component.Version}).Debug("Update component") - manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.InstallingStatus, "") + manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.InstallingStatus, nil) downloadInfo, ok := manager.DownloadResult[*component.ComponentID] if !ok { - err := aoserrors.New("update ID not found").Error() + err := aoserrors.New("update ID not found") - manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.ErrorStatus, err) + manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: err.Error()}) return err } @@ -555,17 +559,15 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component } select { - case errStr := <-manager.asyncUpdate(updateComponents): - return errStr + case err := <-manager.asyncUpdate(updateComponents): + return err case <-ctx.Done(): - errStr := "" - if err := ctx.Err(); err != nil { - errStr = err.Error() + return err } - return errStr + return nil } } @@ -573,7 +575,7 @@ func (manager *firmwareManager) sendCurrentStatus() { manager.statusChannel <- manager.getCurrentStatus() } -func (manager *firmwareManager) updateComponentStatusByID(id, status, componentErr string) { +func (manager *firmwareManager) updateComponentStatusByID(id, status string, componentErr *cloudprotocol.ErrorInfo) { manager.statusMutex.Lock() defer manager.statusMutex.Unlock() @@ -584,10 +586,7 @@ func (manager *firmwareManager) updateComponentStatusByID(id, status, componentE } info.Status = status - - if componentErr != "" { - info.ErrorInfo = &cloudprotocol.ErrorInfo{Message: componentErr} - } + info.ErrorInfo = componentErr manager.statusHandler.updateComponentStatus(*info) } @@ -622,35 +621,33 @@ func (manager *firmwareManager) saveState() (err error) { return nil } -func (manager *firmwareManager) asyncUpdate( - updateComponents []cloudprotocol.ComponentInfo, -) (channel <-chan string) { - finishChannel := make(chan string, 1) +func (manager *firmwareManager) asyncUpdate(updateComponents []cloudprotocol.ComponentInfo) (channel <-chan error) { + finishChannel := make(chan error, 1) - go func() (errorStr string) { - defer func() { finishChannel <- errorStr }() + go func() { + var err error - updateResult, err := manager.firmwareUpdater.UpdateComponents( + updateResult, updateErr := manager.firmwareUpdater.UpdateComponents( updateComponents, manager.CurrentUpdate.CertChains, manager.CurrentUpdate.Certs) - if err != nil { - errorStr = aoserrors.Wrap(err).Error() + if updateErr != nil { + err = aoserrors.Wrap(updateErr) } for id, status := range manager.ComponentStatuses { for _, item := range updateResult { if item.ComponentID == status.ComponentID && item.Version == status.Version { - if errorStr == "" { + if err == nil { if item.ErrorInfo != nil { - errorStr = item.ErrorInfo.Message + err = aoserrors.New(item.ErrorInfo.Message) } } - manager.updateComponentStatusByID(id, item.Status, errorStr) + manager.updateComponentStatusByID(id, item.Status, item.ErrorInfo) } } } - return errorStr + finishChannel <- err }() return finishChannel diff --git a/unitstatushandler/groupdownloader.go b/unitstatushandler/groupdownloader.go index fd824041..2694d28f 100644 --- a/unitstatushandler/groupdownloader.go +++ b/unitstatushandler/groupdownloader.go @@ -37,7 +37,7 @@ type downloadResult struct { Error string `json:"error"` } -type statusNotifier func(id string, status string, componentErr string) +type statusNotifier func(id string, status string, componentErr *cloudprotocol.ErrorInfo) type groupDownloader struct { Downloader @@ -59,7 +59,7 @@ func (downloader *groupDownloader) download(ctx context.Context, request map[str for id := range request { result[id] = &downloadResult{} - updateStatus(id, cloudprotocol.DownloadingStatus, "") + updateStatus(id, cloudprotocol.DownloadingStatus, nil) } downloadCtx, cancelFunc := context.WithCancel(ctx) @@ -70,7 +70,7 @@ func (downloader *groupDownloader) download(ctx context.Context, request map[str handleError := func(id string, err error) { if errorStr := aoserrors.Wrap(err).Error(); !isCancelError(errorStr) { result[id].Error = errorStr - updateStatus(id, cloudprotocol.ErrorStatus, errorStr) + updateStatus(id, cloudprotocol.ErrorStatus, &cloudprotocol.ErrorInfo{Message: errorStr}) } if !continueOnError { @@ -102,7 +102,7 @@ func (downloader *groupDownloader) download(ctx context.Context, request map[str return } - updateStatus(id, cloudprotocol.DownloadedStatus, "") + updateStatus(id, cloudprotocol.DownloadedStatus, nil) }(id) } @@ -115,7 +115,7 @@ func (downloader *groupDownloader) download(ctx context.Context, request map[str for id, item := range result { if item.Error == "" { item.Error = aoserrors.Wrap(downloadCtx.Err()).Error() - updateStatus(id, cloudprotocol.ErrorStatus, item.Error) + updateStatus(id, cloudprotocol.ErrorStatus, &cloudprotocol.ErrorInfo{Message: item.Error}) } } } @@ -143,14 +143,14 @@ func (downloader *groupDownloader) releaseDownloadedSoftware() error { return nil } -func getDownloadError(result map[string]*downloadResult) (downloadErr string) { +func getDownloadError(result map[string]*downloadResult) error { for _, item := range result { if item.Error != "" && !isCancelError(item.Error) { - return item.Error + return aoserrors.New(item.Error) } } - return "" + return nil } func isCancelError(errString string) (result bool) { diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index fbae2658..0f1d9155 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -99,7 +99,7 @@ type softwareManager struct { CurrentUpdate *softwareUpdate `json:"currentUpdate,omitempty"` DownloadResult map[string]*downloadResult `json:"downloadResult,omitempty"` CurrentState string `json:"currentState,omitempty"` - UpdateErr string `json:"updateErr,omitempty"` + UpdateErr *cloudprotocol.ErrorInfo `json:"updateErr,omitempty"` TTLDate time.Time `json:"ttlDate,omitempty"` } @@ -171,9 +171,7 @@ func (manager *softwareManager) close() (err error) { func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTAStatus) { status.State = convertState(manager.CurrentState) - if manager.UpdateErr != "" { - status.Error = &cloudprotocol.ErrorInfo{Message: manager.UpdateErr} - } + status.Error = manager.UpdateErr if status.State == cmserver.NoUpdate || manager.CurrentUpdate == nil { return status @@ -217,18 +215,12 @@ func (manager *softwareManager) processRunStatus(status RunInstancesStatus) { manager.InstanceStatuses = status.Instances for _, errStatus := range status.ErrorServices { - var errMsg string - - if errStatus.ErrorInfo != nil { - errMsg = errStatus.ErrorInfo.Message - } - if _, ok := manager.ServiceStatuses[errStatus.ServiceID]; !ok { status := errStatus manager.ServiceStatuses[errStatus.ServiceID] = &status } - manager.updateServiceStatusByID(errStatus.ServiceID, errStatus.Status, errMsg) + manager.updateServiceStatusByID(errStatus.ServiceID, errStatus.Status, errStatus.ErrorInfo) } manager.runCond.Broadcast() @@ -398,7 +390,7 @@ func (manager *softwareManager) startUpdate() (err error) { log.Debug("Start software update") - if err = manager.stateMachine.sendEvent(eventStartUpdate, ""); err != nil { + if err = manager.stateMachine.sendEvent(eventStartUpdate, nil); err != nil { return aoserrors.Wrap(err) } @@ -486,43 +478,49 @@ func (manager *softwareManager) getUnitConfigStatuses() (status []cloudprotocol. * Implementer **********************************************************************************************************************/ -func (manager *softwareManager) stateChanged(event, state string, updateErr string) { +func (manager *softwareManager) stateChanged(event, state string, updateErr error) { + var errorInfo *cloudprotocol.ErrorInfo + + if updateErr != nil { + errorInfo = &cloudprotocol.ErrorInfo{Message: updateErr.Error()} + } + if event == eventCancel { for id, status := range manager.LayerStatuses { if status.Status != cloudprotocol.ErrorStatus { - manager.updateLayerStatusByID(id, cloudprotocol.ErrorStatus, updateErr) + manager.updateLayerStatusByID(id, cloudprotocol.ErrorStatus, errorInfo) } } for id, status := range manager.ServiceStatuses { if status.Status != cloudprotocol.ErrorStatus { - manager.updateServiceStatusByID(id, cloudprotocol.ErrorStatus, updateErr) + manager.updateServiceStatusByID(id, cloudprotocol.ErrorStatus, errorInfo) } } if manager.CurrentUpdate.UnitConfig != nil { if manager.UnitConfigStatus.Status != cloudprotocol.ErrorStatus { - manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, updateErr) + manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, errorInfo) } } } manager.CurrentState = state - manager.UpdateErr = updateErr + manager.UpdateErr = errorInfo log.WithFields(log.Fields{ "state": state, "event": event, }).Debug("Software manager state changed") - if updateErr != "" { - log.Errorf("Software update error: %s", updateErr) + if updateErr != nil { + log.Errorf("Software update error: %v", updateErr) } manager.sendCurrentStatus() if err := manager.saveState(); err != nil { - log.Errorf("Can't save current software manager state: %s", err) + log.Errorf("Can't save current software manager state: %v", err) } } @@ -547,7 +545,7 @@ func (manager *softwareManager) noUpdate() { if manager.TTLDate, err = manager.stateMachine.startNewUpdate( time.Duration(manager.CurrentUpdate.Schedule.TTL) * time.Second); err != nil { - log.Errorf("Can't start new software update: %s", err) + log.Errorf("Can't start new software update: %v", err) } }() } @@ -555,7 +553,7 @@ func (manager *softwareManager) noUpdate() { func (manager *softwareManager) download(ctx context.Context) { var ( - downloadErr string + downloadErr error finishEvent = eventFinishDownload ) @@ -572,7 +570,7 @@ func (manager *softwareManager) download(ctx context.Context) { if manager.CurrentUpdate.UnitConfig != nil { manager.UnitConfigStatus.Version = manager.CurrentUpdate.UnitConfig.Version - manager.updateUnitConfigStatus(cloudprotocol.PendingStatus, "") + manager.updateUnitConfigStatus(cloudprotocol.PendingStatus, nil) } request := manager.prepareDownloadRequest() @@ -593,7 +591,7 @@ func (manager *softwareManager) download(ctx context.Context) { "id": layerStatus.LayerID, "digest": layerStatus.Digest, "version": layerStatus.Version, - }).Errorf("Error downloading layer: %v", layerStatus.ErrorInfo) + }).Errorf("Error downloading layer: %s", layerStatus.ErrorInfo.Message) continue } @@ -604,13 +602,13 @@ func (manager *softwareManager) download(ctx context.Context) { "version": layerStatus.Version, }).Debug("Layer successfully downloaded") - manager.updateLayerStatusByID(id, cloudprotocol.PendingStatus, "") + manager.updateLayerStatusByID(id, cloudprotocol.PendingStatus, nil) } else if serviceStatus, ok := manager.ServiceStatuses[id]; ok { if serviceStatus.Status == cloudprotocol.ErrorStatus { log.WithFields(log.Fields{ "id": serviceStatus.ServiceID, "version": serviceStatus.Version, - }).Errorf("Error downloading service: %v", serviceStatus.ErrorInfo) + }).Errorf("Error downloading service: %s", serviceStatus.ErrorInfo.Message) continue } @@ -620,7 +618,7 @@ func (manager *softwareManager) download(ctx context.Context) { "version": serviceStatus.Version, }).Debug("Service successfully downloaded") - manager.updateServiceStatusByID(id, cloudprotocol.PendingStatus, "") + manager.updateServiceStatusByID(id, cloudprotocol.PendingStatus, nil) } } @@ -705,7 +703,7 @@ func (manager *softwareManager) update(ctx context.Context) { manager.Lock() defer manager.Unlock() - var updateErr string + var updateErr error if manager.LayerStatuses == nil { manager.LayerStatuses = make(map[string]*cloudprotocol.LayerStatus) @@ -725,38 +723,38 @@ func (manager *softwareManager) update(ctx context.Context) { }() if manager.CurrentUpdate.UnitConfig != nil { - if err := manager.updateUnitConfig(ctx); err != "" { + if err := manager.updateUnitConfig(ctx); err != nil { updateErr = err } } - if errorStr := manager.removeServices(); errorStr != "" && updateErr == "" { - updateErr = errorStr + if err := manager.removeServices(); err != nil && updateErr == nil { + updateErr = err } - if errorStr := manager.installLayers(); errorStr != "" && updateErr == "" { - updateErr = errorStr + if err := manager.installLayers(); err != nil && updateErr == nil { + updateErr = err } - if errorStr := manager.restoreServices(); errorStr != "" && updateErr == "" { - updateErr = errorStr + if err := manager.restoreServices(); err != nil && updateErr == nil { + updateErr = err } - newServices, errorStr := manager.installServices() - if errorStr != "" && updateErr == "" { - updateErr = errorStr + newServices, err := manager.installServices() + if err != nil && updateErr == nil { + updateErr = err } - if errorStr := manager.removeLayers(); errorStr != "" && updateErr == "" { - updateErr = errorStr + if err := manager.removeLayers(); err != nil && updateErr == nil { + updateErr = err } - if errorStr := manager.restoreLayers(); errorStr != "" && updateErr == "" { - updateErr = errorStr + if err := manager.restoreLayers(); err != nil && updateErr == nil { + updateErr = err } - if errorStr := manager.runInstances(newServices); errorStr != "" && updateErr == "" { - updateErr = errorStr + if err := manager.runInstances(newServices); err != nil && updateErr == nil { + updateErr = err } manager.runCond.Wait() @@ -767,7 +765,7 @@ func (manager *softwareManager) updateTimeout() { defer manager.Unlock() if manager.stateMachine.canTransit(eventCancel) { - if err := manager.stateMachine.sendEvent(eventCancel, aoserrors.New("update timeout").Error()); err != nil { + if err := manager.stateMachine.sendEvent(eventCancel, aoserrors.New("update timeout")); err != nil { log.Errorf("Can't cancel update: %s", err) } } @@ -840,7 +838,7 @@ func (manager *softwareManager) newUpdate(update *softwareUpdate) (err error) { return nil } - if err = manager.stateMachine.sendEvent(eventCancel, ""); err != nil { + if err = manager.stateMachine.sendEvent(eventCancel, nil); err != nil { return aoserrors.Wrap(err) } } @@ -852,17 +850,17 @@ func (manager *softwareManager) sendCurrentStatus() { manager.statusChannel <- manager.getCurrentStatus() } -func (manager *softwareManager) updateStatusByID(id string, status string, errorStr string) { +func (manager *softwareManager) updateStatusByID(id string, status string, errorInfo *cloudprotocol.ErrorInfo) { if _, ok := manager.LayerStatuses[id]; ok { - manager.updateLayerStatusByID(id, status, errorStr) + manager.updateLayerStatusByID(id, status, errorInfo) } else if _, ok := manager.ServiceStatuses[id]; ok { - manager.updateServiceStatusByID(id, status, errorStr) + manager.updateServiceStatusByID(id, status, errorInfo) } else { log.Errorf("Software update ID not found: %s", id) } } -func (manager *softwareManager) updateLayerStatusByID(id, status, layerErr string) { +func (manager *softwareManager) updateLayerStatusByID(id, status string, layerErr *cloudprotocol.ErrorInfo) { manager.statusMutex.Lock() defer manager.statusMutex.Unlock() @@ -873,15 +871,12 @@ func (manager *softwareManager) updateLayerStatusByID(id, status, layerErr strin } info.Status = status - - if layerErr != "" { - info.ErrorInfo = &cloudprotocol.ErrorInfo{Message: layerErr} - } + info.ErrorInfo = layerErr manager.statusHandler.updateLayerStatus(*info) } -func (manager *softwareManager) updateServiceStatusByID(id, status, serviceErr string) { +func (manager *softwareManager) updateServiceStatusByID(id, status string, serviceErr *cloudprotocol.ErrorInfo) { manager.statusMutex.Lock() defer manager.statusMutex.Unlock() @@ -892,10 +887,7 @@ func (manager *softwareManager) updateServiceStatusByID(id, status, serviceErr s } info.Status = status - - if serviceErr != "" { - info.ErrorInfo = &cloudprotocol.ErrorInfo{Message: serviceErr} - } + info.ErrorInfo = serviceErr manager.statusHandler.updateServiceStatus(*info) } @@ -930,26 +922,27 @@ func (manager *softwareManager) saveState() (err error) { return nil } -func (manager *softwareManager) installLayers() (installErr string) { +func (manager *softwareManager) installLayers() (installErr error) { var mutex sync.Mutex - handleError := func(layer cloudprotocol.LayerInfo, layerErr string) { + handleError := func(layer cloudprotocol.LayerInfo, layerErr error) { log.WithFields(log.Fields{ "digest": layer.Digest, "id": layer.LayerID, "version": layer.Version, }).Errorf("Can't install layer: %s", layerErr) - if isCancelError(layerErr) { + if errors.Is(layerErr, context.Canceled) { return } - manager.updateLayerStatusByID(layer.Digest, cloudprotocol.ErrorStatus, layerErr) + manager.updateLayerStatusByID(layer.Digest, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: layerErr.Error()}) mutex.Lock() defer mutex.Unlock() - if installErr == "" { + if installErr == nil { installErr = layerErr } } @@ -959,7 +952,7 @@ func (manager *softwareManager) installLayers() (installErr string) { for _, layer := range manager.CurrentUpdate.InstallLayers { downloadInfo, ok := manager.DownloadResult[layer.Digest] if !ok { - handleError(layer, aoserrors.New("can't get download result").Error()) + handleError(layer, aoserrors.New("can't get download result")) continue } @@ -985,7 +978,7 @@ func (manager *softwareManager) installLayers() (installErr string) { "digest": layer.Digest, }).Debug("Install layer") - manager.updateLayerStatusByID(layer.Digest, cloudprotocol.InstallingStatus, "") + manager.updateLayerStatusByID(layer.Digest, cloudprotocol.InstallingStatus, nil) // Create new variable to be captured by action function layerInfo := layer @@ -993,7 +986,7 @@ func (manager *softwareManager) installLayers() (installErr string) { manager.actionHandler.Execute(layerInfo.Digest, func(digest string) error { if err := manager.softwareUpdater.InstallLayer(layerInfo, manager.CurrentUpdate.CertChains, manager.CurrentUpdate.Certs); err != nil { - handleError(layerInfo, aoserrors.Wrap(err).Error()) + handleError(layerInfo, aoserrors.Wrap(err)) return aoserrors.Wrap(err) } @@ -1003,7 +996,7 @@ func (manager *softwareManager) installLayers() (installErr string) { "digest": layerInfo.Digest, }).Info("Layer successfully installed") - manager.updateLayerStatusByID(layerInfo.Digest, cloudprotocol.InstalledStatus, "") + manager.updateLayerStatusByID(layerInfo.Digest, cloudprotocol.InstalledStatus, nil) return nil }) @@ -1014,38 +1007,39 @@ func (manager *softwareManager) installLayers() (installErr string) { return installErr } -func (manager *softwareManager) removeLayers() (removeErr string) { +func (manager *softwareManager) removeLayers() (removeErr error) { return manager.processRemoveRestoreLayers( manager.CurrentUpdate.RemoveLayers, "remove", cloudprotocol.RemovedStatus, manager.softwareUpdater.RemoveLayer) } -func (manager *softwareManager) restoreLayers() (restoreErr string) { +func (manager *softwareManager) restoreLayers() (restoreErr error) { return manager.processRemoveRestoreLayers( manager.CurrentUpdate.RestoreLayers, "restore", cloudprotocol.InstalledStatus, manager.softwareUpdater.RestoreLayer) } func (manager *softwareManager) processRemoveRestoreLayers( layers []cloudprotocol.LayerStatus, operationStr, successStatus string, operation func(digest string) error, -) (processError string) { +) (processError error) { var mutex sync.Mutex - handleError := func(layer cloudprotocol.LayerStatus, layerErr string) { + handleError := func(layer cloudprotocol.LayerStatus, layerErr error) { log.WithFields(log.Fields{ "digest": layer.Digest, "id": layer.LayerID, "aosVersion": layer.Version, }).Errorf("Can't %s layer: %s", operationStr, layerErr) - if isCancelError(layerErr) { + if errors.Is(layerErr, context.Canceled) { return } - manager.updateLayerStatusByID(layer.Digest, cloudprotocol.ErrorStatus, layerErr) + manager.updateLayerStatusByID(layer.Digest, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: layerErr.Error()}) mutex.Lock() defer mutex.Unlock() - if processError == "" { + if processError == nil { processError = layerErr } } @@ -1070,7 +1064,7 @@ func (manager *softwareManager) processRemoveRestoreLayers( manager.actionHandler.Execute(layerInfo.Digest, func(digest string) error { if err := operation(layerInfo.Digest); err != nil { - handleError(layerInfo, aoserrors.Wrap(err).Error()) + handleError(layerInfo, aoserrors.Wrap(err)) return aoserrors.Wrap(err) } @@ -1080,7 +1074,7 @@ func (manager *softwareManager) processRemoveRestoreLayers( "digest": layerInfo.Digest, }).Infof("Layer successfully %sd", operationStr) - manager.updateLayerStatusByID(layerInfo.Digest, successStatus, "") + manager.updateLayerStatusByID(layerInfo.Digest, successStatus, nil) return nil }) @@ -1088,28 +1082,29 @@ func (manager *softwareManager) processRemoveRestoreLayers( manager.actionHandler.Wait() - return "" + return nil } -func (manager *softwareManager) installServices() (newServices []string, installErr string) { +func (manager *softwareManager) installServices() (newServices []string, installErr error) { var mutex sync.Mutex - handleError := func(service cloudprotocol.ServiceInfo, serviceErr string) { + handleError := func(service cloudprotocol.ServiceInfo, serviceErr error) { log.WithFields(log.Fields{ "id": service.ServiceID, "version": service.Version, }).Errorf("Can't install service: %s", serviceErr) - if isCancelError(serviceErr) { + if errors.Is(serviceErr, context.Canceled) { return } - manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, serviceErr) + manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: serviceErr.Error()}) mutex.Lock() defer mutex.Unlock() - if installErr == "" { + if installErr == nil { installErr = serviceErr } } @@ -1119,7 +1114,7 @@ func (manager *softwareManager) installServices() (newServices []string, install for _, service := range manager.CurrentUpdate.InstallServices { downloadInfo, ok := manager.DownloadResult[service.ServiceID] if !ok { - handleError(service, aoserrors.New("can't get download result").Error()) + handleError(service, aoserrors.New("can't get download result")) continue } @@ -1144,7 +1139,7 @@ func (manager *softwareManager) installServices() (newServices []string, install "version": service.Version, }).Debug("Install service") - manager.updateServiceStatusByID(service.ServiceID, cloudprotocol.InstallingStatus, "") + manager.updateServiceStatusByID(service.ServiceID, cloudprotocol.InstallingStatus, nil) // Create new variable to be captured by action function serviceInfo := service @@ -1153,7 +1148,7 @@ func (manager *softwareManager) installServices() (newServices []string, install err := manager.softwareUpdater.InstallService(serviceInfo, manager.CurrentUpdate.CertChains, manager.CurrentUpdate.Certs) if err != nil { - handleError(serviceInfo, aoserrors.Wrap(err).Error()) + handleError(serviceInfo, aoserrors.Wrap(err)) return aoserrors.Wrap(err) } @@ -1164,7 +1159,7 @@ func (manager *softwareManager) installServices() (newServices []string, install newServices = append(newServices, serviceInfo.ServiceID) - manager.updateServiceStatusByID(serviceInfo.ServiceID, cloudprotocol.InstalledStatus, "") + manager.updateServiceStatusByID(serviceInfo.ServiceID, cloudprotocol.InstalledStatus, nil) return nil }) @@ -1175,25 +1170,26 @@ func (manager *softwareManager) installServices() (newServices []string, install return newServices, installErr } -func (manager *softwareManager) restoreServices() (restoreErr string) { +func (manager *softwareManager) restoreServices() (restoreErr error) { var mutex sync.Mutex - handleError := func(service cloudprotocol.ServiceInfo, serviceErr string) { + handleError := func(service cloudprotocol.ServiceInfo, serviceErr error) { log.WithFields(log.Fields{ "id": service.ServiceID, "aosVersion": service.Version, - }).Errorf("Can't restore service: %s", serviceErr) + }).Errorf("Can't restore service: %v", serviceErr) - if isCancelError(serviceErr) { + if errors.Is(serviceErr, context.Canceled) { return } - manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, serviceErr) + manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: serviceErr.Error()}) mutex.Lock() defer mutex.Unlock() - if restoreErr == "" { + if restoreErr == nil { restoreErr = serviceErr } } @@ -1215,8 +1211,7 @@ func (manager *softwareManager) restoreServices() (restoreErr string) { manager.actionHandler.Execute(serviceInfo.ServiceID, func(serviceID string) error { if err := manager.softwareUpdater.RestoreService(serviceInfo.ServiceID); err != nil { - handleError(serviceInfo, aoserrors.Wrap(err).Error()) - + handleError(serviceInfo, aoserrors.Wrap(err)) return aoserrors.Wrap(err) } @@ -1225,7 +1220,7 @@ func (manager *softwareManager) restoreServices() (restoreErr string) { "version": serviceInfo.Version, }).Info("Service successfully restored") - manager.updateServiceStatusByID(serviceInfo.ServiceID, cloudprotocol.InstalledStatus, "") + manager.updateServiceStatusByID(serviceInfo.ServiceID, cloudprotocol.InstalledStatus, nil) return nil }) @@ -1236,25 +1231,26 @@ func (manager *softwareManager) restoreServices() (restoreErr string) { return restoreErr } -func (manager *softwareManager) removeServices() (removeErr string) { +func (manager *softwareManager) removeServices() (removeErr error) { var mutex sync.Mutex - handleError := func(service cloudprotocol.ServiceStatus, serviceErr string) { + handleError := func(service cloudprotocol.ServiceStatus, serviceErr error) { log.WithFields(log.Fields{ "id": service.ServiceID, "version": service.Version, - }).Errorf("Can't install service: %s", serviceErr) + }).Errorf("Can't install service: %v", serviceErr) - if isCancelError(serviceErr) { + if errors.Is(serviceErr, context.Canceled) { return } - manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, serviceErr) + manager.updateStatusByID(service.ServiceID, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: serviceErr.Error()}) mutex.Lock() defer mutex.Unlock() - if removeErr == "" { + if removeErr == nil { removeErr = serviceErr } } @@ -1274,15 +1270,17 @@ func (manager *softwareManager) removeServices() (removeErr string) { } manager.statusMutex.Unlock() - manager.updateServiceStatusByID(service.ServiceID, cloudprotocol.RemovingStatus, "") + manager.updateServiceStatusByID(service.ServiceID, cloudprotocol.RemovingStatus, nil) // Create new variable to be captured by action function serviceStatus := service manager.actionHandler.Execute(serviceStatus.ServiceID, func(serviceID string) error { if err := manager.softwareUpdater.RemoveService(serviceStatus.ServiceID); err != nil { - handleError(serviceStatus, err.Error()) - return aoserrors.Wrap(err) + err = aoserrors.Wrap(err) + handleError(serviceStatus, err) + + return err } log.WithFields(log.Fields{ @@ -1290,7 +1288,7 @@ func (manager *softwareManager) removeServices() (removeErr string) { "aosVersion": serviceStatus.Version, }).Info("Service successfully removed") - manager.updateServiceStatusByID(serviceStatus.ServiceID, cloudprotocol.RemovedStatus, "") + manager.updateServiceStatusByID(serviceStatus.ServiceID, cloudprotocol.RemovedStatus, nil) return nil }) @@ -1301,7 +1299,7 @@ func (manager *softwareManager) removeServices() (removeErr string) { return removeErr } -func (manager *softwareManager) runInstances(newServices []string) (runErr string) { +func (manager *softwareManager) runInstances(newServices []string) (runErr error) { manager.InstanceStatuses = []cloudprotocol.InstanceStatus{} for _, instance := range manager.CurrentUpdate.RunInstances { @@ -1333,18 +1331,19 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr strin manager.statusHandler.setInstanceStatus(manager.InstanceStatuses) if err := manager.instanceRunner.RunInstances(manager.CurrentUpdate.RunInstances, newServices); err != nil { - return err.Error() + return aoserrors.Wrap(err) } - return "" + return nil } -func (manager *softwareManager) updateUnitConfig(ctx context.Context) (unitConfigErr string) { +func (manager *softwareManager) updateUnitConfig(ctx context.Context) (unitConfigErr error) { log.Debug("Update unit config") defer func() { - if unitConfigErr != "" { - manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, unitConfigErr) + if unitConfigErr != nil { + manager.updateUnitConfigStatus(cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: unitConfigErr.Error()}) } }() @@ -1352,34 +1351,31 @@ func (manager *softwareManager) updateUnitConfig(ctx context.Context) (unitConfi if errors.Is(err, unitconfig.ErrAlreadyInstalled) { log.Error("Unit config already installed") - manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, "") + manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, nil) - return "" + return nil } - return aoserrors.Wrap(err).Error() + return aoserrors.Wrap(err) } - manager.updateUnitConfigStatus(cloudprotocol.InstallingStatus, "") + manager.updateUnitConfigStatus(cloudprotocol.InstallingStatus, nil) if err := manager.unitConfigUpdater.UpdateUnitConfig(*manager.CurrentUpdate.UnitConfig); err != nil { - return aoserrors.Wrap(err).Error() + return aoserrors.Wrap(err) } - manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, "") + manager.updateUnitConfigStatus(cloudprotocol.InstalledStatus, nil) - return "" + return nil } -func (manager *softwareManager) updateUnitConfigStatus(status, errorStr string) { +func (manager *softwareManager) updateUnitConfigStatus(status string, errorInfo *cloudprotocol.ErrorInfo) { manager.statusMutex.Lock() defer manager.statusMutex.Unlock() manager.UnitConfigStatus.Status = status - - if errorStr != "" { - manager.UnitConfigStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: errorStr} - } + manager.UnitConfigStatus.ErrorInfo = errorInfo manager.statusHandler.updateUnitConfigStatus(manager.UnitConfigStatus) } diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index e32b88cf..909329da 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -223,7 +223,7 @@ func TestGroupDownloader(t *testing.T) { } result := testGroupDownloader.download(ctx, item.request, item.continueOnError, - func(id string, status string, componentErr string) { + func(id string, status string, componentErr *cloudprotocol.ErrorInfo) { log.WithFields(log.Fields{ "id": id, "status": status, "error": componentErr, }).Debug("Component download status") @@ -1648,12 +1648,12 @@ func (downloader *testGroupDownloader) download( ctx context.Context, request map[string]downloader.PackageInfo, continueOnError bool, updateStatus statusNotifier, ) (result map[string]*downloadResult) { for id := range request { - updateStatus(id, cloudprotocol.DownloadingStatus, "") + updateStatus(id, cloudprotocol.DownloadingStatus, nil) } select { case <-time.After(downloader.downloadTime): - if getDownloadError(downloader.result) != "" && !continueOnError { + if getDownloadError(downloader.result) != nil && !continueOnError { for id := range request { if downloader.result[id].Error == "" { downloader.result[id].Error = aoserrors.Wrap(context.Canceled).Error() @@ -1667,9 +1667,10 @@ func (downloader *testGroupDownloader) download( } if downloader.result[id].Error != "" { - updateStatus(id, cloudprotocol.ErrorStatus, downloader.result[id].Error) + updateStatus(id, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: downloader.result[id].Error}) } else { - updateStatus(id, cloudprotocol.DownloadedStatus, "") + updateStatus(id, cloudprotocol.DownloadedStatus, nil) } } @@ -1678,7 +1679,7 @@ func (downloader *testGroupDownloader) download( case <-ctx.Done(): for id := range request { downloader.result[id].Error = aoserrors.Wrap(context.Canceled).Error() - updateStatus(id, cloudprotocol.ErrorStatus, downloader.result[id].Error) + updateStatus(id, cloudprotocol.ErrorStatus, &cloudprotocol.ErrorInfo{Message: downloader.result[id].Error}) } return result diff --git a/unitstatushandler/updatestatemachine.go b/unitstatushandler/updatestatemachine.go index 3f3e27ef..94dd48c5 100644 --- a/unitstatushandler/updatestatemachine.go +++ b/unitstatushandler/updatestatemachine.go @@ -68,7 +68,7 @@ type updateStateMachine struct { } type updateManager interface { - stateChanged(event, state, updateErr string) + stateChanged(event, state string, updateErr error) download(ctx context.Context) readyToUpdate() update(ctx context.Context) @@ -145,13 +145,13 @@ func (stateMachine *updateStateMachine) canTransit(event string) (result bool) { return stateMachine.fsm.Can(event) } -func (stateMachine *updateStateMachine) sendEvent(event string, managerErr string) (err error) { +func (stateMachine *updateStateMachine) sendEvent(event string, managerErr error) (err error) { if stateMachine.canTransit(event) { stateMachine.cancel() } if err = stateMachine.fsm.Event(context.Background(), event, managerErr); err != nil { - log.Errorf("Can't send event: %s", err) + log.Errorf("Can't send event: %v", err) return aoserrors.Wrap(err) } @@ -180,19 +180,19 @@ func (stateMachine *updateStateMachine) scheduleUpdate(schedule cloudprotocol.Sc stateMachine.updateTimer = time.AfterFunc(updateTime, func() { if err := stateMachine.manager.startUpdate(); err != nil { - log.Errorf("Can't start update: %s", err) + log.Errorf("Can't start update: %v", err) } }) } -func (stateMachine *updateStateMachine) finishOperation(ctx context.Context, finishEvent string, operationErr string) { +func (stateMachine *updateStateMachine) finishOperation(ctx context.Context, finishEvent string, operationErr error) { // Do nothing if context canceled if ctx.Err() != nil { return } if err := stateMachine.sendEvent(finishEvent, operationErr); err != nil { - log.Errorf("Can't send finish event: %s", err) + log.Errorf("Can't send finish event: %v", err) } } @@ -207,7 +207,7 @@ func (stateMachine *updateStateMachine) startNewUpdate(ttlTime time.Duration) (t stateMachine.setTTLTimer(ttlTime) } - if err = stateMachine.sendEvent(eventStartDownload, ""); err != nil { + if err = stateMachine.sendEvent(eventStartDownload, nil); err != nil { return ttlDate, aoserrors.Wrap(err) } @@ -249,11 +249,11 @@ func (stateMachine *updateStateMachine) cancel() { } func (stateMachine *updateStateMachine) onBeforeEvent(ctx context.Context, event *fsm.Event) { - var managerErr string + var managerErr error if len(event.Args) != 0 { - if errorStr, ok := event.Args[0].(string); ok { - managerErr = errorStr + if err, ok := event.Args[0].(error); ok { + managerErr = err } } From a9704ad7cfe227975a8d390b8180c17b1fcf7745 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 8 Jul 2024 11:05:25 +0300 Subject: [PATCH 031/146] [unitconfig] Update to new cloud and protobuf protocols Signed-off-by: Oleksandr Grytsov --- unitconfig/unitconfig.go | 78 ++++++++++++++++++----------------- unitconfig/unitconfig_test.go | 69 ++++++++++++++----------------- 2 files changed, 71 insertions(+), 76 deletions(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 9b0a1227..34cd1136 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -24,6 +24,7 @@ import ( "sync" "github.com/aosedge/aos_common/aoserrors" + semver "github.com/hashicorp/go-version" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_communicationmanager/config" @@ -63,7 +64,9 @@ func New(cfg *config.Config, client Client) (instance *Instance, err error) { unitConfigFile: cfg.UnitConfigFile, } - _ = instance.load() + if err := instance.load(); err != nil { + instance.unitConfigError = err + } return instance, nil } @@ -84,36 +87,30 @@ func (instance *Instance) GetStatus() (unitConfigInfo cloudprotocol.UnitConfigSt return unitConfigInfo, nil } -// GetUnitConfigVersion returns unit config version. -func (instance *Instance) GetUnitConfigVersion(configJSON json.RawMessage) (vendorVersion string, err error) { - unitConfig := cloudprotocol.UnitConfig{Version: "unknown"} - - if err = json.Unmarshal(configJSON, &unitConfig); err != nil { - return unitConfig.Version, aoserrors.Wrap(err) - } - - return unitConfig.Version, nil -} - // CheckUnitConfig checks unit config. -func (instance *Instance) CheckUnitConfig(configJSON json.RawMessage) (vendorVersion string, err error) { +func (instance *Instance) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) error { instance.Lock() defer instance.Unlock() - unitConfig := cloudprotocol.UnitConfig{Version: "unknown"} - - if err = json.Unmarshal(configJSON, &unitConfig); err != nil { - return unitConfig.Version, aoserrors.Wrap(err) + if err := instance.checkVersion(unitConfig.Version); err != nil { + return err } - if vendorVersion, err = instance.checkUnitConfig(unitConfig); err != nil { - return vendorVersion, aoserrors.Wrap(err) + if err := instance.client.CheckUnitConfig(unitConfig); err != nil { + return aoserrors.Wrap(err) } - return vendorVersion, nil + return nil } -func (instance *Instance) GetUnitConfiguration(nodeType string) cloudprotocol.NodeConfig { +// GetUnitConfig returns unit config for node or node type. +func (instance *Instance) GetUnitConfig(nodeID, nodeType string) cloudprotocol.NodeConfig { + for _, node := range instance.unitConfig.Nodes { + if node.NodeID != nil && *node.NodeID == nodeID { + return node + } + } + for _, node := range instance.unitConfig.Nodes { if node.NodeType == nodeType { return node @@ -124,18 +121,12 @@ func (instance *Instance) GetUnitConfiguration(nodeType string) cloudprotocol.No } // UpdateUnitConfig updates unit config. -func (instance *Instance) UpdateUnitConfig(configJSON json.RawMessage) (err error) { +func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) { instance.Lock() defer instance.Unlock() - unitConfig := cloudprotocol.UnitConfig{Version: "unknown"} - - if err = json.Unmarshal(configJSON, &unitConfig); err != nil { - return aoserrors.Wrap(err) - } - - if unitConfig.Version == instance.unitConfig.Version { - return aoserrors.New("invalid vendor version") + if err := instance.checkVersion(unitConfig.Version); err != nil { + return err } instance.unitConfig = unitConfig @@ -144,11 +135,12 @@ func (instance *Instance) UpdateUnitConfig(configJSON json.RawMessage) (err erro return aoserrors.Wrap(err) } - if err = os.WriteFile(instance.unitConfigFile, configJSON, 0o600); err != nil { + configJSON, err := json.Marshal(instance.unitConfig) + if err != nil { return aoserrors.Wrap(err) } - if err = instance.load(); err != nil { + if err = os.WriteFile(instance.unitConfigFile, configJSON, 0o600); err != nil { return aoserrors.Wrap(err) } @@ -176,14 +168,24 @@ func (instance *Instance) load() (err error) { return nil } -func (instance *Instance) checkUnitConfig(unitConfig cloudprotocol.UnitConfig) (vendorVersion string, err error) { - if unitConfig.Version == instance.unitConfig.Version { - return unitConfig.Version, ErrAlreadyInstalled +func (instance *Instance) checkVersion(version string) error { + curVer, err := semver.NewVersion(instance.unitConfig.Version) + if err != nil { + return aoserrors.Wrap(err) } - if err = instance.client.CheckUnitConfig(unitConfig); err != nil { - return unitConfig.Version, aoserrors.Wrap(err) + newVer, err := semver.NewVersion(version) + if err != nil { + return aoserrors.Wrap(err) + } + + if newVer.Equal(curVer) { + return ErrAlreadyInstalled } - return unitConfig.Version, nil + if newVer.LessThan(curVer) { + return aoserrors.New("wrong version") + } + + return nil } diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index f6bc1642..ea9e3eaf 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -36,8 +36,8 @@ import ( const validTestUnitConfig = ` { - "formatVersion": 1, - "vendorVersion": "1.0.0", + "formatVersion": "1", + "version": "1.0.0", "nodes": [ { "nodeType" : "type1" @@ -118,7 +118,7 @@ func TestValidGetStatus(t *testing.T) { t.Errorf("Wrong unit config version: %s", info.Version) } - nodeUnitConfig := unitConfig.GetUnitConfiguration("type1") + nodeUnitConfig := unitConfig.GetUnitConfig("id1", "type1") if nodeUnitConfig.NodeType != "type1" { t.Error("Unexpected node type") @@ -162,63 +162,51 @@ func TestCheckUnitConfig(t *testing.T) { t.Fatalf("Can't create unit config instance: %s", err) } - validUnitConfig := ` - { - "formatVersion": 1, - "vendorVersion": "2.0.0" - }` - - vendorVersion, err := unitConfig.CheckUnitConfig(json.RawMessage(validUnitConfig)) - if err != nil { - t.Errorf("Check unit config error: %s", err) + validUnitConfig := cloudprotocol.UnitConfig{ + FormatVersion: "1", + Version: "2.0.0", } - if vendorVersion != "2.0.0" { - t.Errorf("Wrong unit config version: %s", vendorVersion) + if err := unitConfig.CheckUnitConfig(validUnitConfig); err != nil { + t.Errorf("Check unit config error: %v", err) } - invalidUnitConfig := ` - { - "formatVersion": 1, - "vendorVersion": "1.0.0" - }` - - if vendorVersion, err = unitConfig.CheckUnitConfig(json.RawMessage(invalidUnitConfig)); err == nil { - t.Error("Error expected") + invalidUnitConfig := cloudprotocol.UnitConfig{ + FormatVersion: "1", + Version: "1.0.0", } - if vendorVersion != "1.0.0" { - t.Errorf("Wrong unit config version: %s", vendorVersion) + if err := unitConfig.CheckUnitConfig(invalidUnitConfig); err == nil { + t.Error("Error expected") } } func TestUpdateUnitConfig(t *testing.T) { if err := os.WriteFile(path.Join(tmpDir, "aos_unit.cfg"), []byte(validTestUnitConfig), 0o600); err != nil { - t.Fatalf("Can't create unit config file: %s", err) + t.Fatalf("Can't create unit config file: %v", err) } unitConfig, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, &testClient{}) if err != nil { - t.Fatalf("Can't create unit config instance: %s", err) + t.Fatalf("Can't create unit config instance: %v", err) } - newUnitConfig := ` - { - "formatVersion": 1, - "vendorVersion": "2.0.0" - }` + newUnitConfig := cloudprotocol.UnitConfig{ + FormatVersion: "1", + Version: "2.0.0", + } - if err = unitConfig.UpdateUnitConfig(json.RawMessage(newUnitConfig)); err != nil { - t.Fatalf("Can't update unit config: %s", err) + if err = unitConfig.UpdateUnitConfig(newUnitConfig); err != nil { + t.Fatalf("Can't update unit config: %v", err) } - vendorVersion, err := unitConfig.GetUnitConfigVersion(json.RawMessage(newUnitConfig)) + status, err := unitConfig.GetStatus() if err != nil { - t.Errorf("Get unit config version error: %s", err) + t.Errorf("Get unit config status error: %v", err) } - if vendorVersion != "2.0.0" { - t.Errorf("Wrong unit config version: %s", vendorVersion) + if status.Version != "2.0.0" { + t.Errorf("Wrong unit config version: %s", status.Version) } readUnitConfig, err := os.ReadFile(path.Join(tmpDir, "aos_unit.cfg")) @@ -226,7 +214,12 @@ func TestUpdateUnitConfig(t *testing.T) { t.Fatalf("Can't read unit config file: %s", err) } - if string(readUnitConfig) != newUnitConfig { + newUnitConfigJSON, err := json.Marshal(newUnitConfig) + if err != nil { + t.Fatalf("Can't marshal new unit config: %s", err) + } + + if string(readUnitConfig) != string(newUnitConfigJSON) { t.Errorf("Read wrong unit config: %s", readUnitConfig) } } From ccb0ee1ef7bcb2a29c41789652ac343bf4185acd Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 8 Jul 2024 19:30:10 +0300 Subject: [PATCH 032/146] [smcontroller] Update to new cloud and protobuf protocols Signed-off-by: Oleksandr Grytsov --- smcontroller/smcontroller.go | 169 +++--- smcontroller/smcontroller_test.go | 831 ++++++++++++++---------------- smcontroller/smhandler.go | 267 +++++----- 3 files changed, 595 insertions(+), 672 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 9ed2c849..78911a80 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -18,6 +18,8 @@ package smcontroller import ( + "errors" + "io" "net" "sync" @@ -28,7 +30,9 @@ import ( "github.com/aosedge/aos_common/utils/cryptutils" log "github.com/sirupsen/logrus" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/status" "github.com/aosedge/aos_communicationmanager/amqphandler" "github.com/aosedge/aos_communicationmanager/config" @@ -73,7 +77,7 @@ type AlertSender interface { // MonitoringSender sends monitoring data. type MonitoringSender interface { - SendMonitoringData(monitoringData cloudprotocol.NodeMonitoringData) + SendNodeMonitoring(monitoring aostypes.NodeMonitoring) } // MessageSender sends messages to the cloud. @@ -123,10 +127,6 @@ func New( cloudprotocol.CrashLog: controller.getCrashLog, } - for _, nodeID := range cfg.SMController.NodeIDs { - controller.nodes[nodeID] = nil - } - var opts []grpc.ServerOption if !insecureConn { @@ -173,24 +173,14 @@ func (controller *Controller) Close() error { return nil } -// GetNodeConfiguration gets node static configuration. -func (controller *Controller) GetNodeConfiguration(nodeID string) (cfg launcher.NodeInfo, err error) { - handler, err := controller.getNodeHandlerByID(nodeID) - if err != nil { - return cfg, aoserrors.Wrap(err) - } - - return handler.config, nil -} - -// GetUnitConfigStatus gets unit configuration status fot he node. -func (controller *Controller) GetUnitConfigStatus(nodeID string) (string, error) { +// GetNodeConfigStatus gets node configuration status. +func (controller *Controller) GetNodeConfigStatus(nodeID string) (version string, err error) { handler, err := controller.getNodeHandlerByID(nodeID) if err != nil { return "", aoserrors.Wrap(err) } - return handler.getUnitConfigState() + return handler.getNodeConfigStatus() } // CheckUnitConfig checks unit config for the node. @@ -201,11 +191,19 @@ func (controller *Controller) CheckUnitConfig(unitConfig cloudprotocol.UnitConfi continue } - if node.config.NodeType == nodeConfig.NodeType { - err := node.checkUnitConfigState(nodeConfig, unitConfig.Version) - if err != nil { - return err - } + if nodeConfig.NodeID != nil && *nodeConfig.NodeID != node.nodeID { + continue + } + + if nodeConfig.NodeType != node.nodeType { + continue + } + + nodeConfig.NodeID = &node.nodeID + + err := node.checkNodeConfig(nodeConfig, unitConfig.Version) + if err != nil { + return err } } } @@ -221,11 +219,19 @@ func (controller *Controller) SetUnitConfig(unitConfig cloudprotocol.UnitConfig) continue } - if node.config.NodeType == nodeConfig.NodeType { - err := node.setUnitConfig(nodeConfig, unitConfig.Version) - if err != nil { - return err - } + if nodeConfig.NodeID != nil && *nodeConfig.NodeID != node.nodeID { + continue + } + + if nodeConfig.NodeType != node.nodeType { + continue + } + + nodeConfig.NodeID = &node.nodeID + + err := node.setNodeConfig(nodeConfig, unitConfig.Version) + if err != nil { + return err } } } @@ -279,14 +285,14 @@ func (controller *Controller) GetLog(logRequest cloudprotocol.RequestLog) error return handler(logRequest) } -// GetNodeMonitoringData requests node monitoring data from SM. -func (controller *Controller) GetNodeMonitoringData(nodeID string) (data cloudprotocol.NodeMonitoringData, err error) { +// GetAverageMonitoring returns average monitoring data for the node. +func (controller *Controller) GetAverageMonitoring(nodeID string) (aostypes.NodeMonitoring, error) { handler, err := controller.getNodeHandlerByID(nodeID) if err != nil { - return data, err + return aostypes.NodeMonitoring{}, err } - return handler.getNodeMonitoring() + return handler.getAverageMonitoring() } // GetUpdateInstancesStatusChannel returns channel with update instances status. @@ -306,60 +312,57 @@ func (controller *Controller) GetSystemLimitAlertChannel() <-chan cloudprotocol. // RegisterSM registers new SM client connection. func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) error { - message, err := stream.Recv() - if err != nil { - log.Errorf("Error receive message from SM: %v", err) + var handler *smHandler - return aoserrors.Wrap(err) - } + for { + message, err := stream.Recv() + if err != nil { + if handler != nil { + controller.handleCloseConnection(handler.nodeID) + } - nodeConfig, ok := message.GetSMOutgoingMessage().(*pb.SMOutgoingMessages_NodeConfiguration) - if !ok { - log.Error("Unexpected first message from stream") + if !errors.Is(err, io.EOF) && codes.Canceled != status.Code(err) { + log.Errorf("Close SM client connection error: %v", err) - return aoserrors.New("unexpected first message from stream") - } + return aoserrors.Wrap(err) + } - log.WithFields(log.Fields{"nodeID": nodeConfig.NodeConfiguration.GetNodeId()}).Debug("Register SM") + return nil + } - nodeCfg := launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{ - NodeID: nodeConfig.NodeConfiguration.GetNodeId(), NodeType: nodeConfig.NodeConfiguration.GetNodeType(), - SystemInfo: cloudprotocol.SystemInfo{ - NumCPUs: nodeConfig.NodeConfiguration.GetNumCpus(), TotalRAM: nodeConfig.NodeConfiguration.GetTotalRam(), - Partitions: make([]cloudprotocol.PartitionInfo, len(nodeConfig.NodeConfiguration.GetPartitions())), - }, - }, - RemoteNode: nodeConfig.NodeConfiguration.GetRemoteNode(), - RunnerFeature: message.GetNodeConfiguration().GetRunnerFeatures(), - } + if handler == nil { + registerMessage, ok := message.GetSMOutgoingMessage().(*pb.SMOutgoingMessages_RegisterSm) + if !ok { + log.Error("Unexpected first message from stream") - for i, pbPartition := range nodeConfig.NodeConfiguration.GetPartitions() { - nodeCfg.Partitions[i] = cloudprotocol.PartitionInfo{ - Name: pbPartition.GetName(), - Types: pbPartition.GetTypes(), - TotalSize: pbPartition.GetTotalSize(), - } - } + continue + } - handler, err := newSMHandler( - stream, controller.messageSender, controller.alertSender, controller.monitoringSender, nodeCfg, - controller.runInstancesStatusChan, controller.updateInstancesStatusChan, controller.systemLimitAlertChan) - if err != nil { - return err - } + nodeID := registerMessage.RegisterSm.GetNodeId() + nodeType := registerMessage.RegisterSm.GetNodeType() - if err := controller.handleNewConnection(nodeConfig.NodeConfiguration.GetNodeId(), handler); err != nil { - log.Errorf("Can't register new SM connection: %v", err) + log.WithFields(log.Fields{"nodeID": nodeID, "nodeType": nodeType}).Debug("Register SM") - return err - } + handler, err = newSMHandler(nodeID, nodeType, stream, controller.messageSender, controller.alertSender, + controller.monitoringSender, controller.runInstancesStatusChan, controller.updateInstancesStatusChan, + controller.systemLimitAlertChan) + if err != nil { + log.Errorf("Can't crate SM handler: %v", err) - handler.processSMMessages() + return err + } - controller.handleCloseConnection(nodeConfig.NodeConfiguration.GetNodeId()) + if err := controller.handleNewConnection(nodeID, handler); err != nil { + log.Errorf("Can't register new SM connection: %v", err) - return nil + return err + } + + continue + } + + handler.processSMMessages(message) + } } /*********************************************************************************************************************** @@ -490,12 +493,8 @@ func (controller *Controller) handleNewConnection(nodeID string, newHandler *smH controller.Lock() defer controller.Unlock() - if handler, ok := controller.nodes[nodeID]; ok { - if handler != nil { - return aoserrors.Errorf("connection for nodeID %s already exist", nodeID) - } - } else { - return aoserrors.Errorf("unknown nodeID connection with nodeID %s", nodeID) + if _, ok := controller.nodes[nodeID]; ok { + return aoserrors.Errorf("connection for node ID %s already exist", nodeID) } controller.nodes[nodeID] = newHandler @@ -504,14 +503,6 @@ func (controller *Controller) handleNewConnection(nodeID string, newHandler *smH log.Errorf("Can't send connection status: %v", err) } - for _, node := range controller.nodes { - if node == nil { - return nil - } - } - - log.Info("All SM client connected") - return nil } @@ -525,7 +516,7 @@ func (controller *Controller) handleCloseConnection(nodeID string) { return } - controller.nodes[nodeID] = nil + delete(controller.nodes, nodeID) } func (controller *Controller) getNodeHandlerByID(nodeID string) (*smHandler, error) { diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index ed44f604..c3544f82 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -28,7 +28,9 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" - pb "github.com/aosedge/aos_common/api/servicemanager" + + pbcommon "github.com/aosedge/aos_common/api/common" + pbsm "github.com/aosedge/aos_common/api/servicemanager" log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -57,10 +59,10 @@ const messageTimeout = 5 * time.Second type testSMClient struct { connection *grpc.ClientConn - pbClient pb.SMServiceClient - stream pb.SMService_RegisterSMClient - sendMessageChannel chan *pb.SMOutgoingMessages - receivedMessagesChannel chan *pb.SMIncomingMessages + pbClient pbsm.SMServiceClient + stream pbsm.SMService_RegisterSMClient + sendMessageChannel chan *pbsm.SMOutgoingMessages + receivedMessagesChannel chan *pbsm.SMIncomingMessages cancelFunction context.CancelFunc } @@ -73,7 +75,7 @@ type testAlertSender struct { } type testMonitoringSender struct { - messageChannel chan cloudprotocol.NodeMonitoringData + messageChannel chan aostypes.NodeMonitoring } /*********************************************************************************************************************** @@ -96,42 +98,19 @@ func init() { func TestSMInstancesStatusNotifications(t *testing.T) { var ( - nodeID = "mainSM" - nodeType = "mainSMType" - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, NodeType: nodeType, RemoteNode: true, - RunnerFeatures: []string{"runc"}, NumCpus: 1, TotalRam: 100, - Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - expectedNodeConfiguration = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{ - NodeID: nodeID, NodeType: nodeType, - SystemInfo: cloudprotocol.SystemInfo{ - NumCPUs: 1, TotalRAM: 100, - Partitions: []cloudprotocol.PartitionInfo{ - {Name: "services", Types: []string{"t1"}, TotalSize: 50}, - }, - }, - }, - RemoteNode: true, - RunnerFeature: []string{"runc"}, - } - sendRuntimeStatus = &pb.RunInstancesStatus{ - Instances: []*pb.InstanceStatus{ + nodeID = "mainSM" + nodeType = "mainSMType" + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + sendRuntimeStatus = &pbsm.RunInstancesStatus{ + Instances: []*pbsm.InstanceStatus{ { - Instance: &pb.InstanceIdent{ServiceId: "serv1", SubjectId: "subj1", Instance: 1}, - AosVersion: 1, RunState: "running", + Instance: &pbcommon.InstanceIdent{ServiceId: "serv1", SubjectId: "subj1", Instance: 1}, + ServiceVersion: "1.0.0", RunState: "running", }, { - Instance: &pb.InstanceIdent{ServiceId: "serv2", SubjectId: "subj2", Instance: 1}, - AosVersion: 1, RunState: "fail", - ErrorInfo: &pb.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, + Instance: &pbcommon.InstanceIdent{ServiceId: "serv2", SubjectId: "subj2", Instance: 1}, + ServiceVersion: "1.0.0", RunState: "fail", + ErrorInfo: &pbcommon.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, } @@ -139,29 +118,33 @@ func TestSMInstancesStatusNotifications(t *testing.T) { NodeID: nodeID, NodeType: nodeType, Instances: []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv1", SubjectID: "subj1", Instance: 1}, - AosVersion: 1, RunState: "running", NodeID: nodeID, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv1", SubjectID: "subj1", Instance: 1}, + ServiceVersion: "1.0.0", RunState: "running", NodeID: nodeID, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv2", SubjectID: "subj2", Instance: 1}, - AosVersion: 1, RunState: "fail", NodeID: nodeID, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv2", SubjectID: "subj2", Instance: 1}, + ServiceVersion: "1.0.0", RunState: "fail", NodeID: nodeID, ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, } - sendUpdateStatus = &pb.SMOutgoingMessages{ - SMOutgoingMessage: &pb.SMOutgoingMessages_UpdateInstancesStatus{ - UpdateInstancesStatus: &pb.UpdateInstancesStatus{ - Instances: []*pb.InstanceStatus{ + sendUpdateStatus = &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_UpdateInstancesStatus{ + UpdateInstancesStatus: &pbsm.UpdateInstancesStatus{ + Instances: []*pbsm.InstanceStatus{ { - Instance: &pb.InstanceIdent{ServiceId: "serv1", SubjectId: "subj1", Instance: 1}, - AosVersion: 1, RunState: "running", + Instance: &pbcommon.InstanceIdent{ + ServiceId: "serv1", SubjectId: "subj1", Instance: 1, + }, + ServiceVersion: "1.0.0", RunState: "running", }, { - Instance: &pb.InstanceIdent{ServiceId: "serv2", SubjectId: "subj2", Instance: 1}, - AosVersion: 1, RunState: "fail", - ErrorInfo: &pb.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, + Instance: &pbcommon.InstanceIdent{ + ServiceId: "serv2", SubjectId: "subj2", Instance: 1, + }, + ServiceVersion: "1.0.0", RunState: "fail", + ErrorInfo: &pbcommon.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, }, @@ -169,12 +152,12 @@ func TestSMInstancesStatusNotifications(t *testing.T) { } expectedUpdateState = []cloudprotocol.InstanceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv1", SubjectID: "subj1", Instance: 1}, - AosVersion: 1, RunState: "running", NodeID: nodeID, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv1", SubjectID: "subj1", Instance: 1}, + ServiceVersion: "1.0.0", RunState: "running", NodeID: nodeID, }, { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv2", SubjectID: "subj2", Instance: 1}, - AosVersion: 1, RunState: "fail", NodeID: nodeID, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv2", SubjectID: "subj2", Instance: 1}, + ServiceVersion: "1.0.0", RunState: "fail", NodeID: nodeID, ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, } @@ -186,7 +169,7 @@ func TestSMInstancesStatusNotifications(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, sendRuntimeStatus) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, sendRuntimeStatus) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -198,15 +181,6 @@ func TestSMInstancesStatusNotifications(t *testing.T) { t.Errorf("Incorrect runtime status notification: %v", err) } - cfg, err := controller.GetNodeConfiguration(nodeID) - if err != nil { - t.Errorf("Can't get node configuration: %v", err) - } - - if !reflect.DeepEqual(cfg, expectedNodeConfiguration) { - t.Error("Incorrect node configuration") - } - smClient.sendMessageChannel <- sendUpdateStatus if err := waitMessage( @@ -217,26 +191,17 @@ func TestSMInstancesStatusNotifications(t *testing.T) { func TestUnitConfigMessages(t *testing.T) { var ( - nodeID = "mainSM" - nodeType = "mainType" - messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, NodeType: nodeType, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } - testWaitChan = make(chan struct{}) - originalVersion = "version_1" - configStatus = &pb.SMOutgoingMessages{SMOutgoingMessage: &pb.SMOutgoingMessages_UnitConfigStatus{ - UnitConfigStatus: &pb.UnitConfigStatus{Version: originalVersion}, + nodeID = "mainSM" + nodeType = "mainType" + messageSender = newTestMessageSender() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + testWaitChan = make(chan struct{}) + originalVersion = "1.0.0" + nodeConfigStatus = &pbsm.SMOutgoingMessages{SMOutgoingMessage: &pbsm.SMOutgoingMessages_NodeConfigStatus{ + NodeConfigStatus: &pbsm.NodeConfigStatus{Version: originalVersion}, }} - newVersion = "version_2" - unitConfig = fmt.Sprintf(`{"nodeType":"%s"}`, nodeType) + newVersion = "2.0.0" + nodeConfig = fmt.Sprintf(`{"nodeId":"%s","nodeType":"%s"}`, nodeID, nodeType) ) controller, err := smcontroller.New(&config, messageSender, nil, nil, nil, nil, true) @@ -245,46 +210,40 @@ func TestUnitConfigMessages(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() - if err := waitMessage(controller.GetRunInstancesStatusChannel(), launcher.NodeRunInstanceStatus{ - NodeID: nodeID, NodeType: nodeType, Instances: make([]cloudprotocol.InstanceStatus, 0), + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ConnectionStatus: &pbsm.ConnectionStatus{}}, }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { - t.Fatalf("Wait message error: %v", err) - } - go func() { - version, err := controller.GetUnitConfigStatus(nodeID) + version, err := controller.GetNodeConfigStatus(nodeID) if err != nil { - t.Errorf("Can't get unit config status: %v", err) + t.Errorf("Can't get node config status: %v", err) } if version != originalVersion { - t.Error("Incorrect unit config version") + t.Error("Incorrect node config version") } testWaitChan <- struct{}{} }() if err := smClient.waitMessage( - &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_GetUnitConfigStatus{}}, + &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_GetNodeConfigStatus{}}, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.stream.Send(configStatus); err != nil { - t.Errorf("Can't send unit config status: %v", err) + if err := smClient.stream.Send(nodeConfigStatus); err != nil { + t.Errorf("Can't send node config status: %v", err) } <-testWaitChan @@ -304,15 +263,17 @@ func TestUnitConfigMessages(t *testing.T) { testWaitChan <- struct{}{} }() - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_CheckUnitConfig{ - CheckUnitConfig: &pb.CheckUnitConfig{UnitConfig: unitConfig, Version: newVersion}, - }}, messageTimeout); err != nil { + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_CheckNodeConfig{ + CheckNodeConfig: &pbsm.CheckNodeConfig{NodeConfig: nodeConfig, Version: newVersion}, + }, + }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - configStatus.GetUnitConfigStatus().Version = newVersion + nodeConfigStatus.GetNodeConfigStatus().Version = newVersion - if err := smClient.stream.Send(configStatus); err != nil { + if err := smClient.stream.Send(nodeConfigStatus); err != nil { t.Errorf("Can't send unit config status") } @@ -333,16 +294,18 @@ func TestUnitConfigMessages(t *testing.T) { testWaitChan <- struct{}{} }() - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SetUnitConfig{ - SetUnitConfig: &pb.SetUnitConfig{UnitConfig: unitConfig, Version: newVersion}, - }}, messageTimeout); err != nil { + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_SetNodeConfig{ + SetNodeConfig: &pbsm.SetNodeConfig{NodeConfig: nodeConfig, Version: newVersion}, + }, + }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - configStatus.GetUnitConfigStatus().Version = newVersion + nodeConfigStatus.GetNodeConfigStatus().Version = newVersion - if err := smClient.stream.Send(configStatus); err != nil { - t.Errorf("Can't send unit config status") + if err := smClient.stream.Send(nodeConfigStatus); err != nil { + t.Errorf("Can't send node config status") } <-testWaitChan @@ -351,18 +314,10 @@ func TestUnitConfigMessages(t *testing.T) { func TestSMAlertNotifications(t *testing.T) { var ( nodeID = "mainSM" + nodeType = "mainSMType" messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } - alertSender = newTestAlertSender() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + alertSender = newTestAlertSender() ) controller, err := smcontroller.New(&config, messageSender, alertSender, nil, nil, nil, true) @@ -371,7 +326,7 @@ func TestSMAlertNotifications(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, nil) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -380,7 +335,7 @@ func TestSMAlertNotifications(t *testing.T) { // Test alert notifications type testAlert struct { - sendAlert *pb.Alert + sendAlert *pbsm.Alert expectedAlert cloudprotocol.AlertItem } @@ -390,9 +345,11 @@ func TestSMAlertNotifications(t *testing.T) { Tag: cloudprotocol.AlertTagSystemError, Payload: cloudprotocol.SystemAlert{Message: "SystemAlertMessage", NodeID: nodeID}, }, - sendAlert: &pb.Alert{ - Tag: cloudprotocol.AlertTagSystemError, - Payload: &pb.Alert_SystemAlert{SystemAlert: &pb.SystemAlert{Message: "SystemAlertMessage"}}, + sendAlert: &pbsm.Alert{ + Tag: cloudprotocol.AlertTagSystemError, + Payload: &pbsm.Alert_SystemAlert{ + SystemAlert: &pbsm.SystemAlert{Message: "SystemAlertMessage"}, + }, }, }, { @@ -400,29 +357,33 @@ func TestSMAlertNotifications(t *testing.T) { Tag: cloudprotocol.AlertTagAosCore, Payload: cloudprotocol.CoreAlert{CoreComponent: "SM", Message: "CoreAlertMessage", NodeID: nodeID}, }, - sendAlert: &pb.Alert{ - Tag: cloudprotocol.AlertTagAosCore, - Payload: &pb.Alert_CoreAlert{CoreAlert: &pb.CoreAlert{CoreComponent: "SM", Message: "CoreAlertMessage"}}, + sendAlert: &pbsm.Alert{ + Tag: cloudprotocol.AlertTagAosCore, + Payload: &pbsm.Alert_CoreAlert{ + CoreAlert: &pbsm.CoreAlert{CoreComponent: "SM", Message: "CoreAlertMessage"}, + }, }, }, { expectedAlert: cloudprotocol.AlertItem{ Tag: cloudprotocol.AlertTagResourceValidate, Payload: cloudprotocol.ResourceValidateAlert{ - ResourcesErrors: []cloudprotocol.ResourceValidateError{ - {Name: "someName1", Errors: []string{"error1", "error2"}}, - {Name: "someName2", Errors: []string{"error3", "error4"}}, - }, NodeID: nodeID, + Name: "someName", + Errors: []cloudprotocol.ErrorInfo{ + {AosCode: 200, Message: "error1"}, + {AosCode: 300, Message: "error2"}, + }, }, }, - sendAlert: &pb.Alert{ + sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagResourceValidate, - Payload: &pb.Alert_ResourceValidateAlert{ - ResourceValidateAlert: &pb.ResourceValidateAlert{ - Errors: []*pb.ResourceValidateErrors{ - {Name: "someName1", ErrorMsg: []string{"error1", "error2"}}, - {Name: "someName2", ErrorMsg: []string{"error3", "error4"}}, + Payload: &pbsm.Alert_ResourceValidateAlert{ + ResourceValidateAlert: &pbsm.ResourceValidateAlert{ + Name: "someName", + Errors: []*pbcommon.ErrorInfo{ + {AosCode: 200, Message: "error1"}, + {AosCode: 300, Message: "error2"}, }, }, }, @@ -437,11 +398,11 @@ func TestSMAlertNotifications(t *testing.T) { NodeID: nodeID, }, }, - sendAlert: &pb.Alert{ + sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagDeviceAllocate, - Payload: &pb.Alert_DeviceAllocateAlert{ - DeviceAllocateAlert: &pb.DeviceAllocateAlert{ - Instance: &pb.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, + Payload: &pbsm.Alert_DeviceAllocateAlert{ + DeviceAllocateAlert: &pbsm.DeviceAllocateAlert{ + Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, Device: "someDevice", Message: "someMessage", }, }, @@ -452,10 +413,10 @@ func TestSMAlertNotifications(t *testing.T) { Tag: cloudprotocol.AlertTagSystemQuota, Payload: cloudprotocol.SystemQuotaAlert{Parameter: "cpu", Value: 42, NodeID: nodeID}, }, - sendAlert: &pb.Alert{ + sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemQuota, - Payload: &pb.Alert_SystemQuotaAlert{ - SystemQuotaAlert: &pb.SystemQuotaAlert{Parameter: "cpu", Value: 42}, + Payload: &pbsm.Alert_SystemQuotaAlert{ + SystemQuotaAlert: &pbsm.SystemQuotaAlert{Parameter: "cpu", Value: 42}, }, }, }, @@ -464,10 +425,10 @@ func TestSMAlertNotifications(t *testing.T) { Tag: cloudprotocol.AlertTagSystemQuota, Payload: cloudprotocol.SystemQuotaAlert{Parameter: "ram", Value: 99, NodeID: nodeID}, }, - sendAlert: &pb.Alert{ + sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemQuota, - Payload: &pb.Alert_SystemQuotaAlert{ - SystemQuotaAlert: &pb.SystemQuotaAlert{Parameter: "ram", Value: 99}, + Payload: &pbsm.Alert_SystemQuotaAlert{ + SystemQuotaAlert: &pbsm.SystemQuotaAlert{Parameter: "ram", Value: 99}, }, }, }, @@ -479,11 +440,11 @@ func TestSMAlertNotifications(t *testing.T) { Parameter: "param1", Value: 42, }, }, - sendAlert: &pb.Alert{ + sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagInstanceQuota, - Payload: &pb.Alert_InstanceQuotaAlert{ - InstanceQuotaAlert: &pb.InstanceQuotaAlert{ - Instance: &pb.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, + Payload: &pbsm.Alert_InstanceQuotaAlert{ + InstanceQuotaAlert: &pbsm.InstanceQuotaAlert{ + Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, Parameter: "param1", Value: 42, }, }, @@ -494,15 +455,15 @@ func TestSMAlertNotifications(t *testing.T) { Tag: cloudprotocol.AlertTagServiceInstance, Payload: cloudprotocol.ServiceInstanceAlert{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, - Message: "ServiceInstanceAlert", AosVersion: 42, + Message: "ServiceInstanceAlert", ServiceVersion: "42.0.0", }, }, - sendAlert: &pb.Alert{ + sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagServiceInstance, - Payload: &pb.Alert_InstanceAlert{ - InstanceAlert: &pb.InstanceAlert{ - Instance: &pb.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, - Message: "ServiceInstanceAlert", AosVersion: 42, + Payload: &pbsm.Alert_InstanceAlert{ + InstanceAlert: &pbsm.InstanceAlert{ + Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, + Message: "ServiceInstanceAlert", ServiceVersion: "42.0.0", }, }, }, @@ -514,8 +475,8 @@ func TestSMAlertNotifications(t *testing.T) { testAlert.expectedAlert.Timestamp = currentTime testAlert.sendAlert.Timestamp = timestamppb.New(currentTime) - smClient.sendMessageChannel <- &pb.SMOutgoingMessages{ - SMOutgoingMessage: &pb.SMOutgoingMessages_Alert{Alert: testAlert.sendAlert}, + smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_Alert{Alert: testAlert.sendAlert}, } if err := waitMessage(alertSender.messageChannel, testAlert.expectedAlert, messageTimeout); err != nil { @@ -537,18 +498,10 @@ func TestSMAlertNotifications(t *testing.T) { func TestSMMonitoringNotifications(t *testing.T) { var ( - nodeID = "mainSM" - messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } + nodeID = "mainSM" + nodeType = "mainSMType" + messageSender = newTestMessageSender() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} monitoringSender = newTestMonitoringSender() ) @@ -558,7 +511,7 @@ func TestSMMonitoringNotifications(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, nil) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -566,69 +519,79 @@ func TestSMMonitoringNotifications(t *testing.T) { defer smClient.close() type testMonitoringElement struct { - expectedMonitoring cloudprotocol.NodeMonitoringData - sendMonitoring *pb.NodeMonitoring + expectedMonitoring aostypes.NodeMonitoring + sendMonitoring *pbsm.InstantMonitoring } + now := time.Now().UTC() + testMonitoringData := []testMonitoringElement{ { - expectedMonitoring: cloudprotocol.NodeMonitoringData{ + expectedMonitoring: aostypes.NodeMonitoring{ NodeID: nodeID, - MonitoringData: cloudprotocol.MonitoringData{ + NodeData: aostypes.MonitoringData{ RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 50, - Disk: []cloudprotocol.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: now, }, - ServiceInstances: []cloudprotocol.InstanceMonitoringData{}, + InstancesData: []aostypes.InstanceMonitoring{}, }, - sendMonitoring: &pb.NodeMonitoring{ - MonitoringData: &pb.MonitoringData{ + sendMonitoring: &pbsm.InstantMonitoring{ + NodeMonitoring: &pbsm.MonitoringData{ Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 50, - Disk: []*pb.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: timestamppb.New(now), }, }, }, { - expectedMonitoring: cloudprotocol.NodeMonitoringData{ + expectedMonitoring: aostypes.NodeMonitoring{ NodeID: nodeID, - MonitoringData: cloudprotocol.MonitoringData{ + NodeData: aostypes.MonitoringData{ RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 50, - Disk: []cloudprotocol.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: now, }, - ServiceInstances: []cloudprotocol.InstanceMonitoringData{ + InstancesData: []aostypes.InstanceMonitoring{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "s1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{ + MonitoringData: aostypes.MonitoringData{ RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 0, - Disk: []cloudprotocol.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: now, }, }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "s1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{ + MonitoringData: aostypes.MonitoringData{ RAM: 20, CPU: 30, InTraffic: 50, OutTraffic: 10, - Disk: []cloudprotocol.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Disk: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Timestamp: now, }, }, }, }, - sendMonitoring: &pb.NodeMonitoring{ - MonitoringData: &pb.MonitoringData{ + sendMonitoring: &pbsm.InstantMonitoring{ + NodeMonitoring: &pbsm.MonitoringData{ Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 50, - Disk: []*pb.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: timestamppb.New(now), }, - InstanceMonitoring: []*pb.InstanceMonitoring{ + InstancesMonitoring: []*pbsm.InstanceMonitoring{ { - Instance: &pb.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1}, - MonitoringData: &pb.MonitoringData{ + Instance: &pbcommon.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1}, + MonitoringData: &pbsm.MonitoringData{ Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 0, - Disk: []*pb.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: timestamppb.New(now), }, }, { - Instance: &pb.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1}, - MonitoringData: &pb.MonitoringData{ + Instance: &pbcommon.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1}, + MonitoringData: &pbsm.MonitoringData{ Ram: 20, Cpu: 30, InTraffic: 50, OutTraffic: 10, - Disk: []*pb.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Disk: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Timestamp: timestamppb.New(now), }, }, }, @@ -637,13 +600,11 @@ func TestSMMonitoringNotifications(t *testing.T) { } for _, testMonitoring := range testMonitoringData { - currentTime := time.Now().UTC() - testMonitoring.expectedMonitoring.Timestamp = currentTime - testMonitoring.sendMonitoring.Timestamp = timestamppb.New(currentTime) - - smClient.sendMessageChannel <- &pb.SMOutgoingMessages{SMOutgoingMessage: &pb.SMOutgoingMessages_NodeMonitoring{ - NodeMonitoring: testMonitoring.sendMonitoring, - }} + smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_InstantMonitoring{ + InstantMonitoring: testMonitoring.sendMonitoring, + }, + } if err := waitMessage( monitoringSender.messageChannel, testMonitoring.expectedMonitoring, messageTimeout); err != nil { @@ -655,18 +616,10 @@ func TestSMMonitoringNotifications(t *testing.T) { func TestLogMessages(t *testing.T) { var ( nodeID = "mainSM" + nodeType = "mainSMType" messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } - currentTime = time.Now().UTC() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + currentTime = time.Now().UTC() ) controller, err := smcontroller.New(&config, messageSender, nil, nil, nil, nil, true) @@ -675,28 +628,24 @@ func TestLogMessages(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() - if err := waitMessage(controller.GetRunInstancesStatusChannel(), launcher.NodeRunInstanceStatus{ - NodeID: nodeID, Instances: make([]cloudprotocol.InstanceStatus, 0), + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{}, + }, }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { - t.Fatalf("Wait message error: %v", err) - } - type testLogRequest struct { sendLogRequest cloudprotocol.RequestLog - expectedLogRequest *pb.SMIncomingMessages + expectedLogRequest *pbsm.SMIncomingMessages } testRequests := []testLogRequest{ @@ -708,8 +657,8 @@ func TestLogMessages(t *testing.T) { From: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SystemLogRequest{ - SystemLogRequest: &pb.SystemLogRequest{LogId: "sysLogID1", From: timestamppb.New(currentTime)}, + expectedLogRequest: &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_SystemLogRequest{ + SystemLogRequest: &pbsm.SystemLogRequest{LogId: "sysLogID1", From: timestamppb.New(currentTime)}, }}, }, { @@ -720,8 +669,8 @@ func TestLogMessages(t *testing.T) { Till: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SystemLogRequest{ - SystemLogRequest: &pb.SystemLogRequest{LogId: "sysLogID2", Till: timestamppb.New(currentTime)}, + expectedLogRequest: &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_SystemLogRequest{ + SystemLogRequest: &pbsm.SystemLogRequest{LogId: "sysLogID2", Till: timestamppb.New(currentTime)}, }}, }, { @@ -733,12 +682,14 @@ func TestLogMessages(t *testing.T) { From: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_InstanceLogRequest{ - InstanceLogRequest: &pb.InstanceLogRequest{ - Instance: &pb.InstanceIdent{ServiceId: "ser1", SubjectId: "s1", Instance: -1}, - LogId: "serviceLogID1", From: timestamppb.New(currentTime), + expectedLogRequest: &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_InstanceLogRequest{ + InstanceLogRequest: &pbsm.InstanceLogRequest{ + InstanceFilter: &pbsm.InstanceFilter{ServiceId: "ser1", SubjectId: "s1", Instance: -1}, + LogId: "serviceLogID1", From: timestamppb.New(currentTime), + }, }, - }}, + }, }, { sendLogRequest: cloudprotocol.RequestLog{ @@ -749,12 +700,14 @@ func TestLogMessages(t *testing.T) { Till: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_InstanceLogRequest{ - InstanceLogRequest: &pb.InstanceLogRequest{ - Instance: &pb.InstanceIdent{ServiceId: "ser2", SubjectId: "", Instance: -1}, - LogId: "serviceLogID1", Till: timestamppb.New(currentTime), + expectedLogRequest: &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_InstanceLogRequest{ + InstanceLogRequest: &pbsm.InstanceLogRequest{ + InstanceFilter: &pbsm.InstanceFilter{ServiceId: "ser2", SubjectId: "", Instance: -1}, + LogId: "serviceLogID1", Till: timestamppb.New(currentTime), + }, }, - }}, + }, }, { sendLogRequest: cloudprotocol.RequestLog{ @@ -765,12 +718,14 @@ func TestLogMessages(t *testing.T) { Till: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_InstanceLogRequest{ - InstanceLogRequest: &pb.InstanceLogRequest{ - Instance: &pb.InstanceIdent{ServiceId: "", SubjectId: "", Instance: -1}, - LogId: "serviceLogID2", Till: timestamppb.New(currentTime), + expectedLogRequest: &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_InstanceLogRequest{ + InstanceLogRequest: &pbsm.InstanceLogRequest{ + InstanceFilter: &pbsm.InstanceFilter{ServiceId: "", SubjectId: "", Instance: -1}, + LogId: "serviceLogID2", Till: timestamppb.New(currentTime), + }, }, - }}, + }, }, { sendLogRequest: cloudprotocol.RequestLog{ @@ -781,12 +736,14 @@ func TestLogMessages(t *testing.T) { From: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_InstanceCrashLogRequest{ - InstanceCrashLogRequest: &pb.InstanceCrashLogRequest{ - Instance: &pb.InstanceIdent{ServiceId: "ser1", SubjectId: "s1", Instance: -1}, - LogId: "serviceLogID1", From: timestamppb.New(currentTime), + expectedLogRequest: &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_InstanceCrashLogRequest{ + InstanceCrashLogRequest: &pbsm.InstanceCrashLogRequest{ + InstanceFilter: &pbsm.InstanceFilter{ServiceId: "ser1", SubjectId: "s1", Instance: -1}, + LogId: "serviceLogID1", From: timestamppb.New(currentTime), + }, }, - }}, + }, }, { sendLogRequest: cloudprotocol.RequestLog{ @@ -797,12 +754,14 @@ func TestLogMessages(t *testing.T) { Till: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_InstanceCrashLogRequest{ - InstanceCrashLogRequest: &pb.InstanceCrashLogRequest{ - Instance: &pb.InstanceIdent{ServiceId: "ser2", SubjectId: "", Instance: -1}, - LogId: "serviceLogID1", Till: timestamppb.New(currentTime), + expectedLogRequest: &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_InstanceCrashLogRequest{ + InstanceCrashLogRequest: &pbsm.InstanceCrashLogRequest{ + InstanceFilter: &pbsm.InstanceFilter{ServiceId: "ser2", SubjectId: "", Instance: -1}, + LogId: "serviceLogID1", Till: timestamppb.New(currentTime), + }, }, - }}, + }, }, { sendLogRequest: cloudprotocol.RequestLog{ @@ -813,12 +772,14 @@ func TestLogMessages(t *testing.T) { Till: ¤tTime, }, }, - expectedLogRequest: &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_InstanceCrashLogRequest{ - InstanceCrashLogRequest: &pb.InstanceCrashLogRequest{ - Instance: &pb.InstanceIdent{ServiceId: "", SubjectId: "", Instance: -1}, - LogId: "serviceLogID2", Till: timestamppb.New(currentTime), + expectedLogRequest: &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_InstanceCrashLogRequest{ + InstanceCrashLogRequest: &pbsm.InstanceCrashLogRequest{ + InstanceFilter: &pbsm.InstanceFilter{ServiceId: "", SubjectId: "", Instance: -1}, + LogId: "serviceLogID2", Till: timestamppb.New(currentTime), + }, }, - }}, + }, }, } @@ -839,9 +800,12 @@ func TestLogMessages(t *testing.T) { }, } - smClient.sendMessageChannel <- &pb.SMOutgoingMessages{ - SMOutgoingMessage: &pb.SMOutgoingMessages_Log{ - Log: &pb.LogData{LogId: "log0", PartCount: 2, Part: 1, Data: []byte("this is log"), Error: "this is error"}, + smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_Log{ + Log: &pbsm.LogData{ + LogId: "log0", PartCount: 2, Part: 1, Data: []byte("this is log"), + Error: &pbcommon.ErrorInfo{Message: "this is error"}, + }, }, } @@ -853,49 +817,48 @@ func TestLogMessages(t *testing.T) { func TestOverrideEnvVars(t *testing.T) { var ( nodeID = "mainSM" + nodeType = "mainSMType" messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } - currentTime = time.Now().UTC() - envVars = cloudprotocol.OverrideEnvVars{ - OverrideEnvVars: []cloudprotocol.EnvVarsInstanceInfo{ + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + currentTime = time.Now().UTC() + envVars = cloudprotocol.OverrideEnvVars{ + Items: []cloudprotocol.EnvVarsInstanceInfo{ { InstanceFilter: cloudprotocol.NewInstanceFilter("service0", "subject0", -1), - EnvVars: []cloudprotocol.EnvVarInfo{ - {ID: "id0", Variable: "var0", TTL: ¤tTime}, + Variables: []cloudprotocol.EnvVarInfo{ + {Name: "var0", Value: "val0", TTL: ¤tTime}, }, }, }, } - expectedPbEnvVarRequest = &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_OverrideEnvVars{ - OverrideEnvVars: &pb.OverrideEnvVars{ - EnvVars: []*pb.OverrideInstanceEnvVar{{Instance: &pb.InstanceIdent{ - ServiceId: "service0", - SubjectId: "subject0", Instance: -1, - }, Vars: []*pb.EnvVarInfo{{VarId: "id0", Variable: "var0", Ttl: timestamppb.New(currentTime)}}}}, + expectedPbEnvVarRequest = &pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_OverrideEnvVars{ + OverrideEnvVars: &pbsm.OverrideEnvVars{ + EnvVars: []*pbsm.OverrideInstanceEnvVar{{InstanceFilter: &pbsm.InstanceFilter{ + ServiceId: "service0", + SubjectId: "subject0", Instance: -1, + }, Variables: []*pbsm.EnvVarInfo{{Name: "var0", Value: "val0", Ttl: timestamppb.New(currentTime)}}}}, + }, }, - }} - pbEnvVarStatus = &pb.SMOutgoingMessages{SMOutgoingMessage: &pb.SMOutgoingMessages_OverrideEnvVarStatus{ - OverrideEnvVarStatus: &pb.OverrideEnvVarStatus{EnvVarsStatus: []*pb.EnvVarInstanceStatus{ - {Instance: &pb.InstanceIdent{ + } + pbEnvVarStatus = &pbsm.SMOutgoingMessages{SMOutgoingMessage: &pbsm.SMOutgoingMessages_OverrideEnvVarStatus{ + OverrideEnvVarStatus: &pbsm.OverrideEnvVarStatus{EnvVarsStatus: []*pbsm.EnvVarInstanceStatus{ + {InstanceFilter: &pbsm.InstanceFilter{ ServiceId: "service0", SubjectId: "subject0", Instance: -1, - }, VarsStatus: []*pb.EnvVarStatus{{VarId: "id0", Error: "someError"}}}, + }, Statuses: []*pbsm.EnvVarStatus{{Name: "var0", Error: &pbcommon.ErrorInfo{ + Message: "someError", + }}}}, }}, }} expectedEnvVarStatus = cloudprotocol.OverrideEnvVarsStatus{ - OverrideEnvVarsStatus: []cloudprotocol.EnvVarsInstanceStatus{ + Statuses: []cloudprotocol.EnvVarsInstanceStatus{ { InstanceFilter: cloudprotocol.NewInstanceFilter("service0", "subject0", -1), - Statuses: []cloudprotocol.EnvVarStatus{{ID: "id0", Error: "someError"}}, + Statuses: []cloudprotocol.EnvVarStatus{{ + Name: "var0", + ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, + }}, }, }, } @@ -907,25 +870,21 @@ func TestOverrideEnvVars(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() - if err := waitMessage(controller.GetRunInstancesStatusChannel(), launcher.NodeRunInstanceStatus{ - NodeID: nodeID, Instances: make([]cloudprotocol.InstanceStatus, 0), + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{}, + }, }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { - t.Fatalf("Wait message error: %v", err) - } - if err = controller.OverrideEnvVars(nodeID, envVars); err != nil { t.Fatalf("Error sending override env vars: %v", err) } @@ -943,48 +902,44 @@ func TestOverrideEnvVars(t *testing.T) { func TestRunInstances(t *testing.T) { var ( - nodeID = "mainSM" - messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } - expectedRunInstances = &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_RunInstances{ - RunInstances: &pb.RunInstances{ - Services: []*pb.ServiceInfo{{ - Version: "1.1", + nodeID = "mainSM" + nodeType = "mainSMType" + messageSender = newTestMessageSender() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + expectedRunInstances = &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_RunInstances{ + RunInstances: &pbsm.RunInstances{ + Services: []*pbsm.ServiceInfo{{ + Version: "1.1.0", Url: "url1", ServiceId: "s1", ProviderId: "p1", Gid: 600, Sha256: []byte{0, 0, 0, byte(100)}, Size: uint64(500), }}, - Layers: []*pb.LayerInfo{ + Layers: []*pbsm.LayerInfo{ { - Version: "3", + Version: "3.0.0", Url: "url2", LayerId: "l1", Digest: "digest1", Sha256: []byte{0, 0, 0, byte(100)}, Size: uint64(500), }, }, - Instances: []*pb.InstanceInfo{ + Instances: []*pbsm.InstanceInfo{ { - Instance: &pb.InstanceIdent{ServiceId: "s1", SubjectId: "subj1", Instance: 1}, - NetworkParameters: &pb.NetworkParameters{Ip: "172.17.0.3", Subnet: "172.17.0.0/16", VlanId: 1}, - Uid: 500, Priority: 1, StoragePath: "storage1", StatePath: "state1", + Instance: &pbcommon.InstanceIdent{ + ServiceId: "s1", SubjectId: "subj1", Instance: 1, + }, + NetworkParameters: &pbsm.NetworkParameters{ + Ip: "172.17.0.3", Subnet: "172.17.0.0/16", VlanId: 1, + }, + Uid: 500, Priority: 1, StoragePath: "storage1", StatePath: "state1", }, }, }, }} sendServices = []aostypes.ServiceInfo{{ - Version: "1.1", + Version: "1.1.0", ServiceID: "s1", ProviderID: "p1", URL: "url1", GID: 600, Sha256: []byte{0, 0, 0, byte(100)}, Size: uint64(500), }} sendLayers = []aostypes.LayerInfo{{ - Version: "3.0", + Version: "3.0.0", URL: "url2", LayerID: "l1", Digest: "digest1", Sha256: []byte{0, 0, 0, byte(100)}, Size: uint64(500), }} @@ -1001,7 +956,7 @@ func TestRunInstances(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, &pbsm.RunInstancesStatus{}) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1009,14 +964,16 @@ func TestRunInstances(t *testing.T) { defer smClient.close() if err := waitMessage(controller.GetRunInstancesStatusChannel(), launcher.NodeRunInstanceStatus{ - NodeID: nodeID, Instances: make([]cloudprotocol.InstanceStatus, 0), + NodeID: nodeID, NodeType: nodeType, Instances: make([]cloudprotocol.InstanceStatus, 0), }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{}, + }, + }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } @@ -1032,17 +989,9 @@ func TestRunInstances(t *testing.T) { func TestUpdateNetwork(t *testing.T) { var ( nodeID = "mainSM" + nodeType = "mainSMType" messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} ) networkParameters := []aostypes.NetworkParameters{ @@ -1060,9 +1009,9 @@ func TestUpdateNetwork(t *testing.T) { }, } - expectedUpdatesNetwork := &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_UpdateNetworks{ - UpdateNetworks: &pb.UpdateNetworks{ - Networks: []*pb.NetworkParameters{ + expectedUpdatesNetwork := &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_UpdateNetworks{ + UpdateNetworks: &pbsm.UpdateNetworks{ + Networks: []*pbsm.NetworkParameters{ { Subnet: "172.17.0.0/16", Ip: "172.17.0.1", @@ -1085,25 +1034,21 @@ func TestUpdateNetwork(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() - if err := waitMessage(controller.GetRunInstancesStatusChannel(), launcher.NodeRunInstanceStatus{ - NodeID: nodeID, Instances: make([]cloudprotocol.InstanceStatus, 0), + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{}, + }, }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { - t.Fatalf("Wait message error: %v", err) - } - if err := controller.UpdateNetwork(nodeID, networkParameters); err != nil { t.Fatalf("Can't send run instances: %v", err) } @@ -1116,18 +1061,9 @@ func TestUpdateNetwork(t *testing.T) { func TestSyncClock(t *testing.T) { var ( nodeID = "mainSM" + nodeType = "mainSMType" messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} ) controller, err := smcontroller.New(&config, messageSender, nil, nil, nil, nil, true) @@ -1136,21 +1072,23 @@ func TestSyncClock(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{}, + }, + }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - smClient.sendMessageChannel <- &pb.SMOutgoingMessages{ - SMOutgoingMessage: &pb.SMOutgoingMessages_ClockSyncRequest{}, + smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_ClockSyncRequest{}, } select { @@ -1158,7 +1096,7 @@ func TestSyncClock(t *testing.T) { t.Fatalf("Wait message error: %v", err) case message := <-smClient.receivedMessagesChannel: - clockSync, ok := message.GetSMIncomingMessage().(*pb.SMIncomingMessages_ClockSync) + clockSync, ok := message.GetSMIncomingMessage().(*pbsm.SMIncomingMessages_ClockSync) if !ok { t.Fatalf("Incorrect message type: %v", message) } @@ -1169,66 +1107,62 @@ func TestSyncClock(t *testing.T) { } } -func TestGetNodeMonitoringData(t *testing.T) { +func TestGetAverageMonitoring(t *testing.T) { var ( - nodeID = "mainSM" - messageSender = newTestMessageSender() - nodeConfig = &pb.NodeConfiguration{ - NodeId: nodeID, RemoteNode: true, RunnerFeatures: []string{"runc"}, NumCpus: 1, - TotalRam: 100, Partitions: []*pb.Partition{{Name: "services", Types: []string{"t1"}, TotalSize: 50}}, - } - config = config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } + nodeID = "mainSM" + nodeType = "mainSMType" + messageSender = newTestMessageSender() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} testWaitChan = make(chan struct{}) currentTime = time.Now().UTC() - expectedMonitoring = cloudprotocol.NodeMonitoringData{ - NodeID: nodeID, - Timestamp: currentTime, - MonitoringData: cloudprotocol.MonitoringData{ + expectedMonitoring = aostypes.NodeMonitoring{ + NodeID: nodeID, + NodeData: aostypes.MonitoringData{ RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 50, - Disk: []cloudprotocol.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: currentTime, }, - ServiceInstances: []cloudprotocol.InstanceMonitoringData{ + InstancesData: []aostypes.InstanceMonitoring{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "s1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{ + MonitoringData: aostypes.MonitoringData{ RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 0, - Disk: []cloudprotocol.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: currentTime, }, }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "s1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{ + MonitoringData: aostypes.MonitoringData{ RAM: 20, CPU: 30, InTraffic: 50, OutTraffic: 10, - Disk: []cloudprotocol.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Disk: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Timestamp: currentTime, }, }, }, } - sendMonitoring = &pb.SMOutgoingMessages{SMOutgoingMessage: &pb.SMOutgoingMessages_NodeMonitoring{ - NodeMonitoring: &pb.NodeMonitoring{ - Timestamp: timestamppb.New(currentTime), - MonitoringData: &pb.MonitoringData{ + sendMonitoring = &pbsm.SMOutgoingMessages{SMOutgoingMessage: &pbsm.SMOutgoingMessages_AverageMonitoring{ + AverageMonitoring: &pbsm.AverageMonitoring{ + NodeMonitoring: &pbsm.MonitoringData{ Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 50, - Disk: []*pb.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: timestamppb.New(currentTime), }, - InstanceMonitoring: []*pb.InstanceMonitoring{ + InstancesMonitoring: []*pbsm.InstanceMonitoring{ { - Instance: &pb.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1}, - MonitoringData: &pb.MonitoringData{ + Instance: &pbcommon.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1}, + MonitoringData: &pbsm.MonitoringData{ Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 0, - Disk: []*pb.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, + Timestamp: timestamppb.New(currentTime), }, }, { - Instance: &pb.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1}, - MonitoringData: &pb.MonitoringData{ + Instance: &pbcommon.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1}, + MonitoringData: &pbsm.MonitoringData{ Ram: 20, Cpu: 30, InTraffic: 50, OutTraffic: 10, - Disk: []*pb.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Disk: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}}, + Timestamp: timestamppb.New(currentTime), }, }, }, @@ -1242,42 +1176,36 @@ func TestGetNodeMonitoringData(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, &pb.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() - if err := waitMessage(controller.GetRunInstancesStatusChannel(), launcher.NodeRunInstanceStatus{ - NodeID: nodeID, Instances: make([]cloudprotocol.InstanceStatus, 0), + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{}, + }, }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{}, - }}, messageTimeout); err != nil { - t.Fatalf("Wait message error: %v", err) - } - go func() { - data, err := controller.GetNodeMonitoringData(nodeID) + data, err := controller.GetAverageMonitoring(nodeID) if err != nil { - t.Errorf("Can't get node monitoring data: %v", err) + t.Errorf("Can't get average node monitoring: %v", err) } if !reflect.DeepEqual(data, expectedMonitoring) { - log.Debug("Exp: ", expectedMonitoring) - log.Debug("Rec: ", data) t.Errorf("Incorrect monitoring data") } testWaitChan <- struct{}{} }() - if err := smClient.waitMessage(&pb.SMIncomingMessages{ - SMIncomingMessage: &pb.SMIncomingMessages_GetNodeMonitoring{}, + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ + SMIncomingMessage: &pbsm.SMIncomingMessages_GetAverageMonitoring{}, }, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } @@ -1290,15 +1218,12 @@ func TestGetNodeMonitoringData(t *testing.T) { } func TestConnectionStatus(t *testing.T) { - nodeID := "mainSM" - messageSender := newTestMessageSender() - nodeConfig := &pb.NodeConfiguration{NodeId: nodeID} - config := config.Config{ - SMController: config.SMController{ - CMServerURL: cmServerURL, - NodeIDs: []string{nodeID}, - }, - } + var ( + nodeID = "mainSM" + nodeType = "mainSMType" + messageSender = newTestMessageSender() + config = config.Config{SMController: config.SMController{CMServerURL: cmServerURL}} + ) controller, err := smcontroller.New(&config, messageSender, nil, nil, nil, nil, true) if err != nil { @@ -1308,7 +1233,7 @@ func TestConnectionStatus(t *testing.T) { controller.CloudConnected() - smClient, err := newTestSMClient(cmServerURL, nodeConfig, nil) + smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1317,8 +1242,8 @@ func TestConnectionStatus(t *testing.T) { // check receive correct connection status on registration - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{CloudStatus: pb.ConnectionEnum_CONNECTED}, + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{CloudStatus: pbsm.ConnectionEnum_CONNECTED}, }}, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } @@ -1327,8 +1252,8 @@ func TestConnectionStatus(t *testing.T) { controller.CloudDisconnected() - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{CloudStatus: pb.ConnectionEnum_DISCONNECTED}, + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{CloudStatus: pbsm.ConnectionEnum_DISCONNECTED}, }}, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } @@ -1337,8 +1262,8 @@ func TestConnectionStatus(t *testing.T) { controller.CloudConnected() - if err := smClient.waitMessage(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_ConnectionStatus{ - ConnectionStatus: &pb.ConnectionStatus{CloudStatus: pb.ConnectionEnum_CONNECTED}, + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ + ConnectionStatus: &pbsm.ConnectionStatus{CloudStatus: pbsm.ConnectionEnum_CONNECTED}, }}, messageTimeout); err != nil { t.Fatalf("Wait message error: %v", err) } @@ -1357,11 +1282,11 @@ func (sender *testAlertSender) SendAlert(alert cloudprotocol.AlertItem) { } func newTestMonitoringSender() *testMonitoringSender { - return &testMonitoringSender{messageChannel: make(chan cloudprotocol.NodeMonitoringData, 1)} + return &testMonitoringSender{messageChannel: make(chan aostypes.NodeMonitoring, 1)} } -func (sender *testMonitoringSender) SendMonitoringData(monitoringData cloudprotocol.NodeMonitoringData) { - sender.messageChannel <- monitoringData +func (sender *testMonitoringSender) SendNodeMonitoring(monitoring aostypes.NodeMonitoring) { + sender.messageChannel <- monitoring } func newTestMessageSender() *testMessageSender { @@ -1407,11 +1332,11 @@ func waitMessage[T any](messageChannel <-chan T, expectedMsg interface{}, timeou } func newTestSMClient( - url string, config *pb.NodeConfiguration, runStatus *pb.RunInstancesStatus, + url string, nodeID, nodeType string, runStatus *pbsm.RunInstancesStatus, ) (client *testSMClient, err error) { client = &testSMClient{ - sendMessageChannel: make(chan *pb.SMOutgoingMessages, 10), - receivedMessagesChannel: make(chan *pb.SMIncomingMessages, 10), + sendMessageChannel: make(chan *pbsm.SMOutgoingMessages, 10), + receivedMessagesChannel: make(chan *pbsm.SMIncomingMessages, 10), } ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) @@ -1422,23 +1347,25 @@ func newTestSMClient( return nil, aoserrors.Wrap(err) } - client.pbClient = pb.NewSMServiceClient(client.connection) + client.pbClient = pbsm.NewSMServiceClient(client.connection) - if client.stream, err = pb.NewSMServiceClient(client.connection).RegisterSM(context.Background()); err != nil { + if client.stream, err = pbsm.NewSMServiceClient(client.connection).RegisterSM(context.Background()); err != nil { return nil, aoserrors.Wrap(err) } if err := client.stream.Send( - &pb.SMOutgoingMessages{ - SMOutgoingMessage: &pb.SMOutgoingMessages_NodeConfiguration{NodeConfiguration: config}, + &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_RegisterSm{RegisterSm: &pbsm.RegisterSM{ + NodeId: nodeID, NodeType: nodeType, + }}, }); err != nil { return nil, aoserrors.Wrap(err) } if runStatus != nil { if err := client.stream.Send( - &pb.SMOutgoingMessages{ - SMOutgoingMessage: &pb.SMOutgoingMessages_RunInstancesStatus{RunInstancesStatus: runStatus}, + &pbsm.SMOutgoingMessages{ + SMOutgoingMessage: &pbsm.SMOutgoingMessages_RunInstancesStatus{RunInstancesStatus: runStatus}, }); err != nil { return nil, aoserrors.Wrap(err) } @@ -1493,7 +1420,7 @@ func (client *testSMClient) processSendMessages(ctx context.Context) { } } -func (client *testSMClient) waitMessage(expectedMsg *pb.SMIncomingMessages, timeout time.Duration) error { +func (client *testSMClient) waitMessage(expectedMsg *pbsm.SMIncomingMessages, timeout time.Duration) error { select { case <-time.After(timeout): return aoserrors.New("wait message timeout") diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 7920117a..5f9de20f 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -20,8 +20,6 @@ package smcontroller import ( "context" "encoding/json" - "errors" - "io" "reflect" "time" @@ -33,8 +31,6 @@ import ( "github.com/aosedge/aos_common/utils/pbconvert" "github.com/aosedge/aos_common/utils/syncstream" log "github.com/sirupsen/logrus" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" "github.com/aosedge/aos_communicationmanager/launcher" @@ -56,7 +52,8 @@ type smHandler struct { alertSender AlertSender monitoringSender MonitoringSender syncstream *syncstream.SyncStream - config launcher.NodeInfo + nodeID string + nodeType string runStatusCh chan<- launcher.NodeRunInstanceStatus updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus systemLimitAlertCh chan<- cloudprotocol.SystemQuotaAlert @@ -67,18 +64,19 @@ type smHandler struct { **********************************************************************************************************************/ func newSMHandler( - stream pb.SMService_RegisterSMServer, messageSender MessageSender, alertSender AlertSender, - monitoringSender MonitoringSender, config launcher.NodeInfo, - runStatusCh chan<- launcher.NodeRunInstanceStatus, updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus, + nodeID, nodeType string, stream pb.SMService_RegisterSMServer, messageSender MessageSender, alertSender AlertSender, + monitoringSender MonitoringSender, runStatusCh chan<- launcher.NodeRunInstanceStatus, + updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus, systemLimitAlertCh chan<- cloudprotocol.SystemQuotaAlert, ) (*smHandler, error) { handler := smHandler{ + nodeID: nodeID, + nodeType: nodeType, stream: stream, messageSender: messageSender, alertSender: alertSender, monitoringSender: monitoringSender, syncstream: syncstream.New(), - config: config, runStatusCh: runStatusCh, updateInstanceStatusCh: updateInstanceStatusCh, systemLimitAlertCh: systemLimitAlertCh, @@ -87,69 +85,69 @@ func newSMHandler( return &handler, nil } -func (handler *smHandler) getUnitConfigState() (vendorVersion string, err error) { +func (handler *smHandler) getNodeConfigStatus() (version string, err error) { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() status, err := handler.syncstream.Send( - ctx, handler.sendGetUnitConfigStatus, reflect.TypeOf(&pb.SMOutgoingMessages_UnitConfigStatus{})) + ctx, handler.sendGetUnitConfigStatus, reflect.TypeOf(&pb.SMOutgoingMessages_NodeConfigStatus{})) if err != nil { - return vendorVersion, aoserrors.Wrap(err) + return "", aoserrors.Wrap(err) } - pbStatus, ok := status.(*pb.SMOutgoingMessages_UnitConfigStatus) + pbStatus, ok := status.(*pb.SMOutgoingMessages_NodeConfigStatus) if !ok { return "", aoserrors.New("incorrect type") } - if pbStatus.UnitConfigStatus.GetError().GetMessage() != "" { - return vendorVersion, aoserrors.New(pbStatus.UnitConfigStatus.GetError().GetMessage()) + if pbStatus.NodeConfigStatus.GetError().GetMessage() != "" { + return "", aoserrors.New(pbStatus.NodeConfigStatus.GetError().GetMessage()) } - return pbStatus.UnitConfigStatus.GetVersion(), nil + return pbStatus.NodeConfigStatus.GetVersion(), nil } -func (handler *smHandler) checkUnitConfigState(cfg cloudprotocol.NodeConfig, vendorVersion string) error { +func (handler *smHandler) checkNodeConfig(unitConfig cloudprotocol.NodeConfig, version string) error { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() status, err := handler.syncstream.Send(ctx, func() error { - return handler.sendCheckUnitConfig(cfg, vendorVersion) - }, reflect.TypeOf(&pb.SMOutgoingMessages_UnitConfigStatus{})) + return handler.sendCheckNodeConfig(unitConfig, version) + }, reflect.TypeOf(&pb.SMOutgoingMessages_NodeConfigStatus{})) if err != nil { return aoserrors.Wrap(err) } - pbStatus, ok := status.(*pb.SMOutgoingMessages_UnitConfigStatus) + pbStatus, ok := status.(*pb.SMOutgoingMessages_NodeConfigStatus) if !ok { return aoserrors.New("incorrect type") } - if pbStatus.UnitConfigStatus.GetError().GetMessage() != "" { - return aoserrors.New(pbStatus.UnitConfigStatus.GetError().GetMessage()) + if pbStatus.NodeConfigStatus.GetError() != nil { + return aoserrors.New(pbStatus.NodeConfigStatus.GetError().GetMessage()) } return nil } -func (handler *smHandler) setUnitConfig(cfg cloudprotocol.NodeConfig, vendorVersion string) error { +func (handler *smHandler) setNodeConfig(cfg cloudprotocol.NodeConfig, version string) error { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() status, err := handler.syncstream.Send(ctx, func() error { - return handler.sendSetUnitConfig(cfg, vendorVersion) - }, reflect.TypeOf(&pb.SMOutgoingMessages_UnitConfigStatus{})) + return handler.sendSetNodeConfig(cfg, version) + }, reflect.TypeOf(&pb.SMOutgoingMessages_NodeConfigStatus{})) if err != nil { return aoserrors.Wrap(err) } - pbStatus, ok := status.(*pb.SMOutgoingMessages_UnitConfigStatus) + pbStatus, ok := status.(*pb.SMOutgoingMessages_NodeConfigStatus) if !ok { return aoserrors.New("incorrect type") } - if pbStatus.UnitConfigStatus.GetError().GetMessage() != "" { - return aoserrors.New(pbStatus.UnitConfigStatus.GetError().GetMessage()) + if pbStatus.NodeConfigStatus.GetError() != nil { + return aoserrors.New(pbStatus.NodeConfigStatus.GetError().GetMessage()) } return nil @@ -157,7 +155,7 @@ func (handler *smHandler) setUnitConfig(cfg cloudprotocol.NodeConfig, vendorVers func (handler *smHandler) updateNetworks(networkParameters []aostypes.NetworkParameters) error { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, }).Debug("CM update networks") pbNetworkParameters := make([]*pb.NetworkParameters, len(networkParameters)) @@ -186,7 +184,7 @@ func (handler *smHandler) runInstances( services []aostypes.ServiceInfo, layers []aostypes.LayerInfo, instances []aostypes.InstanceInfo, forceRestart bool, ) error { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, }).Debug("SM run instances") pbRunInstances := &pb.RunInstances{ @@ -241,7 +239,7 @@ func (handler *smHandler) runInstances( func (handler *smHandler) getSystemLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, "logID": logRequest.LogID, "from": logRequest.Filter.From, "till": logRequest.Filter.Till, @@ -269,7 +267,7 @@ func (handler *smHandler) getSystemLog(logRequest cloudprotocol.RequestLog) (err //nolint:dupl func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, "logID": logRequest.LogID, "serviceID": logRequest.Filter.ServiceID, "from": logRequest.Filter.From, @@ -300,7 +298,7 @@ func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (e //nolint:dupl func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, "logID": logRequest.LogID, "serviceID": logRequest.Filter.ServiceID, "from": logRequest.Filter.From, @@ -331,24 +329,24 @@ func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLo } func (handler *smHandler) overrideEnvVars(envVars cloudprotocol.OverrideEnvVars) (err error) { - log.WithFields(log.Fields{"nodeID": handler.config.NodeID}).Debug("Override env vars SM ") + log.WithFields(log.Fields{"nodeID": handler.nodeID}).Debug("Override env vars SM ") - request := &pb.OverrideEnvVars{EnvVars: make([]*pb.OverrideInstanceEnvVar, len(envVars.OverrideEnvVars))} + request := &pb.OverrideEnvVars{EnvVars: make([]*pb.OverrideInstanceEnvVar, len(envVars.Items))} - for i, item := range envVars.OverrideEnvVars { + for i, item := range envVars.Items { requestItem := &pb.OverrideInstanceEnvVar{ InstanceFilter: pbconvert.InstanceFilterToPB(item.InstanceFilter), - Vars: make([]*pb.EnvVarInfo, len(item.EnvVars)), + Variables: make([]*pb.EnvVarInfo, len(item.Variables)), } - for j, envVar := range item.EnvVars { - requestVar := &pb.EnvVarInfo{VarId: envVar.ID, Variable: envVar.Variable} + for j, envVar := range item.Variables { + requestVar := &pb.EnvVarInfo{Name: envVar.Name, Value: envVar.Value} if envVar.TTL != nil { requestVar.Ttl = timestamppb.New(*envVar.TTL) } - requestItem.Vars[j] = requestVar + requestItem.Variables[j] = requestVar } request.EnvVars[i] = requestItem @@ -363,95 +361,86 @@ func (handler *smHandler) overrideEnvVars(envVars cloudprotocol.OverrideEnvVars) return nil } -func (handler *smHandler) getNodeMonitoring() (data cloudprotocol.NodeMonitoringData, err error) { +func (handler *smHandler) getAverageMonitoring() (monitoring aostypes.NodeMonitoring, err error) { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() status, err := handler.syncstream.Send( - ctx, handler.sendGetNodeMonitoring, reflect.TypeOf(&pb.SMOutgoingMessages_NodeMonitoring{})) + ctx, handler.sendGetAverageMonitoring, reflect.TypeOf(&pb.SMOutgoingMessages_AverageMonitoring{})) if err != nil { - return data, aoserrors.Wrap(err) + return monitoring, aoserrors.Wrap(err) } - pbMonitoring, ok := status.(*pb.SMOutgoingMessages_NodeMonitoring) + pbMonitoring, ok := status.(*pb.SMOutgoingMessages_AverageMonitoring) if !ok { - return data, aoserrors.New("incorrect type") + return monitoring, aoserrors.New("incorrect type") } - data = nodeMonitoringFromPb(pbMonitoring.NodeMonitoring) - data.NodeID = handler.config.NodeID + monitoring = averageMonitoringFromPB(pbMonitoring.AverageMonitoring) + monitoring.NodeID = handler.nodeID - return data, nil + return monitoring, nil } /*********************************************************************************************************************** * Private **********************************************************************************************************************/ -func (handler *smHandler) processSMMessages() { - for { - message, err := handler.stream.Recv() - if err != nil { - if !errors.Is(err, io.EOF) && codes.Canceled != status.Code(err) { - log.Errorf("Close SM client connection error: %v", err) - } - - return - } - - if handler.syncstream.ProcessMessages(message.GetSMOutgoingMessage()) { - continue - } +func (handler *smHandler) processSMMessages(message *pb.SMOutgoingMessages) { + if handler.syncstream.ProcessMessages(message.GetSMOutgoingMessage()) { + return + } - switch data := message.GetSMOutgoingMessage().(type) { - case *pb.SMOutgoingMessages_NodeMonitoring: - handler.processMonitoring(data.NodeMonitoring) + switch data := message.GetSMOutgoingMessage().(type) { + case *pb.SMOutgoingMessages_InstantMonitoring: + handler.processInstantMonitoring(data.InstantMonitoring) - case *pb.SMOutgoingMessages_Alert: - handler.processAlert(data.Alert) + case *pb.SMOutgoingMessages_Alert: + handler.processAlert(data.Alert) - case *pb.SMOutgoingMessages_NodeConfiguration: - log.Errorf("Unexpected node configuration msg from %s", data.NodeConfiguration.GetNodeId()) + case *pb.SMOutgoingMessages_RegisterSm: + log.Errorf("Unexpected register SM message from %s", data.RegisterSm.GetNodeId()) - case *pb.SMOutgoingMessages_RunInstancesStatus: - handler.processRunInstanceStatus(data.RunInstancesStatus) + case *pb.SMOutgoingMessages_RunInstancesStatus: + handler.processRunInstanceStatus(data.RunInstancesStatus) - case *pb.SMOutgoingMessages_UpdateInstancesStatus: - handler.processUpdateInstancesStatus(data.UpdateInstancesStatus) + case *pb.SMOutgoingMessages_UpdateInstancesStatus: + handler.processUpdateInstancesStatus(data.UpdateInstancesStatus) - case *pb.SMOutgoingMessages_Log: - handler.processLogMessage(data.Log) + case *pb.SMOutgoingMessages_Log: + handler.processLogMessage(data.Log) - case *pb.SMOutgoingMessages_OverrideEnvVarStatus: - handler.processOverrideEnvVarsStatus(data.OverrideEnvVarStatus) + case *pb.SMOutgoingMessages_OverrideEnvVarStatus: + handler.processOverrideEnvVarsStatus(data.OverrideEnvVarStatus) - case *pb.SMOutgoingMessages_ClockSyncRequest: - handler.sendClockSyncResponse() + case *pb.SMOutgoingMessages_ClockSyncRequest: + handler.sendClockSyncResponse() - default: - log.Warn("Received unprocessed message") - } + default: + log.Warnf("Received unprocessed message: %v", data) } } func (handler *smHandler) processRunInstanceStatus(status *pb.RunInstancesStatus) { runStatus := launcher.NodeRunInstanceStatus{ - NodeID: handler.config.NodeID, NodeType: handler.config.NodeType, - Instances: instancesStatusFromPB(status.GetInstances(), handler.config.NodeID), + NodeID: handler.nodeID, + NodeType: handler.nodeType, + Instances: instancesStatusFromPB(status.GetInstances(), + handler.nodeID), } handler.runStatusCh <- runStatus } func (handler *smHandler) processUpdateInstancesStatus(data *pb.UpdateInstancesStatus) { - log.WithFields(log.Fields{"nodeID": handler.config.NodeID}).Debug("Receive SM update instances status") + log.WithFields(log.Fields{"nodeID": handler.nodeID}).Debug("Receive SM update instances status") - handler.updateInstanceStatusCh <- instancesStatusFromPB(data.GetInstances(), handler.config.NodeID) + handler.updateInstanceStatusCh <- instancesStatusFromPB(data.GetInstances(), handler.nodeID) } func (handler *smHandler) processAlert(alert *pb.Alert) { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, "tag": alert.GetTag(), }).Debug("Receive SM alert") @@ -464,20 +453,20 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { case *pb.Alert_SystemAlert: alertItem.Payload = cloudprotocol.SystemAlert{ Message: data.SystemAlert.GetMessage(), - NodeID: handler.config.NodeID, + NodeID: handler.nodeID, } case *pb.Alert_CoreAlert: alertItem.Payload = cloudprotocol.CoreAlert{ CoreComponent: data.CoreAlert.GetCoreComponent(), Message: data.CoreAlert.GetMessage(), - NodeID: handler.config.NodeID, + NodeID: handler.nodeID, } case *pb.Alert_ResourceValidateAlert: resourceValidate := cloudprotocol.ResourceValidateAlert{ Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), - NodeID: handler.config.NodeID, + NodeID: handler.nodeID, Name: data.ResourceValidateAlert.Name, } @@ -492,14 +481,14 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { InstanceIdent: pbconvert.InstanceIdentFromPB(data.DeviceAllocateAlert.GetInstance()), Device: data.DeviceAllocateAlert.GetDevice(), Message: data.DeviceAllocateAlert.GetMessage(), - NodeID: handler.config.NodeID, + NodeID: handler.nodeID, } case *pb.Alert_SystemQuotaAlert: alertPayload := cloudprotocol.SystemQuotaAlert{ Parameter: data.SystemQuotaAlert.GetParameter(), Value: data.SystemQuotaAlert.GetValue(), - NodeID: handler.config.NodeID, + NodeID: handler.nodeID, } if alertPayload.Parameter == "cpu" || alertPayload.Parameter == "ram" { @@ -531,14 +520,14 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { func (handler *smHandler) processLogMessage(data *pb.LogData) { log.WithFields(log.Fields{ - "nodeID": handler.config.NodeID, + "nodeID": handler.nodeID, "logID": data.GetLogId(), "part": data.GetPart(), "partCount": data.GetPartCount(), }).Debug("Receive SM push log") if err := handler.messageSender.SendLog(cloudprotocol.PushLog{ - NodeID: handler.config.NodeID, + NodeID: handler.nodeID, LogID: data.GetLogId(), PartsCount: data.GetPartCount(), Part: data.GetPart(), @@ -553,38 +542,38 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { } } -func (handler *smHandler) processMonitoring(data *pb.NodeMonitoring) { - log.WithFields(log.Fields{"nodeID": handler.config.NodeID}).Debug("Receive SM monitoring") +func (handler *smHandler) processInstantMonitoring(instantMonitoring *pb.InstantMonitoring) { + log.WithFields(log.Fields{"nodeID": handler.nodeID}).Debug("Receive SM monitoring") - nodeMonitoring := nodeMonitoringFromPb(data) + nodeMonitoring := instantMonitoringFromPB(instantMonitoring) - nodeMonitoring.NodeID = handler.config.NodeID + nodeMonitoring.NodeID = handler.nodeID - handler.monitoringSender.SendMonitoringData(nodeMonitoring) + handler.monitoringSender.SendNodeMonitoring(nodeMonitoring) } func (handler *smHandler) processOverrideEnvVarsStatus(envVarStatus *pb.OverrideEnvVarStatus) { - response := make([]cloudprotocol.EnvVarsInstanceStatus, len(envVarStatus.GetEnvVarsStatus())) + statuses := make([]cloudprotocol.EnvVarsInstanceStatus, len(envVarStatus.GetEnvVarsStatus())) for i, item := range envVarStatus.GetEnvVarsStatus() { - responseItem := cloudprotocol.EnvVarsInstanceStatus{ + statusItem := cloudprotocol.EnvVarsInstanceStatus{ InstanceFilter: cloudprotocol.NewInstanceFilter(item.GetInstanceFilter().GetServiceId(), item.GetInstanceFilter().GetSubjectId(), item.GetInstanceFilter().GetInstance()), - Statuses: make([]cloudprotocol.EnvVarStatus, len(item.GetVarsStatus())), + Statuses: make([]cloudprotocol.EnvVarStatus, len(item.GetStatuses())), } - for j, varStatus := range item.GetVarsStatus() { - responseItem.Statuses[j] = cloudprotocol.EnvVarStatus{ - ID: varStatus.GetVarId(), + for j, varStatus := range item.GetStatuses() { + statusItem.Statuses[j] = cloudprotocol.EnvVarStatus{ + Name: varStatus.GetName(), ErrorInfo: pbconvert.ErrorInfoFromPB(varStatus.GetError()), } } - response[i] = responseItem + statuses[i] = statusItem } if err := handler.messageSender.SendOverrideEnvVarsStatus( - cloudprotocol.OverrideEnvVarsStatus{OverrideEnvVarsStatus: response}); err != nil { + cloudprotocol.OverrideEnvVarsStatus{Statuses: statuses}); err != nil { log.Errorf("Can't send override env ears status: %v", err.Error()) } } @@ -604,21 +593,21 @@ func (handler *smHandler) sendClockSyncResponse() { func (handler *smHandler) sendGetUnitConfigStatus() error { if err := handler.stream.Send( - &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_GetUnitConfigStatus{}}); err != nil { + &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_GetNodeConfigStatus{}}); err != nil { return aoserrors.Wrap(err) } return nil } -func (handler *smHandler) sendCheckUnitConfig(cfg cloudprotocol.NodeConfig, vendorVersion string) error { - configJSON, err := json.Marshal(cfg) +func (handler *smHandler) sendCheckNodeConfig(nodeConfig cloudprotocol.NodeConfig, version string) error { + configJSON, err := json.Marshal(nodeConfig) if err != nil { return aoserrors.Wrap(err) } - if err := handler.stream.Send(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_CheckUnitConfig{ - CheckUnitConfig: &pb.CheckUnitConfig{UnitConfig: string(configJSON), Version: vendorVersion}, + if err := handler.stream.Send(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_CheckNodeConfig{ + CheckNodeConfig: &pb.CheckNodeConfig{NodeConfig: string(configJSON), Version: version}, }}); err != nil { return aoserrors.Wrap(err) } @@ -626,14 +615,14 @@ func (handler *smHandler) sendCheckUnitConfig(cfg cloudprotocol.NodeConfig, vend return nil } -func (handler *smHandler) sendSetUnitConfig(cfg cloudprotocol.NodeConfig, vendorVersion string) error { - configJSON, err := json.Marshal(cfg) +func (handler *smHandler) sendSetNodeConfig(nodeConfig cloudprotocol.NodeConfig, version string) error { + configJSON, err := json.Marshal(nodeConfig) if err != nil { return aoserrors.Wrap(err) } - if err := handler.stream.Send(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SetUnitConfig{ - SetUnitConfig: &pb.SetUnitConfig{UnitConfig: string(configJSON), Version: vendorVersion}, + if err := handler.stream.Send(&pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_SetNodeConfig{ + SetNodeConfig: &pb.SetNodeConfig{NodeConfig: string(configJSON), Version: version}, }}); err != nil { return aoserrors.Wrap(err) } @@ -641,9 +630,9 @@ func (handler *smHandler) sendSetUnitConfig(cfg cloudprotocol.NodeConfig, vendor return nil } -func (handler *smHandler) sendGetNodeMonitoring() error { +func (handler *smHandler) sendGetAverageMonitoring() error { if err := handler.stream.Send( - &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_GetNodeMonitoring{}}); err != nil { + &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_GetAverageMonitoring{}}); err != nil { return aoserrors.Wrap(err) } @@ -693,34 +682,50 @@ func errorInfoFromPB(pbError *common.ErrorInfo) *cloudprotocol.ErrorInfo { } } -func nodeMonitoringFromPb(pbNodeMonitoring *pb.NodeMonitoring) cloudprotocol.NodeMonitoringData { - nodeMonitoringData := cloudprotocol.NodeMonitoringData{ - Timestamp: pbNodeMonitoring.GetTimestamp().AsTime(), - MonitoringData: monitoringDataFromPb(pbNodeMonitoring.GetMonitoringData()), - ServiceInstances: make([]cloudprotocol.InstanceMonitoringData, len(pbNodeMonitoring.GetInstanceMonitoring())), +func averageMonitoringFromPB(averageMonitoring *pb.AverageMonitoring) aostypes.NodeMonitoring { + nodeMonitoringData := aostypes.NodeMonitoring{ + NodeData: monitoringDataFromPB(averageMonitoring.GetNodeMonitoring()), + InstancesData: make([]aostypes.InstanceMonitoring, len(averageMonitoring.GetInstancesMonitoring())), + } + + for i, pbInstanceMonitoring := range averageMonitoring.GetInstancesMonitoring() { + nodeMonitoringData.InstancesData[i] = aostypes.InstanceMonitoring{ + InstanceIdent: pbconvert.InstanceIdentFromPB(pbInstanceMonitoring.GetInstance()), + MonitoringData: monitoringDataFromPB(pbInstanceMonitoring.GetMonitoringData()), + } + } + + return nodeMonitoringData +} + +func instantMonitoringFromPB(instantMonitoring *pb.InstantMonitoring) aostypes.NodeMonitoring { + nodeMonitoringData := aostypes.NodeMonitoring{ + NodeData: monitoringDataFromPB(instantMonitoring.GetNodeMonitoring()), + InstancesData: make([]aostypes.InstanceMonitoring, len(instantMonitoring.GetInstancesMonitoring())), } - for i, pbInstanceMonitoring := range pbNodeMonitoring.GetInstanceMonitoring() { - nodeMonitoringData.ServiceInstances[i] = cloudprotocol.InstanceMonitoringData{ - InstanceIdent: pbconvert.NewInstanceIdentFromPB(pbInstanceMonitoring.GetInstance()), - MonitoringData: monitoringDataFromPb(pbInstanceMonitoring.GetMonitoringData()), + for i, pbInstanceMonitoring := range instantMonitoring.GetInstancesMonitoring() { + nodeMonitoringData.InstancesData[i] = aostypes.InstanceMonitoring{ + InstanceIdent: pbconvert.InstanceIdentFromPB(pbInstanceMonitoring.GetInstance()), + MonitoringData: monitoringDataFromPB(pbInstanceMonitoring.GetMonitoringData()), } } return nodeMonitoringData } -func monitoringDataFromPb(pbMonitoring *pb.MonitoringData) cloudprotocol.MonitoringData { - monitoringData := cloudprotocol.MonitoringData{ +func monitoringDataFromPB(pbMonitoring *pb.MonitoringData) aostypes.MonitoringData { + monitoringData := aostypes.MonitoringData{ + Timestamp: pbMonitoring.GetTimestamp().AsTime(), RAM: pbMonitoring.GetRam(), CPU: pbMonitoring.GetCpu(), InTraffic: pbMonitoring.GetInTraffic(), OutTraffic: pbMonitoring.GetOutTraffic(), - Disk: make([]cloudprotocol.PartitionUsage, len(pbMonitoring.GetDisk())), + Disk: make([]aostypes.PartitionUsage, len(pbMonitoring.GetDisk())), } for i, pbData := range pbMonitoring.GetDisk() { - monitoringData.Disk[i] = cloudprotocol.PartitionUsage{Name: pbData.GetName(), UsedSize: pbData.GetUsedSize()} + monitoringData.Disk[i] = aostypes.PartitionUsage{Name: pbData.GetName(), UsedSize: pbData.GetUsedSize()} } return monitoringData From fb274658eaa64447d252d5cb4b205a4f881dea58 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 8 Jul 2024 20:59:26 +0300 Subject: [PATCH 033/146] [unitstatushandler] Refactor items status update Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 148 ++++++++++++------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index d99a4c6c..1ec364c2 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -122,14 +122,8 @@ type Instance struct { statusMutex sync.Mutex - statusTimer *time.Timer - unitSubjects []string - unitConfigStatus itemStatus - componentStatuses map[string]*itemStatus - layerStatuses map[string]*itemStatus - serviceStatuses map[string]*itemStatus - instanceStatuses []cloudprotocol.InstanceStatus - + unitStatus unitStatus + statusTimer *time.Timer sendStatusPeriod time.Duration firmwareManager *firmwareManager @@ -139,6 +133,15 @@ type Instance struct { isConnected int32 } +type unitStatus struct { + subjects []string + unitConfig itemStatus + components map[string]*itemStatus + layers map[string]*itemStatus + services map[string]*itemStatus + instances []cloudprotocol.InstanceStatus +} + type statusDescriptor struct { amqpStatus interface{} } @@ -168,9 +171,9 @@ func New( } // Initialize maps of statuses for avoiding situation of adding values to uninitialized map on go routine - instance.componentStatuses = make(map[string]*itemStatus) - instance.layerStatuses = make(map[string]*itemStatus) - instance.serviceStatuses = make(map[string]*itemStatus) + instance.unitStatus.components = make(map[string]*itemStatus) + instance.unitStatus.layers = make(map[string]*itemStatus) + instance.unitStatus.services = make(map[string]*itemStatus) groupDownloader := newGroupDownloader(downloader) @@ -240,8 +243,8 @@ func (instance *Instance) ProcessRunStatus(status RunInstancesStatus) error { return aoserrors.Wrap(err) } - instance.unitSubjects = status.UnitSubjects - instance.instanceStatuses = status.Instances + instance.unitStatus.subjects = status.UnitSubjects + instance.unitStatus.instances = status.Instances instance.softwareManager.processRunStatus(status) instance.sendCurrentStatus() @@ -334,10 +337,10 @@ func (instance *Instance) CloudDisconnected() { **********************************************************************************************************************/ func (instance *Instance) initCurrentStatus() error { - instance.unitConfigStatus = nil - instance.componentStatuses = make(map[string]*itemStatus) - instance.serviceStatuses = make(map[string]*itemStatus) - instance.layerStatuses = make(map[string]*itemStatus) + instance.unitStatus.unitConfig = nil + instance.unitStatus.components = make(map[string]*itemStatus) + instance.unitStatus.services = make(map[string]*itemStatus) + instance.unitStatus.layers = make(map[string]*itemStatus) // Get initial unit config info @@ -382,8 +385,8 @@ func (instance *Instance) initCurrentStatus() error { } for _, status := range serviceStatuses { - if _, ok := instance.serviceStatuses[status.ServiceID]; !ok { - instance.serviceStatuses[status.ServiceID] = &itemStatus{} + if _, ok := instance.unitStatus.services[status.ServiceID]; !ok { + instance.unitStatus.services[status.ServiceID] = &itemStatus{} } log.WithFields(log.Fields{ @@ -402,8 +405,8 @@ func (instance *Instance) initCurrentStatus() error { } for _, status := range layerStatuses { - if _, ok := instance.layerStatuses[status.Digest]; !ok { - instance.layerStatuses[status.Digest] = &itemStatus{} + if _, ok := instance.unitStatus.layers[status.Digest]; !ok { + instance.unitStatus.layers[status.Digest] = &itemStatus{} } log.WithFields(log.Fields{ @@ -460,77 +463,74 @@ func (descriptor *statusDescriptor) getVersion() (version string) { } } -func (instance *Instance) updateUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) { +func (instance *Instance) updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "status": unitConfigInfo.Status, - "version": unitConfigInfo.Version, - "error": unitConfigInfo.ErrorInfo, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Update unit config status") - instance.processUnitConfigStatus(unitConfigInfo) + instance.processUnitConfigStatus(status) instance.statusChanged() } -func (instance *Instance) processUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) { - instance.updateStatus(&instance.unitConfigStatus, statusDescriptor{&unitConfigInfo}) +func (instance *Instance) processUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { + instance.updateStatus(&instance.unitStatus.unitConfig, statusDescriptor{&status}) } -func (instance *Instance) updateComponentStatus(componentInfo cloudprotocol.ComponentStatus) { +func (instance *Instance) updateComponentStatus(status cloudprotocol.ComponentStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "id": componentInfo.ComponentID, - "status": componentInfo.Status, - "vendorVersion": componentInfo.Version, - "error": componentInfo.ErrorInfo, + "id": status.ComponentID, + "type": status.ComponentType, + "status": status.Status, + "vendorVersion": status.Version, + "error": status.ErrorInfo, }).Debug("Update component status") - instance.processComponentStatus(componentInfo) + instance.processComponentStatus(status) instance.statusChanged() } -func (instance *Instance) processComponentStatus(componentInfo cloudprotocol.ComponentStatus) { - componentStatus, ok := instance.componentStatuses[componentInfo.ComponentID] +func (instance *Instance) processComponentStatus(status cloudprotocol.ComponentStatus) { + componentStatus, ok := instance.unitStatus.components[status.ComponentID] if !ok { componentStatus = &itemStatus{} - instance.componentStatuses[componentInfo.ComponentID] = componentStatus + instance.unitStatus.components[status.ComponentID] = componentStatus } - instance.updateStatus(componentStatus, statusDescriptor{&componentInfo}) + instance.updateStatus(componentStatus, statusDescriptor{&status}) } -func (instance *Instance) updateLayerStatus(layerInfo cloudprotocol.LayerStatus) { +func (instance *Instance) updateLayerStatus(status cloudprotocol.LayerStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "id": layerInfo.LayerID, - "digest": layerInfo.Digest, - "status": layerInfo.Status, - "version": layerInfo.Version, - "error": layerInfo.ErrorInfo, + "id": status.LayerID, + "digest": status.Digest, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Update layer status") - if _, ok := instance.layerStatuses[layerInfo.Digest]; !ok { - instance.layerStatuses[layerInfo.Digest] = &itemStatus{} - } - - instance.processLayerStatus(layerInfo) + instance.processLayerStatus(status) instance.statusChanged() } -func (instance *Instance) processLayerStatus(layerInfo cloudprotocol.LayerStatus) { - layerStatus, ok := instance.layerStatuses[layerInfo.Digest] +func (instance *Instance) processLayerStatus(status cloudprotocol.LayerStatus) { + layerStatus, ok := instance.unitStatus.layers[status.Digest] if !ok { layerStatus = &itemStatus{} - instance.layerStatuses[layerInfo.Digest] = layerStatus + instance.unitStatus.layers[status.Digest] = layerStatus } - instance.updateStatus(layerStatus, statusDescriptor{&layerInfo}) + instance.updateStatus(layerStatus, statusDescriptor{&status}) } func (instance *Instance) updateServiceStatus(serviceInfo cloudprotocol.ServiceStatus) { @@ -548,14 +548,14 @@ func (instance *Instance) updateServiceStatus(serviceInfo cloudprotocol.ServiceS instance.statusChanged() } -func (instance *Instance) processServiceStatus(serviceInfo cloudprotocol.ServiceStatus) { - serviceStatus, ok := instance.serviceStatuses[serviceInfo.ServiceID] +func (instance *Instance) processServiceStatus(status cloudprotocol.ServiceStatus) { + serviceStatus, ok := instance.unitStatus.services[status.ServiceID] if !ok { serviceStatus = &itemStatus{} - instance.serviceStatuses[serviceInfo.ServiceID] = serviceStatus + instance.unitStatus.services[status.ServiceID] = serviceStatus } - instance.updateStatus(serviceStatus, statusDescriptor{&serviceInfo}) + instance.updateStatus(serviceStatus, statusDescriptor{&status}) } func (instance *Instance) updateInstanceStatus(status []cloudprotocol.InstanceStatus) { @@ -566,9 +566,9 @@ func (instance *Instance) updateInstanceStatus(status []cloudprotocol.InstanceSt foundloop: for _, instanceStatus := range status { - for i := range instance.instanceStatuses { - if instanceStatus.InstanceIdent == instance.instanceStatuses[i].InstanceIdent && - instanceStatus.ServiceVersion == instance.instanceStatuses[i].ServiceVersion { + for i := range instance.unitStatus.instances { + if instanceStatus.InstanceIdent == instance.unitStatus.instances[i].InstanceIdent && + instanceStatus.ServiceVersion == instance.unitStatus.instances[i].ServiceVersion { log.WithFields(log.Fields{ "serviceID": instanceStatus.InstanceIdent.ServiceID, "subjectID": instanceStatus.InstanceIdent.SubjectID, @@ -578,9 +578,9 @@ foundloop: "error": instanceStatus.ErrorInfo, }).Debug("Update instance status") - instance.instanceStatuses[i].StateChecksum = instanceStatus.StateChecksum - instance.instanceStatuses[i].RunState = instanceStatus.RunState - instance.instanceStatuses[i].ErrorInfo = instanceStatus.ErrorInfo + instance.unitStatus.instances[i].StateChecksum = instanceStatus.StateChecksum + instance.unitStatus.instances[i].RunState = instanceStatus.RunState + instance.unitStatus.instances[i].ErrorInfo = instanceStatus.ErrorInfo continue foundloop } @@ -589,7 +589,7 @@ foundloop: newStatuses = append(newStatuses, instanceStatus) } - instance.instanceStatuses = append(instance.instanceStatuses, newStatuses...) + instance.unitStatus.instances = append(instance.unitStatus.instances, newStatuses...) instance.statusChanged() } @@ -598,7 +598,7 @@ func (instance *Instance) setInstanceStatus(status []cloudprotocol.InstanceStatu instance.statusMutex.Lock() defer instance.statusMutex.Unlock() - instance.instanceStatuses = status + instance.unitStatus.instances = status } func (instance *Instance) statusChanged() { @@ -645,15 +645,15 @@ func (instance *Instance) sendCurrentStatus() { } unitStatus := cloudprotocol.UnitStatus{ - UnitSubjects: instance.unitSubjects, - Components: make([]cloudprotocol.ComponentStatus, 0, len(instance.componentStatuses)), - Layers: make([]cloudprotocol.LayerStatus, 0, len(instance.layerStatuses)), - Services: make([]cloudprotocol.ServiceStatus, 0, len(instance.serviceStatuses)), - Instances: instance.instanceStatuses, + UnitSubjects: instance.unitStatus.subjects, + Components: make([]cloudprotocol.ComponentStatus, 0, len(instance.unitStatus.components)), + Layers: make([]cloudprotocol.LayerStatus, 0, len(instance.unitStatus.layers)), + Services: make([]cloudprotocol.ServiceStatus, 0, len(instance.unitStatus.services)), + Instances: instance.unitStatus.instances, Nodes: instance.softwareManager.instanceRunner.GetNodesConfiguration(), } - for _, status := range instance.unitConfigStatus { + for _, status := range instance.unitStatus.unitConfig { unitConfig, ok := status.amqpStatus.(*cloudprotocol.UnitConfigStatus) if !ok { log.Error("Incorrect unit config type") @@ -663,7 +663,7 @@ func (instance *Instance) sendCurrentStatus() { unitStatus.UnitConfig = append(unitStatus.UnitConfig, *unitConfig) } - for _, componentStatus := range instance.componentStatuses { + for _, componentStatus := range instance.unitStatus.components { for _, status := range *componentStatus { status, ok := status.amqpStatus.(*cloudprotocol.ComponentStatus) if !ok { @@ -675,7 +675,7 @@ func (instance *Instance) sendCurrentStatus() { } } - for _, layerStatus := range instance.layerStatuses { + for _, layerStatus := range instance.unitStatus.layers { for _, status := range *layerStatus { status, ok := status.amqpStatus.(*cloudprotocol.LayerStatus) if !ok { @@ -687,7 +687,7 @@ func (instance *Instance) sendCurrentStatus() { } } - for _, serviceStatus := range instance.serviceStatuses { + for _, serviceStatus := range instance.unitStatus.services { for _, status := range *serviceStatus { status, ok := status.amqpStatus.(*cloudprotocol.ServiceStatus) if !ok { From 9f3b88acaf1db7fa4bd862925e8229b0f9bb4197 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 9 Jul 2024 18:26:54 +0300 Subject: [PATCH 034/146] [vendor] Update vendor Signed-off-by: Oleksandr Grytsov --- go.mod | 2 +- go.sum | 4 +- .../aosedge/aos_common/aostypes/aostypes.go | 39 +- .../aos_common/api/cloudprotocol/alerts.go | 4 +- .../api/cloudprotocol/cloudprotocol.go | 5 +- .../api/cloudprotocol/desiredstatus.go | 4 +- .../aos_common/api/cloudprotocol/envvars.go | 18 +- .../aos_common/api/cloudprotocol/log.go | 24 +- .../api/cloudprotocol/monitoring.go | 27 +- .../api/cloudprotocol/unitstatus.go | 21 +- .../updatescheduler.pb.go | 76 +- .../api/servicemanager/servicemanager.pb.go | 1480 ++++++++--------- .../resourcemonitor/cgroupssystemusage.go | 4 +- .../resourcemonitor/resourcemonitor.go | 166 +- .../resourcemonitor/xensystemusage.go | 4 +- .../aos_common/utils/pbconvert/pbconvert.go | 2 +- vendor/modules.txt | 2 +- 17 files changed, 925 insertions(+), 957 deletions(-) diff --git a/go.mod b/go.mod index 2955b4c8..cafe191b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab + github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 702ee558..7e1972d0 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab h1:vON8DvOduWA6mOm5xKibVp6MhPrLjHVvU6oqew2GUco= -github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a h1:oajCSEcVxxUWfDA2ugheAUpJXPIhqhP6QdtfjZQvq9U= +github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go index cf1d5559..4399fb3b 100644 --- a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go +++ b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go @@ -113,12 +113,12 @@ type FirewallRule struct { // NetworkParameters networks parameters. type NetworkParameters struct { - NetworkID string - Subnet string - IP string - VlanID uint64 - DNSServers []string - FirewallRules []FirewallRule + NetworkID string `json:"networkId"` + Subnet string `json:"subnet"` + IP string `json:"ip"` + VlanID uint64 `json:"vlanId"` + DNSServers []string `json:"dnsServers"` + FirewallRules []FirewallRule `json:"firewallRules"` } // InstanceInfo instance information to start it. @@ -213,6 +213,33 @@ type ServiceConfig struct { AlertRules *AlertRules `json:"alertRules,omitempty"` } +// PartitionUsage partition usage information. +type PartitionUsage struct { + Name string `json:"name"` + UsedSize uint64 `json:"usedSize"` +} + +// MonitoringData monitoring data. +type MonitoringData struct { + Timestamp time.Time `json:"timestamp"` + RAM uint64 `json:"ram"` + CPU uint64 `json:"cpu"` + InTraffic uint64 `json:"inTraffic"` + OutTraffic uint64 `json:"outTraffic"` + Disk []PartitionUsage `json:"disk"` +} + +type InstanceMonitoring struct { + InstanceIdent + MonitoringData +} + +type NodeMonitoring struct { + NodeID string `json:"nodeId"` + NodeData MonitoringData `json:"nodeData"` + InstancesData []InstanceMonitoring `json:"instancesData"` +} + /*********************************************************************************************************************** * Interfaces **********************************************************************************************************************/ diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go index 23cc4cf8..c22418c8 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go @@ -124,6 +124,6 @@ type AlertItem struct { // Alerts alerts message structure. type Alerts struct { - MessageType string `json:"messageType"` - Items []AlertItem + MessageType string `json:"messageType"` + Items []AlertItem `json:"items"` } diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go index 7bf77129..60c1f744 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go @@ -42,9 +42,8 @@ type Message struct { // MessageHeader message header. type MessageHeader struct { - Version uint64 `json:"version"` - SystemID string `json:"systemId"` - MessageType string `json:"messageType"` + Version uint64 `json:"version"` + SystemID string `json:"systemId"` } // ErrorInfo error information. diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go index de277ce7..50f2340a 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go @@ -180,8 +180,8 @@ type CertificateChain struct { // TimeSlot time slot with start and finish time. type TimeSlot struct { - Start aostypes.Time `json:"start"` - Finish aostypes.Time `json:"finish"` + Start aostypes.Time `json:"start"` + End aostypes.Time `json:"end"` } // TimetableEntry entry for update timetable. diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go index fa156482..f9c54415 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/envvars.go @@ -36,14 +36,14 @@ const ( // EnvVarsInstanceInfo struct with envs and related service and user. type EnvVarsInstanceInfo struct { InstanceFilter - EnvVars []EnvVarInfo `json:"envVars"` + Variables []EnvVarInfo `json:"variables"` } // EnvVarInfo env info with id and time to live. type EnvVarInfo struct { - ID string `json:"id"` - Variable string `json:"variable"` - TTL *time.Time `json:"ttl"` + Name string `json:"name"` + Value string `json:"value"` + TTL *time.Time `json:"ttl"` } // EnvVarsInstanceStatus struct with envs status and related service and user. @@ -54,18 +54,18 @@ type EnvVarsInstanceStatus struct { // EnvVarStatus env status with error message. type EnvVarStatus struct { - ID string `json:"id"` + Name string `json:"name"` ErrorInfo *ErrorInfo `json:"error,omitempty"` } // OverrideEnvVars request to override service environment variables. type OverrideEnvVars struct { - MessageType string `json:"messageType"` - OverrideEnvVars []EnvVarsInstanceInfo `json:"overrideEnvVars"` + MessageType string `json:"messageType"` + Items []EnvVarsInstanceInfo `json:"items"` } // OverrideEnvVarsStatus override env status. type OverrideEnvVarsStatus struct { - MessageType string `json:"messageType"` - OverrideEnvVarsStatus []EnvVarsInstanceStatus `json:"overrideEnvVarsStatus"` + MessageType string `json:"messageType"` + Statuses []EnvVarsInstanceStatus `json:"statuses"` } diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go index c128880d..defdc361 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/log.go @@ -36,15 +36,32 @@ const ( CrashLog = "crashLog" ) +// Log statuses. +const ( + LogStatusOk = "ok" + LogStatusError = "error" + LogStatusEmpty = "empty" + LogStatusAbsent = "absent" +) + /*********************************************************************************************************************** * Types **********************************************************************************************************************/ +// LogUploadOptions request log message. +type LogUploadOptions struct { + Type string `json:"type"` + URL string `json:"url"` + BearerToken string `json:"bearerToken"` + BearerTokenTTL *time.Time `json:"bearerTokenTtl"` +} + // LogFilter request log message. type LogFilter struct { - From *time.Time `json:"from"` - Till *time.Time `json:"till"` - NodeIDs []string `json:"nodeIds,omitempty"` + From *time.Time `json:"from"` + Till *time.Time `json:"till"` + NodeIDs []string `json:"nodeIds,omitempty"` + UploadOptions *LogUploadOptions `json:"uploadOptions,omitempty"` InstanceFilter } @@ -64,6 +81,7 @@ type PushLog struct { PartsCount uint64 `json:"partsCount,omitempty"` Part uint64 `json:"part,omitempty"` Content []byte `json:"content,omitempty"` + Status string `json:"status"` ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` } diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go index 87cee354..b0a5f1a0 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/monitoring.go @@ -18,8 +18,6 @@ package cloudprotocol import ( - "time" - "github.com/aosedge/aos_common/aostypes" ) @@ -34,34 +32,17 @@ const MonitoringMessageType = "monitoringData" * Types **********************************************************************************************************************/ -// PartitionUsage partition usage information. -type PartitionUsage struct { - Name string `json:"name"` - UsedSize uint64 `json:"usedSize"` -} - -// MonitoringData monitoring data. -type MonitoringData struct { - RAM uint64 `json:"ram"` - CPU uint64 `json:"cpu"` - InTraffic uint64 `json:"inTraffic"` - OutTraffic uint64 `json:"outTraffic"` - Disk []PartitionUsage `json:"disk"` -} - // NodeMonitoringData node monitoring data. type NodeMonitoringData struct { - MonitoringData - NodeID string `json:"nodeId"` - Timestamp time.Time `json:"timestamp"` - ServiceInstances []InstanceMonitoringData `json:"serviceInstances"` + NodeID string `json:"nodeId"` + Items []aostypes.MonitoringData `json:"items"` } // InstanceMonitoringData monitoring data for service. type InstanceMonitoringData struct { aostypes.InstanceIdent - NodeID string `json:"nodeId"` - MonitoringData + NodeID string `json:"nodeId"` + Items []aostypes.MonitoringData `json:"items"` } // Monitoring monitoring message structure. diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go index ad066770..ae4c1c29 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go @@ -18,6 +18,7 @@ package cloudprotocol import ( + "encoding/json" "strings" "github.com/aosedge/aos_common/aoserrors" @@ -115,8 +116,8 @@ type PartitionInfo struct { // NodeInfo node information. type NodeInfo struct { - NodeID string `json:"nodeId"` - NodeType string `json:"nodeType"` + NodeID string `json:"id"` + NodeType string `json:"type"` Name string `json:"name"` Status string `json:"status"` CPUs []CPUInfo `json:"cpus"` @@ -130,7 +131,7 @@ type NodeInfo struct { // ServiceStatus service status. type ServiceStatus struct { - ServiceID string `json:"serviceId"` + ServiceID string `json:"id"` Version string `json:"version"` Status string `json:"status"` ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` @@ -148,7 +149,7 @@ type InstanceStatus struct { // LayerStatus layer status. type LayerStatus struct { - LayerID string `json:"layerId"` + LayerID string `json:"id"` Digest string `json:"digest"` Version string `json:"version"` Status string `json:"status"` @@ -157,11 +158,13 @@ type LayerStatus struct { // ComponentStatus component status. type ComponentStatus struct { - ComponentID string `json:"componentId"` - ComponentType string `json:"componentType"` - Version string `json:"version"` - Status string `json:"status"` - ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` + ComponentID string `json:"id"` + ComponentType string `json:"type"` + Version string `json:"version"` + NodeID string `json:"nodeId"` + Status string `json:"status"` + Annotations json.RawMessage `json:"annotations,omitempty"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` } // UnitStatus unit status structure. diff --git a/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go b/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go index c62071fa..64616d75 100644 --- a/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/communicationmanager/updatescheduler.pb.go @@ -162,8 +162,7 @@ type UpdateFOTAStatus struct { State UpdateState `protobuf:"varint,1,opt,name=state,proto3,enum=communicationmanager.v3.UpdateState" json:"state,omitempty"` Components []*ComponentInfo `protobuf:"bytes,2,rep,name=components,proto3" json:"components,omitempty"` - UnitConfig *UnitConfigInfo `protobuf:"bytes,3,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` - Error *common.ErrorInfo `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` } func (x *UpdateFOTAStatus) Reset() { @@ -212,13 +211,6 @@ func (x *UpdateFOTAStatus) GetComponents() []*ComponentInfo { return nil } -func (x *UpdateFOTAStatus) GetUnitConfig() *UnitConfigInfo { - if x != nil { - return x.UnitConfig - } - return nil -} - func (x *UpdateFOTAStatus) GetError() *common.ErrorInfo { if x != nil { return x.Error @@ -232,12 +224,13 @@ type UpdateSOTAStatus struct { unknownFields protoimpl.UnknownFields State UpdateState `protobuf:"varint,1,opt,name=state,proto3,enum=communicationmanager.v3.UpdateState" json:"state,omitempty"` - InstallServices []*ServiceInfo `protobuf:"bytes,2,rep,name=install_services,json=installServices,proto3" json:"install_services,omitempty"` - RemoveServices []*ServiceInfo `protobuf:"bytes,3,rep,name=remove_services,json=removeServices,proto3" json:"remove_services,omitempty"` - InstallLayers []*LayerInfo `protobuf:"bytes,4,rep,name=install_layers,json=installLayers,proto3" json:"install_layers,omitempty"` - RemoveLayers []*LayerInfo `protobuf:"bytes,5,rep,name=remove_layers,json=removeLayers,proto3" json:"remove_layers,omitempty"` - RebalanceRequest bool `protobuf:"varint,6,opt,name=rebalance_request,json=rebalanceRequest,proto3" json:"rebalance_request,omitempty"` - Error *common.ErrorInfo `protobuf:"bytes,7,opt,name=error,proto3" json:"error,omitempty"` + UnitConfig *UnitConfigInfo `protobuf:"bytes,2,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` + InstallServices []*ServiceInfo `protobuf:"bytes,3,rep,name=install_services,json=installServices,proto3" json:"install_services,omitempty"` + RemoveServices []*ServiceInfo `protobuf:"bytes,4,rep,name=remove_services,json=removeServices,proto3" json:"remove_services,omitempty"` + InstallLayers []*LayerInfo `protobuf:"bytes,5,rep,name=install_layers,json=installLayers,proto3" json:"install_layers,omitempty"` + RemoveLayers []*LayerInfo `protobuf:"bytes,6,rep,name=remove_layers,json=removeLayers,proto3" json:"remove_layers,omitempty"` + RebalanceRequest bool `protobuf:"varint,7,opt,name=rebalance_request,json=rebalanceRequest,proto3" json:"rebalance_request,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,8,opt,name=error,proto3" json:"error,omitempty"` } func (x *UpdateSOTAStatus) Reset() { @@ -279,6 +272,13 @@ func (x *UpdateSOTAStatus) GetState() UpdateState { return UpdateState_NO_UPDATE } +func (x *UpdateSOTAStatus) GetUnitConfig() *UnitConfigInfo { + if x != nil { + return x.UnitConfig + } + return nil +} + func (x *UpdateSOTAStatus) GetInstallServices() []*ServiceInfo { if x != nil { return x.InstallServices @@ -572,7 +572,7 @@ var file_communicationmanager_v3_updatescheduler_proto_rawDesc = []byte{ 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x0a, 0x66, 0x6f, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x17, 0x0a, 0x15, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, - 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x02, + 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xc2, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, @@ -582,42 +582,42 @@ var file_communicationmanager_v3_updatescheduler_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x48, 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xdb, 0x03, 0x0a, - 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x4f, 0x54, 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, 0x0a, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x22, 0xa5, 0x04, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x4f, 0x54, + 0x41, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x48, 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, + 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x33, 0x2e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x10, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x49, 0x0a, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, - 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x47, 0x0a, 0x0d, 0x72, 0x65, 0x6d, 0x6f, - 0x76, 0x65, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x76, 0x65, 0x5f, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0c, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x72, 0x65, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x72, 0x65, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x72, 0x65, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, - 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x73, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x63, @@ -696,9 +696,9 @@ var file_communicationmanager_v3_updatescheduler_proto_depIdxs = []int32{ 2, // 1: communicationmanager.v3.SchedulerNotifications.fota_status:type_name -> communicationmanager.v3.UpdateFOTAStatus 0, // 2: communicationmanager.v3.UpdateFOTAStatus.state:type_name -> communicationmanager.v3.UpdateState 4, // 3: communicationmanager.v3.UpdateFOTAStatus.components:type_name -> communicationmanager.v3.ComponentInfo - 5, // 4: communicationmanager.v3.UpdateFOTAStatus.unit_config:type_name -> communicationmanager.v3.UnitConfigInfo - 8, // 5: communicationmanager.v3.UpdateFOTAStatus.error:type_name -> common.v1.ErrorInfo - 0, // 6: communicationmanager.v3.UpdateSOTAStatus.state:type_name -> communicationmanager.v3.UpdateState + 8, // 4: communicationmanager.v3.UpdateFOTAStatus.error:type_name -> common.v1.ErrorInfo + 0, // 5: communicationmanager.v3.UpdateSOTAStatus.state:type_name -> communicationmanager.v3.UpdateState + 5, // 6: communicationmanager.v3.UpdateSOTAStatus.unit_config:type_name -> communicationmanager.v3.UnitConfigInfo 6, // 7: communicationmanager.v3.UpdateSOTAStatus.install_services:type_name -> communicationmanager.v3.ServiceInfo 6, // 8: communicationmanager.v3.UpdateSOTAStatus.remove_services:type_name -> communicationmanager.v3.ServiceInfo 7, // 9: communicationmanager.v3.UpdateSOTAStatus.install_layers:type_name -> communicationmanager.v3.LayerInfo diff --git a/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go index aeeada6d..0600e23c 100644 --- a/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go @@ -75,9 +75,9 @@ type SMIncomingMessages struct { // Types that are assignable to SMIncomingMessage: // - // *SMIncomingMessages_GetUnitConfigStatus - // *SMIncomingMessages_CheckUnitConfig - // *SMIncomingMessages_SetUnitConfig + // *SMIncomingMessages_GetNodeConfigStatus + // *SMIncomingMessages_CheckNodeConfig + // *SMIncomingMessages_SetNodeConfig // *SMIncomingMessages_RunInstances // *SMIncomingMessages_OverrideEnvVars // *SMIncomingMessages_SystemLogRequest @@ -131,23 +131,23 @@ func (m *SMIncomingMessages) GetSMIncomingMessage() isSMIncomingMessages_SMIncom return nil } -func (x *SMIncomingMessages) GetGetUnitConfigStatus() *GetUnitConfigStatus { - if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_GetUnitConfigStatus); ok { - return x.GetUnitConfigStatus +func (x *SMIncomingMessages) GetGetNodeConfigStatus() *GetNodeConfigStatus { + if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_GetNodeConfigStatus); ok { + return x.GetNodeConfigStatus } return nil } -func (x *SMIncomingMessages) GetCheckUnitConfig() *CheckUnitConfig { - if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_CheckUnitConfig); ok { - return x.CheckUnitConfig +func (x *SMIncomingMessages) GetCheckNodeConfig() *CheckNodeConfig { + if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_CheckNodeConfig); ok { + return x.CheckNodeConfig } return nil } -func (x *SMIncomingMessages) GetSetUnitConfig() *SetUnitConfig { - if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_SetUnitConfig); ok { - return x.SetUnitConfig +func (x *SMIncomingMessages) GetSetNodeConfig() *SetNodeConfig { + if x, ok := x.GetSMIncomingMessage().(*SMIncomingMessages_SetNodeConfig); ok { + return x.SetNodeConfig } return nil } @@ -233,16 +233,16 @@ type isSMIncomingMessages_SMIncomingMessage interface { isSMIncomingMessages_SMIncomingMessage() } -type SMIncomingMessages_GetUnitConfigStatus struct { - GetUnitConfigStatus *GetUnitConfigStatus `protobuf:"bytes,1,opt,name=get_unit_config_status,json=getUnitConfigStatus,proto3,oneof"` +type SMIncomingMessages_GetNodeConfigStatus struct { + GetNodeConfigStatus *GetNodeConfigStatus `protobuf:"bytes,1,opt,name=get_node_config_status,json=getNodeConfigStatus,proto3,oneof"` } -type SMIncomingMessages_CheckUnitConfig struct { - CheckUnitConfig *CheckUnitConfig `protobuf:"bytes,2,opt,name=check_unit_config,json=checkUnitConfig,proto3,oneof"` +type SMIncomingMessages_CheckNodeConfig struct { + CheckNodeConfig *CheckNodeConfig `protobuf:"bytes,2,opt,name=check_node_config,json=checkNodeConfig,proto3,oneof"` } -type SMIncomingMessages_SetUnitConfig struct { - SetUnitConfig *SetUnitConfig `protobuf:"bytes,3,opt,name=set_unit_config,json=setUnitConfig,proto3,oneof"` +type SMIncomingMessages_SetNodeConfig struct { + SetNodeConfig *SetNodeConfig `protobuf:"bytes,3,opt,name=set_node_config,json=setNodeConfig,proto3,oneof"` } type SMIncomingMessages_RunInstances struct { @@ -289,11 +289,11 @@ type SMIncomingMessages_ClockSync struct { ClockSync *ClockSync `protobuf:"bytes,14,opt,name=clock_sync,json=clockSync,proto3,oneof"` } -func (*SMIncomingMessages_GetUnitConfigStatus) isSMIncomingMessages_SMIncomingMessage() {} +func (*SMIncomingMessages_GetNodeConfigStatus) isSMIncomingMessages_SMIncomingMessage() {} -func (*SMIncomingMessages_CheckUnitConfig) isSMIncomingMessages_SMIncomingMessage() {} +func (*SMIncomingMessages_CheckNodeConfig) isSMIncomingMessages_SMIncomingMessage() {} -func (*SMIncomingMessages_SetUnitConfig) isSMIncomingMessages_SMIncomingMessage() {} +func (*SMIncomingMessages_SetNodeConfig) isSMIncomingMessages_SMIncomingMessage() {} func (*SMIncomingMessages_RunInstances) isSMIncomingMessages_SMIncomingMessage() {} @@ -317,14 +317,14 @@ func (*SMIncomingMessages_UpdateNetworks) isSMIncomingMessages_SMIncomingMessage func (*SMIncomingMessages_ClockSync) isSMIncomingMessages_SMIncomingMessage() {} -type GetUnitConfigStatus struct { +type GetNodeConfigStatus struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *GetUnitConfigStatus) Reset() { - *x = GetUnitConfigStatus{} +func (x *GetNodeConfigStatus) Reset() { + *x = GetNodeConfigStatus{} if protoimpl.UnsafeEnabled { mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -332,13 +332,13 @@ func (x *GetUnitConfigStatus) Reset() { } } -func (x *GetUnitConfigStatus) String() string { +func (x *GetNodeConfigStatus) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetUnitConfigStatus) ProtoMessage() {} +func (*GetNodeConfigStatus) ProtoMessage() {} -func (x *GetUnitConfigStatus) ProtoReflect() protoreflect.Message { +func (x *GetNodeConfigStatus) ProtoReflect() protoreflect.Message { mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -350,22 +350,22 @@ func (x *GetUnitConfigStatus) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetUnitConfigStatus.ProtoReflect.Descriptor instead. -func (*GetUnitConfigStatus) Descriptor() ([]byte, []int) { +// Deprecated: Use GetNodeConfigStatus.ProtoReflect.Descriptor instead. +func (*GetNodeConfigStatus) Descriptor() ([]byte, []int) { return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{1} } -type CheckUnitConfig struct { +type CheckNodeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UnitConfig string `protobuf:"bytes,1,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` + NodeConfig string `protobuf:"bytes,1,opt,name=node_config,json=nodeConfig,proto3" json:"node_config,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` } -func (x *CheckUnitConfig) Reset() { - *x = CheckUnitConfig{} +func (x *CheckNodeConfig) Reset() { + *x = CheckNodeConfig{} if protoimpl.UnsafeEnabled { mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -373,13 +373,13 @@ func (x *CheckUnitConfig) Reset() { } } -func (x *CheckUnitConfig) String() string { +func (x *CheckNodeConfig) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CheckUnitConfig) ProtoMessage() {} +func (*CheckNodeConfig) ProtoMessage() {} -func (x *CheckUnitConfig) ProtoReflect() protoreflect.Message { +func (x *CheckNodeConfig) ProtoReflect() protoreflect.Message { mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -391,36 +391,36 @@ func (x *CheckUnitConfig) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CheckUnitConfig.ProtoReflect.Descriptor instead. -func (*CheckUnitConfig) Descriptor() ([]byte, []int) { +// Deprecated: Use CheckNodeConfig.ProtoReflect.Descriptor instead. +func (*CheckNodeConfig) Descriptor() ([]byte, []int) { return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{2} } -func (x *CheckUnitConfig) GetUnitConfig() string { +func (x *CheckNodeConfig) GetNodeConfig() string { if x != nil { - return x.UnitConfig + return x.NodeConfig } return "" } -func (x *CheckUnitConfig) GetVersion() string { +func (x *CheckNodeConfig) GetVersion() string { if x != nil { return x.Version } return "" } -type SetUnitConfig struct { +type SetNodeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UnitConfig string `protobuf:"bytes,1,opt,name=unit_config,json=unitConfig,proto3" json:"unit_config,omitempty"` + NodeConfig string `protobuf:"bytes,1,opt,name=node_config,json=nodeConfig,proto3" json:"node_config,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` } -func (x *SetUnitConfig) Reset() { - *x = SetUnitConfig{} +func (x *SetNodeConfig) Reset() { + *x = SetNodeConfig{} if protoimpl.UnsafeEnabled { mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -428,13 +428,13 @@ func (x *SetUnitConfig) Reset() { } } -func (x *SetUnitConfig) String() string { +func (x *SetNodeConfig) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SetUnitConfig) ProtoMessage() {} +func (*SetNodeConfig) ProtoMessage() {} -func (x *SetUnitConfig) ProtoReflect() protoreflect.Message { +func (x *SetNodeConfig) ProtoReflect() protoreflect.Message { mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -446,19 +446,19 @@ func (x *SetUnitConfig) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SetUnitConfig.ProtoReflect.Descriptor instead. -func (*SetUnitConfig) Descriptor() ([]byte, []int) { +// Deprecated: Use SetNodeConfig.ProtoReflect.Descriptor instead. +func (*SetNodeConfig) Descriptor() ([]byte, []int) { return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{3} } -func (x *SetUnitConfig) GetUnitConfig() string { +func (x *SetNodeConfig) GetNodeConfig() string { if x != nil { - return x.UnitConfig + return x.NodeConfig } return "" } -func (x *SetUnitConfig) GetVersion() string { +func (x *SetNodeConfig) GetVersion() string { if x != nil { return x.Version } @@ -1110,7 +1110,7 @@ type OverrideInstanceEnvVar struct { unknownFields protoimpl.UnknownFields InstanceFilter *InstanceFilter `protobuf:"bytes,1,opt,name=instance_filter,json=instanceFilter,proto3" json:"instance_filter,omitempty"` - Vars []*EnvVarInfo `protobuf:"bytes,2,rep,name=vars,proto3" json:"vars,omitempty"` + Variables []*EnvVarInfo `protobuf:"bytes,2,rep,name=variables,proto3" json:"variables,omitempty"` } func (x *OverrideInstanceEnvVar) Reset() { @@ -1152,9 +1152,9 @@ func (x *OverrideInstanceEnvVar) GetInstanceFilter() *InstanceFilter { return nil } -func (x *OverrideInstanceEnvVar) GetVars() []*EnvVarInfo { +func (x *OverrideInstanceEnvVar) GetVariables() []*EnvVarInfo { if x != nil { - return x.Vars + return x.Variables } return nil } @@ -1164,9 +1164,9 @@ type EnvVarInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VarId string `protobuf:"bytes,1,opt,name=var_id,json=varId,proto3" json:"var_id,omitempty"` - Variable string `protobuf:"bytes,2,opt,name=variable,proto3" json:"variable,omitempty"` - Ttl *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=ttl,proto3" json:"ttl,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Ttl *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=ttl,proto3" json:"ttl,omitempty"` } func (x *EnvVarInfo) Reset() { @@ -1201,16 +1201,16 @@ func (*EnvVarInfo) Descriptor() ([]byte, []int) { return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{14} } -func (x *EnvVarInfo) GetVarId() string { +func (x *EnvVarInfo) GetName() string { if x != nil { - return x.VarId + return x.Name } return "" } -func (x *EnvVarInfo) GetVariable() string { +func (x *EnvVarInfo) GetValue() string { if x != nil { - return x.Variable + return x.Value } return "" } @@ -1780,53 +1780,6 @@ func (x *ImageContent) GetData() []byte { return nil } -type RegisterSM struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` -} - -func (x *RegisterSM) Reset() { - *x = RegisterSM{} - if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RegisterSM) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterSM) ProtoMessage() {} - -func (x *RegisterSM) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[24] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterSM.ProtoReflect.Descriptor instead. -func (*RegisterSM) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{24} -} - -func (x *RegisterSM) GetNodeId() string { - if x != nil { - return x.NodeId - } - return "" -} - type SMOutgoingMessages struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1834,8 +1787,7 @@ type SMOutgoingMessages struct { // Types that are assignable to SMOutgoingMessage: // - // *SMOutgoingMessages_RegisterSm - // *SMOutgoingMessages_UnitConfigStatus + // *SMOutgoingMessages_NodeConfigStatus // *SMOutgoingMessages_RunInstancesStatus // *SMOutgoingMessages_UpdateInstancesStatus // *SMOutgoingMessages_OverrideEnvVarStatus @@ -1851,7 +1803,7 @@ type SMOutgoingMessages struct { func (x *SMOutgoingMessages) Reset() { *x = SMOutgoingMessages{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[25] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1864,7 +1816,7 @@ func (x *SMOutgoingMessages) String() string { func (*SMOutgoingMessages) ProtoMessage() {} func (x *SMOutgoingMessages) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[25] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1877,7 +1829,7 @@ func (x *SMOutgoingMessages) ProtoReflect() protoreflect.Message { // Deprecated: Use SMOutgoingMessages.ProtoReflect.Descriptor instead. func (*SMOutgoingMessages) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{25} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{24} } func (m *SMOutgoingMessages) GetSMOutgoingMessage() isSMOutgoingMessages_SMOutgoingMessage { @@ -1887,16 +1839,9 @@ func (m *SMOutgoingMessages) GetSMOutgoingMessage() isSMOutgoingMessages_SMOutgo return nil } -func (x *SMOutgoingMessages) GetRegisterSm() *RegisterSM { - if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_RegisterSm); ok { - return x.RegisterSm - } - return nil -} - -func (x *SMOutgoingMessages) GetUnitConfigStatus() *UnitConfigStatus { - if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_UnitConfigStatus); ok { - return x.UnitConfigStatus +func (x *SMOutgoingMessages) GetNodeConfigStatus() *NodeConfigStatus { + if x, ok := x.GetSMOutgoingMessage().(*SMOutgoingMessages_NodeConfigStatus); ok { + return x.NodeConfigStatus } return nil } @@ -1968,12 +1913,8 @@ type isSMOutgoingMessages_SMOutgoingMessage interface { isSMOutgoingMessages_SMOutgoingMessage() } -type SMOutgoingMessages_RegisterSm struct { - RegisterSm *RegisterSM `protobuf:"bytes,1,opt,name=register_sm,json=registerSm,proto3,oneof"` -} - -type SMOutgoingMessages_UnitConfigStatus struct { - UnitConfigStatus *UnitConfigStatus `protobuf:"bytes,2,opt,name=unit_config_status,json=unitConfigStatus,proto3,oneof"` +type SMOutgoingMessages_NodeConfigStatus struct { + NodeConfigStatus *NodeConfigStatus `protobuf:"bytes,2,opt,name=node_config_status,json=nodeConfigStatus,proto3,oneof"` } type SMOutgoingMessages_RunInstancesStatus struct { @@ -2012,9 +1953,7 @@ type SMOutgoingMessages_ClockSyncRequest struct { ClockSyncRequest *ClockSyncRequest `protobuf:"bytes,11,opt,name=clock_sync_request,json=clockSyncRequest,proto3,oneof"` } -func (*SMOutgoingMessages_RegisterSm) isSMOutgoingMessages_SMOutgoingMessage() {} - -func (*SMOutgoingMessages_UnitConfigStatus) isSMOutgoingMessages_SMOutgoingMessage() {} +func (*SMOutgoingMessages_NodeConfigStatus) isSMOutgoingMessages_SMOutgoingMessage() {} func (*SMOutgoingMessages_RunInstancesStatus) isSMOutgoingMessages_SMOutgoingMessage() {} @@ -2047,7 +1986,7 @@ type Partition struct { func (x *Partition) Reset() { *x = Partition{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[26] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2060,7 +1999,7 @@ func (x *Partition) String() string { func (*Partition) ProtoMessage() {} func (x *Partition) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[26] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2073,7 +2012,7 @@ func (x *Partition) ProtoReflect() protoreflect.Message { // Deprecated: Use Partition.ProtoReflect.Descriptor instead. func (*Partition) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{26} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{25} } func (x *Partition) GetName() string { @@ -2097,32 +2036,34 @@ func (x *Partition) GetTotalSize() uint64 { return 0 } -type UnitConfigStatus struct { +type NodeConfigStatus struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` - Error *common.ErrorInfo `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` + NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"` + NodeType string `protobuf:"bytes,2,opt,name=node_type,json=nodeType,proto3" json:"node_type,omitempty"` + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` } -func (x *UnitConfigStatus) Reset() { - *x = UnitConfigStatus{} +func (x *NodeConfigStatus) Reset() { + *x = NodeConfigStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[27] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *UnitConfigStatus) String() string { +func (x *NodeConfigStatus) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UnitConfigStatus) ProtoMessage() {} +func (*NodeConfigStatus) ProtoMessage() {} -func (x *UnitConfigStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[27] +func (x *NodeConfigStatus) ProtoReflect() protoreflect.Message { + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2133,19 +2074,33 @@ func (x *UnitConfigStatus) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UnitConfigStatus.ProtoReflect.Descriptor instead. -func (*UnitConfigStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{27} +// Deprecated: Use NodeConfigStatus.ProtoReflect.Descriptor instead. +func (*NodeConfigStatus) Descriptor() ([]byte, []int) { + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{26} +} + +func (x *NodeConfigStatus) GetNodeId() string { + if x != nil { + return x.NodeId + } + return "" +} + +func (x *NodeConfigStatus) GetNodeType() string { + if x != nil { + return x.NodeType + } + return "" } -func (x *UnitConfigStatus) GetVersion() string { +func (x *NodeConfigStatus) GetVersion() string { if x != nil { return x.Version } return "" } -func (x *UnitConfigStatus) GetError() *common.ErrorInfo { +func (x *NodeConfigStatus) GetError() *common.ErrorInfo { if x != nil { return x.Error } @@ -2163,7 +2118,7 @@ type RunInstancesStatus struct { func (x *RunInstancesStatus) Reset() { *x = RunInstancesStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[28] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2176,7 +2131,7 @@ func (x *RunInstancesStatus) String() string { func (*RunInstancesStatus) ProtoMessage() {} func (x *RunInstancesStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[28] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2189,7 +2144,7 @@ func (x *RunInstancesStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use RunInstancesStatus.ProtoReflect.Descriptor instead. func (*RunInstancesStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{28} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{27} } func (x *RunInstancesStatus) GetInstances() []*InstanceStatus { @@ -2210,7 +2165,7 @@ type UpdateInstancesStatus struct { func (x *UpdateInstancesStatus) Reset() { *x = UpdateInstancesStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[29] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2223,7 +2178,7 @@ func (x *UpdateInstancesStatus) String() string { func (*UpdateInstancesStatus) ProtoMessage() {} func (x *UpdateInstancesStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[29] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2236,7 +2191,7 @@ func (x *UpdateInstancesStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateInstancesStatus.ProtoReflect.Descriptor instead. func (*UpdateInstancesStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{29} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{28} } func (x *UpdateInstancesStatus) GetInstances() []*InstanceStatus { @@ -2260,7 +2215,7 @@ type InstanceStatus struct { func (x *InstanceStatus) Reset() { *x = InstanceStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[30] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2273,7 +2228,7 @@ func (x *InstanceStatus) String() string { func (*InstanceStatus) ProtoMessage() {} func (x *InstanceStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[30] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2286,7 +2241,7 @@ func (x *InstanceStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceStatus.ProtoReflect.Descriptor instead. func (*InstanceStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{30} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{29} } func (x *InstanceStatus) GetInstance() *common.InstanceIdent { @@ -2329,7 +2284,7 @@ type OverrideEnvVarStatus struct { func (x *OverrideEnvVarStatus) Reset() { *x = OverrideEnvVarStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[31] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2342,7 +2297,7 @@ func (x *OverrideEnvVarStatus) String() string { func (*OverrideEnvVarStatus) ProtoMessage() {} func (x *OverrideEnvVarStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[31] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2355,7 +2310,7 @@ func (x *OverrideEnvVarStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use OverrideEnvVarStatus.ProtoReflect.Descriptor instead. func (*OverrideEnvVarStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{31} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{30} } func (x *OverrideEnvVarStatus) GetEnvVarsStatus() []*EnvVarInstanceStatus { @@ -2378,13 +2333,13 @@ type EnvVarInstanceStatus struct { unknownFields protoimpl.UnknownFields InstanceFilter *InstanceFilter `protobuf:"bytes,1,opt,name=instance_filter,json=instanceFilter,proto3" json:"instance_filter,omitempty"` - VarsStatus []*EnvVarStatus `protobuf:"bytes,2,rep,name=vars_status,json=varsStatus,proto3" json:"vars_status,omitempty"` + Statuses []*EnvVarStatus `protobuf:"bytes,2,rep,name=statuses,proto3" json:"statuses,omitempty"` } func (x *EnvVarInstanceStatus) Reset() { *x = EnvVarInstanceStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[32] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2397,7 +2352,7 @@ func (x *EnvVarInstanceStatus) String() string { func (*EnvVarInstanceStatus) ProtoMessage() {} func (x *EnvVarInstanceStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[32] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2410,7 +2365,7 @@ func (x *EnvVarInstanceStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvVarInstanceStatus.ProtoReflect.Descriptor instead. func (*EnvVarInstanceStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{32} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{31} } func (x *EnvVarInstanceStatus) GetInstanceFilter() *InstanceFilter { @@ -2420,9 +2375,9 @@ func (x *EnvVarInstanceStatus) GetInstanceFilter() *InstanceFilter { return nil } -func (x *EnvVarInstanceStatus) GetVarsStatus() []*EnvVarStatus { +func (x *EnvVarInstanceStatus) GetStatuses() []*EnvVarStatus { if x != nil { - return x.VarsStatus + return x.Statuses } return nil } @@ -2432,14 +2387,14 @@ type EnvVarStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - VarId string `protobuf:"bytes,1,opt,name=var_id,json=varId,proto3" json:"var_id,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Error *common.ErrorInfo `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } func (x *EnvVarStatus) Reset() { *x = EnvVarStatus{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[33] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2452,7 +2407,7 @@ func (x *EnvVarStatus) String() string { func (*EnvVarStatus) ProtoMessage() {} func (x *EnvVarStatus) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[33] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2465,12 +2420,12 @@ func (x *EnvVarStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvVarStatus.ProtoReflect.Descriptor instead. func (*EnvVarStatus) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{33} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{32} } -func (x *EnvVarStatus) GetVarId() string { +func (x *EnvVarStatus) GetName() string { if x != nil { - return x.VarId + return x.Name } return "" } @@ -2491,13 +2446,14 @@ type LogData struct { PartCount uint64 `protobuf:"varint,2,opt,name=part_count,json=partCount,proto3" json:"part_count,omitempty"` Part uint64 `protobuf:"varint,3,opt,name=part,proto3" json:"part,omitempty"` Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` - Error *common.ErrorInfo `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + Status string `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` + Error *common.ErrorInfo `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"` } func (x *LogData) Reset() { *x = LogData{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[34] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2510,7 +2466,7 @@ func (x *LogData) String() string { func (*LogData) ProtoMessage() {} func (x *LogData) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[34] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2523,7 +2479,7 @@ func (x *LogData) ProtoReflect() protoreflect.Message { // Deprecated: Use LogData.ProtoReflect.Descriptor instead. func (*LogData) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{34} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{33} } func (x *LogData) GetLogId() string { @@ -2554,6 +2510,13 @@ func (x *LogData) GetData() []byte { return nil } +func (x *LogData) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + func (x *LogData) GetError() *common.ErrorInfo { if x != nil { return x.Error @@ -2566,15 +2529,14 @@ type InstantMonitoring struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - NodeMonitoring *MonitoringData `protobuf:"bytes,2,opt,name=node_monitoring,json=nodeMonitoring,proto3" json:"node_monitoring,omitempty"` - InstanceMonitoring []*InstanceMonitoring `protobuf:"bytes,3,rep,name=instance_monitoring,json=instanceMonitoring,proto3" json:"instance_monitoring,omitempty"` + NodeMonitoring *MonitoringData `protobuf:"bytes,1,opt,name=node_monitoring,json=nodeMonitoring,proto3" json:"node_monitoring,omitempty"` + InstancesMonitoring []*InstanceMonitoring `protobuf:"bytes,2,rep,name=instances_monitoring,json=instancesMonitoring,proto3" json:"instances_monitoring,omitempty"` } func (x *InstantMonitoring) Reset() { *x = InstantMonitoring{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[35] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2587,7 +2549,7 @@ func (x *InstantMonitoring) String() string { func (*InstantMonitoring) ProtoMessage() {} func (x *InstantMonitoring) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[35] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2600,14 +2562,7 @@ func (x *InstantMonitoring) ProtoReflect() protoreflect.Message { // Deprecated: Use InstantMonitoring.ProtoReflect.Descriptor instead. func (*InstantMonitoring) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{35} -} - -func (x *InstantMonitoring) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{34} } func (x *InstantMonitoring) GetNodeMonitoring() *MonitoringData { @@ -2617,9 +2572,9 @@ func (x *InstantMonitoring) GetNodeMonitoring() *MonitoringData { return nil } -func (x *InstantMonitoring) GetInstanceMonitoring() []*InstanceMonitoring { +func (x *InstantMonitoring) GetInstancesMonitoring() []*InstanceMonitoring { if x != nil { - return x.InstanceMonitoring + return x.InstancesMonitoring } return nil } @@ -2629,15 +2584,14 @@ type AverageMonitoring struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - NodeMonitoring *MonitoringData `protobuf:"bytes,2,opt,name=node_monitoring,json=nodeMonitoring,proto3" json:"node_monitoring,omitempty"` - InstanceMonitoring []*InstanceMonitoring `protobuf:"bytes,3,rep,name=instance_monitoring,json=instanceMonitoring,proto3" json:"instance_monitoring,omitempty"` + NodeMonitoring *MonitoringData `protobuf:"bytes,1,opt,name=node_monitoring,json=nodeMonitoring,proto3" json:"node_monitoring,omitempty"` + InstancesMonitoring []*InstanceMonitoring `protobuf:"bytes,2,rep,name=instances_monitoring,json=instancesMonitoring,proto3" json:"instances_monitoring,omitempty"` } func (x *AverageMonitoring) Reset() { *x = AverageMonitoring{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[36] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2650,7 +2604,7 @@ func (x *AverageMonitoring) String() string { func (*AverageMonitoring) ProtoMessage() {} func (x *AverageMonitoring) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[36] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2663,14 +2617,7 @@ func (x *AverageMonitoring) ProtoReflect() protoreflect.Message { // Deprecated: Use AverageMonitoring.ProtoReflect.Descriptor instead. func (*AverageMonitoring) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{36} -} - -func (x *AverageMonitoring) GetTimestamp() *timestamppb.Timestamp { - if x != nil { - return x.Timestamp - } - return nil + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{35} } func (x *AverageMonitoring) GetNodeMonitoring() *MonitoringData { @@ -2680,9 +2627,9 @@ func (x *AverageMonitoring) GetNodeMonitoring() *MonitoringData { return nil } -func (x *AverageMonitoring) GetInstanceMonitoring() []*InstanceMonitoring { +func (x *AverageMonitoring) GetInstancesMonitoring() []*InstanceMonitoring { if x != nil { - return x.InstanceMonitoring + return x.InstancesMonitoring } return nil } @@ -2692,17 +2639,18 @@ type MonitoringData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Ram uint64 `protobuf:"varint,1,opt,name=ram,proto3" json:"ram,omitempty"` - Cpu uint64 `protobuf:"varint,2,opt,name=cpu,proto3" json:"cpu,omitempty"` - Disk []*PartitionUsage `protobuf:"bytes,3,rep,name=disk,proto3" json:"disk,omitempty"` - InTraffic uint64 `protobuf:"varint,4,opt,name=in_traffic,json=inTraffic,proto3" json:"in_traffic,omitempty"` - OutTraffic uint64 `protobuf:"varint,5,opt,name=out_traffic,json=outTraffic,proto3" json:"out_traffic,omitempty"` + Ram uint64 `protobuf:"varint,1,opt,name=ram,proto3" json:"ram,omitempty"` + Cpu uint64 `protobuf:"varint,2,opt,name=cpu,proto3" json:"cpu,omitempty"` + Disk []*PartitionUsage `protobuf:"bytes,3,rep,name=disk,proto3" json:"disk,omitempty"` + InTraffic uint64 `protobuf:"varint,4,opt,name=in_traffic,json=inTraffic,proto3" json:"in_traffic,omitempty"` + OutTraffic uint64 `protobuf:"varint,5,opt,name=out_traffic,json=outTraffic,proto3" json:"out_traffic,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *MonitoringData) Reset() { *x = MonitoringData{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[37] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2715,7 +2663,7 @@ func (x *MonitoringData) String() string { func (*MonitoringData) ProtoMessage() {} func (x *MonitoringData) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[37] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[36] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2728,7 +2676,7 @@ func (x *MonitoringData) ProtoReflect() protoreflect.Message { // Deprecated: Use MonitoringData.ProtoReflect.Descriptor instead. func (*MonitoringData) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{37} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{36} } func (x *MonitoringData) GetRam() uint64 { @@ -2766,6 +2714,13 @@ func (x *MonitoringData) GetOutTraffic() uint64 { return 0 } +func (x *MonitoringData) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + type PartitionUsage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2778,7 +2733,7 @@ type PartitionUsage struct { func (x *PartitionUsage) Reset() { *x = PartitionUsage{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[38] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2791,7 +2746,7 @@ func (x *PartitionUsage) String() string { func (*PartitionUsage) ProtoMessage() {} func (x *PartitionUsage) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[38] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2804,7 +2759,7 @@ func (x *PartitionUsage) ProtoReflect() protoreflect.Message { // Deprecated: Use PartitionUsage.ProtoReflect.Descriptor instead. func (*PartitionUsage) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{38} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{37} } func (x *PartitionUsage) GetName() string { @@ -2833,7 +2788,7 @@ type InstanceMonitoring struct { func (x *InstanceMonitoring) Reset() { *x = InstanceMonitoring{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[39] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2846,7 +2801,7 @@ func (x *InstanceMonitoring) String() string { func (*InstanceMonitoring) ProtoMessage() {} func (x *InstanceMonitoring) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[39] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[38] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2859,7 +2814,7 @@ func (x *InstanceMonitoring) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceMonitoring.ProtoReflect.Descriptor instead. func (*InstanceMonitoring) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{39} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{38} } func (x *InstanceMonitoring) GetInstance() *common.InstanceIdent { @@ -2898,7 +2853,7 @@ type Alert struct { func (x *Alert) Reset() { *x = Alert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[40] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2911,7 +2866,7 @@ func (x *Alert) String() string { func (*Alert) ProtoMessage() {} func (x *Alert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[40] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2924,7 +2879,7 @@ func (x *Alert) ProtoReflect() protoreflect.Message { // Deprecated: Use Alert.ProtoReflect.Descriptor instead. func (*Alert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{40} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{39} } func (x *Alert) GetTimestamp() *timestamppb.Timestamp { @@ -3056,7 +3011,7 @@ type ImageContentRequest struct { func (x *ImageContentRequest) Reset() { *x = ImageContentRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[41] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3069,7 +3024,7 @@ func (x *ImageContentRequest) String() string { func (*ImageContentRequest) ProtoMessage() {} func (x *ImageContentRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[41] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3082,7 +3037,7 @@ func (x *ImageContentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ImageContentRequest.ProtoReflect.Descriptor instead. func (*ImageContentRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{41} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{40} } func (x *ImageContentRequest) GetUrl() string { @@ -3115,7 +3070,7 @@ type ClockSyncRequest struct { func (x *ClockSyncRequest) Reset() { *x = ClockSyncRequest{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[42] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3128,7 +3083,7 @@ func (x *ClockSyncRequest) String() string { func (*ClockSyncRequest) ProtoMessage() {} func (x *ClockSyncRequest) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[42] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[41] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3141,7 +3096,7 @@ func (x *ClockSyncRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ClockSyncRequest.ProtoReflect.Descriptor instead. func (*ClockSyncRequest) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{42} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{41} } type SystemQuotaAlert struct { @@ -3157,7 +3112,7 @@ type SystemQuotaAlert struct { func (x *SystemQuotaAlert) Reset() { *x = SystemQuotaAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[43] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3170,7 +3125,7 @@ func (x *SystemQuotaAlert) String() string { func (*SystemQuotaAlert) ProtoMessage() {} func (x *SystemQuotaAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[43] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[42] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3183,7 +3138,7 @@ func (x *SystemQuotaAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemQuotaAlert.ProtoReflect.Descriptor instead. func (*SystemQuotaAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{43} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{42} } func (x *SystemQuotaAlert) GetParameter() string { @@ -3221,7 +3176,7 @@ type InstanceQuotaAlert struct { func (x *InstanceQuotaAlert) Reset() { *x = InstanceQuotaAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[44] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3234,7 +3189,7 @@ func (x *InstanceQuotaAlert) String() string { func (*InstanceQuotaAlert) ProtoMessage() {} func (x *InstanceQuotaAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[44] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[43] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3247,7 +3202,7 @@ func (x *InstanceQuotaAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceQuotaAlert.ProtoReflect.Descriptor instead. func (*InstanceQuotaAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{44} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{43} } func (x *InstanceQuotaAlert) GetInstance() *common.InstanceIdent { @@ -3291,7 +3246,7 @@ type DeviceAllocateAlert struct { func (x *DeviceAllocateAlert) Reset() { *x = DeviceAllocateAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[45] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3304,7 +3259,7 @@ func (x *DeviceAllocateAlert) String() string { func (*DeviceAllocateAlert) ProtoMessage() {} func (x *DeviceAllocateAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[45] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[44] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3317,7 +3272,7 @@ func (x *DeviceAllocateAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use DeviceAllocateAlert.ProtoReflect.Descriptor instead. func (*DeviceAllocateAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{45} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{44} } func (x *DeviceAllocateAlert) GetInstance() *common.InstanceIdent { @@ -3353,7 +3308,7 @@ type ResourceValidateAlert struct { func (x *ResourceValidateAlert) Reset() { *x = ResourceValidateAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[46] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3366,7 +3321,7 @@ func (x *ResourceValidateAlert) String() string { func (*ResourceValidateAlert) ProtoMessage() {} func (x *ResourceValidateAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[46] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[45] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3379,7 +3334,7 @@ func (x *ResourceValidateAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceValidateAlert.ProtoReflect.Descriptor instead. func (*ResourceValidateAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{46} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{45} } func (x *ResourceValidateAlert) GetName() string { @@ -3407,7 +3362,7 @@ type SystemAlert struct { func (x *SystemAlert) Reset() { *x = SystemAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[47] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3420,7 +3375,7 @@ func (x *SystemAlert) String() string { func (*SystemAlert) ProtoMessage() {} func (x *SystemAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[47] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[46] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3433,7 +3388,7 @@ func (x *SystemAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use SystemAlert.ProtoReflect.Descriptor instead. func (*SystemAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{47} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{46} } func (x *SystemAlert) GetMessage() string { @@ -3455,7 +3410,7 @@ type CoreAlert struct { func (x *CoreAlert) Reset() { *x = CoreAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[48] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3468,7 +3423,7 @@ func (x *CoreAlert) String() string { func (*CoreAlert) ProtoMessage() {} func (x *CoreAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[48] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[47] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3481,7 +3436,7 @@ func (x *CoreAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use CoreAlert.ProtoReflect.Descriptor instead. func (*CoreAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{48} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{47} } func (x *CoreAlert) GetCoreComponent() string { @@ -3511,7 +3466,7 @@ type InstanceAlert struct { func (x *InstanceAlert) Reset() { *x = InstanceAlert{} if protoimpl.UnsafeEnabled { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[49] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3524,7 +3479,7 @@ func (x *InstanceAlert) String() string { func (*InstanceAlert) ProtoMessage() {} func (x *InstanceAlert) ProtoReflect() protoreflect.Message { - mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[49] + mi := &file_servicemanager_v4_servicemanager_proto_msgTypes[48] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3537,7 +3492,7 @@ func (x *InstanceAlert) ProtoReflect() protoreflect.Message { // Deprecated: Use InstanceAlert.ProtoReflect.Descriptor instead. func (*InstanceAlert) Descriptor() ([]byte, []int) { - return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{49} + return file_servicemanager_v4_servicemanager_proto_rawDescGZIP(), []int{48} } func (x *InstanceAlert) GetInstance() *common.InstanceIdent { @@ -3573,22 +3528,22 @@ var file_servicemanager_v4_servicemanager_proto_rawDesc = []byte{ 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xba, 0x09, 0x0a, 0x12, 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x5d, 0x0a, 0x16, 0x67, - 0x65, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, + 0x65, 0x74, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x47, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x13, 0x67, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, + 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x13, 0x67, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x50, 0x0a, 0x11, 0x63, 0x68, - 0x65, 0x63, 0x6b, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x65, 0x63, 0x6b, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x55, - 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0f, 0x63, 0x68, 0x65, - 0x63, 0x6b, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4a, 0x0a, 0x0f, - 0x73, 0x65, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4e, + 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0f, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4a, 0x0a, 0x0f, + 0x73, 0x65, 0x74, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x65, 0x74, 0x55, 0x6e, 0x69, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x65, 0x74, 0x55, 0x6e, - 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x46, 0x0a, 0x0d, 0x72, 0x75, 0x6e, 0x5f, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x65, 0x74, 0x4e, 0x6f, 0x64, + 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x65, 0x74, 0x4e, 0x6f, + 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x46, 0x0a, 0x0d, 0x72, 0x75, 0x6e, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, @@ -3647,16 +3602,16 @@ var file_servicemanager_v4_servicemanager_proto_rawDesc = []byte{ 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x00, 0x52, 0x09, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x42, 0x13, 0x0a, 0x11, 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x65, 0x22, 0x15, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x4c, 0x0a, 0x0f, 0x43, 0x68, 0x65, 0x63, - 0x6b, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x75, - 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, + 0x6b, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, + 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x4a, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x55, 0x6e, 0x69, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x6e, 0x69, 0x74, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x6e, - 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x4a, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x4e, 0x6f, 0x64, + 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6e, 0x6f, + 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x52, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x40, 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, @@ -3745,40 +3700,54 @@ var file_servicemanager_v4_servicemanager_proto_rawDesc = []byte{ 0x76, 0x61, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x45, - 0x6e, 0x76, 0x56, 0x61, 0x72, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x22, 0x97, + 0x6e, 0x76, 0x56, 0x61, 0x72, 0x52, 0x07, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x22, 0xa1, 0x01, 0x0a, 0x16, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x12, 0x4a, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, - 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x31, 0x0a, 0x04, 0x76, 0x61, 0x72, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x04, 0x76, 0x61, 0x72, 0x73, 0x22, 0x6d, 0x0a, 0x0a, 0x45, 0x6e, 0x76, 0x56, - 0x61, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x61, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, - 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x74, 0x74, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x89, 0x01, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, - 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, - 0x67, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, - 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, - 0x69, 0x6c, 0x6c, 0x22, 0x6a, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, - 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, - 0xd7, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, 0x52, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x3b, 0x0a, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x76, + 0x56, 0x61, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x76, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x22, 0x64, 0x0a, 0x0a, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x74, 0x74, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x89, 0x01, 0x0a, 0x10, 0x53, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, + 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, + 0x6f, 0x67, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, + 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, + 0x74, 0x69, 0x6c, 0x6c, 0x22, 0x6a, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x22, 0xd7, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4c, 0x6f, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x4a, + 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, + 0x6f, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, + 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0xdc, 0x01, 0x0a, 0x17, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x4a, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, @@ -3791,344 +3760,325 @@ var file_servicemanager_v4_servicemanager_proto_rawDesc = []byte{ 0x61, 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0xdc, 0x01, 0x0a, 0x17, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x72, 0x61, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x4a, 0x0a, 0x0f, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x69, 0x6c, 0x6c, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x41, - 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, - 0x22, 0x58, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x44, 0x0a, 0x0c, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x5f, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0b, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x9c, 0x01, 0x0a, 0x10, 0x49, - 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x3d, - 0x0a, 0x0b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, - 0x65, 0x52, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x2a, 0x0a, - 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x5c, 0x0a, 0x09, 0x49, 0x6d, 0x61, - 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, - 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, 0x61, - 0x32, 0x35, 0x36, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x9b, 0x01, 0x0a, 0x0c, 0x49, 0x6d, 0x61, 0x67, - 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, - 0x70, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, 0x72, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x25, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x53, 0x4d, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0xa4, 0x07, 0x0a, - 0x12, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0b, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, - 0x73, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x4d, 0x48, 0x00, 0x52, 0x0a, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x53, 0x6d, 0x12, 0x53, 0x0a, 0x12, 0x75, 0x6e, 0x69, 0x74, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x55, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x10, 0x75, 0x6e, 0x69, 0x74, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x59, 0x0a, 0x14, 0x72, 0x75, - 0x6e, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x75, 0x6e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, - 0x00, 0x52, 0x12, 0x72, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x62, 0x0a, 0x17, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x48, 0x00, 0x52, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x60, 0x0a, 0x17, 0x6f, 0x76, 0x65, - 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4f, - 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x14, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, - 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2e, 0x0a, 0x03, 0x6c, - 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4c, 0x6f, 0x67, - 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x55, 0x0a, 0x12, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, - 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, - 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, - 0x6e, 0x67, 0x12, 0x55, 0x0a, 0x12, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x6f, - 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, + 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6c, 0x6c, 0x22, 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, + 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, + 0x67, 0x22, 0x58, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x44, 0x0a, 0x0c, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0b, + 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x9c, 0x01, 0x0a, 0x10, + 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, + 0x3d, 0x0a, 0x0b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, + 0x6c, 0x65, 0x52, 0x0a, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x2a, + 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x5c, 0x0a, 0x09, 0x49, 0x6d, + 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x68, + 0x61, 0x32, 0x35, 0x36, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x9b, 0x01, 0x0a, 0x0c, 0x49, 0x6d, 0x61, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, + 0x0b, 0x70, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x70, 0x61, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, + 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xe2, 0x06, 0x0a, 0x12, 0x53, 0x4d, 0x4f, 0x75, 0x74, + 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x53, 0x0a, + 0x12, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4e, 0x6f, + 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, + 0x52, 0x10, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x59, 0x0a, 0x14, 0x72, 0x75, 0x6e, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x12, 0x72, 0x75, 0x6e, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x62, 0x0a, + 0x17, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, - 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x11, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, - 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x30, 0x0a, 0x05, 0x61, 0x6c, 0x65, - 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x41, 0x6c, 0x65, - 0x72, 0x74, 0x48, 0x00, 0x52, 0x05, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x69, - 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, - 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x48, 0x00, 0x52, 0x13, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x12, 0x63, 0x6c, 0x6f, - 0x63, 0x6b, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, - 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, - 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x10, 0x63, 0x6c, - 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x13, - 0x0a, 0x11, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x22, 0x54, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, - 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, - 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x58, 0x0a, 0x10, 0x55, 0x6e, 0x69, - 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x22, 0x55, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, + 0x76, 0x34, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x15, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x60, 0x0a, 0x17, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x65, 0x6e, + 0x76, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, + 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x48, 0x00, 0x52, 0x14, 0x6f, + 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x2e, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4c, 0x6f, 0x67, 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52, 0x03, + 0x6c, 0x6f, 0x67, 0x12, 0x55, 0x0a, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x6d, + 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, + 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x55, 0x0a, 0x12, 0x61, 0x76, + 0x65, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x41, 0x76, 0x65, 0x72, 0x61, + 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x48, 0x00, 0x52, 0x11, + 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, + 0x67, 0x12, 0x30, 0x0a, 0x05, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x05, 0x61, 0x6c, + 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x13, 0x69, 0x6d, + 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x53, 0x0a, 0x12, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x34, 0x2e, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x48, 0x00, 0x52, 0x10, 0x63, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x13, 0x0a, 0x11, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, + 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x54, 0x0a, 0x09, 0x50, + 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x69, 0x7a, + 0x65, 0x22, 0x8e, 0x01, 0x0a, 0x10, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, + 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x22, 0x55, 0x0a, 0x12, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x58, 0x0a, 0x15, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x75, 0x6e, 0x5f, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x75, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x12, 0x33, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x93, 0x01, 0x0a, 0x14, 0x4f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x4f, 0x0a, 0x0f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, + 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x0d, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x9f, 0x01, + 0x0a, 0x14, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4a, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x12, 0x3b, 0x0a, 0x08, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x08, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x65, 0x73, 0x22, + 0x4e, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, + 0xab, 0x01, 0x0a, 0x07, 0x4c, 0x6f, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x15, 0x0a, 0x06, 0x6c, + 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, + 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x70, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xb9, 0x01, + 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, + 0x69, 0x6e, 0x67, 0x12, 0x4a, 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, + 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, - 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x58, 0x0a, 0x15, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, + 0x0e, 0x6e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, + 0x58, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x6d, 0x6f, 0x6e, + 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x4d, + 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xb9, 0x01, 0x0a, 0x11, 0x41, 0x76, + 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, + 0x4a, 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, + 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4d, 0x6f, 0x6e, + 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6e, 0x6f, 0x64, + 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x58, 0x0a, 0x14, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, + 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x4d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xe5, 0x01, 0x0a, 0x0e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, + 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x72, 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, + 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x35, 0x0a, 0x04, + 0x64, 0x69, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x50, + 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, 0x64, + 0x69, 0x73, 0x6b, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, + 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x69, 0x6e, 0x54, 0x72, 0x61, 0x66, 0x66, + 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, + 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x54, 0x72, 0x61, 0x66, + 0x66, 0x69, 0x63, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x41, 0x0a, + 0x0e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x75, 0x73, 0x65, 0x64, 0x53, 0x69, 0x7a, 0x65, + 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, + 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, - 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x75, 0x6e, 0x5f, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x75, 0x6e, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x33, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x69, 0x6e, 0x66, - 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x93, 0x01, 0x0a, 0x14, 0x4f, 0x76, 0x65, - 0x72, 0x72, 0x69, 0x64, 0x65, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x4f, 0x0a, 0x0f, 0x65, 0x6e, 0x76, 0x5f, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, - 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x0d, 0x65, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa4, - 0x01, 0x0a, 0x14, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4a, 0x0a, 0x0f, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x52, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x12, 0x40, 0x0a, 0x0b, 0x76, 0x61, 0x72, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x45, 0x6e, 0x76, - 0x56, 0x61, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x76, 0x61, 0x72, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x51, 0x0a, 0x0c, 0x45, 0x6e, 0x76, 0x56, 0x61, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x61, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x93, 0x01, 0x0a, 0x07, 0x4c, 0x6f, 0x67, - 0x44, 0x61, 0x74, 0x61, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70, - 0x61, 0x72, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x09, 0x70, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, - 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x61, 0x72, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xf1, - 0x01, 0x0a, 0x11, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, - 0x72, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x4a, - 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, - 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6e, 0x6f, 0x64, 0x65, - 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x56, 0x0a, 0x13, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, - 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, - 0x6e, 0x67, 0x22, 0xf1, 0x01, 0x0a, 0x11, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x6f, - 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x4a, 0x0a, 0x0f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, - 0x6e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x56, - 0x0a, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, - 0x6e, 0x67, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, - 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xab, 0x01, 0x0a, 0x0e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x72, 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x63, - 0x70, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x35, 0x0a, - 0x04, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x4a, 0x0a, + 0x0f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6d, 0x6f, 0x6e, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x22, 0x9f, 0x05, 0x0a, 0x05, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, + 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, + 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, + 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, - 0x64, 0x69, 0x73, 0x6b, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, - 0x69, 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x69, 0x6e, 0x54, 0x72, 0x61, 0x66, - 0x66, 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, - 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x54, 0x72, 0x61, - 0x66, 0x66, 0x69, 0x63, 0x22, 0x41, 0x0a, 0x0e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, - 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x75, - 0x73, 0x65, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x34, - 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, - 0x6e, 0x67, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x34, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, - 0x52, 0x0e, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, - 0x22, 0x9f, 0x05, 0x0a, 0x05, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, - 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, - 0x65, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, - 0x48, 0x00, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, - 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x62, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, - 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, - 0x74, 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x64, 0x65, - 0x76, 0x69, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, - 0x65, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x44, 0x65, + 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, + 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, + 0x6c, 0x65, 0x72, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, + 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x12, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, + 0x62, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x61, 0x6c, + 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, + 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x13, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, - 0x74, 0x48, 0x00, 0x52, 0x13, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, - 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, - 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, - 0x52, 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3d, 0x0a, - 0x0a, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, - 0x00, 0x52, 0x09, 0x63, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x49, 0x0a, 0x0e, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x22, 0x69, 0x0a, 0x13, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x12, 0x0a, - 0x10, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x5e, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, - 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, - 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, - 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, - 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x6c, 0x65, 0x72, + 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x61, + 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, + 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x09, 0x63, 0x6f, 0x72, 0x65, + 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x49, 0x0a, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, + 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, + 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x69, 0x0a, 0x13, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, + 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x5e, 0x0a, 0x10, 0x53, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x1c, + 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x7d, 0x0a, 0x13, 0x44, 0x65, - 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x59, 0x0a, 0x15, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, - 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x73, 0x22, 0x27, 0x0a, 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, - 0x65, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, - 0x09, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, - 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, - 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x0d, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, - 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x31, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, - 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, - 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x01, 0x32, 0x6d, 0x0a, 0x09, 0x53, 0x4d, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x53, 0x4d, 0x12, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, - 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x25, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x22, 0x7d, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, + 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x22, 0x59, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x2c, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x22, 0x27, 0x0a, + 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, 0x09, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, + 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, + 0x31, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, + 0x6d, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, + 0x10, 0x01, 0x32, 0x6d, 0x0a, 0x09, 0x53, 0x4d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x60, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x4d, 0x12, 0x25, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, + 0x34, 0x2e, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x73, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, + 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -4144,13 +4094,13 @@ func file_servicemanager_v4_servicemanager_proto_rawDescGZIP() []byte { } var file_servicemanager_v4_servicemanager_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_servicemanager_v4_servicemanager_proto_msgTypes = make([]protoimpl.MessageInfo, 50) +var file_servicemanager_v4_servicemanager_proto_msgTypes = make([]protoimpl.MessageInfo, 49) var file_servicemanager_v4_servicemanager_proto_goTypes = []interface{}{ (ConnectionEnum)(0), // 0: servicemanager.v4.ConnectionEnum (*SMIncomingMessages)(nil), // 1: servicemanager.v4.SMIncomingMessages - (*GetUnitConfigStatus)(nil), // 2: servicemanager.v4.GetUnitConfigStatus - (*CheckUnitConfig)(nil), // 3: servicemanager.v4.CheckUnitConfig - (*SetUnitConfig)(nil), // 4: servicemanager.v4.SetUnitConfig + (*GetNodeConfigStatus)(nil), // 2: servicemanager.v4.GetNodeConfigStatus + (*CheckNodeConfig)(nil), // 3: servicemanager.v4.CheckNodeConfig + (*SetNodeConfig)(nil), // 4: servicemanager.v4.SetNodeConfig (*UpdateNetworks)(nil), // 5: servicemanager.v4.UpdateNetworks (*ClockSync)(nil), // 6: servicemanager.v4.ClockSync (*RunInstances)(nil), // 7: servicemanager.v4.RunInstances @@ -4171,40 +4121,39 @@ var file_servicemanager_v4_servicemanager_proto_goTypes = []interface{}{ (*ImageContentInfo)(nil), // 22: servicemanager.v4.ImageContentInfo (*ImageFile)(nil), // 23: servicemanager.v4.ImageFile (*ImageContent)(nil), // 24: servicemanager.v4.ImageContent - (*RegisterSM)(nil), // 25: servicemanager.v4.RegisterSM - (*SMOutgoingMessages)(nil), // 26: servicemanager.v4.SMOutgoingMessages - (*Partition)(nil), // 27: servicemanager.v4.Partition - (*UnitConfigStatus)(nil), // 28: servicemanager.v4.UnitConfigStatus - (*RunInstancesStatus)(nil), // 29: servicemanager.v4.RunInstancesStatus - (*UpdateInstancesStatus)(nil), // 30: servicemanager.v4.UpdateInstancesStatus - (*InstanceStatus)(nil), // 31: servicemanager.v4.InstanceStatus - (*OverrideEnvVarStatus)(nil), // 32: servicemanager.v4.OverrideEnvVarStatus - (*EnvVarInstanceStatus)(nil), // 33: servicemanager.v4.EnvVarInstanceStatus - (*EnvVarStatus)(nil), // 34: servicemanager.v4.EnvVarStatus - (*LogData)(nil), // 35: servicemanager.v4.LogData - (*InstantMonitoring)(nil), // 36: servicemanager.v4.InstantMonitoring - (*AverageMonitoring)(nil), // 37: servicemanager.v4.AverageMonitoring - (*MonitoringData)(nil), // 38: servicemanager.v4.MonitoringData - (*PartitionUsage)(nil), // 39: servicemanager.v4.PartitionUsage - (*InstanceMonitoring)(nil), // 40: servicemanager.v4.InstanceMonitoring - (*Alert)(nil), // 41: servicemanager.v4.Alert - (*ImageContentRequest)(nil), // 42: servicemanager.v4.ImageContentRequest - (*ClockSyncRequest)(nil), // 43: servicemanager.v4.ClockSyncRequest - (*SystemQuotaAlert)(nil), // 44: servicemanager.v4.SystemQuotaAlert - (*InstanceQuotaAlert)(nil), // 45: servicemanager.v4.InstanceQuotaAlert - (*DeviceAllocateAlert)(nil), // 46: servicemanager.v4.DeviceAllocateAlert - (*ResourceValidateAlert)(nil), // 47: servicemanager.v4.ResourceValidateAlert - (*SystemAlert)(nil), // 48: servicemanager.v4.SystemAlert - (*CoreAlert)(nil), // 49: servicemanager.v4.CoreAlert - (*InstanceAlert)(nil), // 50: servicemanager.v4.InstanceAlert - (*timestamppb.Timestamp)(nil), // 51: google.protobuf.Timestamp - (*common.InstanceIdent)(nil), // 52: common.v1.InstanceIdent - (*common.ErrorInfo)(nil), // 53: common.v1.ErrorInfo + (*SMOutgoingMessages)(nil), // 25: servicemanager.v4.SMOutgoingMessages + (*Partition)(nil), // 26: servicemanager.v4.Partition + (*NodeConfigStatus)(nil), // 27: servicemanager.v4.NodeConfigStatus + (*RunInstancesStatus)(nil), // 28: servicemanager.v4.RunInstancesStatus + (*UpdateInstancesStatus)(nil), // 29: servicemanager.v4.UpdateInstancesStatus + (*InstanceStatus)(nil), // 30: servicemanager.v4.InstanceStatus + (*OverrideEnvVarStatus)(nil), // 31: servicemanager.v4.OverrideEnvVarStatus + (*EnvVarInstanceStatus)(nil), // 32: servicemanager.v4.EnvVarInstanceStatus + (*EnvVarStatus)(nil), // 33: servicemanager.v4.EnvVarStatus + (*LogData)(nil), // 34: servicemanager.v4.LogData + (*InstantMonitoring)(nil), // 35: servicemanager.v4.InstantMonitoring + (*AverageMonitoring)(nil), // 36: servicemanager.v4.AverageMonitoring + (*MonitoringData)(nil), // 37: servicemanager.v4.MonitoringData + (*PartitionUsage)(nil), // 38: servicemanager.v4.PartitionUsage + (*InstanceMonitoring)(nil), // 39: servicemanager.v4.InstanceMonitoring + (*Alert)(nil), // 40: servicemanager.v4.Alert + (*ImageContentRequest)(nil), // 41: servicemanager.v4.ImageContentRequest + (*ClockSyncRequest)(nil), // 42: servicemanager.v4.ClockSyncRequest + (*SystemQuotaAlert)(nil), // 43: servicemanager.v4.SystemQuotaAlert + (*InstanceQuotaAlert)(nil), // 44: servicemanager.v4.InstanceQuotaAlert + (*DeviceAllocateAlert)(nil), // 45: servicemanager.v4.DeviceAllocateAlert + (*ResourceValidateAlert)(nil), // 46: servicemanager.v4.ResourceValidateAlert + (*SystemAlert)(nil), // 47: servicemanager.v4.SystemAlert + (*CoreAlert)(nil), // 48: servicemanager.v4.CoreAlert + (*InstanceAlert)(nil), // 49: servicemanager.v4.InstanceAlert + (*timestamppb.Timestamp)(nil), // 50: google.protobuf.Timestamp + (*common.InstanceIdent)(nil), // 51: common.v1.InstanceIdent + (*common.ErrorInfo)(nil), // 52: common.v1.ErrorInfo } var file_servicemanager_v4_servicemanager_proto_depIdxs = []int32{ - 2, // 0: servicemanager.v4.SMIncomingMessages.get_unit_config_status:type_name -> servicemanager.v4.GetUnitConfigStatus - 3, // 1: servicemanager.v4.SMIncomingMessages.check_unit_config:type_name -> servicemanager.v4.CheckUnitConfig - 4, // 2: servicemanager.v4.SMIncomingMessages.set_unit_config:type_name -> servicemanager.v4.SetUnitConfig + 2, // 0: servicemanager.v4.SMIncomingMessages.get_node_config_status:type_name -> servicemanager.v4.GetNodeConfigStatus + 3, // 1: servicemanager.v4.SMIncomingMessages.check_node_config:type_name -> servicemanager.v4.CheckNodeConfig + 4, // 2: servicemanager.v4.SMIncomingMessages.set_node_config:type_name -> servicemanager.v4.SetNodeConfig 7, // 3: servicemanager.v4.SMIncomingMessages.run_instances:type_name -> servicemanager.v4.RunInstances 13, // 4: servicemanager.v4.SMIncomingMessages.override_env_vars:type_name -> servicemanager.v4.OverrideEnvVars 16, // 5: servicemanager.v4.SMIncomingMessages.system_log_request:type_name -> servicemanager.v4.SystemLogRequest @@ -4217,78 +4166,76 @@ var file_servicemanager_v4_servicemanager_proto_depIdxs = []int32{ 5, // 12: servicemanager.v4.SMIncomingMessages.update_networks:type_name -> servicemanager.v4.UpdateNetworks 6, // 13: servicemanager.v4.SMIncomingMessages.clock_sync:type_name -> servicemanager.v4.ClockSync 11, // 14: servicemanager.v4.UpdateNetworks.networks:type_name -> servicemanager.v4.NetworkParameters - 51, // 15: servicemanager.v4.ClockSync.current_time:type_name -> google.protobuf.Timestamp + 50, // 15: servicemanager.v4.ClockSync.current_time:type_name -> google.protobuf.Timestamp 8, // 16: servicemanager.v4.RunInstances.services:type_name -> servicemanager.v4.ServiceInfo 9, // 17: servicemanager.v4.RunInstances.layers:type_name -> servicemanager.v4.LayerInfo 12, // 18: servicemanager.v4.RunInstances.instances:type_name -> servicemanager.v4.InstanceInfo 10, // 19: servicemanager.v4.NetworkParameters.rules:type_name -> servicemanager.v4.FirewallRule - 52, // 20: servicemanager.v4.InstanceInfo.instance:type_name -> common.v1.InstanceIdent + 51, // 20: servicemanager.v4.InstanceInfo.instance:type_name -> common.v1.InstanceIdent 11, // 21: servicemanager.v4.InstanceInfo.network_parameters:type_name -> servicemanager.v4.NetworkParameters 14, // 22: servicemanager.v4.OverrideEnvVars.env_vars:type_name -> servicemanager.v4.OverrideInstanceEnvVar 17, // 23: servicemanager.v4.OverrideInstanceEnvVar.instance_filter:type_name -> servicemanager.v4.InstanceFilter - 15, // 24: servicemanager.v4.OverrideInstanceEnvVar.vars:type_name -> servicemanager.v4.EnvVarInfo - 51, // 25: servicemanager.v4.EnvVarInfo.ttl:type_name -> google.protobuf.Timestamp - 51, // 26: servicemanager.v4.SystemLogRequest.from:type_name -> google.protobuf.Timestamp - 51, // 27: servicemanager.v4.SystemLogRequest.till:type_name -> google.protobuf.Timestamp + 15, // 24: servicemanager.v4.OverrideInstanceEnvVar.variables:type_name -> servicemanager.v4.EnvVarInfo + 50, // 25: servicemanager.v4.EnvVarInfo.ttl:type_name -> google.protobuf.Timestamp + 50, // 26: servicemanager.v4.SystemLogRequest.from:type_name -> google.protobuf.Timestamp + 50, // 27: servicemanager.v4.SystemLogRequest.till:type_name -> google.protobuf.Timestamp 17, // 28: servicemanager.v4.InstanceLogRequest.instance_filter:type_name -> servicemanager.v4.InstanceFilter - 51, // 29: servicemanager.v4.InstanceLogRequest.from:type_name -> google.protobuf.Timestamp - 51, // 30: servicemanager.v4.InstanceLogRequest.till:type_name -> google.protobuf.Timestamp + 50, // 29: servicemanager.v4.InstanceLogRequest.from:type_name -> google.protobuf.Timestamp + 50, // 30: servicemanager.v4.InstanceLogRequest.till:type_name -> google.protobuf.Timestamp 17, // 31: servicemanager.v4.InstanceCrashLogRequest.instance_filter:type_name -> servicemanager.v4.InstanceFilter - 51, // 32: servicemanager.v4.InstanceCrashLogRequest.from:type_name -> google.protobuf.Timestamp - 51, // 33: servicemanager.v4.InstanceCrashLogRequest.till:type_name -> google.protobuf.Timestamp + 50, // 32: servicemanager.v4.InstanceCrashLogRequest.from:type_name -> google.protobuf.Timestamp + 50, // 33: servicemanager.v4.InstanceCrashLogRequest.till:type_name -> google.protobuf.Timestamp 0, // 34: servicemanager.v4.ConnectionStatus.cloud_status:type_name -> servicemanager.v4.ConnectionEnum 23, // 35: servicemanager.v4.ImageContentInfo.image_files:type_name -> servicemanager.v4.ImageFile - 53, // 36: servicemanager.v4.ImageContentInfo.error:type_name -> common.v1.ErrorInfo - 25, // 37: servicemanager.v4.SMOutgoingMessages.register_sm:type_name -> servicemanager.v4.RegisterSM - 28, // 38: servicemanager.v4.SMOutgoingMessages.unit_config_status:type_name -> servicemanager.v4.UnitConfigStatus - 29, // 39: servicemanager.v4.SMOutgoingMessages.run_instances_status:type_name -> servicemanager.v4.RunInstancesStatus - 30, // 40: servicemanager.v4.SMOutgoingMessages.update_instances_status:type_name -> servicemanager.v4.UpdateInstancesStatus - 32, // 41: servicemanager.v4.SMOutgoingMessages.override_env_var_status:type_name -> servicemanager.v4.OverrideEnvVarStatus - 35, // 42: servicemanager.v4.SMOutgoingMessages.log:type_name -> servicemanager.v4.LogData - 36, // 43: servicemanager.v4.SMOutgoingMessages.instant_monitoring:type_name -> servicemanager.v4.InstantMonitoring - 37, // 44: servicemanager.v4.SMOutgoingMessages.average_monitoring:type_name -> servicemanager.v4.AverageMonitoring - 41, // 45: servicemanager.v4.SMOutgoingMessages.alert:type_name -> servicemanager.v4.Alert - 42, // 46: servicemanager.v4.SMOutgoingMessages.image_content_request:type_name -> servicemanager.v4.ImageContentRequest - 43, // 47: servicemanager.v4.SMOutgoingMessages.clock_sync_request:type_name -> servicemanager.v4.ClockSyncRequest - 53, // 48: servicemanager.v4.UnitConfigStatus.error:type_name -> common.v1.ErrorInfo - 31, // 49: servicemanager.v4.RunInstancesStatus.instances:type_name -> servicemanager.v4.InstanceStatus - 31, // 50: servicemanager.v4.UpdateInstancesStatus.instances:type_name -> servicemanager.v4.InstanceStatus - 52, // 51: servicemanager.v4.InstanceStatus.instance:type_name -> common.v1.InstanceIdent - 53, // 52: servicemanager.v4.InstanceStatus.error_info:type_name -> common.v1.ErrorInfo - 33, // 53: servicemanager.v4.OverrideEnvVarStatus.env_vars_status:type_name -> servicemanager.v4.EnvVarInstanceStatus - 53, // 54: servicemanager.v4.OverrideEnvVarStatus.error:type_name -> common.v1.ErrorInfo - 17, // 55: servicemanager.v4.EnvVarInstanceStatus.instance_filter:type_name -> servicemanager.v4.InstanceFilter - 34, // 56: servicemanager.v4.EnvVarInstanceStatus.vars_status:type_name -> servicemanager.v4.EnvVarStatus - 53, // 57: servicemanager.v4.EnvVarStatus.error:type_name -> common.v1.ErrorInfo - 53, // 58: servicemanager.v4.LogData.error:type_name -> common.v1.ErrorInfo - 51, // 59: servicemanager.v4.InstantMonitoring.timestamp:type_name -> google.protobuf.Timestamp - 38, // 60: servicemanager.v4.InstantMonitoring.node_monitoring:type_name -> servicemanager.v4.MonitoringData - 40, // 61: servicemanager.v4.InstantMonitoring.instance_monitoring:type_name -> servicemanager.v4.InstanceMonitoring - 51, // 62: servicemanager.v4.AverageMonitoring.timestamp:type_name -> google.protobuf.Timestamp - 38, // 63: servicemanager.v4.AverageMonitoring.node_monitoring:type_name -> servicemanager.v4.MonitoringData - 40, // 64: servicemanager.v4.AverageMonitoring.instance_monitoring:type_name -> servicemanager.v4.InstanceMonitoring - 39, // 65: servicemanager.v4.MonitoringData.disk:type_name -> servicemanager.v4.PartitionUsage - 52, // 66: servicemanager.v4.InstanceMonitoring.instance:type_name -> common.v1.InstanceIdent - 38, // 67: servicemanager.v4.InstanceMonitoring.monitoring_data:type_name -> servicemanager.v4.MonitoringData - 51, // 68: servicemanager.v4.Alert.timestamp:type_name -> google.protobuf.Timestamp - 44, // 69: servicemanager.v4.Alert.system_quota_alert:type_name -> servicemanager.v4.SystemQuotaAlert - 45, // 70: servicemanager.v4.Alert.instance_quota_alert:type_name -> servicemanager.v4.InstanceQuotaAlert - 47, // 71: servicemanager.v4.Alert.resource_validate_alert:type_name -> servicemanager.v4.ResourceValidateAlert - 46, // 72: servicemanager.v4.Alert.device_allocate_alert:type_name -> servicemanager.v4.DeviceAllocateAlert - 48, // 73: servicemanager.v4.Alert.system_alert:type_name -> servicemanager.v4.SystemAlert - 49, // 74: servicemanager.v4.Alert.core_alert:type_name -> servicemanager.v4.CoreAlert - 50, // 75: servicemanager.v4.Alert.instance_alert:type_name -> servicemanager.v4.InstanceAlert - 52, // 76: servicemanager.v4.InstanceQuotaAlert.instance:type_name -> common.v1.InstanceIdent - 52, // 77: servicemanager.v4.DeviceAllocateAlert.instance:type_name -> common.v1.InstanceIdent - 53, // 78: servicemanager.v4.ResourceValidateAlert.errors:type_name -> common.v1.ErrorInfo - 52, // 79: servicemanager.v4.InstanceAlert.instance:type_name -> common.v1.InstanceIdent - 26, // 80: servicemanager.v4.SMService.RegisterSM:input_type -> servicemanager.v4.SMOutgoingMessages - 1, // 81: servicemanager.v4.SMService.RegisterSM:output_type -> servicemanager.v4.SMIncomingMessages - 81, // [81:82] is the sub-list for method output_type - 80, // [80:81] is the sub-list for method input_type - 80, // [80:80] is the sub-list for extension type_name - 80, // [80:80] is the sub-list for extension extendee - 0, // [0:80] is the sub-list for field type_name + 52, // 36: servicemanager.v4.ImageContentInfo.error:type_name -> common.v1.ErrorInfo + 27, // 37: servicemanager.v4.SMOutgoingMessages.node_config_status:type_name -> servicemanager.v4.NodeConfigStatus + 28, // 38: servicemanager.v4.SMOutgoingMessages.run_instances_status:type_name -> servicemanager.v4.RunInstancesStatus + 29, // 39: servicemanager.v4.SMOutgoingMessages.update_instances_status:type_name -> servicemanager.v4.UpdateInstancesStatus + 31, // 40: servicemanager.v4.SMOutgoingMessages.override_env_var_status:type_name -> servicemanager.v4.OverrideEnvVarStatus + 34, // 41: servicemanager.v4.SMOutgoingMessages.log:type_name -> servicemanager.v4.LogData + 35, // 42: servicemanager.v4.SMOutgoingMessages.instant_monitoring:type_name -> servicemanager.v4.InstantMonitoring + 36, // 43: servicemanager.v4.SMOutgoingMessages.average_monitoring:type_name -> servicemanager.v4.AverageMonitoring + 40, // 44: servicemanager.v4.SMOutgoingMessages.alert:type_name -> servicemanager.v4.Alert + 41, // 45: servicemanager.v4.SMOutgoingMessages.image_content_request:type_name -> servicemanager.v4.ImageContentRequest + 42, // 46: servicemanager.v4.SMOutgoingMessages.clock_sync_request:type_name -> servicemanager.v4.ClockSyncRequest + 52, // 47: servicemanager.v4.NodeConfigStatus.error:type_name -> common.v1.ErrorInfo + 30, // 48: servicemanager.v4.RunInstancesStatus.instances:type_name -> servicemanager.v4.InstanceStatus + 30, // 49: servicemanager.v4.UpdateInstancesStatus.instances:type_name -> servicemanager.v4.InstanceStatus + 51, // 50: servicemanager.v4.InstanceStatus.instance:type_name -> common.v1.InstanceIdent + 52, // 51: servicemanager.v4.InstanceStatus.error_info:type_name -> common.v1.ErrorInfo + 32, // 52: servicemanager.v4.OverrideEnvVarStatus.env_vars_status:type_name -> servicemanager.v4.EnvVarInstanceStatus + 52, // 53: servicemanager.v4.OverrideEnvVarStatus.error:type_name -> common.v1.ErrorInfo + 17, // 54: servicemanager.v4.EnvVarInstanceStatus.instance_filter:type_name -> servicemanager.v4.InstanceFilter + 33, // 55: servicemanager.v4.EnvVarInstanceStatus.statuses:type_name -> servicemanager.v4.EnvVarStatus + 52, // 56: servicemanager.v4.EnvVarStatus.error:type_name -> common.v1.ErrorInfo + 52, // 57: servicemanager.v4.LogData.error:type_name -> common.v1.ErrorInfo + 37, // 58: servicemanager.v4.InstantMonitoring.node_monitoring:type_name -> servicemanager.v4.MonitoringData + 39, // 59: servicemanager.v4.InstantMonitoring.instances_monitoring:type_name -> servicemanager.v4.InstanceMonitoring + 37, // 60: servicemanager.v4.AverageMonitoring.node_monitoring:type_name -> servicemanager.v4.MonitoringData + 39, // 61: servicemanager.v4.AverageMonitoring.instances_monitoring:type_name -> servicemanager.v4.InstanceMonitoring + 38, // 62: servicemanager.v4.MonitoringData.disk:type_name -> servicemanager.v4.PartitionUsage + 50, // 63: servicemanager.v4.MonitoringData.timestamp:type_name -> google.protobuf.Timestamp + 51, // 64: servicemanager.v4.InstanceMonitoring.instance:type_name -> common.v1.InstanceIdent + 37, // 65: servicemanager.v4.InstanceMonitoring.monitoring_data:type_name -> servicemanager.v4.MonitoringData + 50, // 66: servicemanager.v4.Alert.timestamp:type_name -> google.protobuf.Timestamp + 43, // 67: servicemanager.v4.Alert.system_quota_alert:type_name -> servicemanager.v4.SystemQuotaAlert + 44, // 68: servicemanager.v4.Alert.instance_quota_alert:type_name -> servicemanager.v4.InstanceQuotaAlert + 46, // 69: servicemanager.v4.Alert.resource_validate_alert:type_name -> servicemanager.v4.ResourceValidateAlert + 45, // 70: servicemanager.v4.Alert.device_allocate_alert:type_name -> servicemanager.v4.DeviceAllocateAlert + 47, // 71: servicemanager.v4.Alert.system_alert:type_name -> servicemanager.v4.SystemAlert + 48, // 72: servicemanager.v4.Alert.core_alert:type_name -> servicemanager.v4.CoreAlert + 49, // 73: servicemanager.v4.Alert.instance_alert:type_name -> servicemanager.v4.InstanceAlert + 51, // 74: servicemanager.v4.InstanceQuotaAlert.instance:type_name -> common.v1.InstanceIdent + 51, // 75: servicemanager.v4.DeviceAllocateAlert.instance:type_name -> common.v1.InstanceIdent + 52, // 76: servicemanager.v4.ResourceValidateAlert.errors:type_name -> common.v1.ErrorInfo + 51, // 77: servicemanager.v4.InstanceAlert.instance:type_name -> common.v1.InstanceIdent + 25, // 78: servicemanager.v4.SMService.RegisterSM:input_type -> servicemanager.v4.SMOutgoingMessages + 1, // 79: servicemanager.v4.SMService.RegisterSM:output_type -> servicemanager.v4.SMIncomingMessages + 79, // [79:80] is the sub-list for method output_type + 78, // [78:79] is the sub-list for method input_type + 78, // [78:78] is the sub-list for extension type_name + 78, // [78:78] is the sub-list for extension extendee + 0, // [0:78] is the sub-list for field type_name } func init() { file_servicemanager_v4_servicemanager_proto_init() } @@ -4310,7 +4257,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUnitConfigStatus); i { + switch v := v.(*GetNodeConfigStatus); i { case 0: return &v.state case 1: @@ -4322,7 +4269,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckUnitConfig); i { + switch v := v.(*CheckNodeConfig); i { case 0: return &v.state case 1: @@ -4334,7 +4281,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SetUnitConfig); i { + switch v := v.(*SetNodeConfig); i { case 0: return &v.state case 1: @@ -4586,7 +4533,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RegisterSM); i { + switch v := v.(*SMOutgoingMessages); i { case 0: return &v.state case 1: @@ -4598,7 +4545,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SMOutgoingMessages); i { + switch v := v.(*Partition); i { case 0: return &v.state case 1: @@ -4610,7 +4557,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Partition); i { + switch v := v.(*NodeConfigStatus); i { case 0: return &v.state case 1: @@ -4622,18 +4569,6 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UnitConfigStatus); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_servicemanager_v4_servicemanager_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RunInstancesStatus); i { case 0: return &v.state @@ -4645,7 +4580,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateInstancesStatus); i { case 0: return &v.state @@ -4657,7 +4592,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceStatus); i { case 0: return &v.state @@ -4669,7 +4604,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*OverrideEnvVarStatus); i { case 0: return &v.state @@ -4681,7 +4616,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*EnvVarInstanceStatus); i { case 0: return &v.state @@ -4693,7 +4628,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*EnvVarStatus); i { case 0: return &v.state @@ -4705,7 +4640,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*LogData); i { case 0: return &v.state @@ -4717,7 +4652,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstantMonitoring); i { case 0: return &v.state @@ -4729,7 +4664,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AverageMonitoring); i { case 0: return &v.state @@ -4741,7 +4676,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MonitoringData); i { case 0: return &v.state @@ -4753,7 +4688,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PartitionUsage); i { case 0: return &v.state @@ -4765,7 +4700,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceMonitoring); i { case 0: return &v.state @@ -4777,7 +4712,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Alert); i { case 0: return &v.state @@ -4789,7 +4724,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ImageContentRequest); i { case 0: return &v.state @@ -4801,7 +4736,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ClockSyncRequest); i { case 0: return &v.state @@ -4813,7 +4748,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SystemQuotaAlert); i { case 0: return &v.state @@ -4825,7 +4760,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceQuotaAlert); i { case 0: return &v.state @@ -4837,7 +4772,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeviceAllocateAlert); i { case 0: return &v.state @@ -4849,7 +4784,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceValidateAlert); i { case 0: return &v.state @@ -4861,7 +4796,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SystemAlert); i { case 0: return &v.state @@ -4873,7 +4808,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CoreAlert); i { case 0: return &v.state @@ -4885,7 +4820,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { return nil } } - file_servicemanager_v4_servicemanager_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + file_servicemanager_v4_servicemanager_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstanceAlert); i { case 0: return &v.state @@ -4899,9 +4834,9 @@ func file_servicemanager_v4_servicemanager_proto_init() { } } file_servicemanager_v4_servicemanager_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*SMIncomingMessages_GetUnitConfigStatus)(nil), - (*SMIncomingMessages_CheckUnitConfig)(nil), - (*SMIncomingMessages_SetUnitConfig)(nil), + (*SMIncomingMessages_GetNodeConfigStatus)(nil), + (*SMIncomingMessages_CheckNodeConfig)(nil), + (*SMIncomingMessages_SetNodeConfig)(nil), (*SMIncomingMessages_RunInstances)(nil), (*SMIncomingMessages_OverrideEnvVars)(nil), (*SMIncomingMessages_SystemLogRequest)(nil), @@ -4914,9 +4849,8 @@ func file_servicemanager_v4_servicemanager_proto_init() { (*SMIncomingMessages_UpdateNetworks)(nil), (*SMIncomingMessages_ClockSync)(nil), } - file_servicemanager_v4_servicemanager_proto_msgTypes[25].OneofWrappers = []interface{}{ - (*SMOutgoingMessages_RegisterSm)(nil), - (*SMOutgoingMessages_UnitConfigStatus)(nil), + file_servicemanager_v4_servicemanager_proto_msgTypes[24].OneofWrappers = []interface{}{ + (*SMOutgoingMessages_NodeConfigStatus)(nil), (*SMOutgoingMessages_RunInstancesStatus)(nil), (*SMOutgoingMessages_UpdateInstancesStatus)(nil), (*SMOutgoingMessages_OverrideEnvVarStatus)(nil), @@ -4927,7 +4861,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { (*SMOutgoingMessages_ImageContentRequest)(nil), (*SMOutgoingMessages_ClockSyncRequest)(nil), } - file_servicemanager_v4_servicemanager_proto_msgTypes[40].OneofWrappers = []interface{}{ + file_servicemanager_v4_servicemanager_proto_msgTypes[39].OneofWrappers = []interface{}{ (*Alert_SystemQuotaAlert)(nil), (*Alert_InstanceQuotaAlert)(nil), (*Alert_ResourceValidateAlert)(nil), @@ -4942,7 +4876,7 @@ func file_servicemanager_v4_servicemanager_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_servicemanager_v4_servicemanager_proto_rawDesc, NumEnums: 1, - NumMessages: 50, + NumMessages: 49, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/cgroupssystemusage.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/cgroupssystemusage.go index 9ed6d97e..d148c82a 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/cgroupssystemusage.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/cgroupssystemusage.go @@ -71,9 +71,9 @@ func (usageInstance *cgroupsSystemUsage) FillSystemInfo(instanceID string, insta instance.prevCPU = 0 } - instance.monitoringData.CPU = uint64(math.Round(float64(cpu-instance.prevCPU) * 100.0 / + instance.monitoring.CPU = uint64(math.Round(float64(cpu-instance.prevCPU) * 100.0 / (float64(now.Sub(instance.prevTime).Microseconds())) / float64(cpuCount))) - instance.monitoringData.RAM = ram + instance.monitoring.RAM = ram instance.prevCPU = cpu instance.prevTime = now diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index af3cc57a..b736ca9a 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -84,7 +84,7 @@ type NodeConfigProvider interface { // MonitoringSender sends monitoring data. type MonitoringSender interface { - SendMonitoringData(monitoringData cloudprotocol.NodeMonitoringData) + SendMonitoringData(monitoringData aostypes.NodeMonitoring) } // TrafficMonitoring interface to get network traffic. @@ -114,7 +114,7 @@ type ResourceMonitor struct { pollTimer *time.Ticker averageWindowCount uint64 nodeInfo cloudprotocol.NodeInfo - nodeMonitoringData cloudprotocol.MonitoringData + nodeMonitoring aostypes.MonitoringData nodeAverageData averageMonitoring instanceMonitoringMap map[string]*instanceMonitoring alertProcessors *list.List @@ -141,7 +141,7 @@ type instanceMonitoring struct { uid uint32 gid uint32 partitions []PartitionParam - monitoringData cloudprotocol.InstanceMonitoringData + monitoring aostypes.InstanceMonitoring averageData averageMonitoring alertProcessorElements []*list.Element prevCPU uint64 @@ -258,23 +258,23 @@ func (monitor *ResourceMonitor) StartInstanceMonitor( log.WithFields(log.Fields{"id": instanceID}).Debug("Start instance monitoring") instanceMonitoring := &instanceMonitoring{ - uid: uint32(monitoringConfig.UID), - gid: uint32(monitoringConfig.GID), - partitions: monitoringConfig.Partitions, - monitoringData: cloudprotocol.InstanceMonitoringData{InstanceIdent: monitoringConfig.InstanceIdent}, + uid: uint32(monitoringConfig.UID), + gid: uint32(monitoringConfig.GID), + partitions: monitoringConfig.Partitions, + monitoring: aostypes.InstanceMonitoring{InstanceIdent: monitoringConfig.InstanceIdent}, } monitor.instanceMonitoringMap[instanceID] = instanceMonitoring - instanceMonitoring.monitoringData.Disk = make( - []cloudprotocol.PartitionUsage, len(monitoringConfig.Partitions)) + instanceMonitoring.monitoring.Disk = make( + []aostypes.PartitionUsage, len(monitoringConfig.Partitions)) for i, partitionParam := range monitoringConfig.Partitions { - instanceMonitoring.monitoringData.Disk[i].Name = partitionParam.Name + instanceMonitoring.monitoring.Disk[i].Name = partitionParam.Name } instanceMonitoring.averageData = *newAverageMonitoring( - monitor.averageWindowCount, instanceMonitoring.monitoringData.Disk) + monitor.averageWindowCount, instanceMonitoring.monitoring.Disk) if monitoringConfig.AlertRules != nil && monitor.alertSender != nil { if err := monitor.setupInstanceAlerts( @@ -307,25 +307,25 @@ func (monitor *ResourceMonitor) StopInstanceMonitor(instanceID string) error { } // GetAverageMonitoring returns average monitoring data. -func (monitor *ResourceMonitor) GetAverageMonitoring() (cloudprotocol.NodeMonitoringData, error) { +func (monitor *ResourceMonitor) GetAverageMonitoring() (aostypes.NodeMonitoring, error) { monitor.Lock() defer monitor.Unlock() log.Debug("Get average monitoring data") - averageMonitoringData := cloudprotocol.NodeMonitoringData{ - NodeID: monitor.nodeInfo.NodeID, - Timestamp: time.Now(), - MonitoringData: monitor.nodeAverageData.toMonitoringData(), - ServiceInstances: make([]cloudprotocol.InstanceMonitoringData, 0, len(monitor.instanceMonitoringMap)), + timestamp := time.Now() + + averageMonitoringData := aostypes.NodeMonitoring{ + NodeID: monitor.nodeInfo.NodeID, + NodeData: monitor.nodeAverageData.toMonitoringData(timestamp), + InstancesData: make([]aostypes.InstanceMonitoring, 0, len(monitor.instanceMonitoringMap)), } for _, instanceMonitoring := range monitor.instanceMonitoringMap { - averageMonitoringData.ServiceInstances = append(averageMonitoringData.ServiceInstances, - cloudprotocol.InstanceMonitoringData{ - InstanceIdent: instanceMonitoring.monitoringData.InstanceIdent, - NodeID: monitor.nodeInfo.NodeID, - MonitoringData: instanceMonitoring.averageData.toMonitoringData(), + averageMonitoringData.InstancesData = append(averageMonitoringData.InstancesData, + aostypes.InstanceMonitoring{ + InstanceIdent: instanceMonitoring.monitoring.InstanceIdent, + MonitoringData: instanceMonitoring.averageData.toMonitoringData(timestamp), }) } @@ -346,15 +346,15 @@ func (monitor *ResourceMonitor) setupNodeMonitoring(nodeInfo cloudprotocol.NodeI monitor.nodeInfo = nodeInfo - monitor.nodeMonitoringData = cloudprotocol.MonitoringData{ - Disk: make([]cloudprotocol.PartitionUsage, len(nodeInfo.Partitions)), + monitor.nodeMonitoring = aostypes.MonitoringData{ + Disk: make([]aostypes.PartitionUsage, len(nodeInfo.Partitions)), } for i, partitionParam := range nodeInfo.Partitions { - monitor.nodeMonitoringData.Disk[i].Name = partitionParam.Name + monitor.nodeMonitoring.Disk[i].Name = partitionParam.Name } - monitor.nodeAverageData = *newAverageMonitoring(monitor.averageWindowCount, monitor.nodeMonitoringData.Disk) + monitor.nodeAverageData = *newAverageMonitoring(monitor.averageWindowCount, monitor.nodeMonitoring.Disk) return nil } @@ -376,7 +376,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC monitor.alertProcessors.PushBack(createAlertProcessor( "System CPU", - &monitor.nodeMonitoringData.CPU, + &monitor.nodeMonitoring.CPU, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem("cpu", time, value, status)) }, @@ -386,7 +386,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC if nodeConfig.AlertRules.RAM != nil { monitor.alertProcessors.PushBack(createAlertProcessor( "System RAM", - &monitor.nodeMonitoringData.RAM, + &monitor.nodeMonitoring.RAM, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem("ram", time, value, status)) }, @@ -394,7 +394,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC } for _, diskRule := range nodeConfig.AlertRules.UsedDisks { - diskUsageValue, findErr := getDiskUsageValue(monitor.nodeMonitoringData.Disk, diskRule.Name) + diskUsageValue, findErr := getDiskUsageValue(monitor.nodeMonitoring.Disk, diskRule.Name) if findErr != nil && err == nil { err = findErr @@ -415,7 +415,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC if nodeConfig.AlertRules.InTraffic != nil { monitor.alertProcessors.PushBack(createAlertProcessor( "IN Traffic", - &monitor.nodeMonitoringData.InTraffic, + &monitor.nodeMonitoring.InTraffic, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem("inTraffic", time, value, status)) }, @@ -425,7 +425,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC if nodeConfig.AlertRules.OutTraffic != nil { monitor.alertProcessors.PushBack(createAlertProcessor( "OUT Traffic", - &monitor.nodeMonitoringData.OutTraffic, + &monitor.nodeMonitoring.OutTraffic, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem("outTraffic", time, value, status)) }, @@ -435,7 +435,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC return err } -func getDiskUsageValue(disks []cloudprotocol.PartitionUsage, name string) (*uint64, error) { +func getDiskUsageValue(disks []aostypes.PartitionUsage, name string) (*uint64, error) { for i, disk := range disks { if disk.Name == name { return &disks[i].UsedSize, nil @@ -470,7 +470,7 @@ func (monitor *ResourceMonitor) run(ctx context.Context) { monitor.Lock() monitor.sourceSystemUsage.CacheSystemInfos() monitor.getCurrentSystemData() - monitor.getCurrentInstanceData() + monitor.getCurrentInstancesData() monitor.processAlerts() monitor.sendMonitoringData() monitor.Unlock() @@ -490,11 +490,11 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" CPU", - &instanceMonitoring.monitoringData.CPU, + &instanceMonitoring.monitoring.CPU, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoringData.InstanceIdent, "cpu", time, value, status)) + instanceMonitoring.monitoring.InstanceIdent, "cpu", time, value, status)) }, rules)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) @@ -503,18 +503,18 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM if rules.RAM != nil { e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" RAM", - &instanceMonitoring.monitoringData.RAM, + &instanceMonitoring.monitoring.RAM, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoringData.InstanceIdent, "ram", time, value, status)) + instanceMonitoring.monitoring.InstanceIdent, "ram", time, value, status)) }, *rules.RAM)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } for _, diskRule := range rules.UsedDisks { - diskUsageValue, findErr := getDiskUsageValue(instanceMonitoring.monitoringData.Disk, diskRule.Name) + diskUsageValue, findErr := getDiskUsageValue(instanceMonitoring.monitoring.Disk, diskRule.Name) if findErr != nil && err == nil { log.Errorf("Can't find disk: %s", diskRule.Name) @@ -529,7 +529,7 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoringData.InstanceIdent, diskRule.Name, time, value, status)) + instanceMonitoring.monitoring.InstanceIdent, diskRule.Name, time, value, status)) }, diskRule.AlertRuleParam)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) @@ -538,11 +538,11 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM if rules.InTraffic != nil { e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" Traffic IN", - &instanceMonitoring.monitoringData.InTraffic, + &instanceMonitoring.monitoring.InTraffic, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoringData.InstanceIdent, "inTraffic", time, value, status)) + instanceMonitoring.monitoring.InstanceIdent, "inTraffic", time, value, status)) }, *rules.InTraffic)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) @@ -551,11 +551,11 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM if rules.OutTraffic != nil { e := monitor.alertProcessors.PushBack(createAlertProcessor( instanceID+" Traffic OUT", - &instanceMonitoring.monitoringData.OutTraffic, + &instanceMonitoring.monitoring.OutTraffic, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoringData.InstanceIdent, "outTraffic", time, value, status)) + instanceMonitoring.monitoring.InstanceIdent, "outTraffic", time, value, status)) }, *rules.OutTraffic)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) @@ -565,35 +565,36 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM } func (monitor *ResourceMonitor) sendMonitoringData() { - nodeMonitoringData := cloudprotocol.NodeMonitoringData{ - MonitoringData: monitor.nodeMonitoringData, - NodeID: monitor.nodeInfo.NodeID, - Timestamp: time.Now(), - ServiceInstances: make([]cloudprotocol.InstanceMonitoringData, 0, len(monitor.instanceMonitoringMap)), + nodeMonitoringData := aostypes.NodeMonitoring{ + NodeID: monitor.nodeInfo.NodeID, + NodeData: monitor.nodeMonitoring, + InstancesData: make([]aostypes.InstanceMonitoring, 0, len(monitor.instanceMonitoringMap)), } for _, instanceMonitoring := range monitor.instanceMonitoringMap { - nodeMonitoringData.ServiceInstances = append(nodeMonitoringData.ServiceInstances, - instanceMonitoring.monitoringData) + nodeMonitoringData.InstancesData = append(nodeMonitoringData.InstancesData, + instanceMonitoring.monitoring) } monitor.monitoringSender.SendMonitoringData(nodeMonitoringData) } func (monitor *ResourceMonitor) getCurrentSystemData() { + monitor.nodeMonitoring.Timestamp = time.Now() + cpu, err := getSystemCPUUsage() if err != nil { log.Errorf("Can't get system CPU: %s", err) } - monitor.nodeMonitoringData.CPU = monitor.cpuToDMIPs(cpu) + monitor.nodeMonitoring.CPU = monitor.cpuToDMIPs(cpu) - monitor.nodeMonitoringData.RAM, err = getSystemRAMUsage() + monitor.nodeMonitoring.RAM, err = getSystemRAMUsage() if err != nil { log.Errorf("Can't get system RAM: %s", err) } - for i, disk := range monitor.nodeMonitoringData.Disk { + for i, disk := range monitor.nodeMonitoring.Disk { mountPoint, err := getDiskPath(monitor.nodeInfo.Partitions, disk.Name) if err != nil { log.Errorf("Can't get disk path: %v", err) @@ -601,7 +602,7 @@ func (monitor *ResourceMonitor) getCurrentSystemData() { continue } - monitor.nodeMonitoringData.Disk[i].UsedSize, err = getSystemDiskUsage(mountPoint) + monitor.nodeMonitoring.Disk[i].UsedSize, err = getSystemDiskUsage(mountPoint) if err != nil { log.Errorf("Can't get system Disk usage: %v", err) } @@ -613,32 +614,36 @@ func (monitor *ResourceMonitor) getCurrentSystemData() { log.Errorf("Can't get system traffic value: %s", err) } - monitor.nodeMonitoringData.InTraffic = inTraffic - monitor.nodeMonitoringData.OutTraffic = outTraffic + monitor.nodeMonitoring.InTraffic = inTraffic + monitor.nodeMonitoring.OutTraffic = outTraffic } - monitor.nodeAverageData.updateMonitoringData(monitor.nodeMonitoringData) + monitor.nodeAverageData.updateMonitoringData(monitor.nodeMonitoring) log.WithFields(log.Fields{ - "CPU": monitor.nodeMonitoringData.CPU, - "RAM": monitor.nodeMonitoringData.RAM, - "Disk": monitor.nodeMonitoringData.Disk, - "IN": monitor.nodeMonitoringData.InTraffic, - "OUT": monitor.nodeMonitoringData.OutTraffic, + "CPU": monitor.nodeMonitoring.CPU, + "RAM": monitor.nodeMonitoring.RAM, + "Disk": monitor.nodeMonitoring.Disk, + "IN": monitor.nodeMonitoring.InTraffic, + "OUT": monitor.nodeMonitoring.OutTraffic, }).Debug("Monitoring data") } -func (monitor *ResourceMonitor) getCurrentInstanceData() { +func (monitor *ResourceMonitor) getCurrentInstancesData() { + timestamp := time.Now() + for instanceID, value := range monitor.instanceMonitoringMap { + value.monitoring.Timestamp = timestamp + err := monitor.sourceSystemUsage.FillSystemInfo(instanceID, value) if err != nil { log.Errorf("Can't fill system usage info: %v", err) } - value.monitoringData.CPU = monitor.cpuToDMIPs(float64(value.monitoringData.CPU)) + value.monitoring.CPU = monitor.cpuToDMIPs(float64(value.monitoring.CPU)) for i, partitionParam := range value.partitions { - value.monitoringData.Disk[i].UsedSize, err = getInstanceDiskUsage(partitionParam.Path, value.uid, value.gid) + value.monitoring.Disk[i].UsedSize, err = getInstanceDiskUsage(partitionParam.Path, value.uid, value.gid) if err != nil { log.Errorf("Can't get service disk usage: %v", err) } @@ -650,19 +655,19 @@ func (monitor *ResourceMonitor) getCurrentInstanceData() { log.Errorf("Can't get service traffic: %s", err) } - value.monitoringData.InTraffic = inTraffic - value.monitoringData.OutTraffic = outTraffic + value.monitoring.InTraffic = inTraffic + value.monitoring.OutTraffic = outTraffic } - value.averageData.updateMonitoringData(value.monitoringData.MonitoringData) + value.averageData.updateMonitoringData(value.monitoring.MonitoringData) log.WithFields(log.Fields{ "id": instanceID, - "CPU": value.monitoringData.CPU, - "RAM": value.monitoringData.RAM, - "Disk": value.monitoringData.Disk, - "IN": value.monitoringData.InTraffic, - "OUT": value.monitoringData.OutTraffic, + "CPU": value.monitoring.CPU, + "RAM": value.monitoring.RAM, + "Disk": value.monitoring.Disk, + "IN": value.monitoring.InTraffic, + "OUT": value.monitoring.OutTraffic, }).Debug("Instance monitoring data") } } @@ -767,7 +772,7 @@ func (monitor *ResourceMonitor) cpuToDMIPs(cpu float64) uint64 { return uint64(math.Round(float64(cpu) * float64(monitor.nodeInfo.MaxDMIPs) / 100.0)) } -func newAverageMonitoring(windowCount uint64, partitions []cloudprotocol.PartitionUsage) *averageMonitoring { +func newAverageMonitoring(windowCount uint64, partitions []aostypes.PartitionUsage) *averageMonitoring { averageMonitoring := &averageMonitoring{ ram: newAverageCalc(windowCount), cpu: newAverageCalc(windowCount), @@ -783,25 +788,26 @@ func newAverageMonitoring(windowCount uint64, partitions []cloudprotocol.Partiti return averageMonitoring } -func (average *averageMonitoring) toMonitoringData() cloudprotocol.MonitoringData { - monitoringData := cloudprotocol.MonitoringData{ +func (average *averageMonitoring) toMonitoringData(timestamp time.Time) aostypes.MonitoringData { + data := aostypes.MonitoringData{ CPU: average.cpu.getIntValue(), RAM: average.ram.getIntValue(), InTraffic: average.inTraffic.getIntValue(), OutTraffic: average.outTraffic.getIntValue(), - Disk: make([]cloudprotocol.PartitionUsage, 0, len(average.disks)), + Disk: make([]aostypes.PartitionUsage, 0, len(average.disks)), + Timestamp: timestamp, } for name, diskUsage := range average.disks { - monitoringData.Disk = append(monitoringData.Disk, cloudprotocol.PartitionUsage{ + data.Disk = append(data.Disk, aostypes.PartitionUsage{ Name: name, UsedSize: diskUsage.getIntValue(), }) } - return monitoringData + return data } -func (average *averageMonitoring) updateMonitoringData(data cloudprotocol.MonitoringData) { +func (average *averageMonitoring) updateMonitoringData(data aostypes.MonitoringData) { average.cpu.calculate(float64(data.CPU)) average.ram.calculate(float64(data.RAM)) average.inTraffic.calculate(float64(data.InTraffic)) diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go index 0be2b3b7..f01fdc5b 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/xensystemusage.go @@ -48,8 +48,8 @@ func (xen *xenSystemUsage) CacheSystemInfos() { func (xen *xenSystemUsage) FillSystemInfo(instanceID string, instance *instanceMonitoring) error { systemInfo, ok := xen.systemInfos[instanceID] if ok { - instance.monitoringData.CPU = uint64(systemInfo.CPUFraction) - instance.monitoringData.RAM = uint64(systemInfo.Memory) * 1024 //nolint:mnd + instance.monitoring.CPU = uint64(systemInfo.CPUFraction) + instance.monitoring.RAM = uint64(systemInfo.Memory) * 1024 //nolint:mnd } return nil diff --git a/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go b/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go index 1848754c..08c219dd 100644 --- a/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go +++ b/vendor/github.com/aosedge/aos_common/utils/pbconvert/pbconvert.go @@ -158,7 +158,7 @@ func NetworkParametersToPB(params aostypes.NetworkParameters) *pbsm.NetworkParam } // NodeInfoFromPB converts NodeInfo from protobuf to Aos type. -func NewNodeInfoFromPB(pbNodeInfo *pbiam.NodeInfo) cloudprotocol.NodeInfo { +func NodeInfoFromPB(pbNodeInfo *pbiam.NodeInfo) cloudprotocol.NodeInfo { nodeInfo := cloudprotocol.NodeInfo{ NodeID: pbNodeInfo.GetNodeId(), NodeType: pbNodeInfo.GetNodeType(), diff --git a/vendor/modules.txt b/vendor/modules.txt index e9f00f9a..6493f53c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240704123642-334eadb537ab +# github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From ea4bf66ddfb7a8890f5d52401564dcf3974b13ff Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 9 Jul 2024 15:37:22 +0300 Subject: [PATCH 035/146] [unitconfig] Handle setting node config for dynamic nodes Signed-off-by: Oleksandr Grytsov --- unitconfig/unitconfig.go | 102 +++++++++++++++++++++++-- unitconfig/unitconfig_test.go | 135 ++++++++++++++++++++++++++++++++-- 2 files changed, 224 insertions(+), 13 deletions(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 34cd1136..918a5c2d 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -25,6 +25,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" semver "github.com/hashicorp/go-version" + log "github.com/sirupsen/logrus" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_communicationmanager/config" @@ -46,8 +47,18 @@ type Instance struct { // Client client unit config interface. type Client interface { - CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) - SetUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) + CheckNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error + SetNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error + GetNodeConfigStatuses() ([]NodeConfigStatus, error) + NodeConfigStatusChannel() <-chan NodeConfigStatus +} + +// NodeConfigStatus node config status. +type NodeConfigStatus struct { + NodeID string + NodeType string + Version string + Error *cloudprotocol.ErrorInfo } // ErrAlreadyInstalled error to detect that unit config with the same version already installed. @@ -68,6 +79,8 @@ func New(cfg *config.Config, client Client) (instance *Instance, err error) { instance.unitConfigError = err } + go instance.handleNodeConfigStatus() + return instance, nil } @@ -96,8 +109,24 @@ func (instance *Instance) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) e return err } - if err := instance.client.CheckUnitConfig(unitConfig); err != nil { - return aoserrors.Wrap(err) + nodeConfigStatuses, err := instance.client.GetNodeConfigStatuses() + if err != nil { + log.Errorf("Error getting node config statuses: %v", err) + } + + for i, nodeConfigStatus := range nodeConfigStatuses { + if nodeConfigStatus.Version != unitConfig.Version || nodeConfigStatus.Error != nil { + nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, &unitConfig) + if nodeConfig == nil { + continue + } + + nodeConfig.NodeID = &nodeConfigStatuses[i].NodeID + + if err := instance.client.CheckNodeConfig(unitConfig.Version, *nodeConfig); err != nil { + return aoserrors.Wrap(err) + } + } } return nil @@ -131,8 +160,24 @@ func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) instance.unitConfig = unitConfig - if err = instance.client.SetUnitConfig(instance.unitConfig); err != nil { - return aoserrors.Wrap(err) + nodeConfigStatuses, err := instance.client.GetNodeConfigStatuses() + if err != nil { + log.Errorf("Error getting node config statuses: %v", err) + } + + for i, nodeConfigStatus := range nodeConfigStatuses { + if nodeConfigStatus.Version != unitConfig.Version || nodeConfigStatus.Error != nil { + nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, &unitConfig) + if nodeConfig == nil { + continue + } + + nodeConfig.NodeID = &nodeConfigStatuses[i].NodeID + + if err := instance.client.SetNodeConfig(unitConfig.Version, *nodeConfig); err != nil { + return aoserrors.Wrap(err) + } + } } configJSON, err := json.Marshal(instance.unitConfig) @@ -189,3 +234,48 @@ func (instance *Instance) checkVersion(version string) error { return nil } + +func (instance *Instance) handleNodeConfigStatus() { + for { + nodeConfigStatus, ok := <-instance.client.NodeConfigStatusChannel() + if !ok { + return + } + + if instance.unitConfigError != nil { + log.WithField("NodeID", nodeConfigStatus.NodeID).Warnf( + "Can't update node config due to: %v", instance.unitConfigError) + } + + if nodeConfigStatus.Version == instance.unitConfig.Version && nodeConfigStatus.Error == nil { + continue + } + + nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, &instance.unitConfig) + if nodeConfig == nil { + continue + } + + nodeConfig.NodeID = &nodeConfigStatus.NodeID + + if err := instance.client.SetNodeConfig(instance.unitConfig.Version, *nodeConfig); err != nil { + log.WithField("NodeID", nodeConfigStatus.NodeID).Errorf("Can't update node config: %v", err) + } + } +} + +func findNodeConfig(nodeID, nodeType string, unitConfig *cloudprotocol.UnitConfig) *cloudprotocol.NodeConfig { + for i, nodeConfig := range unitConfig.Nodes { + if nodeConfig.NodeID != nil && *nodeConfig.NodeID == nodeID { + return &unitConfig.Nodes[i] + } + } + + for i, nodeConfig := range unitConfig.Nodes { + if nodeConfig.NodeType == nodeType { + return &unitConfig.Nodes[i] + } + } + + return nil +} diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index ea9e3eaf..44b75b96 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -21,7 +21,9 @@ import ( "encoding/json" "os" "path" + "reflect" "testing" + "time" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_communicationmanager/config" @@ -49,7 +51,17 @@ const validTestUnitConfig = ` * Types **********************************************************************************************************************/ -type testClient struct{} +type testNodeConfig struct { + NodeID string + NodeType string + Version string +} + +type testClient struct { + nodeConfigStatuses []unitconfig.NodeConfigStatus + nodeConfigStatusChannel chan unitconfig.NodeConfigStatus + nodeConfigSetCheckChannel chan testNodeConfig +} /*********************************************************************************************************************** * Vars @@ -100,7 +112,8 @@ func TestValidGetStatus(t *testing.T) { t.Fatalf("Can't create unit config file: %s", err) } - unitConfig, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, &testClient{}) + unitConfig, err := unitconfig.New( + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, newTestClient()) if err != nil { t.Fatalf("Can't create unit config instance: %s", err) } @@ -137,7 +150,8 @@ func TestInvalidGetStatus(t *testing.T) { t.Fatalf("Can't create unit config file: %s", err) } - unitConfig, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, &testClient{}) + unitConfig, err := unitconfig.New( + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, newTestClient()) if err != nil { t.Fatalf("Can't create unit config instance: %s", err) } @@ -157,7 +171,10 @@ func TestCheckUnitConfig(t *testing.T) { t.Fatalf("Can't create unit config file: %s", err) } - unitConfig, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, &testClient{}) + client := newTestClient() + + unitConfig, err := unitconfig.New( + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, client) if err != nil { t.Fatalf("Can't create unit config instance: %s", err) } @@ -165,12 +182,35 @@ func TestCheckUnitConfig(t *testing.T) { validUnitConfig := cloudprotocol.UnitConfig{ FormatVersion: "1", Version: "2.0.0", + Nodes: []cloudprotocol.NodeConfig{{NodeType: "type1"}}, + } + + client.nodeConfigStatuses = []unitconfig.NodeConfigStatus{ + {NodeID: "id1", NodeType: "type1", Version: "1.0.0"}, + {NodeID: "id2", NodeType: "type1", Version: "1.0.0"}, + {NodeID: "id3", NodeType: "type1", Version: "1.0.0"}, } if err := unitConfig.CheckUnitConfig(validUnitConfig); err != nil { t.Errorf("Check unit config error: %v", err) } + for i := 0; i < len(client.nodeConfigStatuses); i++ { + select { + case nodeConfig := <-client.nodeConfigSetCheckChannel: + if !reflect.DeepEqual(nodeConfig, testNodeConfig{ + NodeID: client.nodeConfigStatuses[i].NodeID, + NodeType: "type1", + Version: "2.0.0", + }) { + t.Errorf("Wrong node config: %v", nodeConfig) + } + + case <-time.After(1 * time.Second): + t.Fatalf("Set node config timeout") + } + } + invalidUnitConfig := cloudprotocol.UnitConfig{ FormatVersion: "1", Version: "1.0.0", @@ -186,7 +226,10 @@ func TestUpdateUnitConfig(t *testing.T) { t.Fatalf("Can't create unit config file: %v", err) } - unitConfig, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, &testClient{}) + client := newTestClient() + + unitConfig, err := unitconfig.New( + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, client) if err != nil { t.Fatalf("Can't create unit config instance: %v", err) } @@ -194,12 +237,35 @@ func TestUpdateUnitConfig(t *testing.T) { newUnitConfig := cloudprotocol.UnitConfig{ FormatVersion: "1", Version: "2.0.0", + Nodes: []cloudprotocol.NodeConfig{{NodeType: "type1"}}, + } + + client.nodeConfigStatuses = []unitconfig.NodeConfigStatus{ + {NodeID: "id1", NodeType: "type1", Version: "1.0.0"}, + {NodeID: "id2", NodeType: "type1", Version: "1.0.0"}, + {NodeID: "id3", NodeType: "type1", Version: "1.0.0"}, } if err = unitConfig.UpdateUnitConfig(newUnitConfig); err != nil { t.Fatalf("Can't update unit config: %v", err) } + for i := 0; i < len(client.nodeConfigStatuses); i++ { + select { + case nodeConfig := <-client.nodeConfigSetCheckChannel: + if !reflect.DeepEqual(nodeConfig, testNodeConfig{ + NodeID: client.nodeConfigStatuses[i].NodeID, + NodeType: "type1", + Version: "2.0.0", + }) { + t.Errorf("Wrong node config: %v", nodeConfig) + } + + case <-time.After(1 * time.Second): + t.Fatalf("Set node config timeout") + } + } + status, err := unitConfig.GetStatus() if err != nil { t.Errorf("Get unit config status error: %v", err) @@ -224,14 +290,69 @@ func TestUpdateUnitConfig(t *testing.T) { } } +func TestNodeConfigStatus(t *testing.T) { + if err := os.WriteFile(path.Join(tmpDir, "aos_unit.cfg"), []byte(validTestUnitConfig), 0o600); err != nil { + t.Fatalf("Can't create unit config file: %v", err) + } + + client := newTestClient() + + _, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, client) + if err != nil { + t.Fatalf("Can't create unit config instance: %v", err) + } + + client.nodeConfigStatusChannel <- unitconfig.NodeConfigStatus{ + NodeID: "id1", + NodeType: "type1", + } + + select { + case nodeConfig := <-client.nodeConfigSetCheckChannel: + if !reflect.DeepEqual(nodeConfig, testNodeConfig{NodeID: "id1", NodeType: "type1", Version: "1.0.0"}) { + t.Errorf("Wrong node config: %v", nodeConfig) + } + + case <-time.After(1 * time.Second): + t.Fatalf("Set node config timeout") + } +} + /*********************************************************************************************************************** * testClient **********************************************************************************************************************/ -func (client *testClient) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) { +func newTestClient() *testClient { + return &testClient{ + nodeConfigStatusChannel: make(chan unitconfig.NodeConfigStatus, 1), + nodeConfigSetCheckChannel: make(chan testNodeConfig, 10), + } +} + +func (client *testClient) CheckNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { + client.nodeConfigSetCheckChannel <- testNodeConfig{ + NodeID: *nodeConfig.NodeID, + NodeType: nodeConfig.NodeType, + Version: version, + } + return nil } -func (client *testClient) SetUnitConfig(unitConfig cloudprotocol.UnitConfig) (err error) { +func (client *testClient) SetNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { + client.nodeConfigSetCheckChannel <- testNodeConfig{ + NodeID: *nodeConfig.NodeID, + NodeType: nodeConfig.NodeType, + Version: version, + } + return nil } + +func (client *testClient) GetNodeConfigStatuses() ([]unitconfig.NodeConfigStatus, error) { + return client.nodeConfigStatuses, nil +} + +func (client *testClient) NodeConfigStatusChannel() <-chan unitconfig.NodeConfigStatus { + return client.nodeConfigStatusChannel +} From 69585fe2f369f74f0ee6b35126a585dc54453072 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 9 Jul 2024 17:22:20 +0300 Subject: [PATCH 036/146] [smcontroller] Implement required for unitconfig node config interface Signed-off-by: Oleksandr Grytsov --- smcontroller/smcontroller.go | 125 +++++++++++++++++------------- smcontroller/smcontroller_test.go | 117 +++++++++++++++++----------- smcontroller/smhandler.go | 82 ++++++++++---------- 3 files changed, 182 insertions(+), 142 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 78911a80..0eceab62 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -37,6 +37,7 @@ import ( "github.com/aosedge/aos_communicationmanager/amqphandler" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/launcher" + "github.com/aosedge/aos_communicationmanager/unitconfig" ) /*********************************************************************************************************************** @@ -63,6 +64,7 @@ type Controller struct { updateInstancesStatusChan chan []cloudprotocol.InstanceStatus runInstancesStatusChan chan launcher.NodeRunInstanceStatus systemLimitAlertChan chan cloudprotocol.SystemQuotaAlert + nodeConfigStatusChan chan unitconfig.NodeConfigStatus isCloudConnected bool grpcServer *grpc.Server @@ -112,6 +114,7 @@ func New( runInstancesStatusChan: make(chan launcher.NodeRunInstanceStatus, statusChanSize), updateInstancesStatusChan: make(chan []cloudprotocol.InstanceStatus, statusChanSize), systemLimitAlertChan: make(chan cloudprotocol.SystemQuotaAlert, statusChanSize), + nodeConfigStatusChan: make(chan unitconfig.NodeConfigStatus, statusChanSize), nodes: make(map[string]*smHandler), } @@ -170,75 +173,80 @@ func (controller *Controller) Close() error { } } + close(controller.nodeConfigStatusChan) + return nil } // GetNodeConfigStatus gets node configuration status. -func (controller *Controller) GetNodeConfigStatus(nodeID string) (version string, err error) { +func (controller *Controller) GetNodeConfigStatus(nodeID string) (unitconfig.NodeConfigStatus, error) { handler, err := controller.getNodeHandlerByID(nodeID) if err != nil { - return "", aoserrors.Wrap(err) + return unitconfig.NodeConfigStatus{}, err } - return handler.getNodeConfigStatus() + return handler.nodeConfigStatus, nil } -// CheckUnitConfig checks unit config for the node. -func (controller *Controller) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) error { - for _, nodeConfig := range unitConfig.Nodes { - for _, node := range controller.nodes { - if node == nil { - continue - } - - if nodeConfig.NodeID != nil && *nodeConfig.NodeID != node.nodeID { - continue - } - - if nodeConfig.NodeType != node.nodeType { - continue - } +// CheckNodeConfig checks node config. +func (controller *Controller) CheckNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { + if nodeConfig.NodeID == nil { + return aoserrors.Errorf("node ID is not set") + } - nodeConfig.NodeID = &node.nodeID + handler, err := controller.getNodeHandlerByID(*nodeConfig.NodeID) + if err != nil { + return err + } - err := node.checkNodeConfig(nodeConfig, unitConfig.Version) - if err != nil { - return err - } - } + if err = handler.checkNodeConfig(version, nodeConfig); err != nil { + return err } return nil } -// SetUnitConfig sets unit config for the node. -func (controller *Controller) SetUnitConfig(unitConfig cloudprotocol.UnitConfig) error { - for _, nodeConfig := range unitConfig.Nodes { - for _, node := range controller.nodes { - if node == nil { - continue - } - - if nodeConfig.NodeID != nil && *nodeConfig.NodeID != node.nodeID { - continue - } +// SetNodeConfig sets node config. +func (controller *Controller) SetNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { + if nodeConfig.NodeID == nil { + return aoserrors.Errorf("node ID is not set") + } - if nodeConfig.NodeType != node.nodeType { - continue - } + handler, err := controller.getNodeHandlerByID(*nodeConfig.NodeID) + if err != nil { + return err + } - nodeConfig.NodeID = &node.nodeID + if err = handler.setNodeConfig(version, nodeConfig); err != nil { + return err + } - err := node.setNodeConfig(nodeConfig, unitConfig.Version) - if err != nil { - return err - } - } + if handler.nodeConfigStatus, err = handler.getNodeConfigStatus(); err != nil { + return err } return nil } +// GetNodeConfigStatuses returns node configuration statuses. +func (controller *Controller) GetNodeConfigStatuses() ([]unitconfig.NodeConfigStatus, error) { + controller.Lock() + defer controller.Unlock() + + statuses := make([]unitconfig.NodeConfigStatus, 0, len(controller.nodes)) + + for _, handler := range controller.nodes { + statuses = append(statuses, handler.nodeConfigStatus) + } + + return statuses, nil +} + +// NodeConfigStatusChannel returns channel used to send new node configuration statuses. +func (controller *Controller) NodeConfigStatusChannel() <-chan unitconfig.NodeConfigStatus { + return controller.nodeConfigStatusChan +} + // RunInstances runs desired services instances. func (controller *Controller) RunInstances(nodeID string, services []aostypes.ServiceInfo, layers []aostypes.LayerInfo, instances []aostypes.InstanceInfo, forceRestart bool, @@ -318,7 +326,7 @@ func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) e message, err := stream.Recv() if err != nil { if handler != nil { - controller.handleCloseConnection(handler.nodeID) + controller.handleCloseConnection(handler.nodeConfigStatus.NodeID) } if !errors.Is(err, io.EOF) && codes.Canceled != status.Code(err) { @@ -331,19 +339,19 @@ func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) e } if handler == nil { - registerMessage, ok := message.GetSMOutgoingMessage().(*pb.SMOutgoingMessages_RegisterSm) + nodeConfigStatus, ok := message.GetSMOutgoingMessage().(*pb.SMOutgoingMessages_NodeConfigStatus) if !ok { log.Error("Unexpected first message from stream") continue } - nodeID := registerMessage.RegisterSm.GetNodeId() - nodeType := registerMessage.RegisterSm.GetNodeType() - - log.WithFields(log.Fields{"nodeID": nodeID, "nodeType": nodeType}).Debug("Register SM") + log.WithFields(log.Fields{ + "nodeID": nodeConfigStatus.NodeConfigStatus.GetNodeId(), + "nodeType": nodeConfigStatus.NodeConfigStatus.GetNodeType(), + }).Debug("Register SM") - handler, err = newSMHandler(nodeID, nodeType, stream, controller.messageSender, controller.alertSender, + handler, err = newSMHandler(stream, controller.messageSender, controller.alertSender, controller.monitoringSender, controller.runInstancesStatusChan, controller.updateInstancesStatusChan, controller.systemLimitAlertChan) if err != nil { @@ -352,7 +360,8 @@ func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) e return err } - if err := controller.handleNewConnection(nodeID, handler); err != nil { + if err := controller.handleNewConnection( + nodeConfigStatusFromPB(nodeConfigStatus.NodeConfigStatus), handler); err != nil { log.Errorf("Can't register new SM connection: %v", err) return err @@ -489,15 +498,19 @@ func (controller *Controller) stopServer() { } } -func (controller *Controller) handleNewConnection(nodeID string, newHandler *smHandler) error { +func (controller *Controller) handleNewConnection( + nodeConfigStatus unitconfig.NodeConfigStatus, newHandler *smHandler, +) error { controller.Lock() defer controller.Unlock() - if _, ok := controller.nodes[nodeID]; ok { - return aoserrors.Errorf("connection for node ID %s already exist", nodeID) + if _, ok := controller.nodes[nodeConfigStatus.NodeID]; ok { + return aoserrors.Errorf("connection for node ID %s already exist", nodeConfigStatus.NodeID) } - controller.nodes[nodeID] = newHandler + controller.nodes[nodeConfigStatus.NodeID] = newHandler + newHandler.nodeConfigStatus = nodeConfigStatus + controller.nodeConfigStatusChan <- nodeConfigStatus if err := newHandler.sendConnectionStatus(controller.isCloudConnected); err != nil { log.Errorf("Can't send connection status: %v", err) diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index c3544f82..8c23c853 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -28,6 +28,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" + "github.com/aosedge/aos_common/utils/pbconvert" pbcommon "github.com/aosedge/aos_common/api/common" pbsm "github.com/aosedge/aos_common/api/servicemanager" @@ -43,6 +44,7 @@ import ( "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/launcher" "github.com/aosedge/aos_communicationmanager/smcontroller" + "github.com/aosedge/aos_communicationmanager/unitconfig" ) /*********************************************************************************************************************** @@ -169,7 +171,9 @@ func TestSMInstancesStatusNotifications(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, sendRuntimeStatus) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, sendRuntimeStatus) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -189,7 +193,7 @@ func TestSMInstancesStatusNotifications(t *testing.T) { } } -func TestUnitConfigMessages(t *testing.T) { +func TestNodeConfigMessages(t *testing.T) { var ( nodeID = "mainSM" nodeType = "mainType" @@ -210,13 +214,22 @@ func TestUnitConfigMessages(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, Version: originalVersion, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } defer smClient.close() + if err := waitMessage( + controller.NodeConfigStatusChannel(), unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, Version: originalVersion, + }, messageTimeout); err != nil { + t.Errorf("Incorrect runtime status notification: %v", err) + } + if err := smClient.waitMessage(&pbsm.SMIncomingMessages{ SMIncomingMessage: &pbsm.SMIncomingMessages_ConnectionStatus{ConnectionStatus: &pbsm.ConnectionStatus{}}, }, messageTimeout); err != nil { @@ -224,39 +237,23 @@ func TestUnitConfigMessages(t *testing.T) { } go func() { - version, err := controller.GetNodeConfigStatus(nodeID) + nodeConfigStatus, err := controller.GetNodeConfigStatus(nodeID) if err != nil { t.Errorf("Can't get node config status: %v", err) } - if version != originalVersion { - t.Error("Incorrect node config version") + if nodeConfigStatus.Version != originalVersion { + t.Errorf("Incorrect node config version: %s", nodeConfigStatus.Version) } testWaitChan <- struct{}{} }() - if err := smClient.waitMessage( - &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_GetNodeConfigStatus{}}, - messageTimeout); err != nil { - t.Fatalf("Wait message error: %v", err) - } - - if err := smClient.stream.Send(nodeConfigStatus); err != nil { - t.Errorf("Can't send node config status: %v", err) - } - <-testWaitChan go func() { - if err := controller.CheckUnitConfig(cloudprotocol.UnitConfig{ - Version: newVersion, - Nodes: []cloudprotocol.NodeConfig{ - { - NodeType: nodeType, - }, - }, - }); err != nil { + if err := controller.CheckNodeConfig(newVersion, + cloudprotocol.NodeConfig{NodeID: &nodeID, NodeType: nodeType}); err != nil { t.Errorf("Error check unit config: %v", err) } @@ -280,14 +277,8 @@ func TestUnitConfigMessages(t *testing.T) { <-testWaitChan go func() { - if err := controller.SetUnitConfig(cloudprotocol.UnitConfig{ - Version: newVersion, - Nodes: []cloudprotocol.NodeConfig{ - { - NodeType: nodeType, - }, - }, - }); err != nil { + if err := controller.SetNodeConfig(newVersion, + cloudprotocol.NodeConfig{NodeID: &nodeID, NodeType: nodeType}); err != nil { t.Errorf("Error check unit config: %v", err) } @@ -302,12 +293,22 @@ func TestUnitConfigMessages(t *testing.T) { t.Fatalf("Wait message error: %v", err) } - nodeConfigStatus.GetNodeConfigStatus().Version = newVersion + if err := smClient.stream.Send(nodeConfigStatus); err != nil { + t.Errorf("Can't send node config status: %v", err) + } + + if err := smClient.waitMessage( + &pbsm.SMIncomingMessages{SMIncomingMessage: &pbsm.SMIncomingMessages_GetNodeConfigStatus{}}, + messageTimeout); err != nil { + t.Fatalf("Wait message error: %v", err) + } if err := smClient.stream.Send(nodeConfigStatus); err != nil { - t.Errorf("Can't send node config status") + t.Errorf("Can't send node config status: %v", err) } + nodeConfigStatus.GetNodeConfigStatus().Version = newVersion + <-testWaitChan } @@ -326,7 +327,9 @@ func TestSMAlertNotifications(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -511,7 +514,9 @@ func TestSMMonitoringNotifications(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -628,7 +633,9 @@ func TestLogMessages(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -870,7 +877,9 @@ func TestOverrideEnvVars(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -956,7 +965,9 @@ func TestRunInstances(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, &pbsm.RunInstancesStatus{}) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, &pbsm.RunInstancesStatus{}) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1034,7 +1045,9 @@ func TestUpdateNetwork(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1072,7 +1085,9 @@ func TestSyncClock(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1176,7 +1191,9 @@ func TestGetAverageMonitoring(t *testing.T) { } defer controller.Close() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1233,7 +1250,9 @@ func TestConnectionStatus(t *testing.T) { controller.CloudConnected() - smClient, err := newTestSMClient(cmServerURL, nodeID, nodeType, nil) + smClient, err := newTestSMClient(cmServerURL, unitconfig.NodeConfigStatus{ + NodeID: nodeID, NodeType: nodeType, + }, nil) if err != nil { t.Fatalf("Can't create test SM: %v", err) } @@ -1324,6 +1343,9 @@ func waitMessage[T any](messageChannel <-chan T, expectedMsg interface{}, timeou case message := <-messageChannel: if !reflect.DeepEqual(message, expectedMsg) { + log.Debugf("%v", message) + log.Debugf("%v", expectedMsg) + return aoserrors.New("incorrect received message") } } @@ -1332,7 +1354,7 @@ func waitMessage[T any](messageChannel <-chan T, expectedMsg interface{}, timeou } func newTestSMClient( - url string, nodeID, nodeType string, runStatus *pbsm.RunInstancesStatus, + url string, nodeConfigStatus unitconfig.NodeConfigStatus, runStatus *pbsm.RunInstancesStatus, ) (client *testSMClient, err error) { client = &testSMClient{ sendMessageChannel: make(chan *pbsm.SMOutgoingMessages, 10), @@ -1355,8 +1377,9 @@ func newTestSMClient( if err := client.stream.Send( &pbsm.SMOutgoingMessages{ - SMOutgoingMessage: &pbsm.SMOutgoingMessages_RegisterSm{RegisterSm: &pbsm.RegisterSM{ - NodeId: nodeID, NodeType: nodeType, + SMOutgoingMessage: &pbsm.SMOutgoingMessages_NodeConfigStatus{NodeConfigStatus: &pbsm.NodeConfigStatus{ + NodeId: nodeConfigStatus.NodeID, NodeType: nodeConfigStatus.NodeType, Version: nodeConfigStatus.Version, + Error: pbconvert.ErrorInfoToPB(nodeConfigStatus.Error), }}, }); err != nil { return nil, aoserrors.Wrap(err) @@ -1427,7 +1450,7 @@ func (client *testSMClient) waitMessage(expectedMsg *pbsm.SMIncomingMessages, ti case message := <-client.receivedMessagesChannel: if !proto.Equal(message, expectedMsg) { - return aoserrors.New("incorrect received client message") + return aoserrors.Errorf("incorrect client message received: %v", message) } } diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 5f9de20f..bf1101e0 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -34,6 +34,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "github.com/aosedge/aos_communicationmanager/launcher" + "github.com/aosedge/aos_communicationmanager/unitconfig" ) /*********************************************************************************************************************** @@ -52,8 +53,7 @@ type smHandler struct { alertSender AlertSender monitoringSender MonitoringSender syncstream *syncstream.SyncStream - nodeID string - nodeType string + nodeConfigStatus unitconfig.NodeConfigStatus runStatusCh chan<- launcher.NodeRunInstanceStatus updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus systemLimitAlertCh chan<- cloudprotocol.SystemQuotaAlert @@ -64,14 +64,12 @@ type smHandler struct { **********************************************************************************************************************/ func newSMHandler( - nodeID, nodeType string, stream pb.SMService_RegisterSMServer, messageSender MessageSender, alertSender AlertSender, + stream pb.SMService_RegisterSMServer, messageSender MessageSender, alertSender AlertSender, monitoringSender MonitoringSender, runStatusCh chan<- launcher.NodeRunInstanceStatus, updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus, systemLimitAlertCh chan<- cloudprotocol.SystemQuotaAlert, ) (*smHandler, error) { handler := smHandler{ - nodeID: nodeID, - nodeType: nodeType, stream: stream, messageSender: messageSender, alertSender: alertSender, @@ -85,29 +83,29 @@ func newSMHandler( return &handler, nil } -func (handler *smHandler) getNodeConfigStatus() (version string, err error) { +func (handler *smHandler) getNodeConfigStatus() (unitconfig.NodeConfigStatus, error) { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() status, err := handler.syncstream.Send( - ctx, handler.sendGetUnitConfigStatus, reflect.TypeOf(&pb.SMOutgoingMessages_NodeConfigStatus{})) + ctx, handler.sendGetNodeConfigStatus, reflect.TypeOf(&pb.SMOutgoingMessages_NodeConfigStatus{})) if err != nil { - return "", aoserrors.Wrap(err) + return unitconfig.NodeConfigStatus{}, aoserrors.Wrap(err) } pbStatus, ok := status.(*pb.SMOutgoingMessages_NodeConfigStatus) if !ok { - return "", aoserrors.New("incorrect type") + return unitconfig.NodeConfigStatus{}, aoserrors.New("incorrect type") } if pbStatus.NodeConfigStatus.GetError().GetMessage() != "" { - return "", aoserrors.New(pbStatus.NodeConfigStatus.GetError().GetMessage()) + return unitconfig.NodeConfigStatus{}, aoserrors.New(pbStatus.NodeConfigStatus.GetError().GetMessage()) } - return pbStatus.NodeConfigStatus.GetVersion(), nil + return nodeConfigStatusFromPB(pbStatus.NodeConfigStatus), nil } -func (handler *smHandler) checkNodeConfig(unitConfig cloudprotocol.NodeConfig, version string) error { +func (handler *smHandler) checkNodeConfig(version string, unitConfig cloudprotocol.NodeConfig) error { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() @@ -130,7 +128,7 @@ func (handler *smHandler) checkNodeConfig(unitConfig cloudprotocol.NodeConfig, v return nil } -func (handler *smHandler) setNodeConfig(cfg cloudprotocol.NodeConfig, version string) error { +func (handler *smHandler) setNodeConfig(version string, cfg cloudprotocol.NodeConfig) error { ctx, cancelFunc := context.WithTimeout(context.Background(), waitMessageTimeout) defer cancelFunc() @@ -155,7 +153,7 @@ func (handler *smHandler) setNodeConfig(cfg cloudprotocol.NodeConfig, version st func (handler *smHandler) updateNetworks(networkParameters []aostypes.NetworkParameters) error { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, }).Debug("CM update networks") pbNetworkParameters := make([]*pb.NetworkParameters, len(networkParameters)) @@ -184,7 +182,7 @@ func (handler *smHandler) runInstances( services []aostypes.ServiceInfo, layers []aostypes.LayerInfo, instances []aostypes.InstanceInfo, forceRestart bool, ) error { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, }).Debug("SM run instances") pbRunInstances := &pb.RunInstances{ @@ -239,7 +237,7 @@ func (handler *smHandler) runInstances( func (handler *smHandler) getSystemLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, "logID": logRequest.LogID, "from": logRequest.Filter.From, "till": logRequest.Filter.Till, @@ -267,7 +265,7 @@ func (handler *smHandler) getSystemLog(logRequest cloudprotocol.RequestLog) (err //nolint:dupl func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, "logID": logRequest.LogID, "serviceID": logRequest.Filter.ServiceID, "from": logRequest.Filter.From, @@ -298,7 +296,7 @@ func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (e //nolint:dupl func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, "logID": logRequest.LogID, "serviceID": logRequest.Filter.ServiceID, "from": logRequest.Filter.From, @@ -329,7 +327,7 @@ func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLo } func (handler *smHandler) overrideEnvVars(envVars cloudprotocol.OverrideEnvVars) (err error) { - log.WithFields(log.Fields{"nodeID": handler.nodeID}).Debug("Override env vars SM ") + log.WithFields(log.Fields{"nodeID": handler.nodeConfigStatus.NodeID}).Debug("Override env vars SM ") request := &pb.OverrideEnvVars{EnvVars: make([]*pb.OverrideInstanceEnvVar, len(envVars.Items))} @@ -377,7 +375,7 @@ func (handler *smHandler) getAverageMonitoring() (monitoring aostypes.NodeMonito } monitoring = averageMonitoringFromPB(pbMonitoring.AverageMonitoring) - monitoring.NodeID = handler.nodeID + monitoring.NodeID = handler.nodeConfigStatus.NodeID return monitoring, nil } @@ -398,9 +396,6 @@ func (handler *smHandler) processSMMessages(message *pb.SMOutgoingMessages) { case *pb.SMOutgoingMessages_Alert: handler.processAlert(data.Alert) - case *pb.SMOutgoingMessages_RegisterSm: - log.Errorf("Unexpected register SM message from %s", data.RegisterSm.GetNodeId()) - case *pb.SMOutgoingMessages_RunInstancesStatus: handler.processRunInstanceStatus(data.RunInstancesStatus) @@ -423,24 +418,24 @@ func (handler *smHandler) processSMMessages(message *pb.SMOutgoingMessages) { func (handler *smHandler) processRunInstanceStatus(status *pb.RunInstancesStatus) { runStatus := launcher.NodeRunInstanceStatus{ - NodeID: handler.nodeID, - NodeType: handler.nodeType, + NodeID: handler.nodeConfigStatus.NodeID, + NodeType: handler.nodeConfigStatus.NodeType, Instances: instancesStatusFromPB(status.GetInstances(), - handler.nodeID), + handler.nodeConfigStatus.NodeID), } handler.runStatusCh <- runStatus } func (handler *smHandler) processUpdateInstancesStatus(data *pb.UpdateInstancesStatus) { - log.WithFields(log.Fields{"nodeID": handler.nodeID}).Debug("Receive SM update instances status") + log.WithFields(log.Fields{"nodeID": handler.nodeConfigStatus.NodeID}).Debug("Receive SM update instances status") - handler.updateInstanceStatusCh <- instancesStatusFromPB(data.GetInstances(), handler.nodeID) + handler.updateInstanceStatusCh <- instancesStatusFromPB(data.GetInstances(), handler.nodeConfigStatus.NodeID) } func (handler *smHandler) processAlert(alert *pb.Alert) { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, "tag": alert.GetTag(), }).Debug("Receive SM alert") @@ -453,20 +448,20 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { case *pb.Alert_SystemAlert: alertItem.Payload = cloudprotocol.SystemAlert{ Message: data.SystemAlert.GetMessage(), - NodeID: handler.nodeID, + NodeID: handler.nodeConfigStatus.NodeID, } case *pb.Alert_CoreAlert: alertItem.Payload = cloudprotocol.CoreAlert{ CoreComponent: data.CoreAlert.GetCoreComponent(), Message: data.CoreAlert.GetMessage(), - NodeID: handler.nodeID, + NodeID: handler.nodeConfigStatus.NodeID, } case *pb.Alert_ResourceValidateAlert: resourceValidate := cloudprotocol.ResourceValidateAlert{ Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), - NodeID: handler.nodeID, + NodeID: handler.nodeConfigStatus.NodeID, Name: data.ResourceValidateAlert.Name, } @@ -481,14 +476,14 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { InstanceIdent: pbconvert.InstanceIdentFromPB(data.DeviceAllocateAlert.GetInstance()), Device: data.DeviceAllocateAlert.GetDevice(), Message: data.DeviceAllocateAlert.GetMessage(), - NodeID: handler.nodeID, + NodeID: handler.nodeConfigStatus.NodeID, } case *pb.Alert_SystemQuotaAlert: alertPayload := cloudprotocol.SystemQuotaAlert{ Parameter: data.SystemQuotaAlert.GetParameter(), Value: data.SystemQuotaAlert.GetValue(), - NodeID: handler.nodeID, + NodeID: handler.nodeConfigStatus.NodeID, } if alertPayload.Parameter == "cpu" || alertPayload.Parameter == "ram" { @@ -520,14 +515,14 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { func (handler *smHandler) processLogMessage(data *pb.LogData) { log.WithFields(log.Fields{ - "nodeID": handler.nodeID, + "nodeID": handler.nodeConfigStatus.NodeID, "logID": data.GetLogId(), "part": data.GetPart(), "partCount": data.GetPartCount(), }).Debug("Receive SM push log") if err := handler.messageSender.SendLog(cloudprotocol.PushLog{ - NodeID: handler.nodeID, + NodeID: handler.nodeConfigStatus.NodeID, LogID: data.GetLogId(), PartsCount: data.GetPartCount(), Part: data.GetPart(), @@ -543,11 +538,11 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { } func (handler *smHandler) processInstantMonitoring(instantMonitoring *pb.InstantMonitoring) { - log.WithFields(log.Fields{"nodeID": handler.nodeID}).Debug("Receive SM monitoring") + log.WithFields(log.Fields{"nodeID": handler.nodeConfigStatus.NodeID}).Debug("Receive SM monitoring") nodeMonitoring := instantMonitoringFromPB(instantMonitoring) - nodeMonitoring.NodeID = handler.nodeID + nodeMonitoring.NodeID = handler.nodeConfigStatus.NodeID handler.monitoringSender.SendNodeMonitoring(nodeMonitoring) } @@ -591,7 +586,7 @@ func (handler *smHandler) sendClockSyncResponse() { } } -func (handler *smHandler) sendGetUnitConfigStatus() error { +func (handler *smHandler) sendGetNodeConfigStatus() error { if err := handler.stream.Send( &pb.SMIncomingMessages{SMIncomingMessage: &pb.SMIncomingMessages_GetNodeConfigStatus{}}); err != nil { return aoserrors.Wrap(err) @@ -730,3 +725,12 @@ func monitoringDataFromPB(pbMonitoring *pb.MonitoringData) aostypes.MonitoringDa return monitoringData } + +func nodeConfigStatusFromPB(pbStatus *pb.NodeConfigStatus) unitconfig.NodeConfigStatus { + return unitconfig.NodeConfigStatus{ + NodeID: pbStatus.GetNodeId(), + NodeType: pbStatus.GetNodeType(), + Version: pbStatus.GetVersion(), + Error: pbconvert.ErrorInfoFromPB(pbStatus.GetError()), + } +} From 7199791df621cebdf4d68e276e458e4a28ff0673 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 9 Jul 2024 18:28:24 +0300 Subject: [PATCH 037/146] [ci] Update golangci github action version Signed-off-by: Oleksandr Grytsov --- .github/workflows/ci.yaml | 4 ++-- .golangci.yml | 24 ++++++------------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index facdb517..488993bb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,6 +52,6 @@ jobs: run: bash <(curl -s https://codecov.io/bash) - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: "v1.55" + version: "v1.59" diff --git a/.golangci.yml b/.golangci.yml index 2d0df9c5..7f5d8da7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,9 +1,11 @@ +run: + go: "1.21" + linters: enable-all: true disable: - cyclop - exhaustive - - exhaustivestruct - exhaustruct - depguard - gci @@ -13,26 +15,17 @@ linters: - nestif - nlreturn - nonamedreturns - - nosnakecase - unparam - varnamelen # deprecated - bodyclose - contextcheck - - deadcode - - golint - - ifshort - - interfacer - - maligned - nilerr - noctx - rowserrcheck - - scopelint - sqlclosecheck - - structcheck - tparallel - unparam - - varcheck - wastedassign linters-settings: @@ -49,14 +42,9 @@ linters-settings: excludes: - G204 - gomnd: - settings: - mnd: - ignored-numbers: 0o600,0o755,0o644,5,10,16,32,64,128,100,0xff,3 - ignored-files: config/config.go,fcrypt/utils.go - - gofumpt: - lang-version: "1.21" + mnd: + ignored-numbers: 0o600,0o755,0o644,5,10,16,32,64,128,100,0xff,3 + ignored-files: config/config.go,fcrypt/utils.go interfacebloat: max: 12 From d741dd8eb0f85b9ce262b8b568ab0b1c0d7a3d64 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Fri, 12 Jul 2024 12:17:35 +0300 Subject: [PATCH 038/146] [vendor] aos_common vendor update Signed-off-by: Mykola Kobets --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/aosedge/aos_common/aostypes/aostypes.go | 2 +- .../aosedge/aos_common/resourcemonitor/resourcemonitor.go | 4 ++-- vendor/modules.txt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index cafe191b..a7138d6b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a + github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360 github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 7e1972d0..d69c7d45 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a h1:oajCSEcVxxUWfDA2ugheAUpJXPIhqhP6QdtfjZQvq9U= -github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360 h1:waPgWerxOf+ccCleP1YYeHxhHWCzENMEbBUff0KESSc= +github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go index 4399fb3b..08c9debc 100644 --- a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go +++ b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go @@ -200,7 +200,7 @@ type ServiceConfig struct { Author string `json:"author"` Hostname *string `json:"hostname,omitempty"` BalancingPolicy string `json:"balancingPolicy"` - Runner string `json:"runner"` + Runners []string `json:"runners"` RunParameters RunParameters `json:"runParameters,omitempty"` Sysctl map[string]string `json:"sysctl,omitempty"` OfflineTTL Duration `json:"offlineTtl,omitempty"` diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index b736ca9a..d24af655 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -84,7 +84,7 @@ type NodeConfigProvider interface { // MonitoringSender sends monitoring data. type MonitoringSender interface { - SendMonitoringData(monitoringData aostypes.NodeMonitoring) + SendNodeMonitoring(monitoringData aostypes.NodeMonitoring) } // TrafficMonitoring interface to get network traffic. @@ -576,7 +576,7 @@ func (monitor *ResourceMonitor) sendMonitoringData() { instanceMonitoring.monitoring) } - monitor.monitoringSender.SendMonitoringData(nodeMonitoringData) + monitor.monitoringSender.SendNodeMonitoring(nodeMonitoringData) } func (monitor *ResourceMonitor) getCurrentSystemData() { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6493f53c..5fa31f01 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240709152137-c94ad578854a +# github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360 ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From 0e1e1fcd8f7f8226f867cf2bce65999e7bd5d391 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 8 Jul 2024 08:58:21 +0300 Subject: [PATCH 039/146] [amqphandler] AMQPP handler adaptation Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 90 ++++++++++++++++++--------- amqphandler/amqphandler_test.go | 104 +++++++++++++++++++------------- 2 files changed, 124 insertions(+), 70 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index 151512c0..006cf68d 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -234,6 +234,8 @@ func (handler *AmqpHandler) SendUnitStatus(unitStatus cloudprotocol.UnitStatus) handler.Lock() defer handler.Unlock() + unitStatus.MessageType = cloudprotocol.UnitStatusMessageType + return handler.scheduleMessage(cloudprotocol.UnitStatusMessageType, unitStatus, false) } @@ -242,6 +244,8 @@ func (handler *AmqpHandler) SendMonitoringData(monitoringData cloudprotocol.Moni handler.Lock() defer handler.Unlock() + monitoringData.MessageType = cloudprotocol.MonitoringMessageType + return handler.scheduleMessage(cloudprotocol.MonitoringMessageType, monitoringData, false) } @@ -250,6 +254,8 @@ func (handler *AmqpHandler) SendInstanceNewState(newState cloudprotocol.NewState handler.Lock() defer handler.Unlock() + newState.MessageType = cloudprotocol.NewStateMessageType + return handler.scheduleMessage(cloudprotocol.NewStateMessageType, newState, false) } @@ -258,6 +264,8 @@ func (handler *AmqpHandler) SendInstanceStateRequest(request cloudprotocol.State handler.Lock() defer handler.Unlock() + request.MessageType = cloudprotocol.StateRequestMessageType + return handler.scheduleMessage(cloudprotocol.StateRequestMessageType, request, true) } @@ -266,6 +274,8 @@ func (handler *AmqpHandler) SendLog(serviceLog cloudprotocol.PushLog) error { handler.Lock() defer handler.Unlock() + serviceLog.MessageType = cloudprotocol.PushLogMessageType + return handler.scheduleMessage(cloudprotocol.PushLogMessageType, serviceLog, true) } @@ -274,6 +284,8 @@ func (handler *AmqpHandler) SendAlerts(alerts cloudprotocol.Alerts) error { handler.Lock() defer handler.Unlock() + alerts.MessageType = cloudprotocol.AlertsMessageType + return handler.scheduleMessage(cloudprotocol.AlertsMessageType, alerts, true) } @@ -282,8 +294,11 @@ func (handler *AmqpHandler) SendIssueUnitCerts(requests []cloudprotocol.IssueCer handler.Lock() defer handler.Unlock() - return handler.scheduleMessage( - cloudprotocol.IssueUnitCertsMessageType, cloudprotocol.IssueUnitCerts{Requests: requests}, true) + issueUnitCerts := cloudprotocol.IssueUnitCerts{ + MessageType: cloudprotocol.IssueUnitCertsMessageType, Requests: requests, + } + + return handler.scheduleMessage(cloudprotocol.IssueUnitCertsMessageType, issueUnitCerts, true) } // SendInstallCertsConfirmation sends install certificates confirmation. @@ -291,9 +306,11 @@ func (handler *AmqpHandler) SendInstallCertsConfirmation(confirmations []cloudpr handler.Lock() defer handler.Unlock() - return handler.scheduleMessage( - cloudprotocol.InstallUnitCertsConfirmationMessageType, - cloudprotocol.InstallUnitCertsConfirmation{Certificates: confirmations}, true) + request := cloudprotocol.InstallUnitCertsConfirmation{ + MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType, Certificates: confirmations, + } + + return handler.scheduleMessage(cloudprotocol.InstallUnitCertsConfirmationMessageType, request, true) } // SendOverrideEnvVarsStatus overrides env vars status. @@ -301,6 +318,8 @@ func (handler *AmqpHandler) SendOverrideEnvVarsStatus(envs cloudprotocol.Overrid handler.Lock() defer handler.Unlock() + envs.MessageType = cloudprotocol.OverrideEnvVarsStatusMessageType + return handler.scheduleMessage(cloudprotocol.OverrideEnvVarsStatusMessageType, envs, true) } @@ -580,30 +599,30 @@ func (handler *AmqpHandler) runReceiver(deliveryChannel <-chan amqp.Delivery, pa return } + decryptData, err := handler.cryptoContext.DecryptMetadata(delivery.Body) + if err != nil { + log.Errorf("Can't decrypt message: %v", err) + + continue + } + var incomingMsg cloudprotocol.ReceivedMessage + if err := json.Unmarshal(decryptData, &incomingMsg); err != nil { + log.Errorf("Can't parse message: %v", err) - if err := json.Unmarshal(delivery.Body, &incomingMsg); err != nil { - log.Errorf("Can't parse message header: %s", err) continue } if incomingMsg.Header.Version != cloudprotocol.ProtocolVersion { log.Errorf("Unsupported protocol version: %d", incomingMsg.Header.Version) - continue - } - messageTypeFunc, ok := messageMap[incomingMsg.Header.MessageType] - if !ok { - log.Warnf("AMQP unsupported message type: %s", incomingMsg.Header.MessageType) continue } - decodedData := messageTypeFunc() - - log.Infof("AMQP receive message: %s", incomingMsg.Header.MessageType) + decodedData, err := handler.unmarshalReceiveData(incomingMsg.Data) + if err != nil { + log.Errorf("Can't unmarshal incoming message %s", err) - if err := handler.decodeData(incomingMsg.Data, decodedData); err != nil { - log.Errorf("Can't decode incoming message %s", err) continue } @@ -612,31 +631,44 @@ func (handler *AmqpHandler) runReceiver(deliveryChannel <-chan amqp.Delivery, pa } } -func (handler *AmqpHandler) decodeData(data []byte, result interface{}) error { +func (handler *AmqpHandler) unmarshalReceiveData(data []byte) (Message, error) { if len(data) == 0 { - return nil + return nil, nil } - decryptData, err := handler.cryptoContext.DecryptMetadata(data) - if err != nil { - return aoserrors.Wrap(err) + // unmarshal type name + var messageType struct { + Type string `json:"messageType"` } - if err = json.Unmarshal(decryptData, result); err != nil { - return aoserrors.Wrap(err) + if err := json.Unmarshal(data, &messageType); err != nil { + return nil, aoserrors.Wrap(err) } - desiredStatus, ok := result.(*cloudprotocol.DesiredStatus) + // unmarshal type message + messageTypeFunc, ok := messageMap[messageType.Type] if !ok { - log.WithField("data", string(decryptData)).Debug("Decrypted data") + log.Warnf("AMQP unsupported message type: %s", messageType.Type) - return nil + return nil, aoserrors.New("AMQP unsupported message type") + } + + result := messageTypeFunc() + + if err := json.Unmarshal(data, result); err != nil { + return nil, aoserrors.Wrap(err) + } + + // print DesiredStatus message + desiredStatus, ok := result.(*cloudprotocol.DesiredStatus) + if !ok { + return result, nil } log.Debug("Decrypted data:") if desiredStatus.UnitConfig != nil { - log.Debugf("UnitConfig: %s", desiredStatus.UnitConfig) + log.Debugf("UnitConfig: %v", desiredStatus.UnitConfig) } for _, service := range desiredStatus.Services { @@ -680,7 +712,7 @@ func (handler *AmqpHandler) decodeData(data []byte, result interface{}) error { log.Debugf("Sota schedule: %s", schedule) } - return nil + return result, nil } func (handler *AmqpHandler) createCloudMessage(messageType string, data interface{}) cloudprotocol.Message { diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index ccc55aea..67067b86 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -243,6 +243,7 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.StateAcceptanceMessageType, expectedData: &cloudprotocol.StateAcceptance{ + MessageType: cloudprotocol.StateAcceptanceMessageType, InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj0", Instance: 1}, Checksum: "0123456890", Result: "accepted", Reason: "just because", }, @@ -250,6 +251,7 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.UpdateStateMessageType, expectedData: &cloudprotocol.UpdateState{ + MessageType: cloudprotocol.UpdateStateMessageType, InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "subj1", Instance: 1}, Checksum: "0993478847", State: "This is new state", }, @@ -257,8 +259,9 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.RequestLogMessageType, expectedData: &cloudprotocol.RequestLog{ - LogID: "someID", - LogType: cloudprotocol.ServiceLog, + MessageType: cloudprotocol.RequestLogMessageType, + LogID: "someID", + LogType: cloudprotocol.ServiceLog, Filter: cloudprotocol.LogFilter{ InstanceFilter: cloudprotocol.NewInstanceFilter("service2", "", -1), From: nil, Till: nil, @@ -268,8 +271,9 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.RequestLogMessageType, expectedData: &cloudprotocol.RequestLog{ - LogID: "someID", - LogType: cloudprotocol.CrashLog, + MessageType: cloudprotocol.RequestLogMessageType, + LogID: "someID", + LogType: cloudprotocol.CrashLog, Filter: cloudprotocol.LogFilter{ InstanceFilter: cloudprotocol.NewInstanceFilter("service3", "", -1), From: nil, Till: nil, @@ -279,8 +283,9 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.RequestLogMessageType, expectedData: &cloudprotocol.RequestLog{ - LogID: "someID", - LogType: cloudprotocol.SystemLog, + MessageType: cloudprotocol.RequestLogMessageType, + LogID: "someID", + LogType: cloudprotocol.SystemLog, Filter: cloudprotocol.LogFilter{ From: nil, Till: nil, }, @@ -289,6 +294,7 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.RenewCertsNotificationMessageType, expectedData: &cloudprotocol.RenewCertsNotification{ + MessageType: cloudprotocol.RenewCertsNotificationMessageType, Certificates: []cloudprotocol.RenewCertData{ {Type: "online", Serial: "1234", ValidTill: testTime}, }, @@ -300,19 +306,24 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.IssuedUnitCertsMessageType, expectedData: &cloudprotocol.IssuedUnitCerts{ + MessageType: cloudprotocol.IssuedUnitCertsMessageType, Certificates: []cloudprotocol.IssuedCertData{ {Type: "online", NodeID: "mainNode", CertificateChain: "123456"}, }, }, }, { - messageType: cloudprotocol.OverrideEnvVarsMessageType, - expectedData: &cloudprotocol.OverrideEnvVars{OverrideEnvVars: []cloudprotocol.EnvVarsInstanceInfo{}}, + messageType: cloudprotocol.OverrideEnvVarsMessageType, + expectedData: &cloudprotocol.OverrideEnvVars{ + MessageType: cloudprotocol.OverrideEnvVarsMessageType, + OverrideEnvVars: []cloudprotocol.EnvVarsInstanceInfo{}, + }, }, { messageType: cloudprotocol.DesiredStatusMessageType, expectedData: &cloudprotocol.DesiredStatus{ - UnitConfig: &cloudprotocol.UnitConfig{}, + MessageType: cloudprotocol.DesiredStatusMessageType, + UnitConfig: &cloudprotocol.UnitConfig{}, Components: []cloudprotocol.ComponentInfo{ {Version: "1.0.0", ComponentID: &rootfs}, }, @@ -461,20 +472,23 @@ func TestSendMessages(t *testing.T) { } monitoringData := cloudprotocol.Monitoring{ - Nodes: []cloudprotocol.NodeMonitoringData{nodeMonitoring}, + MessageType: cloudprotocol.MonitoringMessageType, + Nodes: []cloudprotocol.NodeMonitoringData{nodeMonitoring}, } pushServiceLogData := cloudprotocol.PushLog{ - LogID: "log0", - PartsCount: 2, - Part: 1, - Content: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + MessageType: cloudprotocol.PushLogMessageType, + LogID: "log0", + PartsCount: 2, + Part: 1, + Content: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, ErrorInfo: &cloudprotocol.ErrorInfo{ Message: "Error", }, } alertsData := cloudprotocol.Alerts{ + MessageType: cloudprotocol.AlertsMessageType, Items: []cloudprotocol.AlertItem{ { Timestamp: time.Now().UTC(), @@ -495,6 +509,7 @@ func TestSendMessages(t *testing.T) { } overrideEnvStatus := cloudprotocol.OverrideEnvVarsStatus{ + MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType, OverrideEnvVarsStatus: []cloudprotocol.EnvVarsInstanceStatus{ { InstanceFilter: cloudprotocol.NewInstanceFilter("service0", "subject0", -1), @@ -513,6 +528,7 @@ func TestSendMessages(t *testing.T) { } issueCerts := cloudprotocol.IssueUnitCerts{ + MessageType: cloudprotocol.IssueUnitCertsMessageType, Requests: []cloudprotocol.IssueCertData{ {Type: "online", Csr: "This is online CSR", NodeID: "mainNode"}, {Type: "offline", Csr: "This is offline CSR", NodeID: "mainNode"}, @@ -520,6 +536,7 @@ func TestSendMessages(t *testing.T) { } installCertsConfirmation := cloudprotocol.InstallUnitCertsConfirmation{ + MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType, Certificates: []cloudprotocol.InstallCertData{ {Type: "online", Serial: "1234", Status: "ok", Description: "This is online cert", NodeID: "mainNode"}, {Type: "offline", Serial: "1234", Status: "ok", Description: "This is offline cert", NodeID: "mainNode"}, @@ -546,6 +563,7 @@ func TestSendMessages(t *testing.T) { Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.UnitStatus{ + MessageType: cloudprotocol.UnitStatusMessageType, UnitConfig: unitConfigData, Components: componentSetupData, Layers: layersSetupData, @@ -556,7 +574,7 @@ func TestSendMessages(t *testing.T) { }, }, getDataType: func() interface{} { - return &cloudprotocol.UnitStatus{} + return &cloudprotocol.UnitStatus{MessageType: cloudprotocol.UnitStatusMessageType} }, }, { @@ -572,7 +590,7 @@ func TestSendMessages(t *testing.T) { Data: &monitoringData, }, getDataType: func() interface{} { - return &cloudprotocol.Monitoring{} + return &cloudprotocol.Monitoring{MessageType: cloudprotocol.MonitoringMessageType} }, }, { @@ -593,16 +611,18 @@ func TestSendMessages(t *testing.T) { Data: &cloudprotocol.NewState{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, Checksum: "12345679", State: "This is state", + MessageType: cloudprotocol.NewStateMessageType, }, }, getDataType: func() interface{} { - return &cloudprotocol.NewState{} + return &cloudprotocol.NewState{MessageType: cloudprotocol.NewStateMessageType} }, }, { call: func() error { return aoserrors.Wrap(amqpHandler.SendInstanceStateRequest( cloudprotocol.StateRequest{ + MessageType: cloudprotocol.StateRequestMessageType, InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, Default: true, })) @@ -614,12 +634,13 @@ func TestSendMessages(t *testing.T) { Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.StateRequest{ + MessageType: cloudprotocol.StateRequestMessageType, InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, Default: true, }, }, getDataType: func() interface{} { - return &cloudprotocol.StateRequest{} + return &cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType} }, }, { @@ -633,15 +654,16 @@ func TestSendMessages(t *testing.T) { Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.PushLog{ - LogID: pushServiceLogData.LogID, - PartsCount: pushServiceLogData.PartsCount, - Part: pushServiceLogData.Part, - Content: pushServiceLogData.Content, - ErrorInfo: pushServiceLogData.ErrorInfo, + MessageType: cloudprotocol.PushLogMessageType, + LogID: pushServiceLogData.LogID, + PartsCount: pushServiceLogData.PartsCount, + Part: pushServiceLogData.Part, + Content: pushServiceLogData.Content, + ErrorInfo: pushServiceLogData.ErrorInfo, }, }, getDataType: func() interface{} { - return &cloudprotocol.PushLog{} + return &cloudprotocol.PushLog{MessageType: cloudprotocol.PushLogMessageType} }, }, { @@ -657,7 +679,7 @@ func TestSendMessages(t *testing.T) { Data: &alertsData, }, getDataType: func() interface{} { - return &cloudprotocol.Alerts{} + return &cloudprotocol.Alerts{MessageType: cloudprotocol.AlertsMessageType} }, }, { @@ -673,7 +695,7 @@ func TestSendMessages(t *testing.T) { Data: &issueCerts, }, getDataType: func() interface{} { - return &cloudprotocol.IssueUnitCerts{} + return &cloudprotocol.IssueUnitCerts{MessageType: cloudprotocol.IssueUnitCertsMessageType} }, }, { @@ -689,7 +711,7 @@ func TestSendMessages(t *testing.T) { Data: &installCertsConfirmation, }, getDataType: func() interface{} { - return &cloudprotocol.InstallUnitCertsConfirmation{} + return &cloudprotocol.InstallUnitCertsConfirmation{MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType} }, }, { @@ -705,7 +727,7 @@ func TestSendMessages(t *testing.T) { Data: &overrideEnvStatus, }, getDataType: func() interface{} { - return &cloudprotocol.OverrideEnvVarsStatus{} + return &cloudprotocol.OverrideEnvVarsStatus{MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType} }, }, } @@ -845,22 +867,22 @@ func TestSendMultipleMessages(t *testing.T) { testData := []func() error{ func() error { - return aoserrors.Wrap(amqpHandler.SendUnitStatus(cloudprotocol.UnitStatus{})) + return aoserrors.Wrap(amqpHandler.SendUnitStatus(cloudprotocol.UnitStatus{MessageType: cloudprotocol.UnitStatusMessageType})) }, func() error { - return aoserrors.Wrap(amqpHandler.SendMonitoringData(cloudprotocol.Monitoring{})) + return aoserrors.Wrap(amqpHandler.SendMonitoringData(cloudprotocol.Monitoring{MessageType: cloudprotocol.MonitoringMessageType})) }, func() error { - return aoserrors.Wrap(amqpHandler.SendInstanceNewState(cloudprotocol.NewState{})) + return aoserrors.Wrap(amqpHandler.SendInstanceNewState(cloudprotocol.NewState{MessageType: cloudprotocol.NewStateMessageType})) }, func() error { - return aoserrors.Wrap(amqpHandler.SendInstanceStateRequest(cloudprotocol.StateRequest{})) + return aoserrors.Wrap(amqpHandler.SendInstanceStateRequest(cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType})) }, func() error { - return aoserrors.Wrap(amqpHandler.SendLog(cloudprotocol.PushLog{})) + return aoserrors.Wrap(amqpHandler.SendLog(cloudprotocol.PushLog{MessageType: cloudprotocol.PushLogMessageType})) }, func() error { - return aoserrors.Wrap(amqpHandler.SendAlerts(cloudprotocol.Alerts{})) + return aoserrors.Wrap(amqpHandler.SendAlerts(cloudprotocol.Alerts{MessageType: cloudprotocol.AlertsMessageType})) }, func() error { return aoserrors.Wrap(amqpHandler.SendIssueUnitCerts(nil)) @@ -869,7 +891,7 @@ func TestSendMultipleMessages(t *testing.T) { return aoserrors.Wrap(amqpHandler.SendInstallCertsConfirmation(nil)) }, func() error { - return aoserrors.Wrap(amqpHandler.SendOverrideEnvVarsStatus(cloudprotocol.OverrideEnvVarsStatus{})) + return aoserrors.Wrap(amqpHandler.SendOverrideEnvVarsStatus(cloudprotocol.OverrideEnvVarsStatus{MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType})) }, } @@ -904,23 +926,23 @@ func TestSendDisconnectMessages(t *testing.T) { defer amqpHandler.Close() // Send unimportant message - - if err := amqpHandler.SendUnitStatus(cloudprotocol.UnitStatus{}); !errors.Is(err, amqphandler.ErrNotConnected) { + err = amqpHandler.SendUnitStatus(cloudprotocol.UnitStatus{MessageType: cloudprotocol.UnitStatusMessageType}) + if !errors.Is(err, amqphandler.ErrNotConnected) { t.Errorf("Wrong error type: %v", err) } // Send number important messages equals to send channel size - should be accepted without error for i := 0; i < sendQueueSize; i++ { - if err := amqpHandler.SendAlerts(cloudprotocol.Alerts{}); err != nil { + if err := amqpHandler.SendAlerts(cloudprotocol.Alerts{MessageType: cloudprotocol.AlertsMessageType}); err != nil { t.Errorf("Can't send important message: %v", err) } } // Next important message should fail due to send channel size - if err := amqpHandler.SendInstanceStateRequest( - cloudprotocol.StateRequest{}); !errors.Is(err, amqphandler.ErrSendChannelFull) { + err = amqpHandler.SendInstanceStateRequest(cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType}) + if !errors.Is(err, amqphandler.ErrSendChannelFull) { t.Errorf("Wrong error type: %v", err) } @@ -967,7 +989,7 @@ func (context *testCryptoContext) DecryptMetadata(input []byte) (output []byte, return output, aoserrors.Wrap(err) } - return output, nil + return input, nil } func newConnectionEventsConsumer() *testConnectionEventsConsumer { From 1ba2f85a055d41341384852d902bdf9bdd9be74f Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 8 Jul 2024 17:07:51 +0300 Subject: [PATCH 040/146] [amqphandler] Use base64 to do encoding/decoding in unit tests Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 67067b86..8cc68999 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -19,6 +19,7 @@ package amqphandler_test import ( "crypto/tls" + "encoding/base64" "encoding/json" "errors" "math/rand" @@ -184,6 +185,8 @@ func sendCloudMessage(msgType string, message interface{}) error { log.WithFields(log.Fields{"message": string(dataJSON)}).Debug("Send message") + encryptedData := []byte(base64.StdEncoding.EncodeToString(dataJSON)) + return aoserrors.Wrap(testClient.channel.Publish( "", outQueueName, @@ -191,7 +194,7 @@ func sendCloudMessage(msgType string, message interface{}) error { false, amqp.Publishing{ ContentType: "text/plain", - Body: dataJSON, + Body: encryptedData, })) } @@ -984,12 +987,12 @@ func (context *testCryptoContext) GetTLSConfig() (config *tls.Config, err error) } func (context *testCryptoContext) DecryptMetadata(input []byte) (output []byte, err error) { - output, err = json.Marshal(context.currentMessage) + output, err = base64.StdEncoding.DecodeString(string(input)) if err != nil { return output, aoserrors.Wrap(err) } - return input, nil + return output, nil } func newConnectionEventsConsumer() *testConnectionEventsConsumer { From 72fa2957fe68d9a9cd41f437ea09762eeb3f3152 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 9 Jul 2024 19:45:35 +0300 Subject: [PATCH 041/146] [amqphandler] Remove MessageType from MessageHeader Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 67 +++++++++------- amqphandler/amqphandler_test.go | 131 ++++++++++++++++---------------- 2 files changed, 103 insertions(+), 95 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index 006cf68d..24e1ad25 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -132,14 +132,6 @@ var ( ErrSendChannelFull = errors.New("send channel full") ) -var importantMessages = []string{ //nolint:gochecknoglobals // used as const - cloudprotocol.DesiredStatusMessageType, cloudprotocol.StateAcceptanceMessageType, - cloudprotocol.RenewCertsNotificationMessageType, cloudprotocol.IssuedUnitCertsMessageType, cloudprotocol.OverrideEnvVarsMessageType, - cloudprotocol.NewStateMessageType, cloudprotocol.StateRequestMessageType, cloudprotocol.UnitStatusMessageType, - cloudprotocol.IssueUnitCertsMessageType, cloudprotocol.InstallUnitCertsConfirmationMessageType, - cloudprotocol.OverrideEnvVarsStatusMessageType, -} - /*********************************************************************************************************************** * Public **********************************************************************************************************************/ @@ -179,8 +171,7 @@ func (handler *AmqpHandler) Connect(cryptoContext CryptoContext, sdURL, systemID ctx, handler.cancelFunc = context.WithCancel(context.Background()) if connectionInfo, err = getConnectionInfo(ctx, sdURL, - handler.createCloudMessage(cloudprotocol.ServiceDiscoveryType, - cloudprotocol.ServiceDiscoveryRequest{}), tlsConfig); err != nil { + handler.createCloudMessage(cloudprotocol.ServiceDiscoveryRequest{}), tlsConfig); err != nil { return aoserrors.Wrap(err) } @@ -715,12 +706,11 @@ func (handler *AmqpHandler) unmarshalReceiveData(data []byte) (Message, error) { return result, nil } -func (handler *AmqpHandler) createCloudMessage(messageType string, data interface{}) cloudprotocol.Message { +func (handler *AmqpHandler) createCloudMessage(data interface{}) cloudprotocol.Message { return cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - Version: cloudprotocol.ProtocolVersion, - SystemID: handler.systemID, - MessageType: messageType, + Version: cloudprotocol.ProtocolVersion, + SystemID: handler.systemID, }, Data: data, } @@ -744,7 +734,7 @@ func (handler *AmqpHandler) scheduleMessage(messageType string, data interface{} } select { - case handler.sendChannel <- handler.createCloudMessage(messageType, data): + case handler.sendChannel <- handler.createCloudMessage(data): return nil case <-time.After(sendTimeout): @@ -752,18 +742,8 @@ func (handler *AmqpHandler) scheduleMessage(messageType string, data interface{} } } -func isMessageImportant(messageType string) bool { - for _, importantType := range importantMessages { - if messageType == importantType { - return true - } - } - - return false -} - -func getMessageDataForLog(messageType string, data []byte) string { - if len(data) > maxLenLogMessage && !isMessageImportant(messageType) { +func getMessageDataForLog(message interface{}, data []byte) string { + if len(data) > maxLenLogMessage && !isMessageImportant(message) { return string(data[:maxLenLogMessage]) + "..." } @@ -779,9 +759,9 @@ func (handler *AmqpHandler) sendMessage( } if handler.sendTry > 1 { - log.WithField("data", getMessageDataForLog(message.Header.MessageType, data)).Debug("AMQP retry message") + log.WithField("data", getMessageDataForLog(message.Data, data)).Debug("AMQP retry message") } else { - log.WithField("data", getMessageDataForLog(message.Header.MessageType, data)).Debug("AMQP send message") + log.WithField("data", getMessageDataForLog(message.Data, data)).Debug("AMQP send message") } if handler.sendTry++; handler.sendTry > sendMaxTry { @@ -805,3 +785,32 @@ func (handler *AmqpHandler) sendMessage( return nil } + +func isMessageImportant(message interface{}) bool { + switch message.(type) { + case cloudprotocol.DesiredStatus: + return true + case cloudprotocol.StateAcceptance: + return true + case cloudprotocol.RenewCertsNotification: + return true + case cloudprotocol.IssuedUnitCerts: + return true + case cloudprotocol.OverrideEnvVars: + return true + case cloudprotocol.NewState: + return true + case cloudprotocol.StateRequest: + return true + case cloudprotocol.UnitStatus: + return true + case cloudprotocol.IssueUnitCerts: + return true + case cloudprotocol.InstallCertData: + return true + case cloudprotocol.OverrideEnvVarsStatus: + return true + } + + return false +} diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 8cc68999..8e003233 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -174,7 +174,7 @@ func sendCloudMessage(msgType string, message interface{}) error { } dataToSend := cloudprotocol.ReceivedMessage{ - Header: cloudprotocol.MessageHeader{MessageType: msgType, Version: cloudprotocol.ProtocolVersion}, + Header: cloudprotocol.MessageHeader{Version: cloudprotocol.ProtocolVersion}, Data: rawJSON, } @@ -318,8 +318,8 @@ func TestReceiveMessages(t *testing.T) { { messageType: cloudprotocol.OverrideEnvVarsMessageType, expectedData: &cloudprotocol.OverrideEnvVars{ - MessageType: cloudprotocol.OverrideEnvVarsMessageType, - OverrideEnvVars: []cloudprotocol.EnvVarsInstanceInfo{}, + MessageType: cloudprotocol.OverrideEnvVarsMessageType, + Items: []cloudprotocol.EnvVarsInstanceInfo{}, }, }, { @@ -439,44 +439,47 @@ func TestSendMessages(t *testing.T) { } nodeMonitoring := cloudprotocol.NodeMonitoringData{ - MonitoringData: cloudprotocol.MonitoringData{ - RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}, - }, - NodeID: "mainNode", - Timestamp: time.Now().UTC(), - ServiceInstances: []cloudprotocol.InstanceMonitoringData{ + Items: []aostypes.MonitoringData{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{RAM: 1024, CPU: 50, Disk: []cloudprotocol.PartitionUsage{{ + RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Disk: []aostypes.PartitionUsage{{ Name: "p1", UsedSize: 100, - }}}, + }}, + Timestamp: time.Now().UTC(), }, - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "subj1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{RAM: 128, CPU: 60, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}}, + }, + } + + instanceMonitoringData := []cloudprotocol.InstanceMonitoringData{ + { + NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, + Items: []aostypes.MonitoringData{ + {RAM: 1024, CPU: 50, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}}, }, - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "subj1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{RAM: 256, CPU: 70, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}}, + }, + { + NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "subj1", Instance: 1}, + Items: []aostypes.MonitoringData{ + {RAM: 128, CPU: 60, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}}, }, - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service3", SubjectID: "subj1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{RAM: 512, CPU: 80, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}}, + }, + { + NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "subj1", Instance: 1}, + Items: []aostypes.MonitoringData{ + {RAM: 256, CPU: 70, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}}, + }, + }, + { + NodeID: "mainNode", InstanceIdent: aostypes.InstanceIdent{ServiceID: "service3", SubjectID: "subj1", Instance: 1}, + Items: []aostypes.MonitoringData{ + {RAM: 512, CPU: 80, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}}, }, }, } monitoringData := cloudprotocol.Monitoring{ - MessageType: cloudprotocol.MonitoringMessageType, - Nodes: []cloudprotocol.NodeMonitoringData{nodeMonitoring}, + MessageType: cloudprotocol.MonitoringMessageType, + Nodes: []cloudprotocol.NodeMonitoringData{nodeMonitoring}, + ServiceInstances: instanceMonitoringData, } pushServiceLogData := cloudprotocol.PushLog{ @@ -513,18 +516,18 @@ func TestSendMessages(t *testing.T) { overrideEnvStatus := cloudprotocol.OverrideEnvVarsStatus{ MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType, - OverrideEnvVarsStatus: []cloudprotocol.EnvVarsInstanceStatus{ + Statuses: []cloudprotocol.EnvVarsInstanceStatus{ { InstanceFilter: cloudprotocol.NewInstanceFilter("service0", "subject0", -1), Statuses: []cloudprotocol.EnvVarStatus{ - {ID: "1234"}, - {ID: "345", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "some error"}}, + {Name: "1234"}, + {Name: "345", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "some error"}}, }, }, { InstanceFilter: cloudprotocol.NewInstanceFilter("service1", "subject1", -1), Statuses: []cloudprotocol.EnvVarStatus{ - {ID: "0000"}, + {Name: "0000"}, }, }, }, @@ -561,9 +564,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.UnitStatusMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.UnitStatus{ MessageType: cloudprotocol.UnitStatusMessageType, @@ -586,9 +588,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.MonitoringMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &monitoringData, }, @@ -607,9 +608,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.NewStateMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.NewState{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, @@ -632,9 +632,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.StateRequestMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.StateRequest{ MessageType: cloudprotocol.StateRequestMessageType, @@ -652,9 +651,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.PushLogMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &cloudprotocol.PushLog{ MessageType: cloudprotocol.PushLogMessageType, @@ -675,9 +673,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.AlertsMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &alertsData, }, @@ -691,9 +688,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.IssueUnitCertsMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &issueCerts, }, @@ -707,9 +703,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &installCertsConfirmation, }, @@ -723,9 +718,8 @@ func TestSendMessages(t *testing.T) { }, data: cloudprotocol.Message{ Header: cloudprotocol.MessageHeader{ - MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType, - SystemID: systemID, - Version: cloudprotocol.ProtocolVersion, + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, }, Data: &overrideEnvStatus, }, @@ -958,15 +952,20 @@ func TestSendDisconnectMessages(t *testing.T) { for i := 0; i < sendQueueSize; i++ { select { case delivery := <-testClient.delivery: - var message cloudprotocol.Message + // unmarshal type name + var message struct { + Data struct { + MessageType string `json:"messageType"` + } `json:"data"` + } if err = json.Unmarshal(delivery.Body, &message); err != nil { - t.Errorf("Error parsing message: %v", err) + t.Errorf("Can't parse json message: %v", err) continue } - if message.Header.MessageType != cloudprotocol.AlertsMessageType { - t.Errorf("Wrong message type: %s", message.Header.MessageType) + if message.Data.MessageType != cloudprotocol.AlertsMessageType { + t.Errorf("Wrong message type: %s", message.Data.MessageType) } case err = <-testClient.errChannel: From 0dd70d8c2291d3095daed30b9dc564c928bb5b6d Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 11 Jul 2024 18:40:47 +0300 Subject: [PATCH 042/146] [amqphandler] Fix lint errors Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 1 + amqphandler/amqphandler_test.go | 35 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index 24e1ad25..c136d556 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -624,6 +624,7 @@ func (handler *AmqpHandler) runReceiver(deliveryChannel <-chan amqp.Delivery, pa func (handler *AmqpHandler) unmarshalReceiveData(data []byte) (Message, error) { if len(data) == 0 { + //nolint:nilnil return nil, nil } diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 8e003233..b14d7db4 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -709,7 +709,9 @@ func TestSendMessages(t *testing.T) { Data: &installCertsConfirmation, }, getDataType: func() interface{} { - return &cloudprotocol.InstallUnitCertsConfirmation{MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType} + return &cloudprotocol.InstallUnitCertsConfirmation{ + MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType, + } }, }, { @@ -864,22 +866,34 @@ func TestSendMultipleMessages(t *testing.T) { testData := []func() error{ func() error { - return aoserrors.Wrap(amqpHandler.SendUnitStatus(cloudprotocol.UnitStatus{MessageType: cloudprotocol.UnitStatusMessageType})) + return aoserrors.Wrap(amqpHandler.SendUnitStatus( + cloudprotocol.UnitStatus{MessageType: cloudprotocol.UnitStatusMessageType}), + ) }, func() error { - return aoserrors.Wrap(amqpHandler.SendMonitoringData(cloudprotocol.Monitoring{MessageType: cloudprotocol.MonitoringMessageType})) + return aoserrors.Wrap(amqpHandler.SendMonitoringData( + cloudprotocol.Monitoring{MessageType: cloudprotocol.MonitoringMessageType}), + ) }, func() error { - return aoserrors.Wrap(amqpHandler.SendInstanceNewState(cloudprotocol.NewState{MessageType: cloudprotocol.NewStateMessageType})) + return aoserrors.Wrap( + amqpHandler.SendInstanceNewState(cloudprotocol.NewState{MessageType: cloudprotocol.NewStateMessageType}), + ) }, func() error { - return aoserrors.Wrap(amqpHandler.SendInstanceStateRequest(cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType})) + return aoserrors.Wrap(amqpHandler.SendInstanceStateRequest( + cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType}), + ) }, func() error { - return aoserrors.Wrap(amqpHandler.SendLog(cloudprotocol.PushLog{MessageType: cloudprotocol.PushLogMessageType})) + return aoserrors.Wrap( + amqpHandler.SendLog(cloudprotocol.PushLog{MessageType: cloudprotocol.PushLogMessageType}), + ) }, func() error { - return aoserrors.Wrap(amqpHandler.SendAlerts(cloudprotocol.Alerts{MessageType: cloudprotocol.AlertsMessageType})) + return aoserrors.Wrap( + amqpHandler.SendAlerts(cloudprotocol.Alerts{MessageType: cloudprotocol.AlertsMessageType}), + ) }, func() error { return aoserrors.Wrap(amqpHandler.SendIssueUnitCerts(nil)) @@ -888,7 +902,9 @@ func TestSendMultipleMessages(t *testing.T) { return aoserrors.Wrap(amqpHandler.SendInstallCertsConfirmation(nil)) }, func() error { - return aoserrors.Wrap(amqpHandler.SendOverrideEnvVarsStatus(cloudprotocol.OverrideEnvVarsStatus{MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType})) + return aoserrors.Wrap(amqpHandler.SendOverrideEnvVarsStatus( + cloudprotocol.OverrideEnvVarsStatus{MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType}), + ) }, } @@ -938,7 +954,8 @@ func TestSendDisconnectMessages(t *testing.T) { // Next important message should fail due to send channel size - err = amqpHandler.SendInstanceStateRequest(cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType}) + err = amqpHandler.SendInstanceStateRequest( + cloudprotocol.StateRequest{MessageType: cloudprotocol.StateRequestMessageType}) if !errors.Is(err, amqphandler.ErrSendChannelFull) { t.Errorf("Wrong error type: %v", err) } From c7980c0c90a6bfb27afeb8c16fbb8e9f663dc2c9 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Fri, 12 Jul 2024 12:54:21 +0300 Subject: [PATCH 043/146] [vendor] Update vendor Signed-off-by: Mykola Kobets --- .../utils/semverutils/semverutils.go | 53 +++++++++++++++++++ vendor/modules.txt | 1 + 2 files changed, 54 insertions(+) create mode 100644 vendor/github.com/aosedge/aos_common/utils/semverutils/semverutils.go diff --git a/vendor/github.com/aosedge/aos_common/utils/semverutils/semverutils.go b/vendor/github.com/aosedge/aos_common/utils/semverutils/semverutils.go new file mode 100644 index 00000000..6e456bc8 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/utils/semverutils/semverutils.go @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2024 Renesas Electronics Corporation. +// Copyright (C) 2024 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// semverutils is a simple wrapper around go-version library to compare versions + +package semverutils + +import ( + "github.com/aosedge/aos_common/aoserrors" + semver "github.com/hashicorp/go-version" +) + +func LessThan(version1 string, version2 string) (bool, error) { + semver1, err := semver.NewSemver(version1) + if err != nil { + return false, aoserrors.Wrap(err) + } + + semver2, err := semver.NewSemver(version2) + if err != nil { + return false, aoserrors.Wrap(err) + } + + return semver1.LessThan(semver2), nil +} + +func GreaterThan(version1 string, version2 string) (bool, error) { + semver1, err := semver.NewSemver(version1) + if err != nil { + return false, aoserrors.Wrap(err) + } + + semver2, err := semver.NewSemver(version2) + if err != nil { + return false, aoserrors.Wrap(err) + } + + return semver1.GreaterThan(semver2), nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5fa31f01..d7af2cb3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -29,6 +29,7 @@ github.com/aosedge/aos_common/utils/cryptutils github.com/aosedge/aos_common/utils/fs github.com/aosedge/aos_common/utils/pbconvert github.com/aosedge/aos_common/utils/retryhelper +github.com/aosedge/aos_common/utils/semverutils github.com/aosedge/aos_common/utils/syncstream github.com/aosedge/aos_common/utils/testtools github.com/aosedge/aos_common/utils/xentop From c6c78a48e2e482a87bbd5973685f1defa1f14886 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 9 Jul 2024 12:43:05 +0300 Subject: [PATCH 044/146] [networkmanager] Remove NetworkInfo aostypes.NetworkParameters type already contains NetworkID now. There is no need in NetworkInfo Signed-off-by: Mykola Kobets --- database/database.go | 8 +- database/database_internal_test.go | 134 +++++++++++--------------- networkmanager/ipamalloc.go | 3 +- networkmanager/networkmanager.go | 29 ++---- networkmanager/networkmanager_test.go | 4 +- 5 files changed, 72 insertions(+), 106 deletions(-) diff --git a/database/database.go b/database/database.go index d0cc21aa..8ffffec3 100644 --- a/database/database.go +++ b/database/database.go @@ -665,7 +665,7 @@ func (db *Database) RemoveStorageStateInfo(instanceIdent aostypes.InstanceIdent) return err } -func (db *Database) AddNetworkInfo(networkInfo networkmanager.NetworkInfo) error { +func (db *Database) AddNetworkInfo(networkInfo aostypes.NetworkParameters) error { return db.executeQuery("INSERT INTO network values(?, ?, ?, ?)", networkInfo.NetworkID, networkInfo.IP, networkInfo.Subnet, networkInfo.VlanID) } @@ -678,7 +678,7 @@ func (db *Database) RemoveNetworkInfo(networkID string) (err error) { return err } -func (db *Database) GetNetworksInfo() ([]networkmanager.NetworkInfo, error) { +func (db *Database) GetNetworksInfo() ([]aostypes.NetworkParameters, error) { rows, err := db.sql.Query("SELECT * FROM network") if err != nil { return nil, aoserrors.Wrap(err) @@ -689,10 +689,10 @@ func (db *Database) GetNetworksInfo() ([]networkmanager.NetworkInfo, error) { return nil, aoserrors.Wrap(rows.Err()) } - var networks []networkmanager.NetworkInfo + var networks []aostypes.NetworkParameters for rows.Next() { - var networkInfo networkmanager.NetworkInfo + var networkInfo aostypes.NetworkParameters if err = rows.Scan(&networkInfo.NetworkID, &networkInfo.IP, &networkInfo.Subnet, &networkInfo.VlanID); err != nil { return nil, aoserrors.Wrap(err) diff --git a/database/database_internal_test.go b/database/database_internal_test.go index cc0ae5f8..2f601726 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -486,19 +486,17 @@ func TestNetworkInstanceConfiguration(t *testing.T) { SubjectID: "subject1", Instance: 1, }, - NetworkInfo: networkmanager.NetworkInfo{ + NetworkParameters: aostypes.NetworkParameters{ NetworkID: "network1", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.17.0.0/16", - IP: "172.17.0.1", - VlanID: 1, - FirewallRules: []aostypes.FirewallRule{ - { - Proto: "tcp", - DstIP: "172.18.0.1", - SrcIP: "172.17.0.1", - DstPort: "80", - }, + Subnet: "172.17.0.0/16", + IP: "172.17.0.1", + VlanID: 1, + FirewallRules: []aostypes.FirewallRule{ + { + Proto: "tcp", + DstIP: "172.18.0.1", + SrcIP: "172.17.0.1", + DstPort: "80", }, }, }, @@ -511,13 +509,11 @@ func TestNetworkInstanceConfiguration(t *testing.T) { SubjectID: "subject2", Instance: 1, }, - NetworkInfo: networkmanager.NetworkInfo{ + NetworkParameters: aostypes.NetworkParameters{ NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.1", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.1", + VlanID: 1, }, }, }, @@ -528,13 +524,11 @@ func TestNetworkInstanceConfiguration(t *testing.T) { SubjectID: "subject2", Instance: 2, }, - NetworkInfo: networkmanager.NetworkInfo{ + NetworkParameters: aostypes.NetworkParameters{ NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.2", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.2", + VlanID: 1, }, }, }, @@ -563,13 +557,11 @@ func TestNetworkInstanceConfiguration(t *testing.T) { SubjectID: "subject2", Instance: 1, }, - NetworkInfo: networkmanager.NetworkInfo{ + NetworkParameters: aostypes.NetworkParameters{ NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.1", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.1", + VlanID: 1, }, }, { @@ -578,13 +570,11 @@ func TestNetworkInstanceConfiguration(t *testing.T) { SubjectID: "subject2", Instance: 2, }, - NetworkInfo: networkmanager.NetworkInfo{ + NetworkParameters: aostypes.NetworkParameters{ NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.2", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.2", + VlanID: 1, }, }, }, @@ -602,13 +592,11 @@ func TestNetworkInstanceConfiguration(t *testing.T) { SubjectID: "subject2", Instance: 2, }, - NetworkInfo: networkmanager.NetworkInfo{ + NetworkParameters: aostypes.NetworkParameters{ NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.2", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.2", + VlanID: 1, }, }, }, @@ -641,36 +629,30 @@ func TestNetworkInstanceConfiguration(t *testing.T) { func TestNetworkConfiguration(t *testing.T) { casesAdd := []struct { - networkInfo networkmanager.NetworkInfo + networkInfo aostypes.NetworkParameters }{ { - networkInfo: networkmanager.NetworkInfo{ + networkInfo: aostypes.NetworkParameters{ NetworkID: "network1", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.17.0.0/16", - IP: "172.17.0.1", - VlanID: 1, - }, + Subnet: "172.17.0.0/16", + IP: "172.17.0.1", + VlanID: 1, }, }, { - networkInfo: networkmanager.NetworkInfo{ + networkInfo: aostypes.NetworkParameters{ NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.1", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.1", + VlanID: 1, }, }, { - networkInfo: networkmanager.NetworkInfo{ + networkInfo: aostypes.NetworkParameters{ NetworkID: "network3", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.19.0.0/16", - IP: "172.19.0.2", - VlanID: 1, - }, + Subnet: "172.19.0.0/16", + IP: "172.19.0.2", + VlanID: 1, }, }, } @@ -682,40 +664,34 @@ func TestNetworkConfiguration(t *testing.T) { } casesRemove := []struct { - expectedNetworkInfo []networkmanager.NetworkInfo + expectedNetworkInfo []aostypes.NetworkParameters removeNetwork string }{ { removeNetwork: "network1", - expectedNetworkInfo: []networkmanager.NetworkInfo{ + expectedNetworkInfo: []aostypes.NetworkParameters{ { NetworkID: "network2", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.18.0.0/16", - IP: "172.18.0.1", - VlanID: 1, - }, + Subnet: "172.18.0.0/16", + IP: "172.18.0.1", + VlanID: 1, }, { NetworkID: "network3", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.19.0.0/16", - IP: "172.19.0.2", - VlanID: 1, - }, + Subnet: "172.19.0.0/16", + IP: "172.19.0.2", + VlanID: 1, }, }, }, { removeNetwork: "network2", - expectedNetworkInfo: []networkmanager.NetworkInfo{ + expectedNetworkInfo: []aostypes.NetworkParameters{ { NetworkID: "network3", - NetworkParameters: aostypes.NetworkParameters{ - Subnet: "172.19.0.0/16", - IP: "172.19.0.2", - VlanID: 1, - }, + Subnet: "172.19.0.0/16", + IP: "172.19.0.2", + VlanID: 1, }, }, }, diff --git a/networkmanager/ipamalloc.go b/networkmanager/ipamalloc.go index be323b9c..aed91ef6 100644 --- a/networkmanager/ipamalloc.go +++ b/networkmanager/ipamalloc.go @@ -24,6 +24,7 @@ import ( "sync" "github.com/aosedge/aos_common/aoserrors" + "github.com/aosedge/aos_common/aostypes" "github.com/apparentlymart/go-cidr/cidr" log "github.com/sirupsen/logrus" ) @@ -172,7 +173,7 @@ func (ipam *ipSubnet) getAvailableSubnet(networkID string) (*net.IPNet, error) { return subnet.ipNet, nil } -func (ipam *ipSubnet) removeAllocatedSubnets(networks []NetworkInfo, networkInstances []InstanceNetworkInfo) { +func (ipam *ipSubnet) removeAllocatedSubnets(networks []aostypes.NetworkParameters, networkInstances []InstanceNetworkInfo) { ipam.Lock() defer ipam.Unlock() diff --git a/networkmanager/networkmanager.go b/networkmanager/networkmanager.go index 3f355100..301de5a2 100644 --- a/networkmanager/networkmanager.go +++ b/networkmanager/networkmanager.go @@ -56,8 +56,8 @@ type Storage interface { RemoveNetworkInstanceInfo(instance aostypes.InstanceIdent) error GetNetworkInstancesInfo() ([]InstanceNetworkInfo, error) RemoveNetworkInfo(networkID string) error - AddNetworkInfo(info NetworkInfo) error - GetNetworksInfo() ([]NetworkInfo, error) + AddNetworkInfo(info aostypes.NetworkParameters) error + GetNetworksInfo() ([]aostypes.NetworkParameters, error) } // NodeManager nodes controller. @@ -76,12 +76,6 @@ type NetworkManager struct { nodeManager NodeManager } -// NetworkInfo represents network info for instance. -type NetworkInfo struct { - aostypes.NetworkParameters - NetworkID string -} - // FirewallRule represents firewall rule. type FirewallRule struct { Protocol string @@ -91,7 +85,7 @@ type FirewallRule struct { // InstanceNetworkInfo represents network info for instance. type InstanceNetworkInfo struct { aostypes.InstanceIdent - NetworkInfo + aostypes.NetworkParameters Rules []FirewallRule } @@ -162,8 +156,7 @@ func New(storage Storage, nodeManager NodeManager, config *config.Config) (*Netw } for _, networkInfo := range networksInfo { - networkInfo.NetworkParameters.NetworkID = networkInfo.NetworkID - networkManager.providerNetworks[networkInfo.NetworkID] = networkInfo.NetworkParameters + networkManager.providerNetworks[networkInfo.NetworkID] = networkInfo } networkInstancesInfos, err := storage.GetNetworkInstancesInfo() @@ -302,16 +295,14 @@ func (manager *NetworkManager) createNetwork( return networkParameters, err } + networkParameters.NetworkID = networkID networkParameters.IP = ip.String() networkParameters.Subnet = subnet.String() networkParameters.DNSServers = []string{manager.dns.IPAddress} instanceNetworkInfo := InstanceNetworkInfo{ - InstanceIdent: instanceIdent, - NetworkInfo: NetworkInfo{ - NetworkID: networkID, - NetworkParameters: networkParameters, - }, + InstanceIdent: instanceIdent, + NetworkParameters: networkParameters, } if len(params.ExposePorts) > 0 { @@ -482,12 +473,10 @@ func (manager *NetworkManager) addProviderNetworks( networkParameter.Subnet = subnet.String() networkParameter.IP = cidr.Inc(subnet.IP).String() + networkParameter.NetworkID = providerID manager.providerNetworks[providerID] = networkParameter - if err := manager.storage.AddNetworkInfo(NetworkInfo{ - NetworkID: providerID, - NetworkParameters: networkParameter, - }); err != nil { + if err := manager.storage.AddNetworkInfo(networkParameter); err != nil { return nil, aoserrors.Wrap(err) } diff --git a/networkmanager/networkmanager_test.go b/networkmanager/networkmanager_test.go index 7e9c1d2f..e48009aa 100644 --- a/networkmanager/networkmanager_test.go +++ b/networkmanager/networkmanager_test.go @@ -579,11 +579,11 @@ func (storage *testStore) RemoveNetworkInfo(networkID string) error { return nil } -func (storage *testStore) AddNetworkInfo(networkInfo networkmanager.NetworkInfo) error { +func (storage *testStore) AddNetworkInfo(networkInfo aostypes.NetworkParameters) error { return nil } -func (storage *testStore) GetNetworksInfo() (networkInfos []networkmanager.NetworkInfo, err error) { +func (storage *testStore) GetNetworksInfo() (networkInfos []aostypes.NetworkParameters, err error) { return nil, nil } From 7abddc9d5f3e44749fb451b113c03646b30b4485 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 9 Jul 2024 15:23:58 +0300 Subject: [PATCH 045/146] [database] Database adaptation to new proto interfaces Signed-off-by: Mykola Kobets --- database/database.go | 146 ++++++++++++++++++++++++++++++------------- 1 file changed, 101 insertions(+), 45 deletions(-) diff --git a/database/database.go b/database/database.go index 8ffffec3..a8538a72 100644 --- a/database/database.go +++ b/database/database.go @@ -24,6 +24,7 @@ import ( "fmt" "os" "path/filepath" + "sort" "time" "github.com/aosedge/aos_common/aoserrors" @@ -32,6 +33,7 @@ import ( _ "github.com/mattn/go-sqlite3" // ignore lint log "github.com/sirupsen/logrus" + "github.com/aosedge/aos_common/utils/semverutils" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/downloader" "github.com/aosedge/aos_communicationmanager/imagemanager" @@ -51,7 +53,7 @@ const ( syncMode = "NORMAL" ) -const dbVersion = 1 +const dbVersion = 2 const dbFileName = "communicationmanager.db" @@ -365,44 +367,58 @@ func (db *Database) SetDownloadInfo(downloadInfo downloader.DownloadInfo) (err e // GetServicesInfo returns services info. func (db *Database) GetServicesInfo() ([]imagemanager.ServiceInfo, error) { - return db.getServicesFromQuery(`SELECT * FROM services WHERE(id, aosVersion) - IN (SELECT id, MAX(aosVersion) FROM services GROUP BY id)`) -} + allServiceVersions, err := db.getServicesFromQuery(`SELECT * FROM services GROUP BY id`) + if err != nil { + return nil, err + } -// GetServiceInfo returns service info by ID. -func (db *Database) GetServiceInfo(serviceID string) (service imagemanager.ServiceInfo, err error) { - var ( - configJSON []byte - layers []byte - exposedPorts []byte - ) + maxVersionServices := make(map[string]imagemanager.ServiceInfo) - if err = db.getDataFromQuery( - "SELECT * FROM services WHERE aosVersion = (SELECT MAX(aosVersion) FROM services WHERE id = ?) AND id = ?", - []any{serviceID, serviceID}, - &service.ID, &service.AosVersion, &service.ProviderID, &service.VendorVersion, &service.Description, - &service.URL, &service.RemoteURL, &service.Path, &service.Size, &service.Timestamp, &service.Cached, - &configJSON, &layers, &service.Sha256, &service.Sha512, &exposedPorts, &service.GID); err != nil { - if errors.Is(err, errNotExist) { - return service, imagemanager.ErrNotExist + for _, service := range allServiceVersions { + if storedService, found := maxVersionServices[service.ServiceID]; found { + greater, err := semverutils.GreaterThan(service.Version, storedService.Version) + if err != nil { + return nil, aoserrors.Wrap(err) + } + if greater { + maxVersionServices[service.ServiceID] = service + } + } else { + maxVersionServices[service.ServiceID] = service } + } + + result := make([]imagemanager.ServiceInfo, 0) + for _, value := range maxVersionServices { + result = append(result, value) + } + return result, nil +} + +// GetServiceInfo returns service info by ID. +func (db *Database) GetServiceInfo(serviceID string) (service imagemanager.ServiceInfo, err error) { + maxVersion, err := db.getMaxServiceVersion(serviceID) + if err != nil { return service, err } - if err = json.Unmarshal(configJSON, &service.Config); err != nil { - return service, aoserrors.Wrap(err) + services, err := db.getServicesFromQuery( + "SELECT * FROM services WHERE id = ? and version = ?", + serviceID, maxVersion) + if err != nil { + return service, err } - if err = json.Unmarshal(layers, &service.Layers); err != nil { - return service, aoserrors.Wrap(err) + if len(services) == 0 { + return imagemanager.ServiceInfo{}, imagemanager.ErrNotExist } - if err = json.Unmarshal(exposedPorts, &service.ExposedPorts); err != nil { - return service, aoserrors.Wrap(err) + if len(services) > 1 { + return imagemanager.ServiceInfo{}, aoserrors.New("wrong number of services returned") } - return service, nil + return services[0], nil } // AddService adds new service. @@ -422,10 +438,10 @@ func (db *Database) AddService(service imagemanager.ServiceInfo) error { return aoserrors.Wrap(err) } - return db.executeQuery("INSERT INTO services values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - service.ID, service.AosVersion, service.ProviderID, service.VendorVersion, service.Description, - service.URL, service.RemoteURL, service.Path, service.Size, service.Timestamp, service.Cached, - configJSON, layers, service.Sha256, service.Sha512, exposedPorts, service.GID) + return db.executeQuery("INSERT INTO services values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + service.ServiceID, service.Version, service.ProviderID, service.URL, service.RemoteURL, + service.Path, service.Size, service.Timestamp, service.Cached, + configJSON, layers, service.Sha256, exposedPorts, service.GID) } // SetServiceCached sets cached status for the service. @@ -439,9 +455,9 @@ func (db *Database) SetServiceCached(serviceID string, cached bool) (err error) } // RemoveService removes existing service. -func (db *Database) RemoveService(serviceID string, aosVersion uint64) (err error) { - if err = db.executeQuery("DELETE FROM services WHERE id = ? AND aosVersion = ?", - serviceID, aosVersion); errors.Is(err, errNotExist) { +func (db *Database) RemoveService(serviceID string, version string) (err error) { + if err = db.executeQuery("DELETE FROM services WHERE id = ? AND version = ?", + serviceID, version); errors.Is(err, errNotExist) { return nil } @@ -451,7 +467,7 @@ func (db *Database) RemoveService(serviceID string, aosVersion uint64) (err erro // GetAllServiceVersions returns all service versions. func (db *Database) GetServiceVersions(serviceID string) (services []imagemanager.ServiceInfo, err error) { if services, err = db.getServicesFromQuery( - "SELECT * FROM services WHERE id = ? ORDER BY aosVersion", serviceID); err != nil { + "SELECT * FROM services WHERE id = ? GROUP BY version", serviceID); err != nil { return nil, err } @@ -459,6 +475,12 @@ func (db *Database) GetServiceVersions(serviceID string) (services []imagemanage return nil, imagemanager.ErrNotExist } + sort.SliceStable(services, func(left, right int) bool { + res, _ := semverutils.LessThan(services[left].Version, services[right].Version) + + return res + }) + return services, nil } @@ -852,12 +874,10 @@ func (db *Database) createServiceTable() (err error) { log.Info("Create service table") _, err = db.sql.Exec(`CREATE TABLE IF NOT EXISTS services (id TEXT NOT NULL , - aosVersion INTEGER, + version TEXT NOT NULL, providerId TEXT, - vendorVersion TEXT, - description TEXT, - localURL TEXT, - remoteURL TEXT, + localURL TEXT, + remoteURL TEXT, path TEXT, size INTEGER, timestamp TIMESTAMP, @@ -865,10 +885,9 @@ func (db *Database) createServiceTable() (err error) { config BLOB, layers BLOB, sha256 BLOB, - sha512 BLOB, exposedPorts BLOB, gid INTEGER, - PRIMARY KEY(id, aosVersion))`) + PRIMARY KEY(id, version))`) return aoserrors.Wrap(err) } @@ -1012,10 +1031,9 @@ func (db *Database) getServicesFromQuery( exposedPorts []byte ) - if err = rows.Scan(&service.ID, &service.AosVersion, &service.ProviderID, &service.VendorVersion, - &service.Description, &service.URL, &service.RemoteURL, &service.Path, &service.Size, - &service.Timestamp, &service.Cached, &configJSON, &layers, &service.Sha256, - &service.Sha512, &exposedPorts, &service.GID); err != nil { + if err = rows.Scan(&service.ServiceID, &service.Version, &service.ProviderID, &service.URL, &service.RemoteURL, + &service.Path, &service.Size, &service.Timestamp, &service.Cached, &configJSON, &layers, + &service.Sha256, &exposedPorts, &service.GID); err != nil { return nil, aoserrors.Wrap(err) } @@ -1037,6 +1055,44 @@ func (db *Database) getServicesFromQuery( return services, nil } +func (db *Database) getMaxServiceVersion(serviceID string) (version string, err error) { + var rows *sql.Rows + if serviceID != "" { + rows, err = db.sql.Query("SELECT version FROM services WHERE id = ?", serviceID) + } else { + rows, err = db.sql.Query("SELECT version FROM services") + } + + if err != nil { + return "", aoserrors.Wrap(err) + } + defer rows.Close() + + if rows.Err() != nil { + return "", aoserrors.Wrap(rows.Err()) + } + + maxVersion := "0.0.0" + + for rows.Next() { + var version string + if err = rows.Scan(&version); err != nil { + return "", aoserrors.Wrap(err) + } + + greater, err := semverutils.GreaterThan(version, maxVersion) + if err != nil { + return "", aoserrors.Wrap(err) + } + + if greater { + maxVersion = version + } + } + + return maxVersion, nil +} + func (db *Database) getLayersFromQuery( query string, args ...interface{}, ) (layers []imagemanager.LayerInfo, err error) { From 4a6aff74c47f5469526617950b3c6568a94a3223 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 1 Jul 2024 13:38:10 +0300 Subject: [PATCH 046/146] [umcontroller, config] Remove UMClients list Signed-off-by: Mykola Kobets --- aos_communicationmanager.cfg | 7 -- config/config.go | 8 -- config/config_test.go | 8 -- umcontroller/umcontroller.go | 123 +++++++++++++++++++++---- umcontroller/umcontroller_test.go | 146 ++++++++++++++++++++---------- umcontroller/umctrlserver.go | 1 + umcontroller/umhandler.go | 18 ++-- 7 files changed, 216 insertions(+), 95 deletions(-) diff --git a/aos_communicationmanager.cfg b/aos_communicationmanager.cfg index 1e8b3ae8..b04a330e 100644 --- a/aos_communicationmanager.cfg +++ b/aos_communicationmanager.cfg @@ -16,13 +16,6 @@ }, "umController": { "cmServerUrl": ":8091", - "umClients": [ - { - "umId": "um", - "priority": 0, - "isLocal": true - } - ] }, "migration": { "migrationPath": "/usr/share/communicationmanager/migration", diff --git a/config/config.go b/config/config.go index 2ea9d199..ab7dac02 100644 --- a/config/config.go +++ b/config/config.go @@ -45,17 +45,9 @@ type Crypt struct { type UMController struct { FileServerURL string `json:"fileServerUrl"` CMServerURL string `json:"cmServerUrl"` - UMClients []UMClientConfig `json:"umClients"` UpdateTTL aostypes.Duration `json:"updateTtl"` } -// UMClientConfig update manager config. -type UMClientConfig struct { - UMID string `json:"umId"` - Priority uint32 `json:"priority"` - IsLocal bool `json:"isLocal,omitempty"` -} - // Monitoring configuration for system monitoring. type Monitoring struct { MonitorConfig *resourcemonitor.Config `json:"monitorConfig"` diff --git a/config/config_test.go b/config/config_test.go index 07b66a25..061f318c 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -101,11 +101,6 @@ const testConfigContent = `{ "umController": { "fileServerUrl":"localhost:8092", "cmServerUrl": "localhost:8091", - "umClients": [{ - "umId": "um", - "priority": 0, - "isLocal": true - }], "updateTTL": "100h" } }` @@ -255,12 +250,9 @@ func TestGetAlertsConfig(t *testing.T) { } func TestUMControllerConfig(t *testing.T) { - umClient := config.UMClientConfig{UMID: "um", Priority: 0, IsLocal: true} - originalConfig := config.UMController{ FileServerURL: "localhost:8092", CMServerURL: "localhost:8091", - UMClients: []config.UMClientConfig{umClient}, UpdateTTL: aostypes.Duration{Duration: 100 * time.Hour}, } diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 06512d47..3c0f3239 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -25,6 +25,7 @@ import ( "os" "path" "path/filepath" + "slices" "sort" "sync" "time" @@ -48,11 +49,13 @@ import ( // Controller update managers controller. type Controller struct { - storage storage - server *umCtrlServer - eventChannel chan umCtrlInternalMsg - stopChannel chan bool - componentDir string + storage storage + server *umCtrlServer + + eventChannel chan umCtrlInternalMsg + nodeInfoChannel <-chan *cloudprotocol.NodeInfo + stopChannel chan bool + componentDir string decrypter Decrypter @@ -65,7 +68,8 @@ type Controller struct { operable bool updateFinishCond *sync.Cond - updateError error + updateError error + currentNodeID string fileServer *fileserver.FileServer } @@ -99,6 +103,7 @@ type umCtrlInternalMsg struct { type umStatus struct { updateStatus string + nodePriority uint32 componsStatus []systemComponentStatus } @@ -132,6 +137,14 @@ type Decrypter interface { DecryptAndValidate(encryptedFile, decryptedFile string, params fcrypt.DecryptParams) error } +// NodeInfoProvider provides information about the nodes. +type NodeInfoProvider interface { + GetNodeID() string + GetAllNodeIDs() (nodeIds []string, err error) + GetNodeInfo(nodeID string) (nodeInfo *cloudprotocol.NodeInfo, err error) + SubscribeNodeInfoChange() <-chan *cloudprotocol.NodeInfo +} + /*********************************************************************************************************************** * Consts **********************************************************************************************************************/ @@ -199,13 +212,14 @@ const fileScheme = "file" **********************************************************************************************************************/ // New creates new update managers controller. -func New(config *config.Config, storage storage, certProvider CertificateProvider, +func New(config *config.Config, storage storage, certProvider CertificateProvider, nodeInfoProvider NodeInfoProvider, cryptocontext *cryptutils.CryptoContext, decrypter Decrypter, insecure bool) ( umCtrl *Controller, err error, ) { umCtrl = &Controller{ storage: storage, eventChannel: make(chan umCtrlInternalMsg), + nodeInfoChannel: nodeInfoProvider.SubscribeNodeInfoChange(), stopChannel: make(chan bool), componentDir: config.ComponentsDir, connectionMonitor: allConnectionMonitor{stopTimerChan: make(chan bool, 1), timeoutChan: make(chan bool, 1)}, @@ -223,11 +237,10 @@ func New(config *config.Config, storage storage, certProvider CertificateProvide return nil, aoserrors.Wrap(err) } - for _, client := range config.UMController.UMClients { - umCtrl.connections = append(umCtrl.connections, umConnection{ - umID: client.UMID, - isLocalClient: client.IsLocal, updatePriority: client.Priority, handler: nil, - }) + umCtrl.currentNodeID = nodeInfoProvider.GetNodeID() + + if err := umCtrl.createConnections(nodeInfoProvider); err != nil { + return nil, aoserrors.Wrap(err) } sort.Slice(umCtrl.connections, func(i, j int) bool { @@ -418,6 +431,9 @@ func (umCtrl *Controller) processInternalMessages() { log.Error("Unsupported internal message ", internalMsg.requestType) } + case nodeInfo := <-umCtrl.nodeInfoChannel: + umCtrl.handleNodeInfoChange(nodeInfo) + case <-umCtrl.stopChannel: log.Debug("Close all connections") @@ -453,6 +469,7 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s umCtrl.connections[i].handler = handler umCtrl.connections[i].state = handler.GetInitialState() + umCtrl.connections[i].updatePriority = status.nodePriority umCtrl.connections[i].components = []string{} for _, newComponent := range status.componsStatus { @@ -488,15 +505,17 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s } } - log.Debug("All connection to Ums established") + if umCtrl.fsm.Current() == stateInit { + log.Debug("All connection to Ums established") - umCtrl.connectionMonitor.stopConnectionTimer() + umCtrl.connectionMonitor.stopConnectionTimer() - if err := umCtrl.getUpdateComponentsFromStorage(); err != nil { - log.Error("Can't read update components from storage: ", err) - } + if err := umCtrl.getUpdateComponentsFromStorage(); err != nil { + log.Error("Can't read update components from storage: ", err) + } - umCtrl.generateFSMEvent(evAllClientsConnected) + umCtrl.generateFSMEvent(evAllClientsConnected) + } } func (umCtrl *Controller) handleCloseConnection(umID string) { @@ -1021,6 +1040,74 @@ func (umCtrl *Controller) updateComplete(ctx context.Context, e *fsm.Event) { umCtrl.cleanupCurrentComponentStatus() } +func (umCtrl *Controller) createConnections(nodeInfoProvider NodeInfoProvider) error { + ids, err := nodeInfoProvider.GetAllNodeIDs() + if err != nil { + return aoserrors.Wrap(err) + } + + for _, id := range ids { + nodeInfo, err := nodeInfoProvider.GetNodeInfo(id) + if err != nil { + return aoserrors.Wrap(err) + } + + if nodeInfo.Status == "unprovisioned" { + continue + } + + components, err := nodeInfo.GetAosComponents() + if err != nil { + log.WithFields(log.Fields{"err": err, "nodeID": nodeInfo.NodeID}).Error("Can't get aos components") + + continue + } + + if !slices.Contains(components, cloudprotocol.AosComponentUM) { + continue + } + + umCtrl.connections = append(umCtrl.connections, umConnection{ + umID: nodeInfo.NodeID, + isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, + updatePriority: 1000, + handler: nil, + }) + } + + return nil +} + +func (umCtrl *Controller) handleNodeInfoChange(nodeInfo *cloudprotocol.NodeInfo) { + if nodeInfo.Status == "unprovisioned" { + return + } + + components, err := nodeInfo.GetAosComponents() + if err != nil { + log.WithField("err", err).Error("Can't get aos components") + + return + } + + if !slices.Contains(components, cloudprotocol.AosComponentUM) { + return + } + + connectionAdded := slices.ContainsFunc(umCtrl.connections, func(connection umConnection) bool { + return connection.umID == nodeInfo.NodeID + }) + + if connectionAdded { + return + } + + umCtrl.connections = append(umCtrl.connections, umConnection{ + umID: nodeInfo.NodeID, + isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, updatePriority: 1000, handler: nil, + }) +} + func (status systemComponentStatus) String() string { return fmt.Sprintf("{id: %s, status: %s, version: %s }", status.id, status.status, status.version) } diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 404e7e74..65fe3c46 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -80,6 +80,12 @@ type testUmConnection struct { type testCryptoContext struct{} +type testNodeInfoProvider struct { + umcontroller.NodeInfoProvider + nodeInfo []*cloudprotocol.NodeInfo + nodeInfoListeners []chan *cloudprotocol.NodeInfo +} + /*********************************************************************************************************************** * Vars **********************************************************************************************************************/ @@ -100,6 +106,76 @@ func init() { log.SetOutput(os.Stdout) } +/*********************************************************************************************************************** + * testNodeInfoProvider implementation + **********************************************************************************************************************/ + +func NewTestNodeInfoProvider(nodeIds []string) *testNodeInfoProvider { + provider := &testNodeInfoProvider{ + nodeInfo: make([]*cloudprotocol.NodeInfo, 0), + nodeInfoListeners: make([]chan *cloudprotocol.NodeInfo, 0), + } + + for _, nodeId := range nodeIds { + nodeInfo := &cloudprotocol.NodeInfo{ + NodeID: nodeId, + Status: "provisioned", + Attrs: map[string]interface{}{ + cloudprotocol.NodeAttrAosComponents: interface{}(cloudprotocol.AosComponentUM), + }, + } + provider.nodeInfo = append(provider.nodeInfo, nodeInfo) + } + + return provider +} + +func (provider *testNodeInfoProvider) GetNodeID() string { + return "test" +} + +func (provider *testNodeInfoProvider) GetAllNodeIDs() (nodesId []string, err error) { + result := make([]string, 0) + + for _, nodeInfo := range provider.nodeInfo { + result = append(result, nodeInfo.NodeID) + } + + return result, nil +} + +func (provider *testNodeInfoProvider) GetNodeInfo(nodeID string) (nodeInfo *cloudprotocol.NodeInfo, err error) { + for _, nodeInfo := range provider.nodeInfo { + if nodeInfo.NodeID == nodeID { + return nodeInfo, nil + } + } + + return nil, aoserrors.Errorf("not found") +} + +func (provider *testNodeInfoProvider) SubscribeNodeInfoChange() <-chan *cloudprotocol.NodeInfo { + listener := make(chan *cloudprotocol.NodeInfo) + provider.nodeInfoListeners = append(provider.nodeInfoListeners, listener) + + return listener +} + +func (provider *testNodeInfoProvider) addNode(nodeID string) { + nodeInfo := &cloudprotocol.NodeInfo{ + NodeID: nodeID, + Status: "provisioned", + Attrs: map[string]interface{}{ + cloudprotocol.NodeAttrAosComponents: interface{}(cloudprotocol.AosComponentUM), + }, + } + provider.nodeInfo = append(provider.nodeInfo, nodeInfo) + + for _, listener := range provider.nodeInfoListeners { + listener <- nodeInfo + } +} + /*********************************************************************************************************************** * Tests **********************************************************************************************************************/ @@ -141,15 +217,13 @@ func TestConnection(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8092", - UMClients: []config.UMClientConfig{ - {UMID: "umID1", Priority: 10}, - {UMID: "umID2", Priority: 0}, - }, } + + nodeInfoProvider := NewTestNodeInfoProvider([]string{"umID1"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} umCtrl, err := umcontroller.New( - &smConfig, &testStorage{}, nil, nil, &testCryptoContext{}, true) + &smConfig, &testStorage{}, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Fatalf("Can't create: UM controller %s", err) } @@ -164,6 +238,8 @@ func TestConnection(t *testing.T) { t.Errorf("Error connect %s", err) } + nodeInfoProvider.addNode("umID2") + components2 := []*pb.ComponentStatus{ {ComponentId: "component3", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, {ComponentId: "component4", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, @@ -244,18 +320,15 @@ func TestFullUpdate(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM1", Priority: 1}, - {UMID: "testUM2", Priority: 10}, - }, } + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM1", "testUM2"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -407,18 +480,14 @@ func TestFullUpdateWithDisconnect(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM3", Priority: 1}, - {UMID: "testUM4", Priority: 10}, - }, } - + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM3", "testUM4"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -587,18 +656,14 @@ func TestFullUpdateWithReboot(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM5", Priority: 1}, - {UMID: "testUM6", Priority: 10}, - }, } - + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM5", "testUM6"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -693,7 +758,7 @@ func TestFullUpdateWithReboot(t *testing.T) { <-finishChannel umCtrl, err = umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -729,7 +794,7 @@ func TestFullUpdateWithReboot(t *testing.T) { <-um6.notifyTestChan umCtrl, err = umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -792,18 +857,14 @@ func TestRevertOnPrepare(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM7", Priority: 1}, - {UMID: "testUM8", Priority: 10}, - }, } - + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM7", "testUM8"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -928,18 +989,14 @@ func TestRevertOnUpdate(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM9", Priority: 1}, - {UMID: "testUM10", Priority: 10}, - }, } - + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM9", "testUM10"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -1088,18 +1145,14 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM11", Priority: 1}, - {UMID: "testUM12", Priority: 10}, - }, } - + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM11", "testUM12"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -1253,18 +1306,15 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { umCtrlConfig := config.UMController{ CMServerURL: "localhost:8091", FileServerURL: "localhost:8093", - UMClients: []config.UMClientConfig{ - {UMID: "testUM13", Priority: 1, IsLocal: true}, - {UMID: "testUM14", Priority: 10}, - }, } + nodeInfoProvider := NewTestNodeInfoProvider([]string{"testUM13", "testUM14"}) smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} var updateStorage testStorage umCtrl, err := umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } @@ -1370,7 +1420,7 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { // um14 reboot umCtrl, err = umcontroller.New( - &smConfig, &updateStorage, nil, nil, &testCryptoContext{}, true) + &smConfig, &updateStorage, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) if err != nil { t.Errorf("Can't create: UM controller %s", err) } diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index f5955fb5..79f4442f 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -156,6 +156,7 @@ func (server *umCtrlServer) RegisterUM(stream pb.UMService_RegisterUMServer) (er func getUmStatusFromUmMessage(msg *pb.UpdateStatus) (status umStatus) { status.updateStatus = msg.GetUpdateState().String() + status.nodePriority = msg.GetPriority() for _, component := range msg.GetComponents() { if component.GetComponentId() == "" { diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index 0bdee93e..9bbf0194 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -32,12 +32,13 @@ import ( /*********************************************************************************************************************** * Types **********************************************************************************************************************/ +type closeReason int type umHandler struct { umID string stream pb.UMService_RegisterUMServer messageChannel chan umCtrlInternalMsg - closeChannel chan bool + closeChannel chan closeReason FSM *fsm.FSM initialUpdateStatus string } @@ -50,6 +51,11 @@ type prepareRequest struct { * Consts **********************************************************************************************************************/ +const ( + Reconnect closeReason = iota + ConnectionClose +) + const ( hStateIdle = "Idle" hStateWaitForPrepareResp = "WaitForPrepareResp" @@ -78,10 +84,10 @@ const ( // NewUmHandler create update manager connection handler. func newUmHandler(id string, umStream pb.UMService_RegisterUMServer, - messageChannel chan umCtrlInternalMsg, state pb.UpdateState) (handler *umHandler, closeChannel chan bool, err error, + messageChannel chan umCtrlInternalMsg, state pb.UpdateState) (handler *umHandler, closeChannel chan closeReason, err error, ) { handler = &umHandler{umID: id, stream: umStream, messageChannel: messageChannel} - handler.closeChannel = make(chan bool) + handler.closeChannel = make(chan closeReason) handler.initialUpdateStatus = state.String() initFsmState := hStateIdle @@ -141,9 +147,9 @@ func newUmHandler(id string, umStream pb.UMService_RegisterUMServer, } // Close close connection. -func (handler *umHandler) Close() { +func (handler *umHandler) Close(reason closeReason) { log.Debug("Close umhandler with UMID = ", handler.umID) - handler.closeChannel <- true + handler.closeChannel <- reason } func (handler *umHandler) GetInitialState() (state string) { @@ -181,7 +187,7 @@ func (handler *umHandler) StartRevert() (err error) { **********************************************************************************************************************/ func (handler *umHandler) receiveData() { - defer func() { handler.closeChannel <- true }() + defer func() { handler.closeChannel <- ConnectionClose }() for { statusMsg, err := handler.stream.Recv() From 2bab62be8305f9ce12aa75342ce9d5876b98f7d9 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 2 Jul 2024 15:20:07 +0300 Subject: [PATCH 047/146] [umcontroller] Don't switch to Init state if umclient reconnected Signed-off-by: Mykola Kobets --- umcontroller/umcontroller.go | 19 +++++++++++-------- umcontroller/umctrlserver.go | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 3c0f3239..52dbc45d 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -99,6 +99,7 @@ type umCtrlInternalMsg struct { handler *umHandler requestType int status umStatus + close closeReason } type umStatus struct { @@ -422,7 +423,7 @@ func (umCtrl *Controller) processInternalMessages() { umCtrl.handleNewConnection(internalMsg.umID, internalMsg.handler, internalMsg.status) case closeConnection: - umCtrl.handleCloseConnection(internalMsg.umID) + umCtrl.handleCloseConnection(internalMsg.umID, internalMsg.close) case umStatusUpdate: umCtrl.generateFSMEvent(evUpdateStatusUpdated, internalMsg.umID, internalMsg.status) @@ -464,7 +465,7 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s if value.handler != nil { log.Warn("Connection already available umID = ", umID) - value.handler.Close() + value.handler.Close(Reconnect) } umCtrl.connections[i].handler = handler @@ -494,7 +495,7 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s if !umIDfound { log.Error("Unexpected new UM connection with ID = ", umID) - handler.Close() + handler.Close(ConnectionClose) return } @@ -518,17 +519,19 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s } } -func (umCtrl *Controller) handleCloseConnection(umID string) { +func (umCtrl *Controller) handleCloseConnection(umID string, reason closeReason) { log.Debug("Close UM connection umid = ", umID) for i, value := range umCtrl.connections { if value.umID == umID { - umCtrl.connections[i].handler = nil + if reason == ConnectionClose { + umCtrl.connections[i].handler = nil - umCtrl.fsm.SetState(stateInit) - umCtrl.connectionMonitor.wg.Add(1) + umCtrl.fsm.SetState(stateInit) + umCtrl.connectionMonitor.wg.Add(1) - go umCtrl.connectionMonitor.startConnectionTimer(len(umCtrl.connections)) + go umCtrl.connectionMonitor.startConnectionTimer(len(umCtrl.connections)) + } return } diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index 79f4442f..a5178cc3 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -143,11 +143,12 @@ func (server *umCtrlServer) RegisterUM(stream pb.UMService_RegisterUMServer) (er server.controllerCh <- openConnectionMsg // wait for close - <-ch + reason := <-ch closeConnectionMsg := umCtrlInternalMsg{ umID: statusMsg.GetNodeId(), requestType: closeConnection, + close: reason, } server.controllerCh <- closeConnectionMsg From 07720a3a9b2eba3f13c02e8bd6d970e5b7c83fcb Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 11 Jul 2024 00:29:24 +0300 Subject: [PATCH 048/146] [umcontroller] Notify new components listener Signed-off-by: Mykola Kobets --- umcontroller/umcontroller.go | 46 +++++++++++++++----- umcontroller/umcontroller_test.go | 71 +++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 11 deletions(-) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 52dbc45d..ceb64d6a 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -49,6 +49,7 @@ import ( // Controller update managers controller. type Controller struct { + sync.Mutex storage storage server *umCtrlServer @@ -61,8 +62,10 @@ type Controller struct { allocator spaceallocator.Allocator - connections []umConnection - currentComponents []cloudprotocol.ComponentStatus + connections []umConnection + currentComponents []cloudprotocol.ComponentStatus + newComponentListener chan cloudprotocol.ComponentStatus + fsm *fsm.FSM connectionMonitor allConnectionMonitor operable bool @@ -218,15 +221,16 @@ func New(config *config.Config, storage storage, certProvider CertificateProvide umCtrl *Controller, err error, ) { umCtrl = &Controller{ - storage: storage, - eventChannel: make(chan umCtrlInternalMsg), - nodeInfoChannel: nodeInfoProvider.SubscribeNodeInfoChange(), - stopChannel: make(chan bool), - componentDir: config.ComponentsDir, - connectionMonitor: allConnectionMonitor{stopTimerChan: make(chan bool, 1), timeoutChan: make(chan bool, 1)}, - operable: true, - updateFinishCond: sync.NewCond(&sync.Mutex{}), - decrypter: decrypter, + storage: storage, + eventChannel: make(chan umCtrlInternalMsg), + nodeInfoChannel: nodeInfoProvider.SubscribeNodeInfoChange(), + stopChannel: make(chan bool), + componentDir: config.ComponentsDir, + newComponentListener: nil, + connectionMonitor: allConnectionMonitor{stopTimerChan: make(chan bool, 1), timeoutChan: make(chan bool, 1)}, + operable: true, + updateFinishCond: sync.NewCond(&sync.Mutex{}), + decrypter: decrypter, } if err := os.MkdirAll(umCtrl.componentDir, 0o755); err != nil { @@ -400,6 +404,15 @@ func (umCtrl *Controller) UpdateComponents( return umCtrl.currentComponents, umCtrl.updateError } +func (umCtrl *Controller) SetNewComponentListener() <-chan cloudprotocol.ComponentStatus { + umCtrl.Lock() + defer umCtrl.Unlock() + + umCtrl.newComponentListener = make(chan cloudprotocol.ComponentStatus, 1) + + return umCtrl.newComponentListener +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -600,6 +613,8 @@ func (umCtrl *Controller) updateComponentElement(component systemComponentStatus } umCtrl.currentComponents = append(umCtrl.currentComponents, newComponentStatus) + + umCtrl.notifyNewComponentListener(newComponentStatus) } func (umCtrl *Controller) cleanupCurrentComponentStatus() { @@ -1114,3 +1129,12 @@ func (umCtrl *Controller) handleNodeInfoChange(nodeInfo *cloudprotocol.NodeInfo) func (status systemComponentStatus) String() string { return fmt.Sprintf("{id: %s, status: %s, version: %s }", status.id, status.status, status.version) } + +func (umCtrl *Controller) notifyNewComponentListener(status cloudprotocol.ComponentStatus) { + umCtrl.Lock() + defer umCtrl.Unlock() + + if umCtrl.newComponentListener != nil { + umCtrl.newComponentListener <- status + } +} diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 65fe3c46..a73c324b 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -281,6 +281,77 @@ func TestConnection(t *testing.T) { time.Sleep(1 * time.Second) } +func TestNewComponentsUpdate(t *testing.T) { + umCtrlConfig := config.UMController{ + CMServerURL: "localhost:8091", + FileServerURL: "localhost:8092", + } + + // add components for node with ID=umID1 + nodeInfoProvider := NewTestNodeInfoProvider([]string{"umID1"}) + smConfig := config.Config{UMController: umCtrlConfig, ComponentsDir: tmpDir} + + umCtrl, err := umcontroller.New( + &smConfig, &testStorage{}, nil, nodeInfoProvider, nil, &testCryptoContext{}, true) + if err != nil { + t.Fatalf("Can't create: UM controller %s", err) + } + + components := []*pb.ComponentStatus{ + {ComponentId: "component1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + } + + streamUM1, connUM1, err := createClientConnection("umID1", pb.UpdateState_IDLE, components) + if err != nil { + t.Errorf("Error connect %s", err) + } + + newComponents, err := umCtrl.GetStatus() + if err != nil { + t.Errorf("Can't get system components %s", err) + } + + if len(newComponents) != 2 { + t.Errorf("Incorrect count of components %d", len(newComponents)) + } + + newComponentListener := umCtrl.SetNewComponentListener() + + // add new components for node with ID=umID2 + nodeInfoProvider.addNode("umID2") + + components2 := []*pb.ComponentStatus{ + {ComponentId: "component3", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component4", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + } + + streamUM2, connUM2, err := createClientConnection("umID2", pb.UpdateState_IDLE, components2) + if err != nil { + t.Errorf("Error connect %s", err) + } + + if node2Component3 := <-newComponentListener; node2Component3.ComponentID != "component3" { + t.Errorf("Wrong component received %s", node2Component3.ComponentID) + } + + if node2Component4 := <-newComponentListener; node2Component4.ComponentID != "component4" { + t.Errorf("Wrong component received %s", node2Component4.ComponentID) + } + + umCtrl.Close() + + _ = streamUM1.CloseSend() + + connUM1.Close() + + _ = streamUM2.CloseSend() + + connUM2.Close() + + time.Sleep(1 * time.Second) +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ From 7670ad2f0fbd107b1167302fe9b566c2d88f03e4 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 11 Jul 2024 19:08:27 +0300 Subject: [PATCH 049/146] [umcontroller] Fix umcontroller lint errors Signed-off-by: Mykola Kobets --- umcontroller/umcontroller.go | 8 ++++++-- umcontroller/umcontroller_test.go | 12 ++++++------ umcontroller/umhandler.go | 5 +++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index ceb64d6a..29807eb3 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -209,6 +209,8 @@ const ( const connectionTimeout = 600 * time.Second +const lowestUpdatePriority = 1000 + const fileScheme = "file" /*********************************************************************************************************************** @@ -302,6 +304,8 @@ func (umCtrl *Controller) GetStatus() ([]cloudprotocol.ComponentStatus, error) { } // UpdateComponents updates components. +// +//nolint:funlen,gocognit func (umCtrl *Controller) UpdateComponents( components []cloudprotocol.ComponentInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate, @@ -1088,7 +1092,7 @@ func (umCtrl *Controller) createConnections(nodeInfoProvider NodeInfoProvider) e umCtrl.connections = append(umCtrl.connections, umConnection{ umID: nodeInfo.NodeID, isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, - updatePriority: 1000, + updatePriority: lowestUpdatePriority, handler: nil, }) } @@ -1122,7 +1126,7 @@ func (umCtrl *Controller) handleNodeInfoChange(nodeInfo *cloudprotocol.NodeInfo) umCtrl.connections = append(umCtrl.connections, umConnection{ umID: nodeInfo.NodeID, - isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, updatePriority: 1000, handler: nil, + isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, updatePriority: lowestUpdatePriority, handler: nil, }) } diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index a73c324b..693556ae 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -116,9 +116,9 @@ func NewTestNodeInfoProvider(nodeIds []string) *testNodeInfoProvider { nodeInfoListeners: make([]chan *cloudprotocol.NodeInfo, 0), } - for _, nodeId := range nodeIds { + for _, nodeID := range nodeIds { nodeInfo := &cloudprotocol.NodeInfo{ - NodeID: nodeId, + NodeID: nodeID, Status: "provisioned", Attrs: map[string]interface{}{ cloudprotocol.NodeAttrAosComponents: interface{}(cloudprotocol.AosComponentUM), @@ -134,7 +134,7 @@ func (provider *testNodeInfoProvider) GetNodeID() string { return "test" } -func (provider *testNodeInfoProvider) GetAllNodeIDs() (nodesId []string, err error) { +func (provider *testNodeInfoProvider) GetAllNodeIDs() (nodesIds []string, err error) { result := make([]string, 0) for _, nodeInfo := range provider.nodeInfo { @@ -1645,9 +1645,9 @@ func (context *testCryptoContext) DecryptAndValidate( * Private **********************************************************************************************************************/ -func newTestUM(t *testing.T, id string, updateStatus pb.UpdateState, testState string, components []*pb.ComponentStatus) ( - umTest *testUmConnection, -) { +func newTestUM(t *testing.T, id string, updateStatus pb.UpdateState, + testState string, components []*pb.ComponentStatus, +) (umTest *testUmConnection) { t.Helper() stream, conn, err := createClientConnection(id, updateStatus, components) diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index 9bbf0194..0e1faf76 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -32,6 +32,7 @@ import ( /*********************************************************************************************************************** * Types **********************************************************************************************************************/ + type closeReason int type umHandler struct { @@ -84,8 +85,8 @@ const ( // NewUmHandler create update manager connection handler. func newUmHandler(id string, umStream pb.UMService_RegisterUMServer, - messageChannel chan umCtrlInternalMsg, state pb.UpdateState) (handler *umHandler, closeChannel chan closeReason, err error, -) { + messageChannel chan umCtrlInternalMsg, state pb.UpdateState, +) (handler *umHandler, closeChannel chan closeReason, err error) { handler = &umHandler{umID: id, stream: umStream, messageChannel: messageChannel} handler.closeChannel = make(chan closeReason) handler.initialUpdateStatus = state.String() From 06ac76a0bf3f69b49d8aaf05932ead51df5a05eb Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Tue, 9 Jul 2024 16:45:40 +0300 Subject: [PATCH 050/146] [unitstatushandler,firmwaremanager] Download by component type Signed-off-by: Mykhailo Lohvynenko --- unitstatushandler/firmwaremanager.go | 233 +++++++++-- unitstatushandler/unitstatushandler.go | 11 +- .../unitstatushandler_internal_test.go | 388 ++++++++++++------ unitstatushandler/unitstatushandler_test.go | 26 +- 4 files changed, 497 insertions(+), 161 deletions(-) diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 42a0be93..287011bd 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -23,14 +23,17 @@ import ( "errors" "net/url" "reflect" + "slices" "sync" "time" "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" + semver "github.com/hashicorp/go-version" "github.com/looplab/fsm" log "github.com/sirupsen/logrus" + "github.com/aosedge/aos_common/utils/semverutils" "github.com/aosedge/aos_communicationmanager/cmserver" "github.com/aosedge/aos_communicationmanager/downloader" ) @@ -150,7 +153,9 @@ func (manager *firmwareManager) getCurrentStatus() (status cmserver.UpdateFOTASt for _, component := range manager.CurrentUpdate.Components { if component.ComponentID != nil { status.Components = append(status.Components, cloudprotocol.ComponentStatus{ - ComponentID: *component.ComponentID, Version: component.Version, + ComponentID: *component.ComponentID, + ComponentType: component.ComponentType, + Version: component.Version, }) } } @@ -176,14 +181,27 @@ func (manager *firmwareManager) processDesiredStatus(desiredStatus cloudprotocol return aoserrors.Wrap(err) } + var desiredComponentsWithNoID []cloudprotocol.ComponentInfo + desiredLoop: for _, desiredComponent := range desiredStatus.Components { + if err := validateComponent(desiredComponent); err != nil { + log.WithFields(log.Fields{ + "id": desiredComponent.ComponentID, + "type": desiredComponent.ComponentType, + "version": desiredComponent.Version, + }).Warnf("Skip invalid component: %v", err) + continue + } + if desiredComponent.ComponentID == nil { + desiredComponentsWithNoID = append(desiredComponentsWithNoID, desiredComponent) continue } for _, installedComponent := range installedComponents { - if *desiredComponent.ComponentID == installedComponent.ComponentID { + if *desiredComponent.ComponentID == installedComponent.ComponentID && + desiredComponent.ComponentType == installedComponent.ComponentType { if desiredComponent.Version == installedComponent.Version && installedComponent.Status == cloudprotocol.InstalledStatus { continue desiredLoop @@ -196,11 +214,16 @@ desiredLoop: log.WithFields(log.Fields{ "id": desiredComponent.ComponentID, + "type": desiredComponent.ComponentType, "version": desiredComponent.Version, }).Error("Desired component not found") } + handleDesiredComponentsWithNoID(desiredComponentsWithNoID, installedComponents, update) + if len(update.Components) != 0 { + log.WithField("components", update.Components).Debug("FOTA update required") + if err = manager.newUpdate(update); err != nil { return aoserrors.Wrap(err) } @@ -322,6 +345,43 @@ func (manager *firmwareManager) noUpdate() { } } +func createDownloadRequest(components []cloudprotocol.ComponentInfo) map[string]downloader.PackageInfo { + request := make(map[string]downloader.PackageInfo) + + for _, component := range components { + if component.ComponentID == nil { + continue + } + + downloadID := getDownloadID(component) + + if _, ok := request[downloadID]; ok { + log.WithFields(log.Fields{ + "id": downloadID, + "version": component.Version, + }).Debug("Skip duplicate download component") + + continue + } + + log.WithFields(log.Fields{ + "id": downloadID, + "version": component.Version, + }).Debug("Download component") + + request[downloadID] = downloader.PackageInfo{ + URLs: component.URLs, + Sha256: component.Sha256, + Size: component.Size, + TargetType: cloudprotocol.DownloadTargetComponent, + TargetID: downloadID, + TargetVersion: component.Version, + } + } + + return request +} + func (manager *firmwareManager) download(ctx context.Context) { var downloadErr error @@ -343,30 +403,20 @@ func (manager *firmwareManager) download(ctx context.Context) { manager.statusMutex.Lock() manager.ComponentStatuses = make(map[string]*cloudprotocol.ComponentStatus) - request := make(map[string]downloader.PackageInfo) + request := createDownloadRequest(manager.CurrentUpdate.Components) for _, component := range manager.CurrentUpdate.Components { if component.ComponentID == nil { continue } - log.WithFields(log.Fields{ - "id": component.ComponentID, - "version": component.Version, - }).Debug("Download component") - - request[*component.ComponentID] = downloader.PackageInfo{ - URLs: component.URLs, - Sha256: component.Sha256, - Size: component.Size, - TargetType: cloudprotocol.DownloadTargetComponent, - TargetID: *component.ComponentID, - TargetVersion: component.Version, - } - manager.ComponentStatuses[*component.ComponentID] = &cloudprotocol.ComponentStatus{ - ComponentID: *component.ComponentID, - Version: component.Version, - Status: cloudprotocol.DownloadingStatus, + if _, ok := request[getDownloadID(component)]; ok { + manager.ComponentStatuses[*component.ComponentID] = &cloudprotocol.ComponentStatus{ + ComponentID: *component.ComponentID, + ComponentType: component.ComponentType, + Version: component.Version, + Status: cloudprotocol.DownloadingStatus, + } } } @@ -377,26 +427,35 @@ func (manager *firmwareManager) download(ctx context.Context) { return } - manager.DownloadResult = manager.downloader.download(ctx, request, false, manager.updateComponentStatusByID) + manager.DownloadResult = manager.downloader.download(ctx, request, false, manager.updateComponentStatusByDownloadID) downloadErr = getDownloadError(manager.DownloadResult) - for id, item := range manager.ComponentStatuses { + for _, item := range manager.ComponentStatuses { if item.ErrorInfo != nil { log.WithFields(log.Fields{ "id": item.ComponentID, + "type": item.ComponentType, "version": item.Version, }).Errorf("Error downloading component: %s", item.ErrorInfo.Message) continue } + downloadID := getDownloadID(cloudprotocol.ComponentInfo{ + ComponentID: &item.ComponentID, + ComponentType: item.ComponentType, + Version: item.Version, + }) + log.WithFields(log.Fields{ - "id": item.ComponentID, - "version": item.Version, + "downloadID": downloadID, + "componentID": item.ComponentID, + "type": item.ComponentType, + "version": item.Version, }).Debug("Component successfully downloaded") - manager.updateComponentStatusByID(id, cloudprotocol.PendingStatus, nil) + manager.updateComponentStatusByDownloadID(downloadID, cloudprotocol.PendingStatus, nil) } } @@ -507,6 +566,7 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component for _, status := range manager.ComponentStatuses { log.WithFields(log.Fields{ "id": status.ComponentID, + "type": status.ComponentType, "version": status.Version, }).Info("Component successfully updated") } @@ -521,6 +581,7 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component log.WithFields(log.Fields{ "id": status.ComponentID, + "type": status.ComponentType, "version": status.Version, }).Errorf("Error updating component: %s", status.ErrorInfo.Message) } @@ -534,11 +595,15 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component continue } - log.WithFields(log.Fields{"id": component.ComponentID, "version": component.Version}).Debug("Update component") + log.WithFields(log.Fields{ + "id": component.ComponentID, + "type": component.ComponentType, + "version": component.Version, + }).Debug("Update component") manager.updateComponentStatusByID(*component.ComponentID, cloudprotocol.InstallingStatus, nil) - downloadInfo, ok := manager.DownloadResult[*component.ComponentID] + downloadInfo, ok := manager.DownloadResult[getDownloadID(component)] if !ok { err := aoserrors.New("update ID not found") @@ -575,6 +640,40 @@ func (manager *firmwareManager) sendCurrentStatus() { manager.statusChannel <- manager.getCurrentStatus() } +func (manager *firmwareManager) updateComponentStatusByDownloadID(id, status string, + componentErr *cloudprotocol.ErrorInfo, +) { + manager.statusMutex.Lock() + defer manager.statusMutex.Unlock() + + found := false + + for _, info := range manager.ComponentStatuses { + downloadID := getDownloadID(cloudprotocol.ComponentInfo{ + ComponentID: &info.ComponentID, + ComponentType: info.ComponentType, + Version: info.Version, + }) + + if downloadID != id { + continue + } + + info.Status = status + info.ErrorInfo = componentErr + + manager.statusHandler.updateComponentStatus(*info) + + found = true + } + + if !found { + log.Errorf("Can't update firmware component status: id %s not found", id) + + return + } +} + func (manager *firmwareManager) updateComponentStatusByID(id, status string, componentErr *cloudprotocol.ErrorInfo) { manager.statusMutex.Lock() defer manager.statusMutex.Unlock() @@ -652,3 +751,83 @@ func (manager *firmwareManager) asyncUpdate(updateComponents []cloudprotocol.Com return finishChannel } + +func getDownloadID(component cloudprotocol.ComponentInfo) string { + return component.ComponentType + ":" + component.Version +} + +func validateComponent(component cloudprotocol.ComponentInfo) error { + if component.ComponentType == "" { + return aoserrors.New("component type is empty") + } + + if err := validateSemver(component.Version); err != nil { + return aoserrors.Wrap(err) + } + + return nil +} + +func validateSemver(version string) error { + _, err := semver.NewSemver(version) + + return aoserrors.Wrap(err) +} + +func handleDesiredComponentsWithNoID(componentsWithNoID []cloudprotocol.ComponentInfo, + installedComponents []cloudprotocol.ComponentStatus, update *firmwareUpdate, +) { + log.Debug("Handle desired components with no ID") + + newComponents := make(map[string]cloudprotocol.ComponentInfo) + + for _, installedComponent := range installedComponents { + componentID := installedComponent.ComponentID + + if slices.ContainsFunc(update.Components, func(component cloudprotocol.ComponentInfo) bool { + return *component.ComponentID == componentID + }) { + continue + } + + for _, component := range componentsWithNoID { + if component.ComponentType != installedComponent.ComponentType { + continue + } + + component.ComponentID = &componentID + + newComponent, ok := newComponents[*component.ComponentID] + if !ok { + if err := validateSemver(component.Version); err != nil { + log.Errorf("Error validating version: %v", err) + continue + } + + newComponents[*component.ComponentID] = component + + continue + } + + greater, err := semverutils.GreaterThan(component.Version, newComponent.Version) + if err != nil { + log.Errorf("Error comparing versions: %v", err) + continue + } + + if greater { + newComponents[*component.ComponentID] = component + } + } + } + + for _, component := range newComponents { + log.WithFields(log.Fields{ + "id": *component.ComponentID, + "type": component.ComponentType, + "version": component.Version, + }).Debug("Deducted component ID from installed components") + + update.Components = append(update.Components, component) + } +} diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 1ec364c2..bb5c8092 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -369,6 +369,7 @@ func (instance *Instance) initCurrentStatus() error { for _, status := range componentStatuses { log.WithFields(log.Fields{ "id": status.ComponentID, + "type": status.ComponentType, "status": status.Status, "version": status.Version, "error": status.ErrorInfo, @@ -486,11 +487,11 @@ func (instance *Instance) updateComponentStatus(status cloudprotocol.ComponentSt defer instance.statusMutex.Unlock() log.WithFields(log.Fields{ - "id": status.ComponentID, - "type": status.ComponentType, - "status": status.Status, - "vendorVersion": status.Version, - "error": status.ErrorInfo, + "id": status.ComponentID, + "type": status.ComponentType, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, }).Debug("Update component status") instance.processComponentStatus(status) diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 909329da..db7e7e9b 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -254,27 +254,31 @@ func TestFirmwareManager(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("comp1"), - Version: "1.0", - DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, + ComponentID: convertToComponentID("comp1"), + ComponentType: "rootfs", + Version: "1.0.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, }, { - ComponentID: convertToComponentID("comp2"), - Version: "2.0", - DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + ComponentID: convertToComponentID("comp2"), + ComponentType: "rootfs", + Version: "2.0.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, }, } otherUpdateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("comp3"), - Version: "3.0", - DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, + ComponentID: convertToComponentID("comp3"), + ComponentType: "rootfs", + Version: "3.0.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{3}}, }, { - ComponentID: convertToComponentID("comp4"), - Version: "4.0", - DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, + ComponentID: convertToComponentID("comp4"), + ComponentType: "rootfs", + Version: "4.0.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{4}}, }, } @@ -298,17 +302,118 @@ func TestFirmwareManager(t *testing.T) { testID: "success update", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + }, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Downloading}, + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, + }, + { + testID: "success update components with no ID", + initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, + initComponentStatuses: []cloudprotocol.ComponentStatus{ + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "bios", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + }, + desiredStatus: &cloudprotocol.DesiredStatus{Components: []cloudprotocol.ComponentInfo{ + { + ComponentID: convertToComponentID("comp1"), + ComponentType: "rootfs", + Version: "0.0.1", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, + }, + { + ComponentID: nil, + ComponentType: "bios", + Version: "0.0.2", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + { + ComponentID: nil, + ComponentType: "rootfs", + Version: "broken-version", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + { + ComponentID: nil, + ComponentType: "rootfs", + Version: "0.0.2", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + { + ComponentID: nil, + ComponentType: "rootfs", + Version: "0.0.3", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + }}, + downloadResult: map[string]*downloadResult{ + "rootfs:0.0.1": {}, + "bios:0.0.2": {}, + "rootfs:0.0.3": {}, + }, + updateComponentStatuses: []cloudprotocol.ComponentStatus{ + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.1", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "bios", Version: "0.0.2", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "0.0.3", Status: cloudprotocol.InstalledStatus}, + }, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Downloading}, + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, + }, + { + testID: "success update with different component types", + initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, + initComponentStatuses: []cloudprotocol.ComponentStatus{ + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "bios", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + }, + desiredStatus: &cloudprotocol.DesiredStatus{Components: []cloudprotocol.ComponentInfo{ + { + ComponentID: convertToComponentID("comp1"), + ComponentType: "rootfs", + Version: "0.0.1", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, + }, + { + ComponentID: convertToComponentID("comp2"), + ComponentType: "rootfs", + Version: "0.0.1", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + { + ComponentID: convertToComponentID("comp3"), + ComponentType: "bios", + Version: "0.0.1", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + }}, + downloadResult: map[string]*downloadResult{ + "rootfs:0.0.1": {}, + "bios:0.0.1": {}, + }, + updateComponentStatuses: []cloudprotocol.ComponentStatus{ + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.1", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "0.0.1", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "bios", Version: "0.0.1", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -321,17 +426,50 @@ func TestFirmwareManager(t *testing.T) { testID: "download error", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {Error: "download error"}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {Error: "download error"}, + convertToDownloadID(updateComponents[1]): {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + }, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.Downloading}, + {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "download error"}}, + }, + }, + { + testID: "download error on same component type", + initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, + initComponentStatuses: []cloudprotocol.ComponentStatus{ + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + }, + desiredStatus: &cloudprotocol.DesiredStatus{Components: []cloudprotocol.ComponentInfo{ + { + ComponentID: convertToComponentID("comp1"), + ComponentType: "rootfs", + Version: "0.0.1", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{1}}, + }, + { + ComponentID: convertToComponentID("comp2"), + ComponentType: "rootfs", + Version: "0.0.1", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{2}}, + }, + }}, + downloadResult: map[string]*downloadResult{ + "rootfs:0.0.1": {Error: "download error"}, + }, + updateComponentStatuses: []cloudprotocol.ComponentStatus{ + {ComponentID: "comp1", Version: "0.0.0", ComponentType: "rootfs", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", Version: "0.0.0", ComponentType: "rootfs", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -342,18 +480,18 @@ func TestFirmwareManager(t *testing.T) { testID: "update error", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: updateComponents}, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { - ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.ErrorStatus, + ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: "update error"}, }, }, @@ -372,17 +510,17 @@ func TestFirmwareManager(t *testing.T) { }, initStatus: &cmserver.UpdateStatus{State: cmserver.Downloading}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.ReadyToUpdate}, @@ -396,28 +534,30 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateReadyToUpdate, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ *updateComponents[0].ComponentID: { - ComponentID: *updateComponents[0].ComponentID, - Version: updateComponents[0].Version, + ComponentID: *updateComponents[0].ComponentID, + ComponentType: updateComponents[0].ComponentType, + Version: updateComponents[0].Version, }, *updateComponents[1].ComponentID: { - ComponentID: *updateComponents[1].ComponentID, - Version: updateComponents[1].Version, + ComponentID: *updateComponents[1].ComponentID, + ComponentType: updateComponents[1].ComponentType, + Version: updateComponents[1].Version, }, }, }, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Updating}, @@ -430,27 +570,29 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateUpdating, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ *updateComponents[0].ComponentID: { - ComponentID: *updateComponents[0].ComponentID, - Version: updateComponents[0].Version, + ComponentID: *updateComponents[0].ComponentID, + ComponentType: updateComponents[0].ComponentType, + Version: updateComponents[0].Version, }, *updateComponents[1].ComponentID: { - ComponentID: *updateComponents[1].ComponentID, - Version: updateComponents[1].Version, + ComponentID: *updateComponents[1].ComponentID, + ComponentType: updateComponents[1].ComponentType, + Version: updateComponents[1].Version, }, }, }, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate}, @@ -465,32 +607,34 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, DownloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ *updateComponents[0].ComponentID: { - ComponentID: *updateComponents[0].ComponentID, - Version: updateComponents[0].Version, + ComponentID: *updateComponents[0].ComponentID, + ComponentType: updateComponents[0].ComponentType, + Version: updateComponents[0].Version, }, *updateComponents[1].ComponentID: { - ComponentID: *updateComponents[1].ComponentID, - Version: updateComponents[1].Version, + ComponentID: *updateComponents[1].ComponentID, + ComponentType: updateComponents[1].ComponentType, + Version: updateComponents[1].Version, }, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ Components: updateComponents, FOTASchedule: cloudprotocol.ScheduleRule{Type: cloudprotocol.TriggerUpdate}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, triggerUpdate: true, updateWaitStatuses: []cmserver.UpdateStatus{ @@ -504,28 +648,28 @@ func TestFirmwareManager(t *testing.T) { CurrentState: stateDownloading, CurrentUpdate: &firmwareUpdate{Components: updateComponents}, DownloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.Downloading}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp3", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp4", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", ComponentType: "rootfs", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: otherUpdateComponents}, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, - *otherUpdateComponents[0].ComponentID: {}, - *otherUpdateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, + convertToDownloadID(otherUpdateComponents[0]): {}, + convertToDownloadID(otherUpdateComponents[1]): {}, }, downloadTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", ComponentType: "rootfs", Version: "4.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: context.Canceled.Error()}}, @@ -546,22 +690,22 @@ func TestFirmwareManager(t *testing.T) { }, initStatus: &cmserver.UpdateStatus{State: cmserver.ReadyToUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp3", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp4", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", ComponentType: "rootfs", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ Components: otherUpdateComponents, FOTASchedule: cloudprotocol.ScheduleRule{Type: cloudprotocol.TriggerUpdate}, }, downloadResult: map[string]*downloadResult{ - *otherUpdateComponents[0].ComponentID: {}, - *otherUpdateComponents[1].ComponentID: {}, + convertToDownloadID(otherUpdateComponents[0]): {}, + convertToDownloadID(otherUpdateComponents[1]): {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", ComponentType: "rootfs", Version: "4.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: context.Canceled.Error()}}, @@ -577,41 +721,43 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, DownloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, ComponentStatuses: map[string]*cloudprotocol.ComponentStatus{ *updateComponents[0].ComponentID: { - ComponentID: *updateComponents[0].ComponentID, - Version: updateComponents[0].Version, - Status: cloudprotocol.InstallingStatus, + ComponentID: *updateComponents[0].ComponentID, + ComponentType: updateComponents[0].ComponentType, + Version: updateComponents[0].Version, + Status: cloudprotocol.InstallingStatus, }, *updateComponents[1].ComponentID: { - ComponentID: *updateComponents[1].ComponentID, - Version: updateComponents[1].Version, - Status: cloudprotocol.InstallingStatus, + ComponentID: *updateComponents[1].ComponentID, + ComponentType: updateComponents[1].ComponentType, + Version: updateComponents[1].Version, + Status: cloudprotocol.InstallingStatus, }, }, }, initStatus: &cmserver.UpdateStatus{State: cmserver.Updating}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp3", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp4", Version: "3.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", ComponentType: "rootfs", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{Components: otherUpdateComponents}, downloadResult: map[string]*downloadResult{ - *otherUpdateComponents[0].ComponentID: {}, - *otherUpdateComponents[1].ComponentID: {}, + convertToDownloadID(otherUpdateComponents[0]): {}, + convertToDownloadID(otherUpdateComponents[1]): {}, }, downloadTime: 1 * time.Second, updateTime: 1 * time.Second, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp3", Version: "3.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp4", Version: "4.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp3", ComponentType: "rootfs", Version: "3.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp4", ComponentType: "rootfs", Version: "4.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.NoUpdate}, @@ -625,8 +771,8 @@ func TestFirmwareManager(t *testing.T) { testID: "timetable update", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ FOTASchedule: cloudprotocol.ScheduleRule{ @@ -636,12 +782,12 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, updateComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "1.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -654,8 +800,8 @@ func TestFirmwareManager(t *testing.T) { testID: "update TTL", initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, initComponentStatuses: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp1", Version: "0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "rootfs", Version: "0.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "rootfs", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }, desiredStatus: &cloudprotocol.DesiredStatus{ FOTASchedule: cloudprotocol.ScheduleRule{ @@ -665,8 +811,8 @@ func TestFirmwareManager(t *testing.T) { Components: updateComponents, }, downloadResult: map[string]*downloadResult{ - *updateComponents[0].ComponentID: {}, - *updateComponents[1].ComponentID: {}, + convertToDownloadID(updateComponents[0]): {}, + convertToDownloadID(updateComponents[1]): {}, }, updateWaitStatuses: []cmserver.UpdateStatus{ {State: cmserver.Downloading}, @@ -1655,9 +1801,15 @@ func (downloader *testGroupDownloader) download( case <-time.After(downloader.downloadTime): if getDownloadError(downloader.result) != nil && !continueOnError { for id := range request { - if downloader.result[id].Error == "" { - downloader.result[id].Error = aoserrors.Wrap(context.Canceled).Error() + if result, ok := downloader.result[id]; ok { + if result.Error == "" { + result.Error = aoserrors.Wrap(context.Canceled).Error() + } + + continue } + + log.Errorf("Download result for id: %s not found", id) } } @@ -1902,3 +2054,7 @@ func waitForSOTAUpdateStatus( func convertToComponentID(id string) *string { return &id } + +func convertToDownloadID(component cloudprotocol.ComponentInfo) string { + return component.ComponentType + ":" + component.Version +} diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 33a54a2f..44462319 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -244,9 +244,9 @@ func TestUpdateComponents(t *testing.T) { Version: "1.0.0", Status: cloudprotocol.InstalledStatus, }) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater([]cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, }) softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() @@ -277,9 +277,9 @@ func TestUpdateComponents(t *testing.T) { expectedUnitStatus := cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp2", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{}, @@ -289,8 +289,8 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ComponentID: convertToComponentID("comp0"), Version: "2.0.0"}, - {ComponentID: convertToComponentID("comp2"), Version: "2.0.0"}, + {ComponentID: convertToComponentID("comp0"), ComponentType: "type-1", Version: "2.0.0"}, + {ComponentID: convertToComponentID("comp2"), ComponentType: "type-1", Version: "2.0.0"}, }, }) @@ -310,13 +310,13 @@ func TestUpdateComponents(t *testing.T) { expectedUnitStatus = cloudprotocol.UnitStatus{ UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp0", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp1", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { - ComponentID: "comp1", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, + ComponentID: "comp1", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: firmwareUpdater.UpdateError.Error()}, }, - {ComponentID: "comp2", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, + {ComponentID: "comp2", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, Layers: []cloudprotocol.LayerStatus{}, Services: []cloudprotocol.ServiceStatus{}, @@ -326,7 +326,7 @@ func TestUpdateComponents(t *testing.T) { statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ Components: []cloudprotocol.ComponentInfo{ - {ComponentID: convertToComponentID("comp1"), Version: "2.0.0"}, + {ComponentID: convertToComponentID("comp1"), ComponentType: "type-1", Version: "2.0.0"}, }, }) From 7691ddac7667e63bad6655a5fe9dcda3b00180ba Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Wed, 10 Jul 2024 13:20:40 +0300 Subject: [PATCH 051/146] [umcontroller] Handle component type Signed-off-by: Mykhailo Lohvynenko --- database/database_internal_test.go | 4 +- umcontroller/umcontroller.go | 58 ++-- umcontroller/umcontroller_test.go | 417 +++++++++++++++++++---------- umcontroller/umctrlserver.go | 9 +- umcontroller/umhandler.go | 13 +- 5 files changed, 328 insertions(+), 173 deletions(-) diff --git a/database/database_internal_test.go b/database/database_internal_test.go index 2f601726..9491759c 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -135,10 +135,10 @@ func TestCursor(t *testing.T) { func TestComponentsUpdateInfo(t *testing.T) { testData := []umcontroller.ComponentStatus{ { - ID: "component1", Version: "v1", + ComponentID: "component1", Version: "v1", Annotations: "Some annotation", URL: "url12", Sha256: []byte{1, 3, 90, 42}, }, - {ID: "component2", Version: "v1", URL: "url12", Sha256: []byte{1, 3, 90, 42}}, + {ComponentID: "component2", Version: "v1", URL: "url12", Sha256: []byte{1, 3, 90, 42}}, } if err := testDB.SetComponentsUpdateInfo(testData); err != nil { diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 29807eb3..02380b7f 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -79,12 +79,13 @@ type Controller struct { // ComponentStatus information about system component update. type ComponentStatus struct { - ID string `json:"id"` - Version string `json:"version"` - Annotations string `json:"annotations,omitempty"` - URL string `json:"url"` - Sha256 []byte `json:"sha256"` - Size uint64 `json:"size"` + ComponentID string `json:"componentID"` + ComponentType string `json:"componentType"` + Version string `json:"version"` + Annotations string `json:"annotations,omitempty"` + URL string `json:"url"` + Sha256 []byte `json:"sha256"` + Size uint64 `json:"size"` } type umConnection struct { @@ -112,10 +113,11 @@ type umStatus struct { } type systemComponentStatus struct { - id string - version string - status string - err string + componentID string + componentType string + version string + status string + err string } type allConnectionMonitor struct { @@ -327,8 +329,10 @@ func (umCtrl *Controller) UpdateComponents( } componentStatus := systemComponentStatus{ - id: *component.ComponentID, version: component.Version, - status: cloudprotocol.DownloadedStatus, + componentID: *component.ComponentID, + componentType: component.ComponentType, + version: component.Version, + status: cloudprotocol.DownloadedStatus, } encryptedFile, err := getFilePath(component.URLs[0]) @@ -376,9 +380,11 @@ func (umCtrl *Controller) UpdateComponents( } componentInfo := ComponentStatus{ - ID: *component.ComponentID, Version: component.Version, - Annotations: string(component.Annotations), - Sha256: fileInfo.Sha256, Size: fileInfo.Size, + ComponentID: *component.ComponentID, + ComponentType: component.ComponentType, + Version: component.Version, + Annotations: string(component.Annotations), + Sha256: fileInfo.Sha256, Size: fileInfo.Size, URL: url.String(), } @@ -494,7 +500,7 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s idExist := false for _, value := range umCtrl.connections[i].components { - if value == newComponent.id { + if value == newComponent.componentID { idExist = true break } @@ -504,7 +510,7 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s continue } - umCtrl.connections[i].components = append(umCtrl.connections[i].components, newComponent.id) + umCtrl.connections[i].components = append(umCtrl.connections[i].components, newComponent.componentID) } break @@ -563,7 +569,7 @@ func (umCtrl *Controller) updateCurrentComponentsStatus(componsStatus []systemCo toRemove := []int{} for i, curStatus := range umCtrl.currentComponents { - if value.id == curStatus.ComponentID { + if value.componentID == curStatus.ComponentID && value.componentType == curStatus.ComponentType { if curStatus.Status != cloudprotocol.InstalledStatus { continue } @@ -589,7 +595,8 @@ func (umCtrl *Controller) updateCurrentComponentsStatus(componsStatus []systemCo func (umCtrl *Controller) updateComponentElement(component systemComponentStatus) { for i, curElement := range umCtrl.currentComponents { - if curElement.ComponentID == component.id && curElement.Version == component.version { + if curElement.ComponentID == component.componentID && curElement.ComponentType == component.componentType && + curElement.Version == component.version { if curElement.Status == cloudprotocol.InstalledStatus && component.status != cloudprotocol.InstalledStatus { break } @@ -607,9 +614,10 @@ func (umCtrl *Controller) updateComponentElement(component systemComponentStatus } newComponentStatus := cloudprotocol.ComponentStatus{ - ComponentID: component.id, - Version: component.version, - Status: component.status, + ComponentID: component.componentID, + ComponentType: component.componentType, + Version: component.version, + Status: component.status, } if component.err != "" { @@ -688,7 +696,7 @@ func (umCtrl *Controller) getUpdateComponentsFromStorage() (err error) { func (umCtrl *Controller) addComponentForUpdateToUm(componentInfo ComponentStatus) (err error) { for i := range umCtrl.connections { for _, id := range umCtrl.connections[i].components { - if id == componentInfo.ID { + if id == componentInfo.ComponentID { newURL, err := umCtrl.fileServer.TranslateURL(umCtrl.connections[i].isLocalClient, componentInfo.URL) if err != nil { return aoserrors.Wrap(err) @@ -703,7 +711,7 @@ func (umCtrl *Controller) addComponentForUpdateToUm(componentInfo ComponentStatu } } - return aoserrors.Errorf("component id %s not found", componentInfo.ID) + return aoserrors.Errorf("component id %s not found", componentInfo.ComponentID) } func (umCtrl *Controller) cleanupUpdateData() { @@ -1131,7 +1139,7 @@ func (umCtrl *Controller) handleNodeInfoChange(nodeInfo *cloudprotocol.NodeInfo) } func (status systemComponentStatus) String() string { - return fmt.Sprintf("{id: %s, status: %s, version: %s }", status.id, status.status, status.version) + return fmt.Sprintf("{id: %s, status: %s, version: %s }", status.componentID, status.status, status.version) } func (umCtrl *Controller) notifyNewComponentListener(status cloudprotocol.ComponentStatus) { diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 693556ae..1c6a6e6c 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -229,8 +229,8 @@ func TestConnection(t *testing.T) { } components := []*pb.ComponentStatus{ - {ComponentId: "component1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "component2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } streamUM1, connUM1, err := createClientConnection("umID1", pb.UpdateState_IDLE, components) @@ -241,8 +241,8 @@ func TestConnection(t *testing.T) { nodeInfoProvider.addNode("umID2") components2 := []*pb.ComponentStatus{ - {ComponentId: "component3", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "component4", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component3", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "component4", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } streamUM2, connUM2, err := createClientConnection("umID2", pb.UpdateState_IDLE, components2) @@ -405,16 +405,16 @@ func TestFullUpdate(t *testing.T) { } um1Components := []*pb.ComponentStatus{ - {ComponentId: "um1C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um1C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um1C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um1C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um1 := newTestUM(t, "testUM1", pb.UpdateState_IDLE, "init", um1Components) go um1.processMessages() um2Components := []*pb.ComponentStatus{ - {ComponentId: "um2C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um2C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um2C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um2C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um2 := newTestUM(t, "testUM2", pb.UpdateState_IDLE, "init", um2Components) @@ -429,17 +429,23 @@ func TestFullUpdate(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um1C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um1C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um2C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um2C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um2C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um2C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -455,7 +461,7 @@ func TestFullUpdate(t *testing.T) { }(finishChannel) um1Components = append(um1Components, &pb.ComponentStatus{ - ComponentId: "um1C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING, + ComponentId: "um1C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLING, }) um1.setComponents(um1Components) @@ -465,9 +471,19 @@ func TestFullUpdate(t *testing.T) { um1.sendState(pb.UpdateState_PREPARED) um2Components = append(um2Components, - &pb.ComponentStatus{ComponentId: "um2C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um2C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um2Components = append(um2Components, - &pb.ComponentStatus{ComponentId: "um2C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um2C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um2.setComponents(um2Components) um2.step = prepareStep @@ -486,8 +502,8 @@ func TestFullUpdate(t *testing.T) { um2.sendState(pb.UpdateState_UPDATED) um1Components = []*pb.ComponentStatus{ - {ComponentId: "um1C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um1C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um1C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um1C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um1.setComponents(um1Components) @@ -497,8 +513,8 @@ func TestFullUpdate(t *testing.T) { um1.sendState(pb.UpdateState_IDLE) um2Components = []*pb.ComponentStatus{ - {ComponentId: "um2C1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um2C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um2C1", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um2C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um2.setComponents(um2Components) @@ -515,10 +531,10 @@ func TestFullUpdate(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um1C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um1C2", Version: "2.0.0", Status: "installed"}, - {ComponentID: "um2C1", Version: "2.0.0", Status: "installed"}, - {ComponentID: "um2C2", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um1C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um1C2", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um2C1", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um2C2", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, } currentComponents, err := umCtrl.GetStatus() @@ -564,16 +580,16 @@ func TestFullUpdateWithDisconnect(t *testing.T) { } um3Components := []*pb.ComponentStatus{ - {ComponentId: "um3C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um3C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um3C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um3C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um3 := newTestUM(t, "testUM3", pb.UpdateState_IDLE, "init", um3Components) go um3.processMessages() um4Components := []*pb.ComponentStatus{ - {ComponentId: "um4C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um4C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um4C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um4C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um4 := newTestUM(t, "testUM4", pb.UpdateState_IDLE, "init", um4Components) @@ -588,17 +604,23 @@ func TestFullUpdateWithDisconnect(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um3C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um3C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um4C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um4C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um4C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um4C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -616,7 +638,12 @@ func TestFullUpdateWithDisconnect(t *testing.T) { // prepare UM3 um3Components = append(um3Components, - &pb.ComponentStatus{ComponentId: "um3C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um3C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um3.setComponents(um3Components) um3.step = prepareStep @@ -626,9 +653,19 @@ func TestFullUpdateWithDisconnect(t *testing.T) { // prepare UM4 um4Components = append(um4Components, - &pb.ComponentStatus{ComponentId: "um4C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um4C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um4Components = append(um4Components, - &pb.ComponentStatus{ComponentId: "um4C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um4C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um4.setComponents(um4Components) um4.step = prepareStep @@ -670,8 +707,8 @@ func TestFullUpdateWithDisconnect(t *testing.T) { <-um3.notifyTestChan um3Components = []*pb.ComponentStatus{ - {ComponentId: "um3C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um3C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um3C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um3C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um3 = newTestUM(t, "testUM3", pb.UpdateState_IDLE, "init", um3Components) @@ -683,8 +720,8 @@ func TestFullUpdateWithDisconnect(t *testing.T) { <-um4.notifyTestChan um4Components = []*pb.ComponentStatus{ - {ComponentId: "um4C1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um4C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um4C1", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um4C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um4 = newTestUM(t, "testUM4", pb.UpdateState_IDLE, "init", um4Components) @@ -696,10 +733,10 @@ func TestFullUpdateWithDisconnect(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um3C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um3C2", Version: "2.0.0", Status: "installed"}, - {ComponentID: "um4C1", Version: "2.0.0", Status: "installed"}, - {ComponentID: "um4C2", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um3C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um3C2", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um4C1", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um4C2", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, } currentComponents, err := umCtrl.GetStatus() @@ -740,16 +777,16 @@ func TestFullUpdateWithReboot(t *testing.T) { } um5Components := []*pb.ComponentStatus{ - {ComponentId: "um5C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um5C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um5C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um5C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um5 := newTestUM(t, "testUM5", pb.UpdateState_IDLE, "init", um5Components) go um5.processMessages() um6Components := []*pb.ComponentStatus{ - {ComponentId: "um6C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um6C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um6C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um6C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um6 := newTestUM(t, "testUM6", pb.UpdateState_IDLE, "init", um6Components) @@ -764,17 +801,23 @@ func TestFullUpdateWithReboot(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um5C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um5C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um6C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um6C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um6C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um6C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -792,7 +835,12 @@ func TestFullUpdateWithReboot(t *testing.T) { // prepare UM5 um5Components = append(um5Components, - &pb.ComponentStatus{ComponentId: "um5C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um5C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um5.setComponents(um5Components) um5.step = prepareStep @@ -802,9 +850,19 @@ func TestFullUpdateWithReboot(t *testing.T) { // prepare UM6 um6Components = append(um6Components, - &pb.ComponentStatus{ComponentId: "um6C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um6C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um6Components = append(um6Components, - &pb.ComponentStatus{ComponentId: "um6C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um6C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um6.setComponents(um6Components) um6.step = prepareStep @@ -871,8 +929,8 @@ func TestFullUpdateWithReboot(t *testing.T) { } um5Components = []*pb.ComponentStatus{ - {ComponentId: "um5C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um5C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um5C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um5C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um5 = newTestUM(t, "testUM5", pb.UpdateState_IDLE, "init", um5Components) @@ -886,8 +944,8 @@ func TestFullUpdateWithReboot(t *testing.T) { <-um6.notifyTestChan um6Components = []*pb.ComponentStatus{ - {ComponentId: "um6C1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um6C2", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um6C1", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um6C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLED}, } um6 = newTestUM(t, "testUM6", pb.UpdateState_IDLE, "init", um6Components) @@ -897,10 +955,10 @@ func TestFullUpdateWithReboot(t *testing.T) { um6.step = finishStep etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um5C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um5C2", Version: "2.0.0", Status: "installed"}, - {ComponentID: "um6C1", Version: "2.0.0", Status: "installed"}, - {ComponentID: "um6C2", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um5C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um5C2", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um6C1", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, + {ComponentID: "um6C2", ComponentType: "type-1", Version: "2.0.0", Status: "installed"}, } currentComponents, err := umCtrl.GetStatus() @@ -941,16 +999,16 @@ func TestRevertOnPrepare(t *testing.T) { } um7Components := []*pb.ComponentStatus{ - {ComponentId: "um7C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um7C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um7C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um7C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um7 := newTestUM(t, "testUM7", pb.UpdateState_IDLE, "init", um7Components) go um7.processMessages() um8Components := []*pb.ComponentStatus{ - {ComponentId: "um8C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um8C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um8C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um8C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um8 := newTestUM(t, "testUM8", pb.UpdateState_IDLE, "init", um8Components) @@ -965,17 +1023,23 @@ func TestRevertOnPrepare(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um7C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um7C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um8C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um8C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um8C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um8C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -992,7 +1056,12 @@ func TestRevertOnPrepare(t *testing.T) { }() um7Components = append(um7Components, - &pb.ComponentStatus{ComponentId: "um7C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um7C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um7.setComponents(um7Components) um7.step = prepareStep @@ -1001,9 +1070,19 @@ func TestRevertOnPrepare(t *testing.T) { um7.sendState(pb.UpdateState_PREPARED) um8Components = append(um8Components, - &pb.ComponentStatus{ComponentId: "um8C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um8C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um8Components = append(um8Components, - &pb.ComponentStatus{ComponentId: "um8C2", Version: "2.0.0", State: pb.ComponentState_ERROR}) + &pb.ComponentStatus{ + ComponentId: "um8C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_ERROR, + }) um8.setComponents(um8Components) um8.step = prepareStep @@ -1027,11 +1106,11 @@ func TestRevertOnPrepare(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um7C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um7C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um8C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um8C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um8C2", Version: "2.0.0", Status: "error"}, + {ComponentID: "um7C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um7C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um8C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um8C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um8C2", ComponentType: "type-1", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1073,16 +1152,16 @@ func TestRevertOnUpdate(t *testing.T) { } um9Components := []*pb.ComponentStatus{ - {ComponentId: "um9C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um9C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um9C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um9C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um9 := newTestUM(t, "testUM9", pb.UpdateState_IDLE, "init", um9Components) go um9.processMessages() um10Components := []*pb.ComponentStatus{ - {ComponentId: "um10C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um10C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um10 := newTestUM(t, "testUM10", pb.UpdateState_IDLE, "init", um10Components) @@ -1097,17 +1176,23 @@ func TestRevertOnUpdate(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um9C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um9C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um10C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um10C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um10C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um10C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -1124,7 +1209,12 @@ func TestRevertOnUpdate(t *testing.T) { }() um9Components = append(um9Components, - &pb.ComponentStatus{ComponentId: "um9C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um9C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um9.setComponents(um9Components) um9.step = prepareStep @@ -1133,9 +1223,19 @@ func TestRevertOnUpdate(t *testing.T) { um9.sendState(pb.UpdateState_PREPARED) um10Components = append(um10Components, - &pb.ComponentStatus{ComponentId: "um10C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um10C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um10Components = append(um10Components, - &pb.ComponentStatus{ComponentId: "um10C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um10C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um10.setComponents(um10Components) um10.step = prepareStep @@ -1149,10 +1249,10 @@ func TestRevertOnUpdate(t *testing.T) { um9.sendState(pb.UpdateState_UPDATED) um10Components = []*pb.ComponentStatus{ - {ComponentId: "um10C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um10C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um10C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}, - {ComponentId: "um10C2", Version: "2.0.0", State: pb.ComponentState_ERROR}, + {ComponentId: "um10C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um10C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}, + {ComponentId: "um10C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_ERROR}, } um10.setComponents(um10Components) @@ -1162,8 +1262,8 @@ func TestRevertOnUpdate(t *testing.T) { um10.sendState(pb.UpdateState_FAILED) um9Components = []*pb.ComponentStatus{ - {ComponentId: "um9C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um9C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um9C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um9C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um9.setComponents(um9Components) @@ -1183,11 +1283,11 @@ func TestRevertOnUpdate(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um9C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um9C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um10C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um10C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um10C2", Version: "2.0.0", Status: "error"}, + {ComponentID: "um9C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um9C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um10C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um10C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um10C2", ComponentType: "type-1", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1229,16 +1329,16 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { } um11Components := []*pb.ComponentStatus{ - {ComponentId: "um11C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um11C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um11C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um11C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um11 := newTestUM(t, "testUM11", pb.UpdateState_IDLE, "init", um11Components) go um11.processMessages() um12Components := []*pb.ComponentStatus{ - {ComponentId: "um12C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um12C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um12 := newTestUM(t, "testUM12", pb.UpdateState_IDLE, "init", um12Components) @@ -1253,17 +1353,23 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um11C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um11C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um12C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um12C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um12C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um12C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -1280,7 +1386,12 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { }() um11Components = append(um11Components, - &pb.ComponentStatus{ComponentId: "um11C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um11C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um11.setComponents(um11Components) um11.step = prepareStep @@ -1289,9 +1400,19 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um11.sendState(pb.UpdateState_PREPARED) um12Components = append(um12Components, - &pb.ComponentStatus{ComponentId: "um12C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um12C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um12Components = append(um12Components, - &pb.ComponentStatus{ComponentId: "um12C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um12C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um12.setComponents(um12Components) um12.step = prepareStep @@ -1305,9 +1426,9 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { um11.sendState(pb.UpdateState_UPDATED) um12Components = []*pb.ComponentStatus{ - {ComponentId: "um12C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um12C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um12C2", Version: "2.0.0", State: pb.ComponentState_ERROR}, + {ComponentId: "um12C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um12C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_ERROR}, } um12.setComponents(um12Components) @@ -1323,8 +1444,8 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { go um12.processMessages() um11Components = []*pb.ComponentStatus{ - {ComponentId: "um11C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um11C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um11C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um11C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um11.setComponents(um11Components) @@ -1344,11 +1465,11 @@ func TestRevertOnUpdateWithDisconnect(t *testing.T) { <-finishChannel etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um11C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um11C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um12C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um12C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um12C2", Version: "2.0.0", Status: "error"}, + {ComponentID: "um11C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um11C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um12C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um12C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um12C2", ComponentType: "type-1", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1391,16 +1512,16 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { } um13Components := []*pb.ComponentStatus{ - {ComponentId: "um13C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um13C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um13C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um13C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um13 := newTestUM(t, "testUM13", pb.UpdateState_IDLE, "init", um13Components) go um13.processMessages() um14Components := []*pb.ComponentStatus{ - {ComponentId: "um14C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um14C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um14 := newTestUM(t, "testUM14", pb.UpdateState_IDLE, "init", um14Components) @@ -1415,17 +1536,23 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { updateComponents := []cloudprotocol.ComponentInfo{ { - ComponentID: convertToComponentID("um13C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um13C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile1"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um14C1"), Version: "2.0.0", + ComponentID: convertToComponentID("um14C1"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile2"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, { - ComponentID: convertToComponentID("um14C2"), Version: "2.0.0", + ComponentID: convertToComponentID("um14C2"), + ComponentType: "type-1", + Version: "2.0.0", DownloadInfo: prepareDownloadInfo(path.Join(componentDir, "someFile3"), kilobyte*2), DecryptionInfo: prepareDecryptionInfo(), }, @@ -1442,7 +1569,12 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { }() um13Components = append(um13Components, - &pb.ComponentStatus{ComponentId: "um13C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um13C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um13.setComponents(um13Components) um13.step = prepareStep @@ -1451,9 +1583,19 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um13.sendState(pb.UpdateState_PREPARED) um14Components = append(um14Components, - &pb.ComponentStatus{ComponentId: "um14C1", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um14C1", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um14Components = append(um14Components, - &pb.ComponentStatus{ComponentId: "um14C2", Version: "2.0.0", State: pb.ComponentState_INSTALLING}) + &pb.ComponentStatus{ + ComponentId: "um14C2", + ComponentType: "type-1", + Version: "2.0.0", + State: pb.ComponentState_INSTALLING, + }) um14.setComponents(um14Components) um14.step = prepareStep @@ -1467,9 +1609,9 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { um13.sendState(pb.UpdateState_UPDATED) um14Components = []*pb.ComponentStatus{ - {ComponentId: "um14C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um14C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um14C2", Version: "2.0.0", State: pb.ComponentState_ERROR}, + {ComponentId: "um14C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um14C2", ComponentType: "type-1", Version: "2.0.0", State: pb.ComponentState_ERROR}, } um14.setComponents(um14Components) @@ -1503,8 +1645,8 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { go um14.processMessages() um13Components = []*pb.ComponentStatus{ - {ComponentId: "um13C1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, - {ComponentId: "um13C2", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um13C1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, + {ComponentId: "um13C2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, } um13.setComponents(um13Components) @@ -1524,11 +1666,11 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { time.Sleep(time.Second) etalonComponents := []cloudprotocol.ComponentStatus{ - {ComponentID: "um13C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um13C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um14C1", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um14C2", Version: "1.0.0", Status: "installed"}, - {ComponentID: "um14C2", Version: "2.0.0", Status: "error"}, + {ComponentID: "um13C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um13C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um14C1", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um14C2", ComponentType: "type-1", Version: "1.0.0", Status: "installed"}, + {ComponentID: "um14C2", ComponentType: "type-1", Version: "2.0.0", Status: "error"}, } currentComponents, err := umCtrl.GetStatus() @@ -1537,9 +1679,12 @@ func TestRevertOnUpdateWithReboot(t *testing.T) { } if !reflect.DeepEqual(etalonComponents, currentComponents) { - log.Debug(currentComponents) + log.WithFields(log.Fields{ + "etalon": etalonComponents, + "current": currentComponents, + }).Error("incorrect result component list") + t.Error("incorrect result component list") - log.Debug(etalonComponents) } um13.closeConnection() diff --git a/umcontroller/umctrlserver.go b/umcontroller/umctrlserver.go index a5178cc3..9da731e2 100644 --- a/umcontroller/umctrlserver.go +++ b/umcontroller/umctrlserver.go @@ -165,10 +165,11 @@ func getUmStatusFromUmMessage(msg *pb.UpdateStatus) (status umStatus) { } status.componsStatus = append(status.componsStatus, systemComponentStatus{ - id: component.GetComponentId(), - version: component.GetVersion(), - status: strings.ToLower(component.GetState().String()), - err: component.GetError().GetMessage(), + componentID: component.GetComponentId(), + componentType: component.GetComponentType(), + version: component.GetVersion(), + status: strings.ToLower(component.GetState().String()), + err: component.GetError().GetMessage(), }) } diff --git a/umcontroller/umhandler.go b/umcontroller/umhandler.go index 0e1faf76..03241880 100644 --- a/umcontroller/umhandler.go +++ b/umcontroller/umhandler.go @@ -240,12 +240,13 @@ func (handler *umHandler) sendPrepareUpdateRequest(ctx context.Context, e *fsm.E for _, value := range request.components { componetInfo := pb.PrepareComponentInfo{ - ComponentId: value.ID, - Version: value.Version, - Annotations: value.Annotations, - Url: value.URL, - Sha256: value.Sha256, - Size: value.Size, + ComponentId: value.ComponentID, + ComponentType: value.ComponentType, + Version: value.Version, + Annotations: value.Annotations, + Url: value.URL, + Sha256: value.Sha256, + Size: value.Size, } componetForUpdate = append(componetForUpdate, &componetInfo) From 9cf5b6ef323c8f474c5eb3b161bc39d91676ea2a Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Fri, 12 Jul 2024 14:36:59 +0300 Subject: [PATCH 052/146] [smcontroller] Send quota alert with rise status only In new design quota alert was extended status message to perform rebalancing if quota doesn't go back under threshold. But we should send only "raise" status to the cloud. Signed-off-by: Oleksandr Grytsov --- smcontroller/smcontroller.go | 2 +- smcontroller/smcontroller_test.go | 29 +++++++++++++++++++---------- smcontroller/smhandler.go | 17 ++++++++++++++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 0eceab62..553f13b3 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -313,7 +313,7 @@ func (controller *Controller) GetRunInstancesStatusChannel() <-chan launcher.Nod return controller.runInstancesStatusChan } -// GetSystemLimitAlertChannel returns channel with alerts about RAM CLU system limits. +// GetSystemLimitAlertChannel returns channel with alerts about RAM, CPU system limits. func (controller *Controller) GetSystemLimitAlertChannel() <-chan cloudprotocol.SystemQuotaAlert { return controller.systemLimitAlertChan } diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 8c23c853..3eba98de 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -28,6 +28,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" + "github.com/aosedge/aos_common/resourcemonitor" "github.com/aosedge/aos_common/utils/pbconvert" pbcommon "github.com/aosedge/aos_common/api/common" @@ -413,25 +414,33 @@ func TestSMAlertNotifications(t *testing.T) { }, { expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagSystemQuota, - Payload: cloudprotocol.SystemQuotaAlert{Parameter: "cpu", Value: 42, NodeID: nodeID}, + Tag: cloudprotocol.AlertTagSystemQuota, + Payload: cloudprotocol.SystemQuotaAlert{ + Parameter: "cpu", Value: 42, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, + }, }, sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemQuota, Payload: &pbsm.Alert_SystemQuotaAlert{ - SystemQuotaAlert: &pbsm.SystemQuotaAlert{Parameter: "cpu", Value: 42}, + SystemQuotaAlert: &pbsm.SystemQuotaAlert{ + Parameter: "cpu", Value: 42, Status: resourcemonitor.AlertStatusRaise, + }, }, }, }, { expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagSystemQuota, - Payload: cloudprotocol.SystemQuotaAlert{Parameter: "ram", Value: 99, NodeID: nodeID}, + Tag: cloudprotocol.AlertTagSystemQuota, + Payload: cloudprotocol.SystemQuotaAlert{ + Parameter: "ram", Value: 99, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, + }, }, sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemQuota, Payload: &pbsm.Alert_SystemQuotaAlert{ - SystemQuotaAlert: &pbsm.SystemQuotaAlert{Parameter: "ram", Value: 99}, + SystemQuotaAlert: &pbsm.SystemQuotaAlert{ + Parameter: "ram", Value: 99, Status: resourcemonitor.AlertStatusRaise, + }, }, }, }, @@ -440,7 +449,7 @@ func TestSMAlertNotifications(t *testing.T) { Tag: cloudprotocol.AlertTagInstanceQuota, Payload: cloudprotocol.InstanceQuotaAlert{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, - Parameter: "param1", Value: 42, + Parameter: "param1", Value: 42, Status: resourcemonitor.AlertStatusRaise, }, }, sendAlert: &pbsm.Alert{ @@ -448,7 +457,7 @@ func TestSMAlertNotifications(t *testing.T) { Payload: &pbsm.Alert_InstanceQuotaAlert{ InstanceQuotaAlert: &pbsm.InstanceQuotaAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, - Parameter: "param1", Value: 42, + Parameter: "param1", Value: 42, Status: resourcemonitor.AlertStatusRaise, }, }, }, @@ -488,8 +497,8 @@ func TestSMAlertNotifications(t *testing.T) { } expectedSystemLimitAlert := []cloudprotocol.SystemQuotaAlert{ - {Parameter: "cpu", Value: 42, NodeID: nodeID}, - {Parameter: "ram", Value: 99, NodeID: nodeID}, + {Parameter: "cpu", Value: 42, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise}, + {Parameter: "ram", Value: 99, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise}, } for _, limitAlert := range expectedSystemLimitAlert { diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index bf1101e0..1f495272 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -28,6 +28,7 @@ import ( "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_common/api/common" pb "github.com/aosedge/aos_common/api/servicemanager" + "github.com/aosedge/aos_common/resourcemonitor" "github.com/aosedge/aos_common/utils/pbconvert" "github.com/aosedge/aos_common/utils/syncstream" log "github.com/sirupsen/logrus" @@ -484,21 +485,31 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { Parameter: data.SystemQuotaAlert.GetParameter(), Value: data.SystemQuotaAlert.GetValue(), NodeID: handler.nodeConfigStatus.NodeID, + Status: data.SystemQuotaAlert.GetStatus(), } - if alertPayload.Parameter == "cpu" || alertPayload.Parameter == "ram" { - handler.systemLimitAlertCh <- alertPayload + handler.systemLimitAlertCh <- alertPayload + + if alertPayload.Status != resourcemonitor.AlertStatusRaise { + return } alertItem.Payload = alertPayload case *pb.Alert_InstanceQuotaAlert: - alertItem.Payload = cloudprotocol.InstanceQuotaAlert{ + alertPayload := cloudprotocol.InstanceQuotaAlert{ InstanceIdent: pbconvert.InstanceIdentFromPB(data.InstanceQuotaAlert.GetInstance()), Parameter: data.InstanceQuotaAlert.GetParameter(), Value: data.InstanceQuotaAlert.GetValue(), + Status: data.InstanceQuotaAlert.GetStatus(), + } + + if alertPayload.Status != resourcemonitor.AlertStatusRaise { + return } + alertItem.Payload = alertPayload + case *pb.Alert_InstanceAlert: alertItem.Payload = cloudprotocol.ServiceInstanceAlert{ InstanceIdent: pbconvert.InstanceIdentFromPB(data.InstanceAlert.GetInstance()), From 707c44ee907afe0b99468266441ef7eb21752559 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Fri, 12 Jul 2024 14:43:33 +0300 Subject: [PATCH 053/146] [unitstatushandler] Use node info provider to gen node info unitstatushandler should use iamclient to retrieve node info. Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 40 +++++++++++++++++-- .../unitstatushandler_internal_test.go | 22 ++++++++-- unitstatushandler/unitstatushandler_test.go | 30 +++++++------- 3 files changed, 70 insertions(+), 22 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index bb5c8092..0b523c4c 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -39,6 +39,12 @@ import ( * Types **********************************************************************************************************************/ +// NodeInfoProvider provides node info. +type NodeInfoProvider interface { + GetAllNodeIDs() ([]string, error) + GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) +} + // Downloader downloads packages. type Downloader interface { Download(ctx context.Context, packageInfo downloader.PackageInfo) (result downloader.Result, err error) @@ -70,7 +76,6 @@ type FirmwareUpdater interface { type InstanceRunner interface { RunInstances(instances []cloudprotocol.InstanceInfo, newServices []string) error RestartInstances() error - GetNodesConfiguration() []cloudprotocol.NodeInfo } // SoftwareUpdater updates services, layers. @@ -118,7 +123,8 @@ type RunInstancesStatus struct { type Instance struct { sync.Mutex - statusSender StatusSender + nodeInfoProvider NodeInfoProvider + statusSender StatusSender statusMutex sync.Mutex @@ -155,6 +161,7 @@ type itemStatus []statusDescriptor // New creates new unit status handler instance. func New( cfg *config.Config, + nodeInfoProvider NodeInfoProvider, unitConfigUpdater UnitConfigUpdater, firmwareUpdater FirmwareUpdater, softwareUpdater SoftwareUpdater, @@ -166,6 +173,7 @@ func New( log.Debug("Create unit status handler") instance = &Instance{ + nodeInfoProvider: nodeInfoProvider, statusSender: statusSender, sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, } @@ -645,13 +653,18 @@ func (instance *Instance) sendCurrentStatus() { return } + nodesInfo, err := instance.getAllNodesInfo() + if err != nil { + log.Errorf("Can't get nodes info: %v", err) + } + unitStatus := cloudprotocol.UnitStatus{ UnitSubjects: instance.unitStatus.subjects, Components: make([]cloudprotocol.ComponentStatus, 0, len(instance.unitStatus.components)), Layers: make([]cloudprotocol.LayerStatus, 0, len(instance.unitStatus.layers)), Services: make([]cloudprotocol.ServiceStatus, 0, len(instance.unitStatus.services)), Instances: instance.unitStatus.instances, - Nodes: instance.softwareManager.instanceRunner.GetNodesConfiguration(), + Nodes: nodesInfo, } for _, status := range instance.unitStatus.unitConfig { @@ -705,3 +718,24 @@ func (instance *Instance) sendCurrentStatus() { log.Errorf("Can't send unit status: %s", err) } } + +func (instance *Instance) getAllNodesInfo() ([]cloudprotocol.NodeInfo, error) { + nodeIDs, err := instance.nodeInfoProvider.GetAllNodeIDs() + if err != nil { + return nil, aoserrors.Wrap(err) + } + + nodesInfo := make([]cloudprotocol.NodeInfo, 0, len(nodeIDs)) + + for _, nodeID := range nodeIDs { + nodeInfo, err := instance.nodeInfoProvider.GetNodeInfo(nodeID) + if err != nil { + log.WithField("nodeID", nodeID).Errorf("Can't get node info: %s", err) + continue + } + + nodesInfo = append(nodesInfo, nodeInfo) + } + + return nodesInfo, nil +} diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index db7e7e9b..fbc3290c 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -53,6 +53,8 @@ const waitStatusTimeout = 5 * time.Second * Types **********************************************************************************************************************/ +type TestNodeInfoProvider struct{} + type TestSender struct { Consumer amqphandler.ConnectionEventsConsumer statusChannel chan cloudprotocol.UnitStatus @@ -1569,6 +1571,22 @@ func TestSyncExecutor(t *testing.T) { * Interfaces **********************************************************************************************************************/ +/*********************************************************************************************************************** + * TestNodeInfoProvider + **********************************************************************************************************************/ + +func NewTestNodeInfoProvider() *TestNodeInfoProvider { + return &TestNodeInfoProvider{} +} + +func (provider *TestNodeInfoProvider) GetAllNodeIDs() ([]string, error) { + return []string{}, nil +} + +func (provider *TestNodeInfoProvider) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) { + return cloudprotocol.NodeInfo{}, nil +} + /*********************************************************************************************************************** * TestSender **********************************************************************************************************************/ @@ -1712,10 +1730,6 @@ func (runner *TestInstanceRunner) WaitForRunInstance(timeout time.Duration) ([]c } } -func (runner *TestInstanceRunner) GetNodesConfiguration() (nodes []cloudprotocol.NodeInfo) { - return nodes -} - /*********************************************************************************************************************** * TestDownloader **********************************************************************************************************************/ diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 44462319..e225fa1c 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -110,8 +110,8 @@ func TestSendInitialStatus(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, + unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -158,8 +158,8 @@ func TestUpdateUnitConfig(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, + unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -252,7 +252,7 @@ func TestUpdateComponents(t *testing.T) { instanceRunner := unitstatushandler.NewTestInstanceRunner() sender := unitstatushandler.NewTestSender() - statusHandler, err := unitstatushandler.New(cfg, + statusHandler, err := unitstatushandler.New(cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { @@ -359,8 +359,8 @@ func TestUpdateLayers(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -516,8 +516,8 @@ func TestUpdateServices(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -663,8 +663,8 @@ func TestRunInstances(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) } @@ -786,8 +786,8 @@ func TestUpdateInstancesStatus(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) } @@ -903,8 +903,8 @@ func TestUpdateCachedSOTA(t *testing.T) { downloader := unitstatushandler.NewTestDownloader() statusHandler, err := unitstatushandler.New( - cfg, unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, downloader, - unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, downloader, unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } From dc37564155b09cdd216540c48e08d7004ee14d03 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Fri, 12 Jul 2024 14:46:58 +0300 Subject: [PATCH 054/146] [launcher] Update to new cloud and protobuf protocols Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 141 +++++++++--------- launcher/launcher_test.go | 301 ++++++++++++++++++++------------------ 2 files changed, 231 insertions(+), 211 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 1a0247c1..60b408ca 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -45,10 +45,8 @@ import ( var ErrNotExist = errors.New("entry not exist") -const defaultRunner = "crun" - //nolint:gochecknoglobals -var defaultRunnerFeatures = []string{"crun", "runc"} +var defaultRunners = []string{"crun", "runc"} /*********************************************************************************************************************** * Types @@ -61,19 +59,13 @@ type NodeRunInstanceStatus struct { Instances []cloudprotocol.InstanceStatus } -// NodeConfiguration node static configuration. -type NodeInfo struct { - cloudprotocol.NodeInfo - RemoteNode bool - RunnerFeature []string -} - // Launcher service instances launcher. type Launcher struct { sync.Mutex config *config.Config storage Storage + nodeInfoProvider NodeInfoProvider nodeManager NodeManager imageProvider ImageProvider resourceManager ResourceManager @@ -134,19 +126,24 @@ type ImageProvider interface { // NodeManager nodes controller. type NodeManager interface { - GetNodeConfiguration(nodeID string) (NodeInfo, error) RunInstances( nodeID string, services []aostypes.ServiceInfo, layers []aostypes.LayerInfo, instances []aostypes.InstanceInfo, forceRestart bool, ) error GetRunInstancesStatusChannel() <-chan NodeRunInstanceStatus GetSystemLimitAlertChannel() <-chan cloudprotocol.SystemQuotaAlert - GetNodeMonitoringData(nodeID string) (data cloudprotocol.NodeMonitoringData, err error) + GetAverageMonitoring(nodeID string) (aostypes.NodeMonitoring, error) +} + +// NodeInfoProvider node information. +type NodeInfoProvider interface { + GetNodeID() string + GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) } // ResourceManager provides node resources. type ResourceManager interface { - GetUnitConfiguration(nodeType string) cloudprotocol.NodeConfig + GetNodeConfig(nodeID, nodeType string) cloudprotocol.NodeConfig } // StorageStateProvider instances storage state provider. @@ -158,7 +155,7 @@ type StorageStateProvider interface { } type nodeStatus struct { - NodeInfo + nodeInfo cloudprotocol.NodeInfo availableResources []string availableLabels []string availableDevices []nodeDevice @@ -186,14 +183,15 @@ type runRequestInfo struct { // New creates launcher instance. func New( - config *config.Config, storage Storage, nodeManager NodeManager, imageProvider ImageProvider, - resourceManager ResourceManager, storageStateProvider StorageStateProvider, networkManager NetworkManager, + config *config.Config, storage Storage, nodeInfoProvider NodeInfoProvider, nodeManager NodeManager, + imageProvider ImageProvider, resourceManager ResourceManager, storageStateProvider StorageStateProvider, + networkManager NetworkManager, ) (launcher *Launcher, err error) { log.Debug("Create launcher") launcher = &Launcher{ - config: config, storage: storage, nodeManager: nodeManager, imageProvider: imageProvider, - resourceManager: resourceManager, storageStateProvider: storageStateProvider, + config: config, storage: storage, nodeManager: nodeManager, nodeInfoProvider: nodeInfoProvider, + imageProvider: imageProvider, resourceManager: resourceManager, storageStateProvider: storageStateProvider, networkManager: networkManager, runStatusChannel: make(chan unitstatushandler.RunInstancesStatus, 10), nodes: []*nodeStatus{}, @@ -276,7 +274,7 @@ func (launcher *Launcher) RestartInstances() error { launcher.config.SMController.NodesConnectionTimeout.Duration, launcher.sendCurrentStatus) for _, node := range launcher.nodes { - launcher.initNodeUnitConfiguration(node, node.NodeType) + launcher.initNodeConfig(node) } launcher.currentErrorStatus = launcher.performNodeBalancing(launcher.currentDesiredInstances) @@ -289,20 +287,6 @@ func (launcher *Launcher) GetRunStatusesChannel() <-chan unitstatushandler.RunIn return launcher.runStatusChannel } -// GetNodesConfiguration gets nodes configuration. -func (launcher *Launcher) GetNodesConfiguration() []cloudprotocol.NodeInfo { - nodes := make([]cloudprotocol.NodeInfo, len(launcher.nodes)) - - i := 0 - - for _, v := range launcher.nodes { - nodes[i] = v.NodeInfo.NodeInfo - i++ - } - - return nodes -} - /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -327,13 +311,13 @@ func (launcher *Launcher) sendRunInstances(forceRestart bool) (err error) { node.waitStatus = true if err := launcher.saveNodeRunRequest(node); err != nil { - log.WithFields(log.Fields{"nodeID": node.NodeID}).Errorf("Can't save node run request: %v", err) + log.WithFields(log.Fields{"nodeID": node.nodeInfo.NodeID}).Errorf("Can't save node run request: %v", err) } if runErr := launcher.nodeManager.RunInstances( - node.NodeID, node.currentRunRequest.Services, node.currentRunRequest.Layers, + node.nodeInfo.NodeID, node.currentRunRequest.Services, node.currentRunRequest.Layers, node.currentRunRequest.Instances, forceRestart); runErr != nil { - log.WithField("nodeID", node.NodeID).Errorf("Can't run instances %v", runErr) + log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't run instances %v", runErr) if err == nil { err = runErr @@ -360,7 +344,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat var err error - currentStatus, err = launcher.initNodeStatus(runStatus.NodeID, runStatus.NodeType) + currentStatus, err = launcher.initNodeStatus(runStatus.NodeID) if err != nil { log.Errorf("Can't init node: %v", err) @@ -375,7 +359,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat slices.SortFunc(launcher.nodes, func(a, b *nodeStatus) bool { if a.priority == b.priority { - return a.NodeID < b.NodeID + return a.nodeInfo.NodeID < b.nodeInfo.NodeID } return a.priority > b.priority @@ -504,29 +488,29 @@ func (launcher *Launcher) performRebalancing(alert cloudprotocol.SystemQuotaAler log.Warn("No appropriate condition for rebalancing found") } -func (launcher *Launcher) initNodeStatus(nodeID, nodeType string) (*nodeStatus, error) { +func (launcher *Launcher) initNodeStatus(nodeID string) (*nodeStatus, error) { status := &nodeStatus{currentRunRequest: &runRequestInfo{}} log.WithFields(log.Fields{"nodeID": nodeID}).Debug("Init node status") - config, err := launcher.nodeManager.GetNodeConfiguration(nodeID) + nodeInfo, err := launcher.nodeInfoProvider.GetNodeInfo(nodeID) if err != nil { return nil, aoserrors.Errorf("can't get node configuration fot nodeID %s: %v", nodeID, err) } - status.NodeInfo = config + status.nodeInfo = nodeInfo if err := launcher.loadNodeRunRequest(status); err != nil && !errors.Is(err, ErrNotExist) { log.WithFields(log.Fields{"nodeID": nodeID}).Errorf("Can't load node run request") } - launcher.initNodeUnitConfiguration(status, nodeType) + launcher.initNodeConfig(status) return status, nil } -func (launcher *Launcher) initNodeUnitConfiguration(nodeStatus *nodeStatus, nodeType string) { - nodeUnitConfig := launcher.resourceManager.GetUnitConfiguration(nodeType) +func (launcher *Launcher) initNodeConfig(nodeStatus *nodeStatus) { + nodeUnitConfig := launcher.resourceManager.GetNodeConfig(nodeStatus.nodeInfo.NodeID, nodeStatus.nodeInfo.NodeType) nodeStatus.priority = nodeUnitConfig.Priority nodeStatus.availableLabels = nodeUnitConfig.Labels @@ -577,7 +561,7 @@ func (launcher *Launcher) sendCurrentStatus() { for _, errInstance := range node.currentRunRequest.Instances { runStatusToSend.Instances = append(runStatusToSend.Instances, cloudprotocol.InstanceStatus{ InstanceIdent: errInstance.InstanceIdent, - NodeID: node.NodeID, RunState: cloudprotocol.InstanceStateFailed, + NodeID: node.nodeInfo.NodeID, RunState: cloudprotocol.InstanceStateFailed, ErrorInfo: &cloudprotocol.ErrorInfo{Message: "wait run status timeout"}, }) } @@ -682,7 +666,7 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) } for _, node := range launcher.nodes { - if err := launcher.networkManager.UpdateProviderNetwork(providers, node.NodeID); err != nil { + if err := launcher.networkManager.UpdateProviderNetwork(providers, node.nodeInfo.NodeID); err != nil { return aoserrors.Wrap(err) } } @@ -770,7 +754,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } - node := launcher.getMostPriorityNode(nodeForInstance, serviceInfo) + node := launcher.getMostPriorityNode(nodeForInstance) if err = launcher.allocateDevices(node, serviceInfo.Config.Devices); err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, @@ -968,9 +952,9 @@ func (launcher *Launcher) prepareInstanceStartInfo(service imagemanager.ServiceI func (launcher *Launcher) getNodesByStaticResources(allNodes []*nodeStatus, serviceInfo imagemanager.ServiceInfo, instanceInfo cloudprotocol.InstanceInfo, ) ([]*nodeStatus, error) { - nodes := launcher.getNodeByRunner(allNodes, serviceInfo.Config.Runner) + nodes := launcher.getNodeByRunners(allNodes, serviceInfo.Config.Runners) if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with runner: %s", serviceInfo.Config.Runner) + return nodes, aoserrors.Errorf("no node with runner: %s", serviceInfo.Config.Runners) } nodes = launcher.getNodesByLabels(nodes, instanceInfo.Labels) @@ -1024,15 +1008,15 @@ func (launcher *Launcher) getNodeByMonitoringData(nodes []*nodeStatus, alertType nodesResources := []freeNodeResources{} for _, node := range nodes { - monitoringData, err := launcher.nodeManager.GetNodeMonitoringData(node.NodeID) + monitoringData, err := launcher.nodeManager.GetAverageMonitoring(node.nodeInfo.NodeID) if err != nil { log.Errorf("Can't get node monitoring data: %v", err) } nodesResources = append(nodesResources, freeNodeResources{ node: node, - freeRAM: node.TotalRAM - monitoringData.RAM, - freeCPU: uint64(len(node.CPUs)*100) - monitoringData.CPU, + freeRAM: node.nodeInfo.TotalRAM - monitoringData.NodeData.RAM, + freeCPU: uint64(len(node.nodeInfo.CPUs)*100) - monitoringData.NodeData.CPU, }) } @@ -1168,22 +1152,31 @@ nodeLoop: return newNodes } -func (launcher *Launcher) getNodeByRunner(allNodes []*nodeStatus, runner string) (nodes []*nodeStatus) { - if runner == "" { - runner = defaultRunner +func (launcher *Launcher) getNodeByRunners(allNodes []*nodeStatus, runners []string) (nodes []*nodeStatus) { + if len(runners) == 0 { + runners = defaultRunners } - for _, node := range allNodes { - if (len(node.RunnerFeature) == 0 && slices.Contains(defaultRunnerFeatures, runner)) || - slices.Contains(node.RunnerFeature, runner) { - nodes = append(nodes, node) + for _, runner := range runners { + for _, node := range allNodes { + nodeRunners, err := node.nodeInfo.GetNodeRunners() + if err != nil { + log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't get node runners: %v", err) + + continue + } + + if (len(nodeRunners) == 0 && slices.Contains(defaultRunners, runner)) || + slices.Contains(nodeRunners, runner) { + nodes = append(nodes, node) + } } } return nodes } -func (launcher *Launcher) getMostPriorityNode(nodes []*nodeStatus, serviceInfo imagemanager.ServiceInfo) *nodeStatus { +func (launcher *Launcher) getMostPriorityNode(nodes []*nodeStatus) *nodeStatus { if len(nodes) == 1 { return nodes[0] } @@ -1203,13 +1196,13 @@ func (launcher *Launcher) addRunRequest(instance aostypes.InstanceInfo, service layers []imagemanager.LayerInfo, node *nodeStatus, ) { log.WithFields(instanceIdentLogFields( - instance.InstanceIdent, log.Fields{"node": node.NodeID})).Debug("Schedule instance on node") + instance.InstanceIdent, log.Fields{"node": node.nodeInfo.NodeID})).Debug("Schedule instance on node") node.currentRunRequest.Instances = append(node.currentRunRequest.Instances, instance) serviceInfo := service.ServiceInfo - if node.RemoteNode { + if node.nodeInfo.NodeID != launcher.nodeInfoProvider.GetNodeID() { serviceInfo.URL = service.RemoteURL } @@ -1223,7 +1216,9 @@ func (launcher *Launcher) addRunRequest(instance aostypes.InstanceInfo, service } if isNewService { - log.WithFields(log.Fields{"serviceID": serviceInfo.ServiceID, "node": node.NodeID}).Debug("Schedule service on node") + log.WithFields(log.Fields{ + "serviceID": serviceInfo.ServiceID, "node": node.nodeInfo.NodeID, + }).Debug("Schedule service on node") node.currentRunRequest.Services = append(node.currentRunRequest.Services, serviceInfo) } @@ -1232,7 +1227,7 @@ layerLoopLabel: for _, layer := range layers { newLayer := layer.LayerInfo - if node.RemoteNode { + if node.nodeInfo.NodeID != launcher.nodeInfoProvider.GetNodeID() { newLayer.URL = layer.RemoteURL } @@ -1242,14 +1237,16 @@ layerLoopLabel: } } - log.WithFields(log.Fields{"digest": newLayer.Digest, "node": node.NodeID}).Debug("Schedule layer on node") + log.WithFields(log.Fields{ + "digest": newLayer.Digest, "node": node.nodeInfo.NodeID, + }).Debug("Schedule layer on node") node.currentRunRequest.Layers = append(node.currentRunRequest.Layers, newLayer) } } func (launcher *Launcher) removeInstanceFromNode(ident aostypes.InstanceIdent, node *nodeStatus) { - log.WithFields(log.Fields{"ident": ident, "node": node.NodeID}).Debug("Remove instance from node") + log.WithFields(log.Fields{"ident": ident, "node": node.nodeInfo.NodeID}).Debug("Remove instance from node") i := 0 @@ -1264,7 +1261,7 @@ func (launcher *Launcher) removeInstanceFromNode(ident aostypes.InstanceIdent, n } func (launcher *Launcher) removeServiceFromNode(serviceID string, node *nodeStatus) { - log.WithFields(log.Fields{"serviceID": serviceID, "node": node.NodeID}).Debug("Remove service from node") + log.WithFields(log.Fields{"serviceID": serviceID, "node": node.nodeInfo.NodeID}).Debug("Remove service from node") i := 0 @@ -1279,7 +1276,7 @@ func (launcher *Launcher) removeServiceFromNode(serviceID string, node *nodeStat } func (launcher *Launcher) removeLayerFromNode(digest string, node *nodeStatus) { - log.WithFields(log.Fields{"digest": digest, "node": node.NodeID}).Debug("Remove layer from node") + log.WithFields(log.Fields{"digest": digest, "node": node.nodeInfo.NodeID}).Debug("Remove layer from node") i := 0 @@ -1359,7 +1356,7 @@ func createInstanceStatusFromInfo( func (launcher *Launcher) getNode(nodeID string) *nodeStatus { for _, node := range launcher.nodes { - if node.NodeID == nodeID { + if node.nodeInfo.NodeID == nodeID { return node } } @@ -1369,7 +1366,7 @@ func (launcher *Launcher) getNode(nodeID string) *nodeStatus { func (launcher *Launcher) getLowerPriorityNodes(node *nodeStatus) (nodes []*nodeStatus) { for _, currentNode := range launcher.nodes { - if currentNode.priority > node.priority || currentNode.NodeID == node.NodeID { + if currentNode.priority > node.priority || currentNode.nodeInfo.NodeID == node.nodeInfo.NodeID { continue } @@ -1405,7 +1402,7 @@ func (launcher *Launcher) getLayersForService(digests []string) ([]imagemanager. } func (launcher *Launcher) loadNodeRunRequest(node *nodeStatus) error { - currentRunRequestJSON, err := launcher.storage.GetNodeState(node.NodeID) + currentRunRequestJSON, err := launcher.storage.GetNodeState(node.nodeInfo.NodeID) if err != nil { return aoserrors.Wrap(err) } @@ -1423,7 +1420,7 @@ func (launcher *Launcher) saveNodeRunRequest(node *nodeStatus) error { return aoserrors.Wrap(err) } - if err := launcher.storage.SetNodeState(node.NodeID, runRequestJSON); err != nil { + if err := launcher.storage.SetNodeState(node.nodeInfo.NodeID, runRequestJSON); err != nil { log.Errorf("Can't store desired instances: %v", err) } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 30e52371..7e2383c7 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -92,11 +92,15 @@ type runRequest struct { forceRestart bool } +type testNodeInfoProvider struct { + nodeID string + nodeInfo map[string]cloudprotocol.NodeInfo +} + type testNodeManager struct { - runStatusChan chan launcher.NodeRunInstanceStatus - alertsChannel chan cloudprotocol.SystemQuotaAlert - nodeInformation map[string]launcher.NodeInfo - runRequest map[string]runRequest + runStatusChan chan launcher.NodeRunInstanceStatus + alertsChannel chan cloudprotocol.SystemQuotaAlert + runRequest map[string]runRequest } type testImageProvider struct { @@ -150,13 +154,14 @@ func TestInstancesWithRemovedServiceInfoAreRemovedOnStart(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{"localSM", "remoteSM"}, + NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } - nodeManager = newTestNodeManager() - imageManager = &testImageProvider{} - testStorage = newTestStorage() + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + imageManager = &testImageProvider{} + testStorage = newTestStorage() ) err := testStorage.AddInstance(launcher.InstanceInfo{ @@ -166,8 +171,8 @@ func TestInstancesWithRemovedServiceInfoAreRemovedOnStart(t *testing.T) { t.Fatalf("Can't add instance %v", err) } - launcherInstance, err := launcher.New(cfg, testStorage, nodeManager, imageManager, &testResourceManager{}, - &testStateStorage{}, newTestNetworkManager("")) + launcherInstance, err := launcher.New(cfg, testStorage, nodeInfoProvider, nodeManager, imageManager, + &testResourceManager{}, &testStateStorage{}, newTestNetworkManager("")) if err != nil { t.Fatalf("Can't create launcher %v", err) } @@ -187,11 +192,12 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{"localSM", "remoteSM"}, + NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, ServiceTTLDays: 1, } + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() imageManager = &testImageProvider{} testStorage = newTestStorage() @@ -223,8 +229,8 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { testStorage.services[service2] = make([]imagemanager.ServiceInfo, 1) testStorage.services[service2][0].ServiceInfo.ServiceID = service2 - launcherInstance, err := launcher.New(cfg, testStorage, nodeManager, imageManager, &testResourceManager{}, - testStateStorage, newTestNetworkManager("")) + launcherInstance, err := launcher.New(cfg, testStorage, nodeInfoProvider, nodeManager, imageManager, + &testResourceManager{}, testStateStorage, newTestNetworkManager("")) if err != nil { t.Fatalf("Can't create launcher %v", err) } @@ -256,11 +262,12 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{"localSM", "remoteSM"}, + NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, ServiceTTLDays: 1, } + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() testImageManager = newTestImageProvider() testStorage = newTestStorage() @@ -279,8 +286,8 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { testStorage.services[service1] = make([]imagemanager.ServiceInfo, 1) testStorage.services[service1][0].ServiceInfo.ServiceID = service1 - launcherInstance, err := launcher.New(cfg, testStorage, nodeManager, testImageManager, &testResourceManager{}, - testStateStorage, newTestNetworkManager("")) + launcherInstance, err := launcher.New(cfg, testStorage, nodeInfoProvider, nodeManager, testImageManager, + &testResourceManager{}, testStateStorage, newTestNetworkManager("")) if err != nil { t.Fatalf("Can't create launcher %v", err) } @@ -332,18 +339,18 @@ func TestInitialStatus(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{"localSM", "remoteSM"}, + NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() expectedRunStatus = unitstatushandler.RunInstancesStatus{} - expectedNodeInfo = []cloudprotocol.NodeInfo{} imageManager = &testImageProvider{} ) - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeManager, imageManager, &testResourceManager{}, - &testStateStorage{}, newTestNetworkManager("")) + launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + &testResourceManager{}, &testStateStorage{}, newTestNetworkManager("")) if err != nil { t.Fatalf("Can't create launcher %v", err) } @@ -367,9 +374,8 @@ func TestInitialStatus(t *testing.T) { }, } - nodeManager.nodeInformation[id] = launcher.NodeInfo{NodeInfo: nodeInfo} + nodeInfoProvider.nodeInfo[id] = nodeInfo - expectedNodeInfo = append(expectedNodeInfo, nodeInfo) expectedRunStatus.Instances = append(expectedRunStatus.Instances, instances...) nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{NodeID: id, Instances: instances} @@ -379,11 +385,6 @@ func TestInitialStatus(t *testing.T) { launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { t.Errorf("Incorrect run status: %v", err) } - - nodesInfo := launcherInstance.GetNodesConfiguration() - if !reflect.DeepEqual(expectedNodeInfo, nodesInfo) { - t.Error("Incorrect nodes info") - } } func TestBalancing(t *testing.T) { @@ -394,27 +395,28 @@ func TestBalancing(t *testing.T) { NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + resourceManager = newTestResourceManager() + imageManager = &testImageProvider{} ) - nodeManager.nodeInformation = map[string]launcher.NodeInfo{ + nodeInfoProvider.nodeInfo = map[string]cloudprotocol.NodeInfo{ nodeIDLocalSM: { - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, - RemoteNode: false, RunnerFeature: []string{runnerRunc}, + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, }, nodeIDRemoteSM1: { - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM}, - RemoteNode: true, RunnerFeature: []string{runnerRunc}, + NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, }, nodeIDRemoteSM2: { - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM}, - RemoteNode: true, RunnerFeature: []string{runnerRunc}, + NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, }, nodeIDRunxSM: { - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM}, - RemoteNode: true, RunnerFeature: []string{runnerRunx}, + NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, }, } @@ -464,9 +466,9 @@ func TestBalancing(t *testing.T) { nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, }, serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runner: runnerRunc}, - service2: {Runner: runnerRunc}, - service3: {Runner: runnerRunx}, + service1: {Runners: []string{runnerRunc}}, + service2: {Runners: []string{runnerRunc}}, + service3: {Runners: []string{runnerRunx}}, }, desiredInstances: []cloudprotocol.InstanceInfo{ {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, @@ -552,9 +554,9 @@ func TestBalancing(t *testing.T) { nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, }, serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runner: runnerRunc}, - service2: {Runner: runnerRunc}, - service3: {Runner: runnerRunx}, + service1: {Runners: []string{runnerRunc}}, + service2: {Runners: []string{runnerRunc}}, + service3: {Runners: []string{runnerRunx}}, }, desiredInstances: []cloudprotocol.InstanceInfo{ {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2, Labels: []string{"label2"}}, @@ -640,9 +642,9 @@ func TestBalancing(t *testing.T) { nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, }, serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runner: runnerRunc, Resources: []string{"resource1", "resource2"}}, - service2: {Runner: runnerRunc, Resources: []string{"resource1"}}, - service3: {Runner: runnerRunc, Resources: []string{"resource3"}}, + service1: {Runners: []string{runnerRunc}, Resources: []string{"resource1", "resource2"}}, + service2: {Runners: []string{runnerRunc}, Resources: []string{"resource1"}}, + service3: {Runners: []string{runnerRunc}, Resources: []string{"resource3"}}, }, desiredInstances: []cloudprotocol.InstanceInfo{ {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, @@ -729,9 +731,18 @@ func TestBalancing(t *testing.T) { }}, }, serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runner: runnerRunc, Devices: []aostypes.ServiceDevice{{Name: "dev1"}, {Name: "dev2"}}}, - service2: {Runner: runnerRunc, Devices: []aostypes.ServiceDevice{{Name: "dev2"}}}, - service3: {Runner: runnerRunc, Devices: []aostypes.ServiceDevice{{Name: "dev3"}}}, + service1: { + Runners: []string{runnerRunc}, + Devices: []aostypes.ServiceDevice{{Name: "dev1"}, {Name: "dev2"}}, + }, + service2: { + Runners: []string{runnerRunc}, + Devices: []aostypes.ServiceDevice{{Name: "dev2"}}, + }, + service3: { + Runners: []string{runnerRunc}, + Devices: []aostypes.ServiceDevice{{Name: "dev3"}}, + }, }, desiredInstances: []cloudprotocol.InstanceInfo{ {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 4}, @@ -839,15 +850,15 @@ func TestBalancing(t *testing.T) { imageManager.services[serviceID] = service } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeManager, imageManager, resourceManager, - &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) + launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } // Wait initial run status - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -885,17 +896,16 @@ func TestServiceRevert(t *testing.T) { NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } - nodeManager = newTestNodeManager() - imageManager = &testImageProvider{} - resourceManager = newTestResourceManager() + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + imageManager = &testImageProvider{} + resourceManager = newTestResourceManager() ) - nodeManager.nodeInformation[nodeIDLocalSM] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, - RemoteNode: false, + nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } - resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{NodeType: nodeTypeLocalSM, Priority: 100} - imageManager.services = map[string]imagemanager.ServiceInfo{ service1: { ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), @@ -916,15 +926,15 @@ func TestServiceRevert(t *testing.T) { }, } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeManager, imageManager, resourceManager, - &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) + launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } // Wait initial run status - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -984,48 +994,48 @@ func TestStorageCleanup(t *testing.T) { NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() resourceManager = newTestResourceManager() imageManager = &testImageProvider{} stateStorageProvider = &testStateStorage{} ) - nodeManager.nodeInformation[nodeIDLocalSM] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, - RemoteNode: false, - RunnerFeature: []string{runnerRunc}, + nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{Priority: 100} - nodeManager.nodeInformation[nodeIDRunxSM] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeRunxSM}, - RemoteNode: true, RunnerFeature: []string{runnerRunx}, + nodeInfoProvider.nodeInfo[nodeIDRunxSM] = cloudprotocol.NodeInfo{ + NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, } resourceManager.nodeResources[nodeTypeRunxSM] = cloudprotocol.NodeConfig{Priority: 0} imageManager.services = map[string]imagemanager.ServiceInfo{ service1: { ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), - RemoteURL: service1RemoteURL, Config: aostypes.ServiceConfig{Runner: runnerRunc}, + RemoteURL: service1RemoteURL, Config: aostypes.ServiceConfig{Runners: []string{runnerRunc}}, }, service2: { ServiceInfo: createServiceInfo(service2, 5001, service2LocalURL), - RemoteURL: service2RemoteURL, Config: aostypes.ServiceConfig{Runner: runnerRunc}, + RemoteURL: service2RemoteURL, Config: aostypes.ServiceConfig{Runners: []string{runnerRunc}}, }, service3: { ServiceInfo: createServiceInfo(service3, 5002, service3LocalURL), - RemoteURL: service3RemoteURL, Config: aostypes.ServiceConfig{Runner: runnerRunx}, + RemoteURL: service3RemoteURL, Config: aostypes.ServiceConfig{Runners: []string{runnerRunx}}, }, } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeManager, imageManager, resourceManager, - stateStorageProvider, newTestNetworkManager("172.17.0.1/16")) + launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + resourceManager, stateStorageProvider, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } defer launcherInstance.Close() - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -1096,7 +1106,7 @@ func TestStorageCleanup(t *testing.T) { if err := waitRunInstancesStatus( launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) + t.Errorf("Error waiting for run instances status: %v", err) } if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { @@ -1141,14 +1151,15 @@ func TestRebalancing(t *testing.T) { NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + resourceManager = newTestResourceManager() + imageManager = &testImageProvider{} ) - nodeManager.nodeInformation[nodeIDLocalSM] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, - RemoteNode: false, RunnerFeature: []string{runnerRunc, "crun"}, + nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ @@ -1158,14 +1169,14 @@ func TestRebalancing(t *testing.T) { }, } - nodeManager.nodeInformation[nodeIDRemoteSM1] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM}, - RemoteNode: true, RunnerFeature: []string{runnerRunc}, + nodeInfoProvider.nodeInfo[nodeIDRemoteSM1] = cloudprotocol.NodeInfo{ + NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } - nodeManager.nodeInformation[nodeIDRemoteSM2] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM}, - RemoteNode: true, RunnerFeature: []string{runnerRunc}, + nodeInfoProvider.nodeInfo[nodeIDRemoteSM2] = cloudprotocol.NodeInfo{ + NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ @@ -1177,14 +1188,14 @@ func TestRebalancing(t *testing.T) { Resources: []cloudprotocol.ResourceInfo{{Name: "resource1"}}, } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeManager, imageManager, resourceManager, - &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) + launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } defer launcherInstance.Close() - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -1200,7 +1211,7 @@ func TestRebalancing(t *testing.T) { ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), RemoteURL: service1RemoteURL, Config: aostypes.ServiceConfig{ - Runner: runnerRunc, + Runners: []string{runnerRunc}, Resources: []string{"resource1"}, }, }, @@ -1208,14 +1219,14 @@ func TestRebalancing(t *testing.T) { ServiceInfo: createServiceInfo(service2, 5001, service1LocalURL), RemoteURL: service2RemoteURL, Config: aostypes.ServiceConfig{ - Runner: runnerRunc, + Runners: []string{runnerRunc}, }, }, service3: { ServiceInfo: createServiceInfo(service3, 5002, service3LocalURL), RemoteURL: service3RemoteURL, Config: aostypes.ServiceConfig{ - Runner: runnerRunc, + Runners: []string{runnerRunc}, Devices: []aostypes.ServiceDevice{ {Name: "dev1"}, }, @@ -1394,38 +1405,39 @@ func TestRebalancingSameNodePriority(t *testing.T) { NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} - storage = newTestStorage() + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + resourceManager = newTestResourceManager() + imageManager = &testImageProvider{} + storage = newTestStorage() ) - nodeManager.nodeInformation[nodeIDLocalSM] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, - RemoteNode: false, + nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeLocalSM, Labels: []string{"label1"}, } - nodeManager.nodeInformation[nodeIDRemoteSM1] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM}, - RemoteNode: true, + nodeInfoProvider.nodeInfo[nodeIDRemoteSM1] = cloudprotocol.NodeInfo{ + NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeRemoteSM, Labels: []string{"label2"}, } - launcherInstance, err := launcher.New(cfg, storage, nodeManager, imageManager, resourceManager, + launcherInstance, err := launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } defer launcherInstance.Close() - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -1630,37 +1642,38 @@ func TestRebalancingAfterRestart(t *testing.T) { NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} - storage = newTestStorage() + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + resourceManager = newTestResourceManager() + imageManager = &testImageProvider{} + storage = newTestStorage() ) - nodeManager.nodeInformation[nodeIDLocalSM] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM}, - RemoteNode: false, + nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeLocalSM, Labels: []string{"label1"}, } - nodeManager.nodeInformation[nodeIDRemoteSM1] = launcher.NodeInfo{ - NodeInfo: cloudprotocol.NodeInfo{NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM}, - RemoteNode: true, + nodeInfoProvider.nodeInfo[nodeIDRemoteSM1] = cloudprotocol.NodeInfo{ + NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ NodeType: nodeTypeRemoteSM, Labels: []string{"label2"}, } - launcherInstance, err := launcher.New(cfg, storage, nodeManager, imageManager, resourceManager, + launcherInstance, err := launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -1752,13 +1765,13 @@ func TestRebalancingAfterRestart(t *testing.T) { // Restart - launcherInstance, err = launcher.New(cfg, storage, nodeManager, imageManager, resourceManager, + launcherInstance, err = launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) } - for nodeID, info := range nodeManager.nodeInformation { + for nodeID, info := range nodeInfoProvider.nodeInfo { nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, } @@ -1828,28 +1841,38 @@ func TestRebalancingAfterRestart(t *testing.T) { * Interfaces **********************************************************************************************************************/ -// testNodeManager +// testNodeInfoProvider -func newTestNodeManager() *testNodeManager { - nodeManager := &testNodeManager{ - runStatusChan: make(chan launcher.NodeRunInstanceStatus, 10), - nodeInformation: make(map[string]launcher.NodeInfo), - runRequest: make(map[string]runRequest), - alertsChannel: make(chan cloudprotocol.SystemQuotaAlert, 10), +func newTestNodeInfoProvider(nodeID string) *testNodeInfoProvider { + return &testNodeInfoProvider{ + nodeID: nodeID, + nodeInfo: make(map[string]cloudprotocol.NodeInfo), } +} - return nodeManager +func (provider *testNodeInfoProvider) GetNodeID() string { + return provider.nodeID } -func (nodeManager *testNodeManager) GetNodeConfiguration(nodeID string) (launcher.NodeInfo, error) { - config, ok := nodeManager.nodeInformation[nodeID] +func (provider *testNodeInfoProvider) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) { + nodeInfo, ok := provider.nodeInfo[nodeID] if !ok { - return launcher.NodeInfo{}, aoserrors.New("node config doesn't exist") + return cloudprotocol.NodeInfo{}, aoserrors.New("node info not found") } - config.NodeID = nodeID + return nodeInfo, nil +} + +// testNodeManager + +func newTestNodeManager() *testNodeManager { + nodeManager := &testNodeManager{ + runStatusChan: make(chan launcher.NodeRunInstanceStatus, 10), + runRequest: make(map[string]runRequest), + alertsChannel: make(chan cloudprotocol.SystemQuotaAlert, 10), + } - return config, nil + return nodeManager } func (nodeManager *testNodeManager) RunInstances(nodeID string, @@ -1890,8 +1913,8 @@ func (nodeManager *testNodeManager) GetSystemLimitAlertChannel() <-chan cloudpro return nodeManager.alertsChannel } -func (nodeManager *testNodeManager) GetNodeMonitoringData(nodeID string) (cloudprotocol.NodeMonitoringData, error) { - return cloudprotocol.NodeMonitoringData{}, nil +func (nodeManager *testNodeManager) GetAverageMonitoring(nodeID string) (aostypes.NodeMonitoring, error) { + return aostypes.NodeMonitoring{}, nil } func (nodeManager *testNodeManager) compareRunRequests(expectedRunRequests map[string]runRequest) error { @@ -1926,7 +1949,7 @@ func newTestResourceManager() *testResourceManager { return resourceManager } -func (resourceManager *testResourceManager) GetUnitConfiguration(nodeType string) cloudprotocol.NodeConfig { +func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType string) cloudprotocol.NodeConfig { resource := resourceManager.nodeResources[nodeType] resource.NodeType = nodeType From 0e9a781f6354b79f06d068ffbc63f154eedc8408 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 11 Jul 2024 13:47:53 +0300 Subject: [PATCH 055/146] [monitorcontroller] Update interval of sending monitor data MonitorController witll send data if queue is overloaded or a configured time interval elapsed. Signed-off-by: Mykola Kobets --- config/config.go | 6 +- monitorcontroller/monitorcontroller.go | 154 +++++++++++++++----- monitorcontroller/monitorcontroller_test.go | 133 ++++++++--------- 3 files changed, 191 insertions(+), 102 deletions(-) diff --git a/config/config.go b/config/config.go index ab7dac02..00f9a616 100644 --- a/config/config.go +++ b/config/config.go @@ -52,6 +52,8 @@ type UMController struct { type Monitoring struct { MonitorConfig *resourcemonitor.Config `json:"monitorConfig"` MaxOfflineMessages int `json:"maxOfflineMessages"` + SendPeriod aostypes.Duration `json:"sendPeriod"` + MaxMessageSize int `json:"maxMessageSize"` } // Alerts configuration for alerts. @@ -130,7 +132,9 @@ func New(fileName string) (config *Config, err error) { MaxOfflineMessages: 25, }, Monitoring: Monitoring{ - MaxOfflineMessages: 25, + MaxOfflineMessages: 16, + SendPeriod: aostypes.Duration{Duration: 1 * time.Minute}, + MaxMessageSize: 65536, }, Downloader: Downloader{ MaxConcurrentDownloads: 4, diff --git a/monitorcontroller/monitorcontroller.go b/monitorcontroller/monitorcontroller.go index f96e8cde..5de5d0fe 100644 --- a/monitorcontroller/monitorcontroller.go +++ b/monitorcontroller/monitorcontroller.go @@ -19,11 +19,14 @@ package monitorcontroller import ( "context" + "encoding/json" "errors" + "slices" "sync" "time" "github.com/aosedge/aos_common/aoserrors" + "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" @@ -45,21 +48,17 @@ type MonitoringSender interface { // MonitorController instance. type MonitorController struct { sync.Mutex - monitoringQueue []cloudprotocol.NodeMonitoringData - monitoringQueueSize int - monitoringSender MonitoringSender - cancelFunction context.CancelFunc - isConnected bool -} + offlineMessages []cloudprotocol.Monitoring -/*********************************************************************************************************************** - * Vars - **********************************************************************************************************************/ + sendMessageEvent chan struct{} + maxMessageSize int + currentMessageSize int + sendPeriod aostypes.Duration -// MinSendPeriod used to adjust min send period. -// -//nolint:gochecknoglobals -var MinSendPeriod = 1 * time.Second + monitoringSender MonitoringSender + cancelFunction context.CancelFunc + isConnected bool +} /*********************************************************************************************************************** * Public @@ -70,9 +69,16 @@ func New( config *config.Config, monitoringSender MonitoringSender, ) (monitor *MonitorController, err error) { monitor = &MonitorController{ - monitoringSender: monitoringSender, - monitoringQueue: make([]cloudprotocol.NodeMonitoringData, 0, config.Monitoring.MaxOfflineMessages), - monitoringQueueSize: config.Monitoring.MaxOfflineMessages, + monitoringSender: monitoringSender, + offlineMessages: make([]cloudprotocol.Monitoring, 0, config.Monitoring.MaxOfflineMessages), + sendMessageEvent: make(chan struct{}, 1), + maxMessageSize: config.Monitoring.MaxMessageSize, + sendPeriod: config.Monitoring.SendPeriod, + } + + if monitor.sendPeriod.Seconds() < 1.0 { + log.Warningf("MonitorController send interval is less than 1sec.: %v", monitor.sendPeriod) + monitor.sendPeriod = aostypes.Duration{Duration: 1 * time.Second} } if err = monitor.monitoringSender.SubscribeForConnectionEvents(monitor); err != nil { @@ -98,16 +104,43 @@ func (monitor *MonitorController) Close() { } } -// SendMonitoringData sends monitoring data. -func (monitor *MonitorController) SendMonitoringData(monitoringData cloudprotocol.NodeMonitoringData) { +// SendNodeMonitoring sends monitoring data. +func (monitor *MonitorController) SendNodeMonitoring(nodeMonitoring aostypes.NodeMonitoring) { monitor.Lock() - defer monitor.Unlock() - if len(monitor.monitoringQueue) >= monitor.monitoringQueueSize { - monitor.monitoringQueue = monitor.monitoringQueue[1:] + // calculate size of input parameter + messageSize := 0 + + message, err := json.Marshal(nodeMonitoring) + if err == nil { + messageSize = len(message) + } else { + log.Errorf("Can't marshal nodeMonitoring: %v", err) } - monitor.monitoringQueue = append(monitor.monitoringQueue, monitoringData) + // allocate new offline message + currentMessageOverflows := monitor.currentMessageSize+messageSize > monitor.maxMessageSize + + if len(monitor.offlineMessages) == 0 || currentMessageOverflows { + if len(monitor.offlineMessages) == cap(monitor.offlineMessages) { + monitor.offlineMessages = monitor.offlineMessages[1:] + } + + monitor.offlineMessages = append(monitor.offlineMessages, cloudprotocol.Monitoring{}) + monitor.currentMessageSize = 0 + } + + monitor.currentMessageSize += messageSize + + // add monitoring data + monitor.addNodeMonitoring(nodeMonitoring) + + // send notification message + monitor.Unlock() + + if currentMessageOverflows { + monitor.sendMessageEvent <- struct{}{} + } } /*********************************************************************************************************************** @@ -135,27 +168,78 @@ func (monitor *MonitorController) CloudDisconnected() { **********************************************************************************************************************/ func (monitor *MonitorController) processQueue(ctx context.Context) { - sendTicker := time.NewTicker(MinSendPeriod) + sendTicker := time.NewTicker(monitor.sendPeriod.Duration) for { select { case <-sendTicker.C: - monitor.Lock() - - if len(monitor.monitoringQueue) > 0 && monitor.isConnected { - if err := monitor.monitoringSender.SendMonitoringData( - cloudprotocol.Monitoring{Nodes: monitor.monitoringQueue}); err != nil && - !errors.Is(err, amqphandler.ErrNotConnected) { - log.Errorf("Can't send monitoring data: %v", err) - } else { - monitor.monitoringQueue = make([]cloudprotocol.NodeMonitoringData, 0, monitor.monitoringQueueSize) - } - } + monitor.sendMessages() - monitor.Unlock() + case <-monitor.sendMessageEvent: + monitor.sendMessages() + sendTicker.Reset(monitor.sendPeriod.Duration) case <-ctx.Done(): return } } } + +func (monitor *MonitorController) sendMessages() { + monitor.Lock() + defer monitor.Unlock() + + if len(monitor.offlineMessages) > 0 && monitor.isConnected { + for _, offlineMessage := range monitor.offlineMessages { + err := monitor.monitoringSender.SendMonitoringData(offlineMessage) + if err != nil && !errors.Is(err, amqphandler.ErrNotConnected) { + log.Errorf("Can't send monitoring data: %v", err) + } + } + + monitor.offlineMessages = make([]cloudprotocol.Monitoring, 0, cap(monitor.offlineMessages)) + monitor.currentMessageSize = 0 + } +} + +func (monitor *MonitorController) addNodeMonitoring(nodeMonitoring aostypes.NodeMonitoring) { + latestMessage := &monitor.offlineMessages[len(monitor.offlineMessages)-1] + + // add node monitoring data + nodeDataInd := slices.IndexFunc(latestMessage.Nodes, + func(item cloudprotocol.NodeMonitoringData) bool { return item.NodeID == nodeMonitoring.NodeID }, + ) + + if nodeDataInd >= 0 { + nodeItems := &latestMessage.Nodes[nodeDataInd].Items + *nodeItems = append(*nodeItems, nodeMonitoring.NodeData) + } else { + latestMessage.Nodes = append(latestMessage.Nodes, + cloudprotocol.NodeMonitoringData{ + NodeID: nodeMonitoring.NodeID, Items: []aostypes.MonitoringData{nodeMonitoring.NodeData}, + }, + ) + } + + // add instance monitoring data + for _, instanceData := range nodeMonitoring.InstancesData { + instanceDataInd := slices.IndexFunc(latestMessage.ServiceInstances, + func(item cloudprotocol.InstanceMonitoringData) bool { + return item.NodeID == nodeMonitoring.NodeID && item.InstanceIdent == instanceData.InstanceIdent + }, + ) + + if instanceDataInd >= 0 { + serviceInstanceItems := &latestMessage.ServiceInstances[instanceDataInd].Items + *serviceInstanceItems = append(*serviceInstanceItems, instanceData.MonitoringData) + } else { + latestMessage.ServiceInstances = append(latestMessage.ServiceInstances, + cloudprotocol.InstanceMonitoringData{ + NodeID: nodeMonitoring.NodeID, + InstanceIdent: instanceData.InstanceIdent, + Items: []aostypes.MonitoringData{instanceData.MonitoringData}, + }, + ) + } + } +} diff --git a/monitorcontroller/monitorcontroller_test.go b/monitorcontroller/monitorcontroller_test.go index a6e888a4..efbc5943 100644 --- a/monitorcontroller/monitorcontroller_test.go +++ b/monitorcontroller/monitorcontroller_test.go @@ -56,18 +56,6 @@ func init() { log.SetOutput(os.Stdout) } -/*********************************************************************************************************************** - * Main - **********************************************************************************************************************/ - -func TestMain(m *testing.M) { - monitorcontroller.MinSendPeriod = 100 * time.Millisecond - - ret := m.Run() - - os.Exit(ret) -} - /*********************************************************************************************************************** * Tests **********************************************************************************************************************/ @@ -76,7 +64,7 @@ func TestSendMonitorData(t *testing.T) { sender := newTestMonitoringSender() controller, err := monitorcontroller.New(&config.Config{ - Monitoring: config.Monitoring{MaxOfflineMessages: 8}, + Monitoring: config.Monitoring{MaxOfflineMessages: 8, SendPeriod: aostypes.Duration{Duration: 1 * time.Second}}, }, sender) if err != nil { t.Fatalf("Can't create monitoring controller: %v", err) @@ -85,33 +73,14 @@ func TestSendMonitorData(t *testing.T) { sender.consumer.CloudConnected() - nodeMonitoring := cloudprotocol.NodeMonitoringData{ - MonitoringData: cloudprotocol.MonitoringData{ - RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}, - }, - NodeID: "mainNode", - Timestamp: time.Now().UTC(), - ServiceInstances: []cloudprotocol.InstanceMonitoringData{ - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{RAM: 1024, CPU: 50, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}}, - }, - }, - } - - controller.SendMonitoringData(nodeMonitoring) + inputData, expectedData := getTestMonitoringData() + controller.SendNodeMonitoring(inputData) receivedMonitoringData, err := sender.waitMonitoringData() if err != nil { t.Fatalf("Error waiting for monitoring data: %v", err) } - expectedData := cloudprotocol.Monitoring{Nodes: []cloudprotocol.NodeMonitoringData{nodeMonitoring}} - if !reflect.DeepEqual(receivedMonitoringData, expectedData) { t.Errorf("Incorrect monitoring data: %v", receivedMonitoringData) } @@ -119,44 +88,32 @@ func TestSendMonitorData(t *testing.T) { func TestSendMonitorOffline(t *testing.T) { const ( - numOfflineMessages = 32 - numExtraMessages = 16 + numOfflineMessages = 2 + numExtraMessages = 1 + maxMessageSize = 400 ) sender := newTestMonitoringSender() - controller, err := monitorcontroller.New(&config.Config{ - Monitoring: config.Monitoring{MaxOfflineMessages: numOfflineMessages}, - }, sender) + controller, err := monitorcontroller.New( + &config.Config{Monitoring: config.Monitoring{ + MaxOfflineMessages: numOfflineMessages, + SendPeriod: aostypes.Duration{Duration: 1 * time.Second}, + MaxMessageSize: maxMessageSize, + }}, sender) if err != nil { t.Fatalf("Can't create monitoring controller: %v", err) } defer controller.Close() - var sentData []cloudprotocol.NodeMonitoringData + var sentData []cloudprotocol.Monitoring for i := 0; i < numOfflineMessages+numExtraMessages; i++ { - nodeMonitoring := cloudprotocol.NodeMonitoringData{ - MonitoringData: cloudprotocol.MonitoringData{ - RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}, - }, - NodeID: "mainNode", - Timestamp: time.Now().UTC(), - ServiceInstances: []cloudprotocol.InstanceMonitoringData{ - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, - MonitoringData: cloudprotocol.MonitoringData{RAM: 1024, CPU: 50, Disk: []cloudprotocol.PartitionUsage{{ - Name: "p1", UsedSize: 100, - }}}, - }, - }, - } + inputData, expectedData := getTestMonitoringData() - controller.SendMonitoringData(nodeMonitoring) + controller.SendNodeMonitoring(inputData) - sentData = append(sentData, nodeMonitoring) + sentData = append(sentData, expectedData) } if _, err := sender.waitMonitoringData(); err == nil { @@ -165,13 +122,18 @@ func TestSendMonitorOffline(t *testing.T) { sender.consumer.CloudConnected() - receivedData, err := sender.waitMonitoringData() - if err != nil { - t.Fatalf("Error waiting for monitoring data: %v", err) - } + expectedList := sentData[len(sentData)-numOfflineMessages:] + for _, message := range expectedList { + receivedData, err := sender.waitMonitoringData() + if err != nil { + t.Fatalf("Error waiting for monitoring data: %v", err) + return + } - if !reflect.DeepEqual(receivedData.Nodes, sentData[len(sentData)-numOfflineMessages:]) { - t.Errorf("Wrong monitoring data received: %v", receivedData) + if !reflect.DeepEqual(receivedData, message) { + t.Errorf("Wrong monitoring data received: %v", receivedData) + return + } } if data, err := sender.waitMonitoringData(); err == nil { @@ -210,7 +172,46 @@ func (sender *testMonitoringSender) waitMonitoringData() (cloudprotocol.Monitori case monitoringData := <-sender.monitoringData: return monitoringData, nil - case <-time.After(1 * time.Second): + case <-time.After(2 * time.Second): return cloudprotocol.Monitoring{}, aoserrors.New("wait monitoring data timeout") } } + +func getTestMonitoringData() (aostypes.NodeMonitoring, cloudprotocol.Monitoring) { + timestamp := time.Now().UTC() + nodeMonitoring := cloudprotocol.NodeMonitoringData{ + NodeID: "mainNode", + Items: []aostypes.MonitoringData{ + { + RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Timestamp: timestamp, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + }, + }, + } + + instanceMonitoring := cloudprotocol.InstanceMonitoringData{ + NodeID: "mainNode", + InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, + Items: []aostypes.MonitoringData{ + { + RAM: 1024, CPU: 50, Timestamp: timestamp, + Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, + }, + }, + } + + input := aostypes.NodeMonitoring{ + NodeID: "mainNode", + NodeData: nodeMonitoring.Items[0], + InstancesData: []aostypes.InstanceMonitoring{ + {InstanceIdent: instanceMonitoring.InstanceIdent, MonitoringData: instanceMonitoring.Items[0]}, + }, + } + + output := cloudprotocol.Monitoring{ + Nodes: []cloudprotocol.NodeMonitoringData{nodeMonitoring}, + ServiceInstances: []cloudprotocol.InstanceMonitoringData{instanceMonitoring}, + } + + return input, output +} From 1f66e85928af407e60b42c0a4a5d6f6a89f2855b Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sun, 14 Jul 2024 15:43:49 +0300 Subject: [PATCH 056/146] [unitstatushandler] Remove unused Restart method from InstanceRunner Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 1 - unitstatushandler/unitstatushandler_internal_test.go | 4 ---- 2 files changed, 5 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 0b523c4c..6fd740cd 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -75,7 +75,6 @@ type FirmwareUpdater interface { // InstanceRunner instances runner. type InstanceRunner interface { RunInstances(instances []cloudprotocol.InstanceInfo, newServices []string) error - RestartInstances() error } // SoftwareUpdater updates services, layers. diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index fbc3290c..a6d3dcaf 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -1716,10 +1716,6 @@ func (runner *TestInstanceRunner) RunInstances(instances []cloudprotocol.Instanc return nil } -func (runner *TestInstanceRunner) RestartInstances() error { - return nil -} - func (runner *TestInstanceRunner) WaitForRunInstance(timeout time.Duration) ([]cloudprotocol.InstanceInfo, error) { select { case receivedRunInstances := <-runner.runInstanceChan: From 6451763462cdabd247fc670f164da7f467a676a2 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sun, 14 Jul 2024 16:56:25 +0300 Subject: [PATCH 057/146] [umcontroller] Fix new component listener New component listener should send only components that appear after init state. Signed-off-by: Oleksandr Grytsov --- umcontroller/umcontroller.go | 52 ++++++++++++++++++++----------- umcontroller/umcontroller_test.go | 26 +++++++++++----- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 02380b7f..dbbe0473 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -64,7 +64,7 @@ type Controller struct { connections []umConnection currentComponents []cloudprotocol.ComponentStatus - newComponentListener chan cloudprotocol.ComponentStatus + newComponentsChannel chan []cloudprotocol.ComponentStatus fsm *fsm.FSM connectionMonitor allConnectionMonitor @@ -79,7 +79,7 @@ type Controller struct { // ComponentStatus information about system component update. type ComponentStatus struct { - ComponentID string `json:"componentID"` + ComponentID string `json:"componentId"` ComponentType string `json:"componentType"` Version string `json:"version"` Annotations string `json:"annotations,omitempty"` @@ -230,10 +230,10 @@ func New(config *config.Config, storage storage, certProvider CertificateProvide nodeInfoChannel: nodeInfoProvider.SubscribeNodeInfoChange(), stopChannel: make(chan bool), componentDir: config.ComponentsDir, - newComponentListener: nil, connectionMonitor: allConnectionMonitor{stopTimerChan: make(chan bool, 1), timeoutChan: make(chan bool, 1)}, operable: true, updateFinishCond: sync.NewCond(&sync.Mutex{}), + newComponentsChannel: make(chan []cloudprotocol.ComponentStatus, 1), decrypter: decrypter, } @@ -289,6 +289,7 @@ func (umCtrl *Controller) Close() { } } + close(umCtrl.newComponentsChannel) umCtrl.operable = false umCtrl.stopChannel <- true } @@ -414,13 +415,8 @@ func (umCtrl *Controller) UpdateComponents( return umCtrl.currentComponents, umCtrl.updateError } -func (umCtrl *Controller) SetNewComponentListener() <-chan cloudprotocol.ComponentStatus { - umCtrl.Lock() - defer umCtrl.Unlock() - - umCtrl.newComponentListener = make(chan cloudprotocol.ComponentStatus, 1) - - return umCtrl.newComponentListener +func (umCtrl *Controller) NewComponentsChannel() <-chan []cloudprotocol.ComponentStatus { + return umCtrl.newComponentsChannel } /*********************************************************************************************************************** @@ -469,6 +465,7 @@ func (umCtrl *Controller) processInternalMessages() { } } +//nolint:funlen func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, status umStatus) { if handler == nil { log.Error("Handler is nil") @@ -484,6 +481,10 @@ func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, s umCtrl.updateCurrentComponentsStatus(status.componsStatus) + if umCtrl.fsm.Current() != stateInit { + umCtrl.notifyNewComponents(umID, status.componsStatus) + } + umIDfound = true if value.handler != nil { @@ -625,8 +626,6 @@ func (umCtrl *Controller) updateComponentElement(component systemComponentStatus } umCtrl.currentComponents = append(umCtrl.currentComponents, newComponentStatus) - - umCtrl.notifyNewComponentListener(newComponentStatus) } func (umCtrl *Controller) cleanupCurrentComponentStatus() { @@ -1035,7 +1034,7 @@ func (umCtrl *Controller) processUpdateUpdateStatus(ctx context.Context, e *fsm. for i, v := range umCtrl.connections { if v.umID == umID { umCtrl.connections[i].state = status.updateStatus - log.Debugf("UMid = %s state= %s", umID, status.updateStatus) + log.Debugf("umID = %s state = %s", umID, status.updateStatus) break } @@ -1142,11 +1141,28 @@ func (status systemComponentStatus) String() string { return fmt.Sprintf("{id: %s, status: %s, version: %s }", status.componentID, status.status, status.version) } -func (umCtrl *Controller) notifyNewComponentListener(status cloudprotocol.ComponentStatus) { - umCtrl.Lock() - defer umCtrl.Unlock() +func (umCtrl *Controller) notifyNewComponents(umID string, componsStatus []systemComponentStatus) { + newComponents := make([]cloudprotocol.ComponentStatus, 0, len(componsStatus)) + + for _, status := range componsStatus { + newComponent := cloudprotocol.ComponentStatus{ + ComponentID: status.componentID, + ComponentType: status.componentType, + Version: status.version, + NodeID: umID, + Status: status.status, + } - if umCtrl.newComponentListener != nil { - umCtrl.newComponentListener <- status + if status.err != "" { + newComponent.ErrorInfo = &cloudprotocol.ErrorInfo{Message: status.err} + } + + newComponents = append(newComponents, newComponent) + } + + if len(newComponents) == 0 { + return } + + umCtrl.newComponentsChannel <- newComponents } diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 1c6a6e6c..27bd4c33 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -228,6 +228,15 @@ func TestConnection(t *testing.T) { t.Fatalf("Can't create: UM controller %s", err) } + go func() { + for { + _, ok := <-umCtrl.NewComponentsChannel() + if !ok { + return + } + } + }() + components := []*pb.ComponentStatus{ {ComponentId: "component1", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, {ComponentId: "component2", ComponentType: "type-1", Version: "1.0.0", State: pb.ComponentState_INSTALLED}, @@ -316,8 +325,6 @@ func TestNewComponentsUpdate(t *testing.T) { t.Errorf("Incorrect count of components %d", len(newComponents)) } - newComponentListener := umCtrl.SetNewComponentListener() - // add new components for node with ID=umID2 nodeInfoProvider.addNode("umID2") @@ -331,12 +338,17 @@ func TestNewComponentsUpdate(t *testing.T) { t.Errorf("Error connect %s", err) } - if node2Component3 := <-newComponentListener; node2Component3.ComponentID != "component3" { - t.Errorf("Wrong component received %s", node2Component3.ComponentID) - } + select { + case newComponents := <-umCtrl.NewComponentsChannel(): + if !reflect.DeepEqual(newComponents, []cloudprotocol.ComponentStatus{ + {ComponentID: "component3", Version: "1.0.0", Status: "installed", NodeID: "umID2"}, + {ComponentID: "component4", Version: "1.0.0", Status: "installed", NodeID: "umID2"}, + }) { + t.Errorf("Incorrect new components: %v", newComponents) + } - if node2Component4 := <-newComponentListener; node2Component4.ComponentID != "component4" { - t.Errorf("Wrong component received %s", node2Component4.ComponentID) + case <-time.After(5 * time.Second): + t.Error("Waiting for new components timeout") } umCtrl.Close() From bc50476f9a529a1beb90c2d617e26ad697798fd8 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 15 Jul 2024 10:53:14 +0300 Subject: [PATCH 058/146] [unitstatushandler] Update components status on new components Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 27 ++++++- .../unitstatushandler_internal_test.go | 15 +++- unitstatushandler/unitstatushandler_test.go | 72 +++++++++++++++++++ 3 files changed, 110 insertions(+), 4 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 6fd740cd..2c317517 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -70,6 +70,7 @@ type FirmwareUpdater interface { GetStatus() (componentsInfo []cloudprotocol.ComponentStatus, err error) UpdateComponents(components []cloudprotocol.ComponentInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate) (status []cloudprotocol.ComponentStatus, err error) + NewComponentsChannel() <-chan []cloudprotocol.ComponentStatus } // InstanceRunner instances runner. @@ -134,6 +135,8 @@ type Instance struct { firmwareManager *firmwareManager softwareManager *softwareManager + newComponentsChannel <-chan []cloudprotocol.ComponentStatus + initDone bool isConnected int32 } @@ -172,9 +175,10 @@ func New( log.Debug("Create unit status handler") instance = &Instance{ - nodeInfoProvider: nodeInfoProvider, - statusSender: statusSender, - sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, + nodeInfoProvider: nodeInfoProvider, + statusSender: statusSender, + sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, + newComponentsChannel: firmwareUpdater.NewComponentsChannel(), } // Initialize maps of statuses for avoiding situation of adding values to uninitialized map on go routine @@ -198,6 +202,8 @@ func New( return nil, aoserrors.Wrap(err) } + go instance.handleChannels() + return instance, nil } @@ -738,3 +744,18 @@ func (instance *Instance) getAllNodesInfo() ([]cloudprotocol.NodeInfo, error) { return nodesInfo, nil } + +func (instance *Instance) handleChannels() { + for { + select { + case newComponents, ok := <-instance.newComponentsChannel: + if !ok { + return + } + + for _, componentStatus := range newComponents { + instance.updateComponentStatus(componentStatus) + } + } + } +} diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index a6d3dcaf..47705755 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -70,6 +70,8 @@ type TestFirmwareUpdater struct { InitComponentsInfo []cloudprotocol.ComponentStatus UpdateComponentsInfo []cloudprotocol.ComponentStatus UpdateError error + + newComponentsChannel chan []cloudprotocol.ComponentStatus } type TestSoftwareUpdater struct { @@ -1642,7 +1644,10 @@ func (updater *TestUnitConfigUpdater) UpdateUnitConfig(unitConfig cloudprotocol. **********************************************************************************************************************/ func NewTestFirmwareUpdater(componentsInfo []cloudprotocol.ComponentStatus) (updater *TestFirmwareUpdater) { - return &TestFirmwareUpdater{InitComponentsInfo: componentsInfo} + return &TestFirmwareUpdater{ + InitComponentsInfo: componentsInfo, + newComponentsChannel: make(chan []cloudprotocol.ComponentStatus, 1), + } } func (updater *TestFirmwareUpdater) GetStatus() (info []cloudprotocol.ComponentStatus, err error) { @@ -1657,6 +1662,14 @@ func (updater *TestFirmwareUpdater) UpdateComponents( return updater.UpdateComponentsInfo, updater.UpdateError } +func (updater *TestFirmwareUpdater) NewComponentsChannel() <-chan []cloudprotocol.ComponentStatus { + return updater.newComponentsChannel +} + +func (updater *TestFirmwareUpdater) SetNewComponents(newComponents []cloudprotocol.ComponentStatus) { + updater.newComponentsChannel <- newComponents +} + /*********************************************************************************************************************** * TestSoftwareUpdater **********************************************************************************************************************/ diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index e225fa1c..d11587d5 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -1008,6 +1008,78 @@ func TestUpdateCachedSOTA(t *testing.T) { } } +func TestNewComponents(t *testing.T) { + unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) + firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) + softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) + instanceRunner := unitstatushandler.NewTestInstanceRunner() + sender := unitstatushandler.NewTestSender() + + statusHandler, err := unitstatushandler.New( + cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + if err != nil { + t.Fatalf("Can't create unit status handler: %v", err) + } + defer statusHandler.Close() + + sender.Consumer.CloudConnected() + + go handleUpdateStatus(statusHandler) + + if err := statusHandler.ProcessRunStatus( + unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{}}); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + + receivedUnitStatus, err := sender.WaitForStatus(waitStatusTimeout) + if err != nil { + t.Fatalf("Can't receive unit status: %v", err) + } + + expectedUnitStatus := cloudprotocol.UnitStatus{ + UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, + } + + if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { + t.Errorf("Wrong unit status received: %v, expected: %v", receivedUnitStatus, expectedUnitStatus) + } + + // New components + + newComponents := []cloudprotocol.ComponentStatus{ + { + ComponentID: "comp1", ComponentType: "type1", Version: "1.0.0", + Status: cloudprotocol.InstalledStatus, NodeID: "node1", + }, + { + ComponentID: "comp2", ComponentType: "type2", Version: "1.0.0", + Status: cloudprotocol.InstalledStatus, NodeID: "node2", + }, + { + ComponentID: "comp3", ComponentType: "type3", Version: "1.0.0", + Status: cloudprotocol.InstalledStatus, NodeID: "node3", + }, + } + + firmwareUpdater.SetNewComponents(newComponents) + + receivedUnitStatus, err = sender.WaitForStatus(waitStatusTimeout) + if err != nil { + t.Fatalf("Can't receive unit status: %v", err) + } + + expectedUnitStatus = cloudprotocol.UnitStatus{ + UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, + Components: newComponents, + } + + if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { + t.Errorf("Wrong unit status received: %v, expected: %v", receivedUnitStatus, expectedUnitStatus) + } +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ From ff68bae3dc35f96869579b30a9125c631a67d12f Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 15 Jul 2024 12:58:48 +0300 Subject: [PATCH 059/146] [unitstatushandler] Update node info when it is changed Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 55 +++++++-- .../unitstatushandler_internal_test.go | 60 ++++++++-- unitstatushandler/unitstatushandler_test.go | 106 ++++++++++++++++-- 3 files changed, 195 insertions(+), 26 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 2c317517..f086c09b 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "errors" + "slices" "sync" "sync/atomic" "time" @@ -43,6 +44,7 @@ import ( type NodeInfoProvider interface { GetAllNodeIDs() ([]string, error) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) + SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo } // Downloader downloads packages. @@ -136,6 +138,7 @@ type Instance struct { softwareManager *softwareManager newComponentsChannel <-chan []cloudprotocol.ComponentStatus + nodeChangedChannel <-chan cloudprotocol.NodeInfo initDone bool isConnected int32 @@ -148,6 +151,7 @@ type unitStatus struct { layers map[string]*itemStatus services map[string]*itemStatus instances []cloudprotocol.InstanceStatus + nodes []cloudprotocol.NodeInfo } type statusDescriptor struct { @@ -179,6 +183,7 @@ func New( statusSender: statusSender, sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, newComponentsChannel: firmwareUpdater.NewComponentsChannel(), + nodeChangedChannel: nodeInfoProvider.SubscribeNodeInfoChange(), } // Initialize maps of statuses for avoiding situation of adding values to uninitialized map on go routine @@ -259,6 +264,13 @@ func (instance *Instance) ProcessRunStatus(status RunInstancesStatus) error { instance.unitStatus.subjects = status.UnitSubjects instance.unitStatus.instances = status.Instances + nodesInfo, err := instance.getAllNodesInfo() + if err != nil { + log.Errorf("Can't get nodes info: %v", err) + } + + instance.unitStatus.nodes = nodesInfo + instance.softwareManager.processRunStatus(status) instance.sendCurrentStatus() @@ -608,11 +620,36 @@ foundloop: instance.statusChanged() } -func (instance *Instance) setInstanceStatus(status []cloudprotocol.InstanceStatus) { +func (instance *Instance) setInstancesStatus(statuses []cloudprotocol.InstanceStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() - instance.unitStatus.instances = status + instance.unitStatus.instances = statuses + + instance.statusChanged() +} + +func (instance *Instance) updateNodeInfo(nodeInfo cloudprotocol.NodeInfo) { + instance.statusMutex.Lock() + defer instance.statusMutex.Unlock() + + log.WithFields(log.Fields{ + "nodeID": nodeInfo.NodeID, + "nodeType": nodeInfo.NodeType, + "status": nodeInfo.Status, + }).Debug("Node info changed") + + index := slices.IndexFunc(instance.unitStatus.nodes, func(curNodeInfo cloudprotocol.NodeInfo) bool { + return curNodeInfo.NodeID == nodeInfo.NodeID + }) + + if index == -1 { + instance.unitStatus.nodes = append(instance.unitStatus.nodes, nodeInfo) + } else { + instance.unitStatus.nodes[index] = nodeInfo + } + + instance.statusChanged() } func (instance *Instance) statusChanged() { @@ -658,18 +695,13 @@ func (instance *Instance) sendCurrentStatus() { return } - nodesInfo, err := instance.getAllNodesInfo() - if err != nil { - log.Errorf("Can't get nodes info: %v", err) - } - unitStatus := cloudprotocol.UnitStatus{ UnitSubjects: instance.unitStatus.subjects, Components: make([]cloudprotocol.ComponentStatus, 0, len(instance.unitStatus.components)), Layers: make([]cloudprotocol.LayerStatus, 0, len(instance.unitStatus.layers)), Services: make([]cloudprotocol.ServiceStatus, 0, len(instance.unitStatus.services)), Instances: instance.unitStatus.instances, - Nodes: nodesInfo, + Nodes: instance.unitStatus.nodes, } for _, status := range instance.unitStatus.unitConfig { @@ -756,6 +788,13 @@ func (instance *Instance) handleChannels() { for _, componentStatus := range newComponents { instance.updateComponentStatus(componentStatus) } + + case nodeInfo, ok := <-instance.nodeChangedChannel: + if !ok { + return + } + + instance.updateNodeInfo(nodeInfo) } } } diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 47705755..3d0ea240 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -53,7 +53,10 @@ const waitStatusTimeout = 5 * time.Second * Types **********************************************************************************************************************/ -type TestNodeInfoProvider struct{} +type TestNodeInfoProvider struct { + nodesInfo map[string]cloudprotocol.NodeInfo + nodeInfoChannel chan cloudprotocol.NodeInfo +} type TestSender struct { Consumer amqphandler.ConnectionEventsConsumer @@ -1577,16 +1580,59 @@ func TestSyncExecutor(t *testing.T) { * TestNodeInfoProvider **********************************************************************************************************************/ -func NewTestNodeInfoProvider() *TestNodeInfoProvider { - return &TestNodeInfoProvider{} +func NewTestNodeInfoProvider(nodesInfo []cloudprotocol.NodeInfo) *TestNodeInfoProvider { + nodesInfoMap := make(map[string]cloudprotocol.NodeInfo) + + for _, nodeInfo := range nodesInfo { + nodesInfoMap[nodeInfo.NodeID] = nodeInfo + } + + return &TestNodeInfoProvider{ + nodesInfo: nodesInfoMap, + } } func (provider *TestNodeInfoProvider) GetAllNodeIDs() ([]string, error) { - return []string{}, nil + nodeIDs := make([]string, 0, len(provider.nodesInfo)) + + for nodeID := range provider.nodesInfo { + nodeIDs = append(nodeIDs, nodeID) + } + + return nodeIDs, nil } func (provider *TestNodeInfoProvider) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) { - return cloudprotocol.NodeInfo{}, nil + nodeInfo, ok := provider.nodesInfo[nodeID] + if !ok { + return cloudprotocol.NodeInfo{}, aoserrors.New("node not found") + } + + return nodeInfo, nil +} + +func (provider *TestNodeInfoProvider) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { + provider.nodeInfoChannel = make(chan cloudprotocol.NodeInfo, 1) + + return provider.nodeInfoChannel +} + +func (provider *TestNodeInfoProvider) NodeInfoChanged(nodeInfo cloudprotocol.NodeInfo) { + provider.nodesInfo[nodeInfo.NodeID] = nodeInfo + + if provider.nodeInfoChannel != nil { + provider.nodeInfoChannel <- nodeInfo + } +} + +func (provider *TestNodeInfoProvider) GetAllNodesInfo() []cloudprotocol.NodeInfo { + nodesInfo := make([]cloudprotocol.NodeInfo, 0, len(provider.nodesInfo)) + + for _, nodeInfo := range provider.nodesInfo { + nodesInfo = append(nodesInfo, nodeInfo) + } + + return nodesInfo } /*********************************************************************************************************************** @@ -1917,8 +1963,8 @@ func (statusHandler *testStatusHandler) updateServiceStatus(serviceInfo cloudpro }).Debug("Update service status") } -func (statusHandler *testStatusHandler) setInstanceStatus(status []cloudprotocol.InstanceStatus) { - for _, instanceStatus := range status { +func (statusHandler *testStatusHandler) setInstancesStatus(statuses []cloudprotocol.InstanceStatus) { + for _, instanceStatus := range statuses { log.WithFields(log.Fields{ "serviceID": instanceStatus.ServiceID, "subjectID": instanceStatus.SubjectID, diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index d11587d5..134c521d 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -110,8 +110,8 @@ func TestSendInitialStatus(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, - unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -158,8 +158,8 @@ func TestUpdateUnitConfig(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, - unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -252,7 +252,7 @@ func TestUpdateComponents(t *testing.T) { instanceRunner := unitstatushandler.NewTestInstanceRunner() sender := unitstatushandler.NewTestSender() - statusHandler, err := unitstatushandler.New(cfg, unitstatushandler.NewTestNodeInfoProvider(), + statusHandler, err := unitstatushandler.New(cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { @@ -359,7 +359,7 @@ func TestUpdateLayers(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -516,7 +516,7 @@ func TestUpdateServices(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -663,7 +663,7 @@ func TestRunInstances(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) @@ -786,7 +786,7 @@ func TestUpdateInstancesStatus(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) @@ -903,7 +903,7 @@ func TestUpdateCachedSOTA(t *testing.T) { downloader := unitstatushandler.NewTestDownloader() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, downloader, unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -1017,7 +1017,7 @@ func TestNewComponents(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) @@ -1080,6 +1080,76 @@ func TestNewComponents(t *testing.T) { } } +func TestNodeInfoChanged(t *testing.T) { + unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) + firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) + softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) + instanceRunner := unitstatushandler.NewTestInstanceRunner() + sender := unitstatushandler.NewTestSender() + nodeInfoProvider := unitstatushandler.NewTestNodeInfoProvider([]cloudprotocol.NodeInfo{ + {NodeID: "node1", NodeType: "type1", Status: cloudprotocol.NodeStatusProvisioned}, + {NodeID: "node2", NodeType: "type2", Status: cloudprotocol.NodeStatusProvisioned}, + }) + + statusHandler, err := unitstatushandler.New( + cfg, nodeInfoProvider, unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + if err != nil { + t.Fatalf("Can't create unit status handler: %v", err) + } + defer statusHandler.Close() + + sender.Consumer.CloudConnected() + + go handleUpdateStatus(statusHandler) + + if err := statusHandler.ProcessRunStatus( + unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{}}); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + + receivedUnitStatus, err := sender.WaitForStatus(waitStatusTimeout) + if err != nil { + t.Fatalf("Can't receive unit status: %v", err) + } + + expectedUnitStatus := cloudprotocol.UnitStatus{ + UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, + Nodes: nodeInfoProvider.GetAllNodesInfo(), + } + + if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { + t.Errorf("Wrong unit status received: %v, expected: %v", receivedUnitStatus, expectedUnitStatus) + } + + // New nodes info + + newNodesInfo := []cloudprotocol.NodeInfo{ + {NodeID: "node1", NodeType: "type1", Status: cloudprotocol.NodeStatusPaused}, + {NodeID: "node2", NodeType: "type2", Status: cloudprotocol.NodeStatusProvisioned}, + {NodeID: "node3", NodeType: "type3", Status: cloudprotocol.NodeStatusProvisioned}, + } + + for _, newNodeInfo := range newNodesInfo { + nodeInfoProvider.NodeInfoChanged(newNodeInfo) + } + + receivedUnitStatus, err = sender.WaitForStatus(waitStatusTimeout) + if err != nil { + t.Fatalf("Can't receive unit status: %v", err) + } + + expectedUnitStatus = cloudprotocol.UnitStatus{ + UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, + Nodes: nodeInfoProvider.GetAllNodesInfo(), + } + + if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { + t.Errorf("Wrong unit status received: %v, expected: %v", receivedUnitStatus, expectedUnitStatus) + } +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -1151,6 +1221,20 @@ func compareUnitStatus(status1, status2 cloudprotocol.UnitStatus) (err error) { return aoserrors.Wrap(err) } + if err = compareStatus(len(status1.Instances), len(status2.Instances), + func(index1, index2 int) (result bool) { + return reflect.DeepEqual(status1.Instances[index1], status2.Instances[index2]) + }); err != nil { + return aoserrors.Wrap(err) + } + + if err = compareStatus(len(status1.Nodes), len(status2.Nodes), + func(index1, index2 int) (result bool) { + return reflect.DeepEqual(status1.Nodes[index1], status2.Nodes[index2]) + }); err != nil { + return aoserrors.Wrap(err) + } + return nil } From 62b7a24f3dbf6caef757ae102c22ceb6dfa0985b Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 15 Jul 2024 14:38:39 +0300 Subject: [PATCH 060/146] [unitstatushandler] Add ready to update state to sate machine Add and handle ready to update state. This state is optimization not switching to downloading state if donwload is not required. Signed-off-by: Oleksandr Grytsov --- unitstatushandler/firmwaremanager.go | 4 +- unitstatushandler/softwaremanager.go | 38 +++++++++++++------ .../unitstatushandler_internal_test.go | 2 - unitstatushandler/updatestatemachine.go | 15 ++++++-- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 287011bd..a918b28f 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -338,7 +338,7 @@ func (manager *firmwareManager) noUpdate() { var err error if manager.TTLDate, err = manager.stateMachine.startNewUpdate( - time.Duration(manager.CurrentUpdate.Schedule.TTL) * time.Second); err != nil { + time.Duration(manager.CurrentUpdate.Schedule.TTL)*time.Second, true); err != nil { log.Errorf("Can't start new firmware update: %v", err) } }() @@ -521,7 +521,7 @@ func (manager *firmwareManager) newUpdate(update *firmwareUpdate) (err error) { manager.CurrentUpdate = update if manager.TTLDate, err = manager.stateMachine.startNewUpdate( - time.Duration(manager.CurrentUpdate.Schedule.TTL) * time.Second); err != nil { + time.Duration(manager.CurrentUpdate.Schedule.TTL)*time.Second, true); err != nil { return aoserrors.Wrap(err) } diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 0f1d9155..48d3b659 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -54,10 +54,10 @@ type softwareDownloader interface { releaseDownloadedSoftware() error } type softwareStatusHandler interface { - updateLayerStatus(layerInfo cloudprotocol.LayerStatus) - updateServiceStatus(serviceInfo cloudprotocol.ServiceStatus) - updateUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) - setInstanceStatus(status []cloudprotocol.InstanceStatus) + updateLayerStatus(status cloudprotocol.LayerStatus) + updateServiceStatus(status cloudprotocol.ServiceStatus) + updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) + setInstancesStatus(statuses []cloudprotocol.InstanceStatus) } type softwareUpdate struct { @@ -134,6 +134,7 @@ func newSoftwareManager(statusHandler softwareStatusHandler, downloader software manager.stateMachine = newUpdateStateMachine(manager.CurrentState, fsm.Events{ // no update state {Name: eventStartDownload, Src: []string{stateNoUpdate}, Dst: stateDownloading}, + {Name: eventReadyToUpdate, Src: []string{stateNoUpdate}, Dst: stateReadyToUpdate}, // downloading state {Name: eventFinishDownload, Src: []string{stateDownloading}, Dst: stateReadyToUpdate}, {Name: eventCancel, Src: []string{stateDownloading}, Dst: stateNoUpdate}, @@ -505,6 +506,13 @@ func (manager *softwareManager) stateChanged(event, state string, updateErr erro } } + if state == stateDownloading || state == stateReadyToUpdate { + if manager.CurrentUpdate.UnitConfig != nil { + manager.UnitConfigStatus.Version = manager.CurrentUpdate.UnitConfig.Version + manager.updateUnitConfigStatus(cloudprotocol.PendingStatus, nil) + } + } + manager.CurrentState = state manager.UpdateErr = errorInfo @@ -544,7 +552,8 @@ func (manager *softwareManager) noUpdate() { var err error if manager.TTLDate, err = manager.stateMachine.startNewUpdate( - time.Duration(manager.CurrentUpdate.Schedule.TTL) * time.Second); err != nil { + time.Duration(manager.CurrentUpdate.Schedule.TTL)*time.Second, + manager.isDownloadRequired()); err != nil { log.Errorf("Can't start new software update: %v", err) } }() @@ -568,11 +577,6 @@ func (manager *softwareManager) download(ctx context.Context) { manager.DownloadResult = nil - if manager.CurrentUpdate.UnitConfig != nil { - manager.UnitConfigStatus.Version = manager.CurrentUpdate.UnitConfig.Version - manager.updateUnitConfigStatus(cloudprotocol.PendingStatus, nil) - } - request := manager.prepareDownloadRequest() // Nothing to download @@ -801,7 +805,7 @@ func (manager *softwareManager) newUpdate(update *softwareUpdate) (err error) { manager.CurrentUpdate = update if manager.TTLDate, err = manager.stateMachine.startNewUpdate( - time.Duration(manager.CurrentUpdate.Schedule.TTL) * time.Second); err != nil { + time.Duration(manager.CurrentUpdate.Schedule.TTL)*time.Second, manager.isDownloadRequired()); err != nil { return aoserrors.Wrap(err) } @@ -1328,7 +1332,7 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr error } } - manager.statusHandler.setInstanceStatus(manager.InstanceStatuses) + manager.statusHandler.setInstancesStatus(manager.InstanceStatuses) if err := manager.instanceRunner.RunInstances(manager.CurrentUpdate.RunInstances, newServices); err != nil { return aoserrors.Wrap(err) @@ -1379,3 +1383,13 @@ func (manager *softwareManager) updateUnitConfigStatus(status string, errorInfo manager.statusHandler.updateUnitConfigStatus(manager.UnitConfigStatus) } + +func (manager *softwareManager) isDownloadRequired() bool { + if manager.CurrentUpdate != nil && + (len(manager.CurrentUpdate.InstallLayers) > 0 || + len(manager.CurrentUpdate.InstallServices) > 0) { + return true + } + + return false +} diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 3d0ea240..653e1666 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -1162,7 +1162,6 @@ func TestSoftwareManager(t *testing.T) { Version: "1.0.0", }}, updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, {State: cmserver.NoUpdate}, @@ -1176,7 +1175,6 @@ func TestSoftwareManager(t *testing.T) { }}, updateError: aoserrors.New("unit config error"), updateWaitStatuses: []cmserver.UpdateStatus{ - {State: cmserver.Downloading}, {State: cmserver.ReadyToUpdate}, {State: cmserver.Updating}, {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "unit config error"}}, diff --git a/unitstatushandler/updatestatemachine.go b/unitstatushandler/updatestatemachine.go index 94dd48c5..4eeaef2d 100644 --- a/unitstatushandler/updatestatemachine.go +++ b/unitstatushandler/updatestatemachine.go @@ -45,6 +45,7 @@ const ( const ( eventStartDownload = "startDownload" eventFinishDownload = "finishDownload" + eventReadyToUpdate = "readyToUpdate" eventStartUpdate = "startUpdate" eventFinishUpdate = "finishUpdate" eventCancel = "cancel" @@ -196,7 +197,9 @@ func (stateMachine *updateStateMachine) finishOperation(ctx context.Context, fin } } -func (stateMachine *updateStateMachine) startNewUpdate(ttlTime time.Duration) (ttlDate time.Time, err error) { +func (stateMachine *updateStateMachine) startNewUpdate( + ttlTime time.Duration, downloadRequired bool, +) (ttlDate time.Time, err error) { if ttlTime == 0 { ttlTime = stateMachine.defaultTTL } @@ -207,8 +210,14 @@ func (stateMachine *updateStateMachine) startNewUpdate(ttlTime time.Duration) (t stateMachine.setTTLTimer(ttlTime) } - if err = stateMachine.sendEvent(eventStartDownload, nil); err != nil { - return ttlDate, aoserrors.Wrap(err) + if downloadRequired { + if err = stateMachine.sendEvent(eventStartDownload, nil); err != nil { + return ttlDate, aoserrors.Wrap(err) + } + } else { + if err = stateMachine.sendEvent(eventReadyToUpdate, nil); err != nil { + return ttlDate, aoserrors.Wrap(err) + } } return ttlDate, nil From fd6baef30392918b933fc595cb94c1738e9ac4dc Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 15 Jul 2024 16:05:09 +0300 Subject: [PATCH 061/146] [unitstatushandler] Implement node status updating Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 70 ++++++++++- unitstatushandler/unitstatushandler.go | 43 +++++-- .../unitstatushandler_internal_test.go | 113 ++++++++++++++---- unitstatushandler/unitstatushandler_test.go | 20 ++-- 4 files changed, 193 insertions(+), 53 deletions(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 48d3b659..5bb037be 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -58,6 +58,7 @@ type softwareStatusHandler interface { updateServiceStatus(status cloudprotocol.ServiceStatus) updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) setInstancesStatus(statuses []cloudprotocol.InstanceStatus) + getNodesStatus() ([]cloudprotocol.NodeStatus, error) } type softwareUpdate struct { @@ -72,6 +73,7 @@ type softwareUpdate struct { RunInstances []cloudprotocol.InstanceInfo `json:"runInstances,omitempty"` CertChains []cloudprotocol.CertificateChain `json:"certChains,omitempty"` Certs []cloudprotocol.Certificate `json:"certs,omitempty"` + NodesStatus []cloudprotocol.NodeStatus `json:"nodesStatus,omitempty"` } type softwareManager struct { @@ -80,6 +82,7 @@ type softwareManager struct { statusChannel chan cmserver.UpdateSOTAStatus + nodeManager NodeManager unitConfigUpdater UnitConfigUpdater downloader softwareDownloader statusHandler softwareStatusHandler @@ -107,7 +110,7 @@ type softwareManager struct { * Interface **********************************************************************************************************************/ -func newSoftwareManager(statusHandler softwareStatusHandler, downloader softwareDownloader, +func newSoftwareManager(statusHandler softwareStatusHandler, downloader softwareDownloader, nodeManager NodeManager, unitConfigUpdater UnitConfigUpdater, softwareUpdater SoftwareUpdater, instanceRunner InstanceRunner, storage Storage, defaultTTL time.Duration, ) (manager *softwareManager, err error) { @@ -115,6 +118,7 @@ func newSoftwareManager(statusHandler softwareStatusHandler, downloader software statusChannel: make(chan cmserver.UpdateSOTAStatus, 1), downloader: downloader, statusHandler: statusHandler, + nodeManager: nodeManager, unitConfigUpdater: unitConfigUpdater, softwareUpdater: softwareUpdater, instanceRunner: instanceRunner, @@ -242,6 +246,7 @@ func (manager *softwareManager) processDesiredStatus(desiredStatus cloudprotocol RemoveLayers: make([]cloudprotocol.LayerStatus, 0), RunInstances: desiredStatus.Instances, CertChains: desiredStatus.CertificateChains, Certs: desiredStatus.Certificates, + NodesStatus: make([]cloudprotocol.NodeStatus, 0), } allServices, err := manager.softwareUpdater.GetServicesStatus() @@ -256,10 +261,12 @@ func (manager *softwareManager) processDesiredStatus(desiredStatus cloudprotocol manager.processDesiredServices(update, allServices, desiredStatus.Services) manager.processDesiredLayers(update, allLayers, desiredStatus.Layers) + manager.processNodesStatus(update, desiredStatus.Nodes) if len(update.InstallServices) != 0 || len(update.RemoveServices) != 0 || len(update.InstallLayers) != 0 || len(update.RemoveLayers) != 0 || len(update.RestoreServices) != 0 || - len(update.RestoreLayers) != 0 || manager.needRunInstances(desiredStatus.Instances) || update.UnitConfig != nil { + len(update.RestoreLayers) != 0 || manager.needRunInstances(desiredStatus.Instances) || + update.UnitConfig != nil || len(update.NodesStatus) != 0 { if err := manager.newUpdate(update); err != nil { return aoserrors.Wrap(err) } @@ -347,6 +354,31 @@ removeLayersLoop: } } +func (manager *softwareManager) processNodesStatus( + update *softwareUpdate, desiredNodesStatus []cloudprotocol.NodeStatus, +) { + curNodesStatus, err := manager.statusHandler.getNodesStatus() + if err != nil { + log.Errorf("Can't get nodes status: %v", err) + return + } + +desiredNodesLoop: + for _, desiredNodeStatus := range desiredNodesStatus { + for _, curNodeStatus := range curNodesStatus { + if desiredNodeStatus.NodeID == curNodeStatus.NodeID { + if desiredNodeStatus.Status != curNodeStatus.Status { + update.NodesStatus = append(update.NodesStatus, desiredNodeStatus) + } + + goto desiredNodesLoop + } + } + + update.NodesStatus = append(update.NodesStatus, desiredNodeStatus) + } +} + func (manager *softwareManager) needRunInstances(desiredInstances []cloudprotocol.InstanceInfo) bool { currentIdents := make([]aostypes.InstanceIdent, len(manager.InstanceStatuses)) desiredIdents := []aostypes.InstanceIdent{} @@ -726,8 +758,12 @@ func (manager *softwareManager) update(ctx context.Context) { }() }() + if err := manager.updateNodes(); err != nil { + updateErr = err + } + if manager.CurrentUpdate.UnitConfig != nil { - if err := manager.updateUnitConfig(ctx); err != nil { + if err := manager.updateUnitConfig(); err != nil { updateErr = err } } @@ -1341,7 +1377,33 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr error return nil } -func (manager *softwareManager) updateUnitConfig(ctx context.Context) (unitConfigErr error) { +func (manager *softwareManager) updateNodes() (nodesErr error) { + log.Debug("Update nodes status") + + for _, nodeStatus := range manager.CurrentUpdate.NodesStatus { + if nodeStatus.Status == cloudprotocol.NodeStatusPaused { + if err := manager.nodeManager.PauseNode(nodeStatus.NodeID); err != nil && nodesErr == nil { + log.WithField("nodeID", nodeStatus.NodeID).Errorf("Can't pause node: %v", err) + + nodesErr = aoserrors.Wrap(err) + } + } + + if nodeStatus.Status == cloudprotocol.NodeStatusProvisioned { + log.WithField("nodeID", nodeStatus.NodeID).Debug("Resume node") + + if err := manager.nodeManager.ResumeNode(nodeStatus.NodeID); err != nil && nodesErr == nil { + log.WithField("nodeID", nodeStatus.NodeID).Errorf("Can't resume node: %v", err) + + nodesErr = aoserrors.Wrap(err) + } + } + } + + return nodesErr +} + +func (manager *softwareManager) updateUnitConfig() (unitConfigErr error) { log.Debug("Update unit config") defer func() { diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index f086c09b..1613f890 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -40,11 +40,13 @@ import ( * Types **********************************************************************************************************************/ -// NodeInfoProvider provides node info. -type NodeInfoProvider interface { +// NodeManager manages nodes. +type NodeManager interface { GetAllNodeIDs() ([]string, error) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo + PauseNode(nodeID string) error + ResumeNode(nodeID string) error } // Downloader downloads packages. @@ -125,8 +127,8 @@ type RunInstancesStatus struct { type Instance struct { sync.Mutex - nodeInfoProvider NodeInfoProvider - statusSender StatusSender + nodeManager NodeManager + statusSender StatusSender statusMutex sync.Mutex @@ -167,7 +169,7 @@ type itemStatus []statusDescriptor // New creates new unit status handler instance. func New( cfg *config.Config, - nodeInfoProvider NodeInfoProvider, + nodeManager NodeManager, unitConfigUpdater UnitConfigUpdater, firmwareUpdater FirmwareUpdater, softwareUpdater SoftwareUpdater, @@ -179,11 +181,11 @@ func New( log.Debug("Create unit status handler") instance = &Instance{ - nodeInfoProvider: nodeInfoProvider, + nodeManager: nodeManager, statusSender: statusSender, sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, newComponentsChannel: firmwareUpdater.NewComponentsChannel(), - nodeChangedChannel: nodeInfoProvider.SubscribeNodeInfoChange(), + nodeChangedChannel: nodeManager.SubscribeNodeInfoChange(), } // Initialize maps of statuses for avoiding situation of adding values to uninitialized map on go routine @@ -198,8 +200,8 @@ func New( return nil, aoserrors.Wrap(err) } - if instance.softwareManager, err = newSoftwareManager(instance, groupDownloader, unitConfigUpdater, softwareUpdater, - instanceRunner, storage, cfg.SMController.UpdateTTL.Duration); err != nil { + if instance.softwareManager, err = newSoftwareManager(instance, groupDownloader, nodeManager, unitConfigUpdater, + softwareUpdater, instanceRunner, storage, cfg.SMController.UpdateTTL.Duration); err != nil { return nil, aoserrors.Wrap(err) } @@ -590,7 +592,7 @@ func (instance *Instance) updateInstanceStatus(status []cloudprotocol.InstanceSt newStatuses := []cloudprotocol.InstanceStatus{} -foundloop: +foundLoop: for _, instanceStatus := range status { for i := range instance.unitStatus.instances { if instanceStatus.InstanceIdent == instance.unitStatus.instances[i].InstanceIdent && @@ -608,7 +610,7 @@ foundloop: instance.unitStatus.instances[i].RunState = instanceStatus.RunState instance.unitStatus.instances[i].ErrorInfo = instanceStatus.ErrorInfo - continue foundloop + continue foundLoop } } @@ -757,7 +759,7 @@ func (instance *Instance) sendCurrentStatus() { } func (instance *Instance) getAllNodesInfo() ([]cloudprotocol.NodeInfo, error) { - nodeIDs, err := instance.nodeInfoProvider.GetAllNodeIDs() + nodeIDs, err := instance.nodeManager.GetAllNodeIDs() if err != nil { return nil, aoserrors.Wrap(err) } @@ -765,7 +767,7 @@ func (instance *Instance) getAllNodesInfo() ([]cloudprotocol.NodeInfo, error) { nodesInfo := make([]cloudprotocol.NodeInfo, 0, len(nodeIDs)) for _, nodeID := range nodeIDs { - nodeInfo, err := instance.nodeInfoProvider.GetNodeInfo(nodeID) + nodeInfo, err := instance.nodeManager.GetNodeInfo(nodeID) if err != nil { log.WithField("nodeID", nodeID).Errorf("Can't get node info: %s", err) continue @@ -777,6 +779,21 @@ func (instance *Instance) getAllNodesInfo() ([]cloudprotocol.NodeInfo, error) { return nodesInfo, nil } +func (instance *Instance) getNodesStatus() ([]cloudprotocol.NodeStatus, error) { + nodesInfo, err := instance.getAllNodesInfo() + if err != nil { + return nil, err + } + + nodesStatus := make([]cloudprotocol.NodeStatus, 0, len(nodesInfo)) + + for _, nodeInfo := range nodesInfo { + nodesStatus = append(nodesStatus, cloudprotocol.NodeStatus{NodeID: nodeInfo.NodeID, Status: nodeInfo.Status}) + } + + return nodesStatus, nil +} + func (instance *Instance) handleChannels() { for { select { diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 653e1666..d1273148 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -53,8 +53,8 @@ const waitStatusTimeout = 5 * time.Second * Types **********************************************************************************************************************/ -type TestNodeInfoProvider struct { - nodesInfo map[string]cloudprotocol.NodeInfo +type TestNodeManager struct { + nodesInfo map[string]*cloudprotocol.NodeInfo nodeInfoChannel chan cloudprotocol.NodeInfo } @@ -1221,8 +1221,27 @@ func TestSoftwareManager(t *testing.T) { {State: cmserver.NoUpdate, Error: &cloudprotocol.ErrorInfo{Message: "update timeout"}}, }, }, + { + testID: "update node status", + initStatus: &cmserver.UpdateStatus{State: cmserver.NoUpdate}, + desiredStatus: &cloudprotocol.DesiredStatus{ + Nodes: []cloudprotocol.NodeStatus{ + {NodeID: "node1", Status: cloudprotocol.NodeStatusPaused}, + {NodeID: "node2", Status: cloudprotocol.NodeStatusPaused}, + }, + }, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, + }, } + nodeManager := NewTestNodeManager([]cloudprotocol.NodeInfo{ + {NodeID: "node1", NodeType: "type1", Status: cloudprotocol.NodeStatusProvisioned}, + {NodeID: "node2", NodeType: "type2", Status: cloudprotocol.NodeStatusProvisioned}, + }) unitConfigUpdater := NewTestUnitConfigUpdater(cloudprotocol.UnitConfigStatus{}) softwareUpdater := NewTestSoftwareUpdater(nil, nil) instanceRunner := NewTestInstanceRunner() @@ -1247,8 +1266,8 @@ func TestSoftwareManager(t *testing.T) { // Create software manager - softwareManager, err := newSoftwareManager(newTestStatusHandler(), softwareDownloader, unitConfigUpdater, - softwareUpdater, instanceRunner, testStorage, 30*time.Second) + softwareManager, err := newSoftwareManager(newTestStatusHandler(), softwareDownloader, nodeManager, + unitConfigUpdater, softwareUpdater, instanceRunner, testStorage, 30*time.Second) if err != nil { t.Errorf("Can't create software manager: %s", err) continue @@ -1307,6 +1326,19 @@ func TestSoftwareManager(t *testing.T) { } } + if item.desiredStatus != nil && item.desiredStatus.Nodes != nil { + for _, nodeStatus := range item.desiredStatus.Nodes { + nodeInfo, err := nodeManager.GetNodeInfo(nodeStatus.NodeID) + if err != nil { + t.Errorf("Get node info error: %v", err) + } + + if nodeInfo.Status != nodeStatus.Status { + t.Errorf("Wrong node status: %v", nodeInfo.Status) + } + } + } + closeSM: // Close software manager @@ -1575,64 +1607,89 @@ func TestSyncExecutor(t *testing.T) { **********************************************************************************************************************/ /*********************************************************************************************************************** - * TestNodeInfoProvider + * TestNodeManager **********************************************************************************************************************/ -func NewTestNodeInfoProvider(nodesInfo []cloudprotocol.NodeInfo) *TestNodeInfoProvider { - nodesInfoMap := make(map[string]cloudprotocol.NodeInfo) +func NewTestNodeManager(nodesInfo []cloudprotocol.NodeInfo) *TestNodeManager { + nodesInfoMap := make(map[string]*cloudprotocol.NodeInfo) for _, nodeInfo := range nodesInfo { - nodesInfoMap[nodeInfo.NodeID] = nodeInfo + nodesInfoMap[nodeInfo.NodeID] = &cloudprotocol.NodeInfo{} + *nodesInfoMap[nodeInfo.NodeID] = nodeInfo } - return &TestNodeInfoProvider{ + return &TestNodeManager{ nodesInfo: nodesInfoMap, } } -func (provider *TestNodeInfoProvider) GetAllNodeIDs() ([]string, error) { - nodeIDs := make([]string, 0, len(provider.nodesInfo)) +func (manager *TestNodeManager) GetAllNodeIDs() ([]string, error) { + nodeIDs := make([]string, 0, len(manager.nodesInfo)) - for nodeID := range provider.nodesInfo { + for nodeID := range manager.nodesInfo { nodeIDs = append(nodeIDs, nodeID) } return nodeIDs, nil } -func (provider *TestNodeInfoProvider) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) { - nodeInfo, ok := provider.nodesInfo[nodeID] +func (manager *TestNodeManager) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) { + nodeInfo, ok := manager.nodesInfo[nodeID] if !ok { return cloudprotocol.NodeInfo{}, aoserrors.New("node not found") } - return nodeInfo, nil + return *nodeInfo, nil } -func (provider *TestNodeInfoProvider) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { - provider.nodeInfoChannel = make(chan cloudprotocol.NodeInfo, 1) +func (manager *TestNodeManager) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { + manager.nodeInfoChannel = make(chan cloudprotocol.NodeInfo, 1) - return provider.nodeInfoChannel + return manager.nodeInfoChannel } -func (provider *TestNodeInfoProvider) NodeInfoChanged(nodeInfo cloudprotocol.NodeInfo) { - provider.nodesInfo[nodeInfo.NodeID] = nodeInfo +func (manager *TestNodeManager) NodeInfoChanged(nodeInfo cloudprotocol.NodeInfo) { + if _, ok := manager.nodesInfo[nodeInfo.NodeID]; !ok { + manager.nodesInfo[nodeInfo.NodeID] = &cloudprotocol.NodeInfo{} + } + + *manager.nodesInfo[nodeInfo.NodeID] = nodeInfo - if provider.nodeInfoChannel != nil { - provider.nodeInfoChannel <- nodeInfo + if manager.nodeInfoChannel != nil { + manager.nodeInfoChannel <- nodeInfo } } -func (provider *TestNodeInfoProvider) GetAllNodesInfo() []cloudprotocol.NodeInfo { - nodesInfo := make([]cloudprotocol.NodeInfo, 0, len(provider.nodesInfo)) +func (manager *TestNodeManager) GetAllNodesInfo() []cloudprotocol.NodeInfo { + nodesInfo := make([]cloudprotocol.NodeInfo, 0, len(manager.nodesInfo)) - for _, nodeInfo := range provider.nodesInfo { - nodesInfo = append(nodesInfo, nodeInfo) + for _, nodeInfo := range manager.nodesInfo { + nodesInfo = append(nodesInfo, *nodeInfo) } return nodesInfo } +func (manager *TestNodeManager) PauseNode(nodeID string) error { + if _, ok := manager.nodesInfo[nodeID]; !ok { + return aoserrors.New("node not found") + } + + manager.nodesInfo[nodeID].Status = cloudprotocol.NodeStatusPaused + + return nil +} + +func (manager *TestNodeManager) ResumeNode(nodeID string) error { + if _, ok := manager.nodesInfo[nodeID]; !ok { + return aoserrors.New("node not found") + } + + manager.nodesInfo[nodeID].Status = cloudprotocol.NodeStatusProvisioned + + return nil +} + /*********************************************************************************************************************** * TestSender **********************************************************************************************************************/ @@ -1974,6 +2031,10 @@ func (statusHandler *testStatusHandler) setInstancesStatus(statuses []cloudproto } } +func (statusHandler *testStatusHandler) getNodesStatus() ([]cloudprotocol.NodeStatus, error) { + return []cloudprotocol.NodeStatus{}, nil +} + /*********************************************************************************************************************** * testStorage **********************************************************************************************************************/ diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 134c521d..3a8a4d7a 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -110,7 +110,7 @@ func TestSendInitialStatus(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -158,7 +158,7 @@ func TestUpdateUnitConfig(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -252,7 +252,7 @@ func TestUpdateComponents(t *testing.T) { instanceRunner := unitstatushandler.NewTestInstanceRunner() sender := unitstatushandler.NewTestSender() - statusHandler, err := unitstatushandler.New(cfg, unitstatushandler.NewTestNodeInfoProvider(nil), + statusHandler, err := unitstatushandler.New(cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { @@ -359,7 +359,7 @@ func TestUpdateLayers(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -516,7 +516,7 @@ func TestUpdateServices(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -663,7 +663,7 @@ func TestRunInstances(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) @@ -786,7 +786,7 @@ func TestUpdateInstancesStatus(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) @@ -903,7 +903,7 @@ func TestUpdateCachedSOTA(t *testing.T) { downloader := unitstatushandler.NewTestDownloader() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, downloader, unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) @@ -1017,7 +1017,7 @@ func TestNewComponents(t *testing.T) { sender := unitstatushandler.NewTestSender() statusHandler, err := unitstatushandler.New( - cfg, unitstatushandler.NewTestNodeInfoProvider(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) @@ -1087,7 +1087,7 @@ func TestNodeInfoChanged(t *testing.T) { softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() sender := unitstatushandler.NewTestSender() - nodeInfoProvider := unitstatushandler.NewTestNodeInfoProvider([]cloudprotocol.NodeInfo{ + nodeInfoProvider := unitstatushandler.NewTestNodeManager([]cloudprotocol.NodeInfo{ {NodeID: "node1", NodeType: "type1", Status: cloudprotocol.NodeStatusProvisioned}, {NodeID: "node2", NodeType: "type2", Status: cloudprotocol.NodeStatusProvisioned}, }) From 861bb30b7554f693f0cf2ec5385fdeaa6c2c1e2e Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 16 Jul 2024 12:48:41 +0300 Subject: [PATCH 062/146] [unitstatushandler] Schedule rebalancing on system quota alert Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 105 +++++++++++++----- unitstatushandler/unitstatushandler.go | 40 +++++-- .../unitstatushandler_internal_test.go | 73 +++++++++++- unitstatushandler/unitstatushandler_test.go | 29 +++-- 4 files changed, 197 insertions(+), 50 deletions(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 5bb037be..a0dbdb07 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -62,18 +62,19 @@ type softwareStatusHandler interface { } type softwareUpdate struct { - Schedule cloudprotocol.ScheduleRule `json:"schedule,omitempty"` - UnitConfig *cloudprotocol.UnitConfig `json:"unitConfig,omitempty"` - InstallServices []cloudprotocol.ServiceInfo `json:"installServices,omitempty"` - RemoveServices []cloudprotocol.ServiceStatus `json:"removeServices,omitempty"` - RestoreServices []cloudprotocol.ServiceInfo `json:"restoreServices,omitempty"` - InstallLayers []cloudprotocol.LayerInfo `json:"installLayers,omitempty"` - RemoveLayers []cloudprotocol.LayerStatus `json:"removeLayers,omitempty"` - RestoreLayers []cloudprotocol.LayerStatus `json:"restoreLayers,omitempty"` - RunInstances []cloudprotocol.InstanceInfo `json:"runInstances,omitempty"` - CertChains []cloudprotocol.CertificateChain `json:"certChains,omitempty"` - Certs []cloudprotocol.Certificate `json:"certs,omitempty"` - NodesStatus []cloudprotocol.NodeStatus `json:"nodesStatus,omitempty"` + Schedule cloudprotocol.ScheduleRule `json:"schedule,omitempty"` + UnitConfig *cloudprotocol.UnitConfig `json:"unitConfig,omitempty"` + InstallServices []cloudprotocol.ServiceInfo `json:"installServices,omitempty"` + RemoveServices []cloudprotocol.ServiceStatus `json:"removeServices,omitempty"` + RestoreServices []cloudprotocol.ServiceInfo `json:"restoreServices,omitempty"` + InstallLayers []cloudprotocol.LayerInfo `json:"installLayers,omitempty"` + RemoveLayers []cloudprotocol.LayerStatus `json:"removeLayers,omitempty"` + RestoreLayers []cloudprotocol.LayerStatus `json:"restoreLayers,omitempty"` + RunInstances []cloudprotocol.InstanceInfo `json:"runInstances,omitempty"` + CertChains []cloudprotocol.CertificateChain `json:"certChains,omitempty"` + Certs []cloudprotocol.Certificate `json:"certs,omitempty"` + NodesStatus []cloudprotocol.NodeStatus `json:"nodesStatus,omitempty"` + RebalanceRequest bool `json:"rebalanceRequest,omitempty"` } type softwareManager struct { @@ -175,13 +176,14 @@ func (manager *softwareManager) close() (err error) { func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTAStatus) { status.State = convertState(manager.CurrentState) - status.Error = manager.UpdateErr if status.State == cmserver.NoUpdate || manager.CurrentUpdate == nil { return status } + status.RebalanceRequest = manager.CurrentUpdate.RebalanceRequest + for _, layer := range manager.CurrentUpdate.InstallLayers { status.InstallLayers = append(status.InstallLayers, cloudprotocol.LayerStatus{ LayerID: layer.LayerID, Digest: layer.Digest, Version: layer.Version, @@ -277,6 +279,34 @@ func (manager *softwareManager) processDesiredStatus(desiredStatus cloudprotocol return nil } +func (manager *softwareManager) requestRebalancing() error { + manager.Lock() + defer manager.Unlock() + + log.Debug("Request rebalancing") + + if manager.CurrentUpdate == nil || len(manager.CurrentUpdate.RunInstances) == 0 { + return aoserrors.New("no previous update") + } + + update := &softwareUpdate{ + Schedule: manager.CurrentUpdate.Schedule, + InstallServices: make([]cloudprotocol.ServiceInfo, 0), + RemoveServices: make([]cloudprotocol.ServiceStatus, 0), + InstallLayers: make([]cloudprotocol.LayerInfo, 0), + RemoveLayers: make([]cloudprotocol.LayerStatus, 0), + RunInstances: manager.CurrentUpdate.RunInstances, + NodesStatus: make([]cloudprotocol.NodeStatus, 0), + RebalanceRequest: true, + } + + if err := manager.newUpdate(update); err != nil { + return err + } + + return nil +} + func (manager *softwareManager) processDesiredServices( update *softwareUpdate, allServices []ServiceStatus, desiredServices []cloudprotocol.ServiceInfo, ) { @@ -846,18 +876,23 @@ func (manager *softwareManager) newUpdate(update *softwareUpdate) (err error) { } default: - if reflect.DeepEqual(update.UnitConfig, manager.CurrentUpdate.UnitConfig) && - reflect.DeepEqual(update.InstallLayers, manager.CurrentUpdate.InstallLayers) && - reflect.DeepEqual(update.RemoveLayers, manager.CurrentUpdate.RemoveLayers) && - reflect.DeepEqual(update.InstallServices, manager.CurrentUpdate.InstallServices) && - reflect.DeepEqual(update.RemoveServices, manager.CurrentUpdate.RemoveServices) && - reflect.DeepEqual(update.RunInstances, manager.CurrentUpdate.RunInstances) && - reflect.DeepEqual(update.RestoreServices, manager.CurrentUpdate.RestoreServices) && - reflect.DeepEqual(update.RestoreLayers, manager.CurrentUpdate.RestoreLayers) { + if manager.isUpdateEquals(update) { + if update.RebalanceRequest { + log.Debug("Skip rebalancing during update") + + return nil + } + if reflect.DeepEqual(update.Schedule, manager.CurrentUpdate.Schedule) { + log.Debug("Skip update without changes") + return nil } + if update.RebalanceRequest { + log.Debug("Skip rebalancing") + } + // Schedule changed: in ready to update state we can reschedule update. Except current update is forced type, // because in this case force update is already scheduled if manager.CurrentState == stateReadyToUpdate && (manager.CurrentUpdate.Schedule.Type != cloudprotocol.ForceUpdate) { @@ -1345,12 +1380,8 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr error for _, instance := range manager.CurrentUpdate.RunInstances { var version string - for _, serviceInfo := range manager.CurrentUpdate.InstallServices { - if serviceInfo.ServiceID == instance.ServiceID { - version = serviceInfo.Version - - break - } + if serviceInfo, ok := manager.ServiceStatuses[instance.ServiceID]; ok { + version = serviceInfo.Version } ident := aostypes.InstanceIdent{ @@ -1378,10 +1409,10 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr error } func (manager *softwareManager) updateNodes() (nodesErr error) { - log.Debug("Update nodes status") - for _, nodeStatus := range manager.CurrentUpdate.NodesStatus { if nodeStatus.Status == cloudprotocol.NodeStatusPaused { + log.WithField("nodeID", nodeStatus.NodeID).Debug("Pause node") + if err := manager.nodeManager.PauseNode(nodeStatus.NodeID); err != nil && nodesErr == nil { log.WithField("nodeID", nodeStatus.NodeID).Errorf("Can't pause node: %v", err) @@ -1455,3 +1486,19 @@ func (manager *softwareManager) isDownloadRequired() bool { return false } + +func (manager *softwareManager) isUpdateEquals(update *softwareUpdate) bool { + if reflect.DeepEqual(update.NodesStatus, manager.CurrentUpdate.NodesStatus) && + reflect.DeepEqual(update.UnitConfig, manager.CurrentUpdate.UnitConfig) && + reflect.DeepEqual(update.InstallLayers, manager.CurrentUpdate.InstallLayers) && + reflect.DeepEqual(update.RemoveLayers, manager.CurrentUpdate.RemoveLayers) && + reflect.DeepEqual(update.InstallServices, manager.CurrentUpdate.InstallServices) && + reflect.DeepEqual(update.RemoveServices, manager.CurrentUpdate.RemoveServices) && + reflect.DeepEqual(update.RunInstances, manager.CurrentUpdate.RunInstances) && + reflect.DeepEqual(update.RestoreServices, manager.CurrentUpdate.RestoreServices) && + reflect.DeepEqual(update.RestoreLayers, manager.CurrentUpdate.RestoreLayers) { + return true + } + + return false +} diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 1613f890..6a8c4e34 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -28,6 +28,7 @@ import ( "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" + "github.com/aosedge/aos_common/resourcemonitor" log "github.com/sirupsen/logrus" "github.com/aosedge/aos_communicationmanager/amqphandler" @@ -82,6 +83,11 @@ type InstanceRunner interface { RunInstances(instances []cloudprotocol.InstanceInfo, newServices []string) error } +// SystemQuotaAlertProvider provides system quota alerts. +type SystemQuotaAlertProvider interface { + GetSystemQuoteAlertChannel() <-chan cloudprotocol.SystemQuotaAlert +} + // SoftwareUpdater updates services, layers. type SoftwareUpdater interface { GetServicesStatus() ([]ServiceStatus, error) @@ -139,8 +145,9 @@ type Instance struct { firmwareManager *firmwareManager softwareManager *softwareManager - newComponentsChannel <-chan []cloudprotocol.ComponentStatus - nodeChangedChannel <-chan cloudprotocol.NodeInfo + newComponentsChannel <-chan []cloudprotocol.ComponentStatus + nodeChangedChannel <-chan cloudprotocol.NodeInfo + systemQuotaAlertChannel <-chan cloudprotocol.SystemQuotaAlert initDone bool isConnected int32 @@ -177,15 +184,17 @@ func New( downloader Downloader, storage Storage, statusSender StatusSender, + systemQuotaAlertProvider SystemQuotaAlertProvider, ) (instance *Instance, err error) { log.Debug("Create unit status handler") instance = &Instance{ - nodeManager: nodeManager, - statusSender: statusSender, - sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, - newComponentsChannel: firmwareUpdater.NewComponentsChannel(), - nodeChangedChannel: nodeManager.SubscribeNodeInfoChange(), + nodeManager: nodeManager, + statusSender: statusSender, + sendStatusPeriod: cfg.UnitStatusSendTimeout.Duration, + newComponentsChannel: firmwareUpdater.NewComponentsChannel(), + nodeChangedChannel: nodeManager.SubscribeNodeInfoChange(), + systemQuotaAlertChannel: systemQuotaAlertProvider.GetSystemQuoteAlertChannel(), } // Initialize maps of statuses for avoiding situation of adding values to uninitialized map on go routine @@ -812,6 +821,23 @@ func (instance *Instance) handleChannels() { } instance.updateNodeInfo(nodeInfo) + + case systemQuotaAlert, ok := <-instance.systemQuotaAlertChannel: + if !ok { + return + } + + if systemQuotaAlert.Status == resourcemonitor.AlertStatusFall { + return + } + + rebalancingParameters := []string{"cpu", "ram"} + + if slices.Contains(rebalancingParameters, systemQuotaAlert.Parameter) { + if err := instance.softwareManager.requestRebalancing(); err != nil { + log.Errorf("Can't perform rebalancing: %v", err) + } + } } } } diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index d1273148..5056fc6a 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -88,6 +88,10 @@ type TestInstanceRunner struct { newServices []string } +type TestSystemQuotaAlertProvider struct { + alertsChannel chan cloudprotocol.SystemQuotaAlert +} + type TestDownloader struct { DownloadTime time.Duration DownloadedURLs []string @@ -921,29 +925,30 @@ func TestSoftwareManager(t *testing.T) { updateError error updateWaitStatuses []cmserver.UpdateStatus newServices []string + requestRebalancing bool } updateLayers := []cloudprotocol.LayerInfo{ { LayerID: "layer1", Digest: "digest1", - Version: "1.0", + Version: "1.0.0", }, { LayerID: "layer2", Digest: "digest2", - Version: "2.0", + Version: "2.0.0", }, } updateServices := []cloudprotocol.ServiceInfo{ { ServiceID: "service1", - Version: "1.0", + Version: "1.0.0", }, { ServiceID: "service2", - Version: "2.0", + Version: "2.0.0", }, } @@ -1236,6 +1241,44 @@ func TestSoftwareManager(t *testing.T) { {State: cmserver.NoUpdate}, }, }, + { + testID: "rebalancing request", + initState: &softwareManager{ + CurrentState: stateNoUpdate, + CurrentUpdate: &softwareUpdate{ + RunInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: "service1", SubjectID: "subject1", NumInstances: 1}, + {ServiceID: "service2", SubjectID: "subject2", NumInstances: 1}, + }, + }, + ServiceStatuses: map[string]*cloudprotocol.ServiceStatus{ + "service1": {ServiceID: "service1", Version: "1.0.0"}, + "service2": {ServiceID: "service2", Version: "2.0.0"}, + }, + }, + initServices: []ServiceStatus{ + { + ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: updateServices[0].ServiceID, + Version: updateServices[0].Version, + Status: cloudprotocol.InstalledStatus, + }, + }, + { + ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: updateServices[1].ServiceID, + Version: updateServices[1].Version, + Status: cloudprotocol.InstalledStatus, + }, + }, + }, + updateWaitStatuses: []cmserver.UpdateStatus{ + {State: cmserver.ReadyToUpdate}, + {State: cmserver.Updating}, + {State: cmserver.NoUpdate}, + }, + requestRebalancing: true, + }, } nodeManager := NewTestNodeManager([]cloudprotocol.NodeInfo{ @@ -1298,6 +1341,12 @@ func TestSoftwareManager(t *testing.T) { } } + if item.requestRebalancing { + if err = softwareManager.requestRebalancing(); err != nil { + t.Errorf("Rebalancing failed: %s", err) + } + } + for _, expectedStatus := range item.updateWaitStatuses { if expectedStatus.State == cmserver.Updating { if _, err := instanceRunner.WaitForRunInstance(time.Second); err != nil { @@ -1840,6 +1889,22 @@ func (runner *TestInstanceRunner) WaitForRunInstance(timeout time.Duration) ([]c } } +/*********************************************************************************************************************** + * TestSystemQuotaAlertProvider + **********************************************************************************************************************/ + +func NewTestSystemQuotaAlertProvider() *TestSystemQuotaAlertProvider { + return &TestSystemQuotaAlertProvider{alertsChannel: make(chan cloudprotocol.SystemQuotaAlert, 1)} +} + +func (provider *TestSystemQuotaAlertProvider) GetSystemQuoteAlertChannel() <-chan cloudprotocol.SystemQuotaAlert { + return provider.alertsChannel +} + +func (provider *TestSystemQuotaAlertProvider) SendSystemQuotaAlert(alert cloudprotocol.SystemQuotaAlert) { + provider.alertsChannel <- alert +} + /*********************************************************************************************************************** * TestDownloader **********************************************************************************************************************/ diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 3a8a4d7a..07ca1966 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -111,7 +111,8 @@ func TestSendInitialStatus(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -159,7 +160,8 @@ func TestUpdateUnitConfig(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, fotaUpdater, sotaUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -254,7 +256,7 @@ func TestUpdateComponents(t *testing.T) { statusHandler, err := unitstatushandler.New(cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, instanceRunner, unitstatushandler.NewTestDownloader(), - unitstatushandler.NewTestStorage(), sender) + unitstatushandler.NewTestStorage(), sender, unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -360,7 +362,8 @@ func TestUpdateLayers(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -517,7 +520,8 @@ func TestUpdateServices(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -664,7 +668,8 @@ func TestRunInstances(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) } @@ -787,7 +792,8 @@ func TestUpdateInstancesStatus(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) } @@ -904,7 +910,8 @@ func TestUpdateCachedSOTA(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, downloader, unitstatushandler.NewTestStorage(), sender) + instanceRunner, downloader, unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %s", err) } @@ -1018,7 +1025,8 @@ func TestNewComponents(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) } @@ -1094,7 +1102,8 @@ func TestNodeInfoChanged(t *testing.T) { statusHandler, err := unitstatushandler.New( cfg, nodeInfoProvider, unitConfigUpdater, firmwareUpdater, softwareUpdater, - instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender) + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) if err != nil { t.Fatalf("Can't create unit status handler: %v", err) } From 0d0b2348f33eb05a1000b09f27e065fc33fca7bb Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 16 Jul 2024 12:49:40 +0300 Subject: [PATCH 063/146] [cmserver] Add missing rebalance request field Signed-off-by: Oleksandr Grytsov --- cmserver/cmserver.go | 16 +++++++++------- cmserver/cmserver_test.go | 9 +++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cmserver/cmserver.go b/cmserver/cmserver.go index 73da6d18..ac0af917 100644 --- a/cmserver/cmserver.go +++ b/cmserver/cmserver.go @@ -73,11 +73,12 @@ type UpdateFOTAStatus struct { // UpdateSOTAStatus SOTA update status for update scheduler service. type UpdateSOTAStatus struct { - UnitConfig *cloudprotocol.UnitConfigStatus - InstallServices []cloudprotocol.ServiceStatus - RemoveServices []cloudprotocol.ServiceStatus - InstallLayers []cloudprotocol.LayerStatus - RemoveLayers []cloudprotocol.LayerStatus + UnitConfig *cloudprotocol.UnitConfigStatus + InstallServices []cloudprotocol.ServiceStatus + RemoveServices []cloudprotocol.ServiceStatus + InstallLayers []cloudprotocol.LayerStatus + RemoveLayers []cloudprotocol.LayerStatus + RebalanceRequest bool UpdateStatus } @@ -318,8 +319,9 @@ func (server *CMServer) notifyAllClients(notification *pb.SchedulerNotifications func (updateStatus *UpdateSOTAStatus) convertToPBStatus() (pbStatus *pb.UpdateSOTAStatus) { pbStatus = &pb.UpdateSOTAStatus{ - Error: pbconvert.ErrorInfoToPB(updateStatus.Error), - State: updateStatus.State.getPbState(), + Error: pbconvert.ErrorInfoToPB(updateStatus.Error), + State: updateStatus.State.getPbState(), + RebalanceRequest: updateStatus.RebalanceRequest, } if updateStatus.UnitConfig != nil { diff --git a/cmserver/cmserver_test.go b/cmserver/cmserver_test.go index 6d7157a2..71fd72cb 100644 --- a/cmserver/cmserver_test.go +++ b/cmserver/cmserver_test.go @@ -177,6 +177,7 @@ func TestConnection(t *testing.T) { UpdateStatus: cmserver.UpdateStatus{State: cmserver.Downloading, Error: &cloudprotocol.ErrorInfo{ Message: "SOTA error", }}, + RebalanceRequest: true, } unitStatusHandler.sotaChannel <- statusNotification @@ -216,7 +217,7 @@ func TestConnection(t *testing.T) { } if sotaStatus.GetInstallServices()[0].GetVersion() != "1.0.0" { - t.Error("Incorrect service aos version") + t.Error("Incorrect service version") } if len(sotaStatus.GetInstallLayers()) != 1 { @@ -232,7 +233,11 @@ func TestConnection(t *testing.T) { } if sotaStatus.GetInstallLayers()[0].GetVersion() != "3.0.0" { - t.Error("Incorrect layer aos version") + t.Error("Incorrect layer version") + } + + if sotaStatus.GetRebalanceRequest() != true { + t.Error("Incorrect rebalance request") } if _, err := client.pbclient.StartFOTAUpdate(ctx, &emptypb.Empty{}); err != nil { From ab931cd85ed49c0fc814e193778ec9ccc01b26a8 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 16 Jul 2024 12:51:15 +0300 Subject: [PATCH 064/146] [smcontroller] Rename GetSystemLimitAlertChannel Rename GetSystemLimitAlertChannel to GetSystemQuotaAlertChannel. Signed-off-by: Oleksandr Grytsov --- smcontroller/smcontroller.go | 12 ++++++------ smcontroller/smcontroller_test.go | 2 +- smcontroller/smhandler.go | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 553f13b3..0c050147 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -63,7 +63,7 @@ type Controller struct { monitoringSender MonitoringSender updateInstancesStatusChan chan []cloudprotocol.InstanceStatus runInstancesStatusChan chan launcher.NodeRunInstanceStatus - systemLimitAlertChan chan cloudprotocol.SystemQuotaAlert + systemQuotaAlertChan chan cloudprotocol.SystemQuotaAlert nodeConfigStatusChan chan unitconfig.NodeConfigStatus isCloudConnected bool @@ -113,7 +113,7 @@ func New( monitoringSender: monitoringSender, runInstancesStatusChan: make(chan launcher.NodeRunInstanceStatus, statusChanSize), updateInstancesStatusChan: make(chan []cloudprotocol.InstanceStatus, statusChanSize), - systemLimitAlertChan: make(chan cloudprotocol.SystemQuotaAlert, statusChanSize), + systemQuotaAlertChan: make(chan cloudprotocol.SystemQuotaAlert, statusChanSize), nodeConfigStatusChan: make(chan unitconfig.NodeConfigStatus, statusChanSize), nodes: make(map[string]*smHandler), } @@ -313,9 +313,9 @@ func (controller *Controller) GetRunInstancesStatusChannel() <-chan launcher.Nod return controller.runInstancesStatusChan } -// GetSystemLimitAlertChannel returns channel with alerts about RAM, CPU system limits. -func (controller *Controller) GetSystemLimitAlertChannel() <-chan cloudprotocol.SystemQuotaAlert { - return controller.systemLimitAlertChan +// GetSystemQuoteAlertChannel returns channel with alerts about RAM, CPU system limits. +func (controller *Controller) GetSystemQuoteAlertChannel() <-chan cloudprotocol.SystemQuotaAlert { + return controller.systemQuotaAlertChan } // RegisterSM registers new SM client connection. @@ -353,7 +353,7 @@ func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) e handler, err = newSMHandler(stream, controller.messageSender, controller.alertSender, controller.monitoringSender, controller.runInstancesStatusChan, controller.updateInstancesStatusChan, - controller.systemLimitAlertChan) + controller.systemQuotaAlertChan) if err != nil { log.Errorf("Can't crate SM handler: %v", err) diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 3eba98de..125ce36e 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -502,7 +502,7 @@ func TestSMAlertNotifications(t *testing.T) { } for _, limitAlert := range expectedSystemLimitAlert { - if err := waitMessage(controller.GetSystemLimitAlertChannel(), limitAlert, messageTimeout); err != nil { + if err := waitMessage(controller.GetSystemQuoteAlertChannel(), limitAlert, messageTimeout); err != nil { t.Errorf("Incorrect system limit alert: %v", err) } } diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 1f495272..31dd59f4 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -57,7 +57,7 @@ type smHandler struct { nodeConfigStatus unitconfig.NodeConfigStatus runStatusCh chan<- launcher.NodeRunInstanceStatus updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus - systemLimitAlertCh chan<- cloudprotocol.SystemQuotaAlert + systemQuotasAlertCh chan<- cloudprotocol.SystemQuotaAlert } /*********************************************************************************************************************** @@ -68,7 +68,7 @@ func newSMHandler( stream pb.SMService_RegisterSMServer, messageSender MessageSender, alertSender AlertSender, monitoringSender MonitoringSender, runStatusCh chan<- launcher.NodeRunInstanceStatus, updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus, - systemLimitAlertCh chan<- cloudprotocol.SystemQuotaAlert, + systemQuotasAlertCh chan<- cloudprotocol.SystemQuotaAlert, ) (*smHandler, error) { handler := smHandler{ stream: stream, @@ -78,7 +78,7 @@ func newSMHandler( syncstream: syncstream.New(), runStatusCh: runStatusCh, updateInstanceStatusCh: updateInstanceStatusCh, - systemLimitAlertCh: systemLimitAlertCh, + systemQuotasAlertCh: systemQuotasAlertCh, } return &handler, nil @@ -463,7 +463,7 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { resourceValidate := cloudprotocol.ResourceValidateAlert{ Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), NodeID: handler.nodeConfigStatus.NodeID, - Name: data.ResourceValidateAlert.Name, + Name: data.ResourceValidateAlert.GetName(), } for i, error := range data.ResourceValidateAlert.GetErrors() { @@ -488,7 +488,7 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { Status: data.SystemQuotaAlert.GetStatus(), } - handler.systemLimitAlertCh <- alertPayload + handler.systemQuotasAlertCh <- alertPayload if alertPayload.Status != resourcemonitor.AlertStatusRaise { return From cadef06913cc310adf40ea56c1441b0f69251719 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 16 Jul 2024 12:56:06 +0300 Subject: [PATCH 065/146] [launcher] Remove rebalancing functionality Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 123 ------- launcher/launcher_test.go | 700 -------------------------------------- 2 files changed, 823 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 60b408ca..f69f7ed6 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -131,7 +131,6 @@ type NodeManager interface { forceRestart bool, ) error GetRunInstancesStatusChannel() <-chan NodeRunInstanceStatus - GetSystemLimitAlertChannel() <-chan cloudprotocol.SystemQuotaAlert GetAverageMonitoring(nodeID string) (aostypes.NodeMonitoring, error) } @@ -265,23 +264,6 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, n return launcher.sendRunInstances(false) } -// RestartInstances performs restart service instances. -func (launcher *Launcher) RestartInstances() error { - launcher.Lock() - defer launcher.Unlock() - - launcher.connectionTimer = time.AfterFunc( - launcher.config.SMController.NodesConnectionTimeout.Duration, launcher.sendCurrentStatus) - - for _, node := range launcher.nodes { - launcher.initNodeConfig(node) - } - - launcher.currentErrorStatus = launcher.performNodeBalancing(launcher.currentDesiredInstances) - - return launcher.sendRunInstances(true) -} - // GetRunStatusesChannel gets channel with run status instances status. func (launcher *Launcher) GetRunStatusesChannel() <-chan unitstatushandler.RunInstancesStatus { return launcher.runStatusChannel @@ -297,9 +279,6 @@ func (launcher *Launcher) processChannels(ctx context.Context) { case instances := <-launcher.nodeManager.GetRunInstancesStatusChannel(): launcher.processRunInstanceStatus(instances) - case alert := <-launcher.nodeManager.GetSystemLimitAlertChannel(): - launcher.performRebalancing(alert) - case <-ctx.Done(): return } @@ -386,108 +365,6 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat launcher.sendCurrentStatus() } -//nolint:funlen -func (launcher *Launcher) performRebalancing(alert cloudprotocol.SystemQuotaAlert) { - launcher.Lock() - defer launcher.Unlock() - - log.Debug("Perform rebalancing") - - nodeWithIssue := launcher.getNode(alert.NodeID) - if nodeWithIssue == nil { - log.Errorf("Can't get node: %s", alert.NodeID) - - return - } - - if len(nodeWithIssue.currentRunRequest.Instances) <= 1 { - log.Warn("No instances for rebalancing") - - return - } - - nodes := launcher.getLowerPriorityNodes(nodeWithIssue) - if len(nodes) == 0 { - log.Error("No nodes with lower priority for rebalancing") - - return - } - - for i := len(nodeWithIssue.currentRunRequest.Instances) - 1; i >= 0; i-- { - currentInstance := nodeWithIssue.currentRunRequest.Instances[i] - - serviceInfo, err := launcher.imageProvider.GetServiceInfo(currentInstance.ServiceID) - if err != nil { - log.Errorf("Can't get service: %v", err) - continue - } - - labels, err := launcher.getLabelsForInstance(currentInstance.InstanceIdent) - if err != nil { - log.Errorf("Can't get labels for instance %v", err) - } - - nodes, err := launcher.getNodesByStaticResources(nodes, serviceInfo, cloudprotocol.InstanceInfo{ - ServiceID: currentInstance.ServiceID, SubjectID: currentInstance.SubjectID, Labels: labels, - }) - if err != nil { - continue - } - - nodes, err = launcher.getNodesByDevices(nodes, serviceInfo.Config.Devices) - if err != nil { - continue - } - - nodes = launcher.getNodeByMonitoringData(nodes, alert.Parameter) - - layersForService, err := launcher.getLayersForService(serviceInfo.Layers) - if err != nil { - log.Errorf("Can't get layer: %v", err) - - continue - } - - if err = launcher.allocateDevices(nodes[0], serviceInfo.Config.Devices); err != nil { - log.Errorf("Can't allocate devices: %v", err) - - continue - } - - launcher.addRunRequest(currentInstance, serviceInfo, layersForService, nodes[0]) - - if err := launcher.releaseDevices(nodeWithIssue, serviceInfo.Config.Devices); err != nil { - log.Errorf("Can't release devices: %v", err) - - continue - } - - sort.Slice(nodeWithIssue.currentRunRequest.Instances, func(i, j int) bool { - if nodeWithIssue.currentRunRequest.Instances[i].Priority == - nodeWithIssue.currentRunRequest.Instances[j].Priority { - return nodeWithIssue.currentRunRequest.Instances[i].ServiceID < - nodeWithIssue.currentRunRequest.Instances[j].ServiceID - } - - return nodeWithIssue.currentRunRequest.Instances[i].Priority > - nodeWithIssue.currentRunRequest.Instances[j].Priority - }) - - launcher.removeRunRequest(currentInstance, nodeWithIssue) - - launcher.connectionTimer = time.AfterFunc( - launcher.config.SMController.NodesConnectionTimeout.Duration, launcher.sendCurrentStatus) - - if err := launcher.sendRunInstances(false); err != nil { - log.Errorf("Can't send run instance while rebalancing: %v", err) - } - - return - } - - log.Warn("No appropriate condition for rebalancing found") -} - func (launcher *Launcher) initNodeStatus(nodeID string) (*nodeStatus, error) { status := &nodeStatus{currentRunRequest: &runRequestInfo{}} diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 7e2383c7..0862c84a 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -99,7 +99,6 @@ type testNodeInfoProvider struct { type testNodeManager struct { runStatusChan chan launcher.NodeRunInstanceStatus - alertsChannel chan cloudprotocol.SystemQuotaAlert runRequest map[string]runRequest } @@ -1143,700 +1142,6 @@ func TestStorageCleanup(t *testing.T) { } } -func TestRebalancing(t *testing.T) { - var ( - cfg = &config.Config{ - SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1, nodeIDRemoteSM2}, - NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, - }, - } - nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} - ) - - nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ - NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - - resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ - Priority: 100, - NodeType: nodeTypeLocalSM, Devices: []cloudprotocol.DeviceInfo{ - {Name: "dev1", SharedCount: 1}, - }, - } - - nodeInfoProvider.nodeInfo[nodeIDRemoteSM1] = cloudprotocol.NodeInfo{ - NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - - nodeInfoProvider.nodeInfo[nodeIDRemoteSM2] = cloudprotocol.NodeInfo{ - NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - - resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ - Priority: 50, - NodeType: nodeTypeRemoteSM, - Devices: []cloudprotocol.DeviceInfo{ - {Name: "dev1", SharedCount: 2}, - }, - Resources: []cloudprotocol.ResourceInfo{{Name: "resource1"}}, - } - - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, - resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) - if err != nil { - t.Fatalf("Can't create launcher %v", err) - } - defer launcherInstance.Close() - - for nodeID, info := range nodeInfoProvider.nodeInfo { - nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ - NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, - } - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - imageManager.services = map[string]imagemanager.ServiceInfo{ - service1: { - ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), - RemoteURL: service1RemoteURL, - Config: aostypes.ServiceConfig{ - Runners: []string{runnerRunc}, - Resources: []string{"resource1"}, - }, - }, - service2: { - ServiceInfo: createServiceInfo(service2, 5001, service1LocalURL), - RemoteURL: service2RemoteURL, - Config: aostypes.ServiceConfig{ - Runners: []string{runnerRunc}, - }, - }, - service3: { - ServiceInfo: createServiceInfo(service3, 5002, service3LocalURL), - RemoteURL: service3RemoteURL, - Config: aostypes.ServiceConfig{ - Runners: []string{runnerRunc}, - Devices: []aostypes.ServiceDevice{ - {Name: "dev1"}, - }, - }, - }, - } - - desiredInstances := []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1}, - {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 1}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 3}, - } - - expectedRunRequests := map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service1LocalURL), - createServiceInfo(service3, 5002, service3LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 2, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 50), - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1RemoteURL), - createServiceInfo(service3, 5002, service3RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 4, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5003, 5, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, 0), - createInstanceInfo(5004, 6, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 2, - }, 0), - }, - }, - nodeIDRemoteSM2: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - } - - expectedRunStatus := unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 2, - }, nodeIDRemoteSM1, nil), - }, - } - - if err := launcherInstance.RunInstances(desiredInstances, []string{}); err != nil { - t.Fatalf("Can't run instances %v", err) - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("Incorrect run request: %v", err) - } - - nodeManager.alertsChannel <- cloudprotocol.SystemQuotaAlert{NodeID: nodeIDLocalSM, Parameter: "cpu"} - - expectedRunRequests = map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service1LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 2, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 50), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1RemoteURL), - createServiceInfo(service3, 5002, service3RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 4, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5003, 5, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, 0), - createInstanceInfo(5004, 6, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 2, - }, 0), - }, - }, - nodeIDRemoteSM2: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service3, 5002, service3RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - } - - expectedRunStatus = unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 2, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM2, nil), - }, - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("incorrect run request: %v", err) - } - - nodeManager.alertsChannel <- cloudprotocol.SystemQuotaAlert{NodeID: nodeIDRemoteSM2, Parameter: "cpu"} - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err == nil || - !strings.Contains(err.Error(), "message timeout") { - t.Error("Timeout expected") - } -} - -func TestRebalancingSameNodePriority(t *testing.T) { - var ( - cfg = &config.Config{ - SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, - NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, - }, - } - nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} - storage = newTestStorage() - ) - - nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ - NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ - NodeType: nodeTypeLocalSM, - Labels: []string{"label1"}, - } - - nodeInfoProvider.nodeInfo[nodeIDRemoteSM1] = cloudprotocol.NodeInfo{ - NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ - NodeType: nodeTypeRemoteSM, - Labels: []string{"label2"}, - } - - launcherInstance, err := launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, - &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) - if err != nil { - t.Fatalf("Can't create launcher %v", err) - } - defer launcherInstance.Close() - - for nodeID, info := range nodeInfoProvider.nodeInfo { - nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ - NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, - } - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - imageManager.services = map[string]imagemanager.ServiceInfo{ - service1: { - ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), - RemoteURL: service1RemoteURL, - }, - service2: { - ServiceInfo: createServiceInfo(service2, 5001, service2LocalURL), - RemoteURL: service2RemoteURL, - }, - service3: { - ServiceInfo: createServiceInfo(service3, 5002, service3LocalURL), - RemoteURL: service3RemoteURL, - }, - } - - desiredInstances := []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1, Labels: []string{"label1"}}, - {ServiceID: service2, SubjectID: subject1, Priority: 100, NumInstances: 1, Labels: []string{"label2"}}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 1}, - } - - expectedRunRequests := map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - createServiceInfo(service3, 5002, service3LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service2RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 4, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 100), - }, - }, - } - - expectedRunStatus := unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - }, - } - - if err := launcherInstance.RunInstances(desiredInstances, []string{}); err != nil { - t.Fatalf("Can't run instances %v", err) - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("Incorrect run request: %v", err) - } - - nodeManager.alertsChannel <- cloudprotocol.SystemQuotaAlert{NodeID: nodeIDLocalSM, Parameter: "cpu"} - - expectedRunRequests = map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service2RemoteURL), - createServiceInfo(service3, 5002, service3RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 4, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - } - - expectedRunStatus = unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - }, - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("Incorrect run request: %v", err) - } - - nodeManager.alertsChannel <- cloudprotocol.SystemQuotaAlert{NodeID: nodeIDRemoteSM1, Parameter: "cpu"} - - expectedRunRequests = map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - createServiceInfo(service3, 5002, service3LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service2RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 4, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 100), - }, - }, - } - - expectedRunStatus = unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - }, - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("Incorrect run request: %v", err) - } -} - -func TestRebalancingAfterRestart(t *testing.T) { - var ( - cfg = &config.Config{ - SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, - NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, - }, - } - nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) - nodeManager = newTestNodeManager() - resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} - storage = newTestStorage() - ) - - nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ - NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{ - NodeType: nodeTypeLocalSM, - Labels: []string{"label1"}, - } - - nodeInfoProvider.nodeInfo[nodeIDRemoteSM1] = cloudprotocol.NodeInfo{ - NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - resourceManager.nodeResources[nodeTypeRemoteSM] = cloudprotocol.NodeConfig{ - NodeType: nodeTypeRemoteSM, - Labels: []string{"label2"}, - } - - launcherInstance, err := launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, - &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) - if err != nil { - t.Fatalf("Can't create launcher %v", err) - } - - for nodeID, info := range nodeInfoProvider.nodeInfo { - nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ - NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, - } - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - imageManager.services = map[string]imagemanager.ServiceInfo{ - service1: { - ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), - RemoteURL: service1RemoteURL, - }, - service2: { - ServiceInfo: createServiceInfo(service2, 5001, service2LocalURL), - RemoteURL: service2RemoteURL, - }, - service3: { - ServiceInfo: createServiceInfo(service3, 5002, service3LocalURL), - RemoteURL: service3RemoteURL, - }, - } - - desiredInstances := []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1, Labels: []string{"label1"}}, - {ServiceID: service2, SubjectID: subject1, Priority: 100, NumInstances: 1, Labels: []string{"label2"}}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 1}, - } - - expectedRunRequests := map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - createServiceInfo(service3, 5002, service3LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service2RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 4, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 100), - }, - }, - } - - expectedRunStatus := unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - }, - } - - if err := launcherInstance.RunInstances(desiredInstances, []string{}); err != nil { - t.Fatalf("Can't run instances %v", err) - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("Incorrect run request: %v", err) - } - - launcherInstance.Close() - - // Restart - - launcherInstance, err = launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, - &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) - if err != nil { - t.Fatalf("Can't create launcher %v", err) - } - - for nodeID, info := range nodeInfoProvider.nodeInfo { - nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ - NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, - } - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - nodeManager.alertsChannel <- cloudprotocol.SystemQuotaAlert{NodeID: nodeIDLocalSM, Parameter: "cpu"} - - expectedRunRequests = map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service2, 5001, service2RemoteURL), - createServiceInfo(service3, 5002, service3RemoteURL), - }, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 4, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5002, 3, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - }, - }, - } - - expectedRunStatus = unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - }, - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if err := nodeManager.compareRunRequests(expectedRunRequests); err != nil { - t.Errorf("Incorrect run request: %v", err) - } -} - /*********************************************************************************************************************** * Interfaces **********************************************************************************************************************/ @@ -1869,7 +1174,6 @@ func newTestNodeManager() *testNodeManager { nodeManager := &testNodeManager{ runStatusChan: make(chan launcher.NodeRunInstanceStatus, 10), runRequest: make(map[string]runRequest), - alertsChannel: make(chan cloudprotocol.SystemQuotaAlert, 10), } return nodeManager @@ -1909,10 +1213,6 @@ func (nodeManager *testNodeManager) GetUpdateInstancesStatusChannel() <-chan []c return nil } -func (nodeManager *testNodeManager) GetSystemLimitAlertChannel() <-chan cloudprotocol.SystemQuotaAlert { - return nodeManager.alertsChannel -} - func (nodeManager *testNodeManager) GetAverageMonitoring(nodeID string) (aostypes.NodeMonitoring, error) { return aostypes.NodeMonitoring{}, nil } From 5cc1cc32e642e5b026adf9f49040b6c742360dd2 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 12 Jul 2024 14:09:51 +0300 Subject: [PATCH 066/146] [amqphandler] Handle new provisionig messages Signed-off-by: Mykhailo Lohvynenko --- amqphandler/amqphandler.go | 33 ++++++++++++ amqphandler/amqphandler_test.go | 92 +++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index c136d556..1334864d 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -123,6 +123,15 @@ var messageMap = map[string]func() interface{}{ //nolint:gochecknoglobals cloudprotocol.OverrideEnvVarsMessageType: func() interface{} { return &cloudprotocol.OverrideEnvVars{} }, + cloudprotocol.StartProvisioningRequestMessageType: func() interface{} { + return &cloudprotocol.StartProvisioningRequest{} + }, + cloudprotocol.FinishProvisioningRequestMessageType: func() interface{} { + return &cloudprotocol.FinishProvisioningRequest{} + }, + cloudprotocol.DeprovisioningRequestMessageType: func() interface{} { + return &cloudprotocol.DeprovisioningRequest{} + }, } var ( @@ -314,6 +323,30 @@ func (handler *AmqpHandler) SendOverrideEnvVarsStatus(envs cloudprotocol.Overrid return handler.scheduleMessage(cloudprotocol.OverrideEnvVarsStatusMessageType, envs, true) } +// SendStartProvisioningResponse sends start provisioning response. +func (handler *AmqpHandler) SendStartProvisioningResponse(response cloudprotocol.StartProvisioningResponse) error { + handler.Lock() + defer handler.Unlock() + + return handler.scheduleMessage(cloudprotocol.StartProvisioningResponseMessageType, response, true) +} + +// SendFinishProvisioningResponse sends finish provisioning response. +func (handler *AmqpHandler) SendFinishProvisioningResponse(response cloudprotocol.FinishProvisioningResponse) error { + handler.Lock() + defer handler.Unlock() + + return handler.scheduleMessage(cloudprotocol.FinishProvisioningResponseMessageType, response, true) +} + +// SendDeprovisioningResponse sends deprovisioning response. +func (handler *AmqpHandler) SendDeprovisioningResponse(response cloudprotocol.DeprovisioningResponse) error { + handler.Lock() + defer handler.Unlock() + + return handler.scheduleMessage(cloudprotocol.DeprovisioningResponseMessageType, response, true) +} + // SubscribeForConnectionEvents subscribes for connection events. func (handler *AmqpHandler) SubscribeForConnectionEvents(consumer ConnectionEventsConsumer) error { handler.Lock() diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index b14d7db4..02229886 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -341,6 +341,34 @@ func TestReceiveMessages(t *testing.T) { SOTASchedule: cloudprotocol.ScheduleRule{TTL: uint64(200), Type: "type2"}, }, }, + { + messageType: cloudprotocol.StartProvisioningRequestMessageType, + expectedData: &cloudprotocol.StartProvisioningRequest{ + MessageType: cloudprotocol.StartProvisioningRequestMessageType, + NodeID: "node-1", + Password: "password-1", + }, + }, + { + messageType: cloudprotocol.FinishProvisioningRequestMessageType, + expectedData: &cloudprotocol.FinishProvisioningRequest{ + MessageType: cloudprotocol.FinishProvisioningRequestMessageType, + NodeID: "node1", + Certificates: []cloudprotocol.IssuedCertData{ + {NodeID: "node1", Type: "online", CertificateChain: "onlineCSR"}, + {NodeID: "node1", Type: "offline", CertificateChain: "offlineCSR"}, + }, + Password: "password-1", + }, + }, + { + messageType: cloudprotocol.DeprovisioningRequestMessageType, + expectedData: &cloudprotocol.DeprovisioningRequest{ + MessageType: cloudprotocol.DeprovisioningRequestMessageType, + NodeID: "node-1", + Password: "password-1", + }, + }, } for _, data := range testData { @@ -533,6 +561,25 @@ func TestSendMessages(t *testing.T) { }, } + startProvisioningResponse := cloudprotocol.StartProvisioningResponse{ + MessageType: cloudprotocol.StartProvisioningResponseMessageType, + NodeID: "node-1", + ErrorInfo: nil, + CSRs: []cloudprotocol.IssueCertData{{Type: "online", Csr: "iam"}, {Type: "offline", Csr: "iam"}}, + } + + finishProvisioningResponse := cloudprotocol.FinishProvisioningResponse{ + MessageType: cloudprotocol.FinishProvisioningResponseMessageType, + NodeID: "node-1", + ErrorInfo: nil, + } + + deProvisioningResponse := cloudprotocol.DeprovisioningResponse{ + MessageType: cloudprotocol.DeprovisioningResponseMessageType, + NodeID: "node-1", + ErrorInfo: nil, + } + issueCerts := cloudprotocol.IssueUnitCerts{ MessageType: cloudprotocol.IssueUnitCertsMessageType, Requests: []cloudprotocol.IssueCertData{ @@ -729,6 +776,51 @@ func TestSendMessages(t *testing.T) { return &cloudprotocol.OverrideEnvVarsStatus{MessageType: cloudprotocol.OverrideEnvVarsStatusMessageType} }, }, + { + call: func() error { + return aoserrors.Wrap(amqpHandler.SendStartProvisioningResponse(startProvisioningResponse)) + }, + data: cloudprotocol.Message{ + Header: cloudprotocol.MessageHeader{ + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, + }, + Data: &startProvisioningResponse, + }, + getDataType: func() interface{} { + return &cloudprotocol.StartProvisioningResponse{MessageType: cloudprotocol.StartProvisioningResponseMessageType} + }, + }, + { + call: func() error { + return aoserrors.Wrap(amqpHandler.SendFinishProvisioningResponse(finishProvisioningResponse)) + }, + data: cloudprotocol.Message{ + Header: cloudprotocol.MessageHeader{ + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, + }, + Data: &finishProvisioningResponse, + }, + getDataType: func() interface{} { + return &cloudprotocol.FinishProvisioningResponse{MessageType: cloudprotocol.FinishProvisioningResponseMessageType} + }, + }, + { + call: func() error { + return aoserrors.Wrap(amqpHandler.SendDeprovisioningResponse(deProvisioningResponse)) + }, + data: cloudprotocol.Message{ + Header: cloudprotocol.MessageHeader{ + SystemID: systemID, + Version: cloudprotocol.ProtocolVersion, + }, + Data: &deProvisioningResponse, + }, + getDataType: func() interface{} { + return &cloudprotocol.DeprovisioningResponse{MessageType: cloudprotocol.DeprovisioningResponseMessageType} + }, + }, } for _, message := range testData { From 9e3c2849c5bdc6eebddd7d284c0701a444d62d24 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 12 Jul 2024 16:22:41 +0300 Subject: [PATCH 067/146] [iamclient] Handle provisioning messages Signed-off-by: Mykhailo Lohvynenko --- communicationmanager.go | 21 ++++ iamclient/iamclient.go | 216 +++++++++++++++++++++++++++++++++++- iamclient/iamclient_test.go | 193 ++++++++++++++++++++++++++++++-- 3 files changed, 420 insertions(+), 10 deletions(-) diff --git a/communicationmanager.go b/communicationmanager.go index c36415c8..692e8212 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -398,6 +398,27 @@ func (cm *communicationManager) processMessage(message amqp.Message) (err error) return aoserrors.Wrap(err) } + case *cloudprotocol.StartProvisioningRequest: + log.Info("Receive start provisioning request message") + + if err = cm.iam.StartProvisioning(data.NodeID, data.Password); err != nil { + return aoserrors.Wrap(err) + } + + case *cloudprotocol.FinishProvisioningRequest: + log.Info("Receive finish provisioning request message") + + if err = cm.iam.FinishProvisioning(data.NodeID, data.Password, data.Certificates); err != nil { + return aoserrors.Wrap(err) + } + + case *cloudprotocol.DeprovisioningRequest: + log.Info("Receive deprovisioning request message") + + if err = cm.iam.Deprovision(data.NodeID, data.Password); err != nil { + return aoserrors.Wrap(err) + } + default: log.Warnf("Receive unsupported amqp message: %s", reflect.TypeOf(data)) } diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 245026ca..3317fb38 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -69,6 +69,7 @@ type Client struct { publicService pb.IAMPublicServiceClient identService pb.IAMPublicIdentityServiceClient certificateService pb.IAMCertificateServiceClient + provisioningService pb.IAMProvisioningServiceClient closeChannel chan struct{} nodeService pb.IAMPublicNodesServiceClient @@ -79,6 +80,9 @@ type Client struct { type Sender interface { SendIssueUnitCerts(requests []cloudprotocol.IssueCertData) (err error) SendInstallCertsConfirmation(confirmations []cloudprotocol.InstallCertData) (err error) + SendStartProvisioningResponse(response cloudprotocol.StartProvisioningResponse) (err error) + SendFinishProvisioningResponse(response cloudprotocol.FinishProvisioningResponse) (err error) + SendDeprovisioningResponse(response cloudprotocol.DeprovisioningResponse) (err error) } // CertificateProvider provides certificate info. @@ -127,6 +131,7 @@ func New( } localClient.certificateService = pb.NewIAMCertificateServiceClient(localClient.protectedConnection) + localClient.provisioningService = pb.NewIAMProvisioningServiceClient(localClient.protectedConnection) log.Debug("Connected to IAM") @@ -167,7 +172,7 @@ func (client *Client) GetNodeInfo(nodeID string) (nodeInfo cloudprotocol.NodeInf return cloudprotocol.NodeInfo{}, aoserrors.Wrap(err) } - return pbconvert.NewNodeInfoFromPB(response), nil + return pbconvert.NodeInfoFromPB(response), nil } // GetAllNodeIDs returns node ids. @@ -302,6 +307,108 @@ func (client *Client) GetCertificate( return response.GetCertUrl(), response.GetKeyUrl(), nil } +// StartProvisioning starts provisioning. +func (client *Client) StartProvisioning(nodeID, password string) (err error) { + log.WithField("nodeID", nodeID).Debug("Start provisioning") + + var ( + errorInfo *cloudprotocol.ErrorInfo + csrs []cloudprotocol.IssueCertData + ) + + defer func() { + errSend := client.sender.SendStartProvisioningResponse(cloudprotocol.StartProvisioningResponse{ + MessageType: cloudprotocol.StartProvisioningResponseMessageType, + NodeID: nodeID, + ErrorInfo: errorInfo, + CSRs: csrs, + }) + if errSend != nil && err == nil { + err = aoserrors.Wrap(errSend) + } + }() + + errorInfo = client.startProvisioning(nodeID, password) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + csrs, errorInfo = client.createKeys(nodeID, password) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + return nil +} + +// FinishProvisioning starts provisioning. +func (client *Client) FinishProvisioning( + nodeID, password string, certificates []cloudprotocol.IssuedCertData, +) (err error) { + log.WithField("nodeID", nodeID).Debug("Finish provisioning") + + var errorInfo *cloudprotocol.ErrorInfo + + defer func() { + errSend := client.sender.SendFinishProvisioningResponse(cloudprotocol.FinishProvisioningResponse{ + MessageType: cloudprotocol.StartProvisioningResponseMessageType, + NodeID: nodeID, + ErrorInfo: errorInfo, + }) + if errSend != nil && err == nil { + err = aoserrors.Wrap(errSend) + } + }() + + errorInfo = client.applyCertificates(nodeID, certificates) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + errorInfo = client.finishProvisioning(nodeID, password) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + return nil +} + +// Deprovision deprovisions node. +func (client *Client) Deprovision(nodeID, password string) (err error) { + log.WithField("nodeID", nodeID).Debug("Deprovision node") + + var errorInfo *cloudprotocol.ErrorInfo + + defer func() { + errSend := client.sender.SendDeprovisioningResponse(cloudprotocol.DeprovisioningResponse{ + MessageType: cloudprotocol.StartProvisioningResponseMessageType, + NodeID: nodeID, + ErrorInfo: errorInfo, + }) + if errSend != nil && err == nil { + err = aoserrors.Wrap(errSend) + } + }() + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.provisioningService.Deprovision( + ctx, &pb.DeprovisionRequest{NodeId: nodeID, Password: password}) + if err != nil { + errorInfo = &cloudprotocol.ErrorInfo{Message: err.Error()} + + return aoserrors.Wrap(err) + } + + errorInfo = pbconvert.ErrorInfoFromPB(response.GetError()) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + return nil +} + // Close closes IAM client. func (client *Client) Close() (err error) { if client.publicConnection != nil || client.protectedConnection != nil { @@ -434,7 +541,7 @@ func (client *Client) processMessages(listener pb.IAMPublicNodesService_Subscrib client.Lock() for _, listener := range client.nodeInfoListeners { - listener <- pbconvert.NewNodeInfoFromPB(nodeInfo) + listener <- pbconvert.NodeInfoFromPB(nodeInfo) } client.Unlock() } @@ -485,3 +592,108 @@ func (client *Client) subscribeNodeInfoChange() (listener pb.IAMPublicNodesServi return listener, err } + +func (client *Client) getCertTypes(nodeID string) ([]string, error) { + log.WithField("nodeID", nodeID).Debug("Get certificate types") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.provisioningService.GetCertTypes( + ctx, &pb.GetCertTypesRequest{NodeId: nodeID}) + if err != nil { + return nil, aoserrors.Wrap(err) + } + + return response.GetTypes(), nil +} + +func (client *Client) createKeys(nodeID, password string) ( + certs []cloudprotocol.IssueCertData, errorInfo *cloudprotocol.ErrorInfo, +) { + certTypes, err := client.getCertTypes(nodeID) + if err != nil { + return nil, &cloudprotocol.ErrorInfo{Message: err.Error()} + } + + for _, certType := range certTypes { + log.WithFields(log.Fields{"nodeID": nodeID, "type": certType}).Debug("Create key") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.certificateService.CreateKey(ctx, &pb.CreateKeyRequest{ + Type: certType, + NodeId: nodeID, + Password: password, + }) + if err != nil { + return nil, &cloudprotocol.ErrorInfo{Message: err.Error()} + } + + if response.GetError() != nil { + return nil, pbconvert.ErrorInfoFromPB(response.GetError()) + } + + certs = append(certs, cloudprotocol.IssueCertData{ + Type: certType, + Csr: response.GetCsr(), + NodeID: nodeID, + }) + } + + return certs, nil +} + +func (client *Client) startProvisioning(nodeID, password string) (errorInfo *cloudprotocol.ErrorInfo) { + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.provisioningService.StartProvisioning( + ctx, &pb.StartProvisioningRequest{NodeId: nodeID, Password: password}) + if err != nil { + return &cloudprotocol.ErrorInfo{Message: err.Error()} + } + + return pbconvert.ErrorInfoFromPB(response.GetError()) +} + +func (client *Client) applyCertificates( + nodeID string, certificates []cloudprotocol.IssuedCertData, +) (errorInfo *cloudprotocol.ErrorInfo) { + for _, certificate := range certificates { + log.WithFields(log.Fields{"nodeID": nodeID, "type": certificate.Type}).Debug("Apply certificate") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.certificateService.ApplyCert( + ctx, &pb.ApplyCertRequest{ + NodeId: nodeID, + Type: certificate.Type, + Cert: certificate.CertificateChain, + }) + if err != nil { + return &cloudprotocol.ErrorInfo{Message: err.Error()} + } + + if response.GetError() != nil { + return pbconvert.ErrorInfoFromPB(response.GetError()) + } + } + + return nil +} + +func (client *Client) finishProvisioning(nodeID, password string) (errorInfo *cloudprotocol.ErrorInfo) { + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.provisioningService.FinishProvisioning( + ctx, &pb.FinishProvisioningRequest{NodeId: nodeID, Password: password}) + if err != nil { + return &cloudprotocol.ErrorInfo{Message: err.Error()} + } + + return pbconvert.ErrorInfoFromPB(response.GetError()) +} diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index b037ee04..2ac22eb0 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -77,6 +77,7 @@ type testPublicServer struct { type testProtectedServer struct { pb.UnimplementedIAMCertificateServiceServer + pb.UnimplementedIAMProvisioningServiceServer grpcServer *grpc.Server csr map[string]string @@ -84,8 +85,11 @@ type testProtectedServer struct { } type testSender struct { - csr map[string]string - currentConfirmations []cloudprotocol.InstallCertData + csr map[string]string + currentConfirmations []cloudprotocol.InstallCertData + startProvisioningResponse *cloudprotocol.StartProvisioningResponse + finishProvisioningResponse *cloudprotocol.FinishProvisioningResponse + deprovisioningResponse *cloudprotocol.DeprovisioningResponse } type testCertProvider struct{} @@ -408,6 +412,128 @@ func TestSubscribeNodeInfoChange(t *testing.T) { } } +func TestStartProvisioning(t *testing.T) { + sender := &testSender{} + + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + protectedServer.csr = map[string]string{"online": "onlineCSR", "offline": "offlineCSR"} + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, sender, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + err = client.StartProvisioning("node1", "password") + if err != nil { + t.Errorf("Error is not expected: %s", err) + } + + expectedResponse := cloudprotocol.StartProvisioningResponse{ + MessageType: cloudprotocol.StartProvisioningResponseMessageType, + NodeID: "node1", + CSRs: []cloudprotocol.IssueCertData{ + {NodeID: "node1", Type: "online", Csr: "onlineCSR"}, + {NodeID: "node1", Type: "offline", Csr: "offlineCSR"}, + }, + } + + if sender.startProvisioningResponse == nil { + t.Error("Sender didn't receive start provisioning response") + } + + if !reflect.DeepEqual(expectedResponse, *sender.startProvisioningResponse) { + log.Debug(expectedResponse) + log.Debug(*sender.startProvisioningResponse) + t.Error("Wrong start provisioning response") + } +} + +func TestFinishProvisioning(t *testing.T) { + sender := &testSender{} + + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + protectedServer.certURL = map[string]string{"online": "onlineCSR", "offline": "offlineCSR"} + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, sender, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + err = client.FinishProvisioning("node2", "password", + []cloudprotocol.IssuedCertData{ + {NodeID: "node1", Type: "online", CertificateChain: "onlineCSR"}, + {NodeID: "node1", Type: "offline", CertificateChain: "offlineCSR"}, + }, + ) + if err != nil { + t.Errorf("Error is not expected: %v", err) + } + + if sender.finishProvisioningResponse == nil { + t.Error("Sender didn't receive finish provisioning response") + } + + if sender.finishProvisioningResponse.ErrorInfo != nil { + t.Errorf("Error is not expected: %v", sender.finishProvisioningResponse.ErrorInfo) + } +} + +func TestDeprovisioning(t *testing.T) { + sender := &testSender{} + + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, sender, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + err = client.Deprovision("test-node-id", "password") + if err != nil { + t.Errorf("Error is not expected: %s", err) + } + + if sender.deprovisioningResponse == nil { + t.Error("Sender didn't receive deprovisioning response") + } + + if sender.deprovisioningResponse.ErrorInfo != nil { + t.Errorf("Error is not expected: %v", sender.deprovisioningResponse.ErrorInfo) + } +} + /******************************************************************************* * Private ******************************************************************************/ @@ -445,6 +571,7 @@ func newTestServer( protectedServer.grpcServer = grpc.NewServer() pb.RegisterIAMCertificateServiceServer(protectedServer.grpcServer, protectedServer) + pb.RegisterIAMProvisioningServiceServer(protectedServer.grpcServer, protectedServer) go func() { if err := protectedServer.grpcServer.Serve(protectedListener); err != nil { @@ -501,6 +628,38 @@ func (server *testProtectedServer) ApplyCert( return rsp, nil } +func (server *testProtectedServer) GetCertTypes( + context context.Context, req *pb.GetCertTypesRequest, +) (rsp *pb.CertTypes, err error) { + rsp = &pb.CertTypes{Types: []string{"online", "offline"}} + + return rsp, nil +} + +func (server *testProtectedServer) StartProvisioning( + context context.Context, req *pb.StartProvisioningRequest, +) (rsp *pb.StartProvisioningResponse, err error) { + rsp = &pb.StartProvisioningResponse{} + + return rsp, nil +} + +func (server *testProtectedServer) FinishProvisioning( + context context.Context, req *pb.FinishProvisioningRequest, +) (rsp *pb.FinishProvisioningResponse, err error) { + rsp = &pb.FinishProvisioningResponse{} + + return rsp, nil +} + +func (server *testProtectedServer) Deprovision( + context context.Context, req *pb.DeprovisionRequest, +) (rsp *pb.DeprovisionResponse, err error) { + rsp = &pb.DeprovisionResponse{} + + return rsp, nil +} + func (server *testPublicServer) GetCert( context context.Context, req *pb.GetCertRequest, ) (rsp *pb.GetCertResponse, err error) { @@ -526,12 +685,6 @@ func (server *testPublicServer) GetCertTypes(context context.Context, req *empty return rsp, nil } -func (server *testProtectedServer) FinishProvisioning( - context context.Context, req *empty.Empty, -) (rsp *empty.Empty, err error) { - return rsp, nil -} - func (server *testPublicServer) GetSystemInfo( context context.Context, req *empty.Empty, ) (rsp *pb.SystemInfo, err error) { @@ -586,6 +739,30 @@ func (sender *testSender) SendInstallCertsConfirmation(confirmations []cloudprot return nil } +func (sender *testSender) SendStartProvisioningResponse( + response cloudprotocol.StartProvisioningResponse, +) (err error) { + sender.startProvisioningResponse = &response + + return nil +} + +func (sender *testSender) SendFinishProvisioningResponse( + response cloudprotocol.FinishProvisioningResponse, +) (err error) { + sender.finishProvisioningResponse = &response + + return nil +} + +func (sender *testSender) SendDeprovisioningResponse( + response cloudprotocol.DeprovisioningResponse, +) (err error) { + sender.deprovisioningResponse = &response + + return nil +} + func (provider *testCertProvider) GetCertSerial(certURLStr string) (serial string, err error) { certURL, err := url.Parse(certURLStr) if err != nil { From 7c1ac187aed0e95c52bf5ab224c0eda3cb36701e Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Tue, 16 Jul 2024 13:50:22 +0300 Subject: [PATCH 068/146] [iamclient] Add pause/resume node methods Signed-off-by: Mykhailo Lohvynenko --- iamclient/iamclient.go | 58 +++++++++++++++++++++++++++----- iamclient/iamclient_test.go | 66 +++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 8 deletions(-) diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 3317fb38..f232f3a5 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -71,9 +71,10 @@ type Client struct { certificateService pb.IAMCertificateServiceClient provisioningService pb.IAMProvisioningServiceClient - closeChannel chan struct{} - nodeService pb.IAMPublicNodesServiceClient - nodeInfoListeners []chan cloudprotocol.NodeInfo + closeChannel chan struct{} + publicNodesService pb.IAMPublicNodesServiceClient + nodesService pb.IAMNodesServiceClient + nodeInfoListeners []chan cloudprotocol.NodeInfo } // Sender provides API to send messages to the cloud. @@ -123,7 +124,7 @@ func New( localClient.publicService = pb.NewIAMPublicServiceClient(localClient.publicConnection) localClient.identService = pb.NewIAMPublicIdentityServiceClient(localClient.publicConnection) - localClient.nodeService = pb.NewIAMPublicNodesServiceClient(localClient.publicConnection) + localClient.publicNodesService = pb.NewIAMPublicNodesServiceClient(localClient.publicConnection) if localClient.protectedConnection, err = localClient.createProtectedConnection( config, cryptocontext, insecure); err != nil { @@ -132,6 +133,7 @@ func New( localClient.certificateService = pb.NewIAMCertificateServiceClient(localClient.protectedConnection) localClient.provisioningService = pb.NewIAMProvisioningServiceClient(localClient.protectedConnection) + localClient.nodesService = pb.NewIAMNodesServiceClient(localClient.protectedConnection) log.Debug("Connected to IAM") @@ -167,7 +169,7 @@ func (client *Client) GetNodeInfo(nodeID string) (nodeInfo cloudprotocol.NodeInf request := &pb.GetNodeInfoRequest{NodeId: nodeID} - response, err := client.nodeService.GetNodeInfo(ctx, request) + response, err := client.publicNodesService.GetNodeInfo(ctx, request) if err != nil { return cloudprotocol.NodeInfo{}, aoserrors.Wrap(err) } @@ -182,7 +184,7 @@ func (client *Client) GetAllNodeIDs() (nodeIDs []string, err error) { ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) defer cancel() - response, err := client.nodeService.GetAllNodeIDs(ctx, &emptypb.Empty{}) + response, err := client.publicNodesService.GetAllNodeIDs(ctx, &emptypb.Empty{}) if err != nil { return nil, aoserrors.Wrap(err) } @@ -409,6 +411,46 @@ func (client *Client) Deprovision(nodeID, password string) (err error) { return nil } +// PauseNode pauses node. +func (client *Client) PauseNode(nodeID string) error { + log.WithField("nodeID", nodeID).Debug("Pause node") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.nodesService.PauseNode(ctx, &pb.PauseNodeRequest{NodeId: nodeID}) + if err != nil { + return aoserrors.Wrap(err) + } + + errorInfo := pbconvert.ErrorInfoFromPB(response.GetError()) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + return nil +} + +// ResumeNode resumes node. +func (client *Client) ResumeNode(nodeID string) error { + log.WithField("nodeID", nodeID).Debug("Resume node") + + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) + defer cancel() + + response, err := client.nodesService.ResumeNode(ctx, &pb.ResumeNodeRequest{NodeId: nodeID}) + if err != nil { + return aoserrors.Wrap(err) + } + + errorInfo := pbconvert.ErrorInfoFromPB(response.GetError()) + if errorInfo != nil { + return aoserrors.New(errorInfo.Message) + } + + return nil +} + // Close closes IAM client. func (client *Client) Close() (err error) { if client.publicConnection != nil || client.protectedConnection != nil { @@ -581,9 +623,9 @@ func (client *Client) subscribeNodeInfoChange() (listener pb.IAMPublicNodesServi client.Lock() defer client.Unlock() - client.nodeService = pb.NewIAMPublicNodesServiceClient(client.publicConnection) + client.publicNodesService = pb.NewIAMPublicNodesServiceClient(client.publicConnection) - listener, err = client.nodeService.SubscribeNodeChanged(context.Background(), &emptypb.Empty{}) + listener, err = client.publicNodesService.SubscribeNodeChanged(context.Background(), &emptypb.Empty{}) if err != nil { log.WithField("error", err).Error("Can't subscribe on NodeChange event") diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index 2ac22eb0..e29673b7 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -78,6 +78,7 @@ type testPublicServer struct { type testProtectedServer struct { pb.UnimplementedIAMCertificateServiceServer pb.UnimplementedIAMProvisioningServiceServer + pb.UnimplementedIAMNodesServiceServer grpcServer *grpc.Server csr map[string]string @@ -534,6 +535,54 @@ func TestDeprovisioning(t *testing.T) { } } +func TestPauseNode(t *testing.T) { + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, &testSender{}, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + err = client.PauseNode("test-node-id") + if err != nil { + t.Errorf("Error is not expected: %s", err) + } +} + +func TestResumeNode(t *testing.T) { + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, &testSender{}, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + err = client.ResumeNode("test-node-id") + if err != nil { + t.Errorf("Error is not expected: %s", err) + } +} + /******************************************************************************* * Private ******************************************************************************/ @@ -572,6 +621,7 @@ func newTestServer( pb.RegisterIAMCertificateServiceServer(protectedServer.grpcServer, protectedServer) pb.RegisterIAMProvisioningServiceServer(protectedServer.grpcServer, protectedServer) + pb.RegisterIAMNodesServiceServer(protectedServer.grpcServer, protectedServer) go func() { if err := protectedServer.grpcServer.Serve(protectedListener); err != nil { @@ -660,6 +710,22 @@ func (server *testProtectedServer) Deprovision( return rsp, nil } +func (server *testProtectedServer) PauseNode( + context context.Context, req *pb.PauseNodeRequest, +) (rsp *pb.PauseNodeResponse, err error) { + rsp = &pb.PauseNodeResponse{} + + return rsp, nil +} + +func (server *testProtectedServer) ResumeNode( + context context.Context, req *pb.ResumeNodeRequest, +) (rsp *pb.ResumeNodeResponse, err error) { + rsp = &pb.ResumeNodeResponse{} + + return rsp, nil +} + func (server *testPublicServer) GetCert( context context.Context, req *pb.GetCertRequest, ) (rsp *pb.GetCertResponse, err error) { From 16f29325e07493c54d8903c4c17cc5d2ee0795aa Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 18 Jul 2024 12:13:43 +0300 Subject: [PATCH 069/146] [config_test] Update monitoring config to new design Signed-off-by: Oleksandr Grytsov --- config/config_test.go | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 061f318c..3ab6e16a 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -64,19 +64,10 @@ const testConfigContent = `{ }, "monitoring": { "monitorConfig": { - "sendPeriod": "5m", - "pollPeriod": "1s", - "ram": { - "minTimeout": "10s", - "minThreshold": 10, - "maxThreshold": 150 - }, - "outTraffic": { - "minTimeout": "20s", - "minThreshold": 10, - "maxThreshold": 150 - } + "pollPeriod": "1s" }, + "sendPeriod": "5m", + "maxMessageSize": 1024, "maxOfflineMessages": 25 }, "alerts": { @@ -212,20 +203,20 @@ func TestDurationMarshal(t *testing.T) { } func TestGetMonitoringConfig(t *testing.T) { - if testCfg.Monitoring.MonitorConfig.SendPeriod.Duration != 5*time.Minute { - t.Errorf("Wrong send period value: %s", testCfg.Monitoring.MonitorConfig.SendPeriod) - } - if testCfg.Monitoring.MonitorConfig.PollPeriod.Duration != 1*time.Second { t.Errorf("Wrong poll period value: %s", testCfg.Monitoring.MonitorConfig.PollPeriod) } - if testCfg.Monitoring.MonitorConfig.RAM.MinTimeout.Duration != 10*time.Second { - t.Errorf("Wrong value: %s", testCfg.Monitoring.MonitorConfig.RAM.MinTimeout) + if testCfg.Monitoring.SendPeriod.Duration != 5*time.Minute { + t.Errorf("Wrong send period value: %s", testCfg.Monitoring.SendPeriod) + } + + if time.Duration(testCfg.Monitoring.MaxOfflineMessages) != 25 { + t.Errorf("Wrong max offline messages value: %d", testCfg.Monitoring.MaxOfflineMessages) } - if testCfg.Monitoring.MonitorConfig.OutTraffic.MinTimeout.Duration != 20*time.Second { - t.Errorf("Wrong value: %s", testCfg.Monitoring.MonitorConfig.RAM.MinTimeout) + if time.Duration(testCfg.Monitoring.MaxMessageSize) != 1024 { + t.Errorf("Wrong max message size value: %d", testCfg.Monitoring.MaxMessageSize) } } From f1ea78be413d27b17b5e72f98a2f2f47f3ed222f Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 17 Jul 2024 21:55:22 +0300 Subject: [PATCH 070/146] [vendor] Update vendor Signed-off-by: Mykola Kobets --- go.mod | 2 +- go.sum | 4 +- .../api/cloudprotocol/provisioning.go | 80 +++++++++++++++++++ .../resourcemonitor/resourcemonitor.go | 12 +-- vendor/modules.txt | 2 +- 5 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 vendor/github.com/aosedge/aos_common/api/cloudprotocol/provisioning.go diff --git a/go.mod b/go.mod index a7138d6b..d93fa1b9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360 + github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817 github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index d69c7d45..4ffdb764 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360 h1:waPgWerxOf+ccCleP1YYeHxhHWCzENMEbBUff0KESSc= -github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817 h1:kH+sa+lG8ZVpiidELLbaLTslVKsxDgl9tavhwPPAaTA= +github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/provisioning.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/provisioning.go new file mode 100644 index 00000000..2058e30b --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/provisioning.go @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2024 Renesas Electronics Corporation. +// Copyright (C) 2024 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cloudprotocol + +/*********************************************************************************************************************** + * Consts + **********************************************************************************************************************/ + +// Provisioning message types. +const ( + StartProvisioningRequestMessageType = "startProvisioningRequest" + StartProvisioningResponseMessageType = "startProvisioningResponse" + FinishProvisioningRequestMessageType = "finishProvisioningRequest" + FinishProvisioningResponseMessageType = "finishProvisioningResponse" + DeprovisioningRequestMessageType = "deprovisioningRequest" + DeprovisioningResponseMessageType = "deprovisioningResponse" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +// StartProvisioningRequest message. +type StartProvisioningRequest struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + Password string `json:"password"` +} + +// StartProvisioningResponse message. +type StartProvisioningResponse struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` + CSRs []IssueCertData `json:"csrs"` +} + +// FinishProvisioningRequest message. +type FinishProvisioningRequest struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + Certificates []IssuedCertData `json:"certificates"` + Password string `json:"password"` +} + +// FinishProvisioningResponse message. +type FinishProvisioningResponse struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} + +// DeprovisioningRequest message. +type DeprovisioningRequest struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + Password string `json:"password"` +} + +// DeprovisioningResponse message. +type DeprovisioningResponse struct { + MessageType string `json:"messageType"` + NodeID string `json:"nodeId"` + ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` +} diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index d24af655..8fba86d0 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -73,13 +73,13 @@ type AlertSender interface { // NodeInfoProvider interface to get node information. type NodeInfoProvider interface { - GetNodeInfo() (cloudprotocol.NodeInfo, error) + GetCurrentNodeInfo() (cloudprotocol.NodeInfo, error) } // NodeConfigProvider interface to get node config. type NodeConfigProvider interface { - GetNodeConfig() (cloudprotocol.NodeConfig, error) - NodeConfigChangedChannel() <-chan cloudprotocol.NodeConfig + GetCurrentNodeConfig() (cloudprotocol.NodeConfig, error) + CurrentNodeConfigChannel() <-chan cloudprotocol.NodeConfig } // MonitoringSender sends monitoring data. @@ -193,7 +193,7 @@ func New( sourceSystemUsage: getSourceSystemUsage(config.Source), } - nodeInfo, err := nodeInfoProvider.GetNodeInfo() + nodeInfo, err := nodeInfoProvider.GetCurrentNodeInfo() if err != nil { return nil, aoserrors.Wrap(err) } @@ -208,7 +208,7 @@ func New( return nil, aoserrors.Wrap(err) } - nodeConfig, err := nodeConfigProvider.GetNodeConfig() + nodeConfig, err := nodeConfigProvider.GetCurrentNodeConfig() if err != nil { log.Errorf("Can't get node config: %v", err) } @@ -461,7 +461,7 @@ func (monitor *ResourceMonitor) run(ctx context.Context) { case <-ctx.Done(): return - case nodeConfig := <-monitor.nodeConfigProvider.NodeConfigChangedChannel(): + case nodeConfig := <-monitor.nodeConfigProvider.CurrentNodeConfigChannel(): if err := monitor.setupSystemAlerts(nodeConfig); err != nil { log.Errorf("Can't setup system alerts: %v", err) } diff --git a/vendor/modules.txt b/vendor/modules.txt index d7af2cb3..9b81fbaa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240711152142-dac882c71360 +# github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817 ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From 8a5608b160bc2f216fd3d2fc9d95dd39acbdc5c8 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 18 Jul 2024 13:58:32 +0300 Subject: [PATCH 071/146] [unitconfig] Implement GetCurrentNodeConfig/CurrentNodeConfigChannel Signed-off-by: Mykola Kobets --- unitconfig/unitconfig.go | 60 ++++++++++++++++++----- unitconfig/unitconfig_test.go | 90 ++++++++++++++++++++++++++++++++--- 2 files changed, 132 insertions(+), 18 deletions(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 918a5c2d..a6649ad6 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -39,10 +39,18 @@ import ( type Instance struct { sync.Mutex - client Client - unitConfigFile string - unitConfig cloudprotocol.UnitConfig - unitConfigError error + client Client + curNodeID string + curNodeType string + unitConfigFile string + unitConfig cloudprotocol.UnitConfig + currentNodeConfigChannel chan cloudprotocol.NodeConfig + unitConfigError error +} + +// NodeInfoProvider node info provider interface. +type NodeInfoProvider interface { + GetCurrentNodeInfo() (cloudprotocol.NodeInfo, error) } // Client client unit config interface. @@ -69,12 +77,22 @@ var ErrAlreadyInstalled = errors.New("already installed") **********************************************************************************************************************/ // New creates new unit config instance. -func New(cfg *config.Config, client Client) (instance *Instance, err error) { +func New(cfg *config.Config, nodeInfoProvider NodeInfoProvider, client Client) (instance *Instance, err error) { instance = &Instance{ - client: client, - unitConfigFile: cfg.UnitConfigFile, + client: client, + unitConfigFile: cfg.UnitConfigFile, + currentNodeConfigChannel: make(chan cloudprotocol.NodeConfig, 1), } + var nodeInfo cloudprotocol.NodeInfo + + if nodeInfo, err = nodeInfoProvider.GetCurrentNodeInfo(); err != nil { + return nil, aoserrors.Wrap(err) + } + + instance.curNodeID = nodeInfo.NodeID + instance.curNodeType = nodeInfo.NodeType + if err := instance.load(); err != nil { instance.unitConfigError = err } @@ -132,21 +150,31 @@ func (instance *Instance) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) e return nil } -// GetUnitConfig returns unit config for node or node type. -func (instance *Instance) GetUnitConfig(nodeID, nodeType string) cloudprotocol.NodeConfig { +// GetNodeConfig returns node config for node or node type. +func (instance *Instance) GetNodeConfig(nodeID, nodeType string) (cloudprotocol.NodeConfig, error) { for _, node := range instance.unitConfig.Nodes { if node.NodeID != nil && *node.NodeID == nodeID { - return node + return node, nil } } for _, node := range instance.unitConfig.Nodes { if node.NodeType == nodeType { - return node + return node, nil } } - return cloudprotocol.NodeConfig{} + return cloudprotocol.NodeConfig{}, aoserrors.New("not found") +} + +// GetNodeConfig returns node config of the node with given id and type. +func (instance *Instance) GetCurrentNodeConfig() (cloudprotocol.NodeConfig, error) { + return instance.GetNodeConfig(instance.curNodeID, instance.curNodeType) +} + +// CurrentNodeConfigChannel returns channel of current node config updates. +func (instance *Instance) CurrentNodeConfigChannel() <-chan cloudprotocol.NodeConfig { + return instance.currentNodeConfigChannel } // UpdateUnitConfig updates unit config. @@ -177,6 +205,10 @@ func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) if err := instance.client.SetNodeConfig(unitConfig.Version, *nodeConfig); err != nil { return aoserrors.Wrap(err) } + + if nodeConfigStatus.NodeID == instance.curNodeID { + instance.currentNodeConfigChannel <- *nodeConfig + } } } @@ -261,6 +293,10 @@ func (instance *Instance) handleNodeConfigStatus() { if err := instance.client.SetNodeConfig(instance.unitConfig.Version, *nodeConfig); err != nil { log.WithField("NodeID", nodeConfigStatus.NodeID).Errorf("Can't update node config: %v", err) } + + if nodeConfigStatus.NodeID == instance.curNodeID { + instance.currentNodeConfigChannel <- *nodeConfig + } } } diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index 44b75b96..be1c69c9 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -47,6 +47,18 @@ const validTestUnitConfig = ` ] }` +const node0TestUnitConfig = ` + { + "formatVersion": "1", + "version": "1.0.0", + "nodes": [ + { + "nodeId" : "node0", + "nodeType" : "type1" + } + ] + }` + /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -63,6 +75,11 @@ type testClient struct { nodeConfigSetCheckChannel chan testNodeConfig } +type testNodeInfoProvider struct { + nodeID string + nodeType string +} + /*********************************************************************************************************************** * Vars **********************************************************************************************************************/ @@ -112,8 +129,10 @@ func TestValidGetStatus(t *testing.T) { t.Fatalf("Can't create unit config file: %s", err) } + nodeInfoProvider := newTestInfoProvider("node0", "type1") + unitConfig, err := unitconfig.New( - &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, newTestClient()) + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, newTestClient()) if err != nil { t.Fatalf("Can't create unit config instance: %s", err) } @@ -131,7 +150,10 @@ func TestValidGetStatus(t *testing.T) { t.Errorf("Wrong unit config version: %s", info.Version) } - nodeUnitConfig := unitConfig.GetUnitConfig("id1", "type1") + nodeUnitConfig, err := unitConfig.GetNodeConfig("id1", "type1") + if err != nil { + t.Errorf("Unexpected error: %v", err) + } if nodeUnitConfig.NodeType != "type1" { t.Error("Unexpected node type") @@ -150,8 +172,10 @@ func TestInvalidGetStatus(t *testing.T) { t.Fatalf("Can't create unit config file: %s", err) } + nodeInfoProvider := newTestInfoProvider("node0", "type1") + unitConfig, err := unitconfig.New( - &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, newTestClient()) + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, newTestClient()) if err != nil { t.Fatalf("Can't create unit config instance: %s", err) } @@ -172,9 +196,10 @@ func TestCheckUnitConfig(t *testing.T) { } client := newTestClient() + nodeInfoProvider := newTestInfoProvider("node0", "type1") unitConfig, err := unitconfig.New( - &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, client) + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, client) if err != nil { t.Fatalf("Can't create unit config instance: %s", err) } @@ -227,9 +252,10 @@ func TestUpdateUnitConfig(t *testing.T) { } client := newTestClient() + nodeInfoProvider := newTestInfoProvider("node0", "type1") unitConfig, err := unitconfig.New( - &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, client) + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, client) if err != nil { t.Fatalf("Can't create unit config instance: %v", err) } @@ -296,8 +322,9 @@ func TestNodeConfigStatus(t *testing.T) { } client := newTestClient() + nodeInfoProvider := newTestInfoProvider("node0", "type1") - _, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, client) + _, err := unitconfig.New(&config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, client) if err != nil { t.Fatalf("Can't create unit config instance: %v", err) } @@ -318,6 +345,45 @@ func TestNodeConfigStatus(t *testing.T) { } } +func TestCurrentNodeConfigUpdate(t *testing.T) { + if err := os.WriteFile(path.Join(tmpDir, "aos_unit.cfg"), []byte(node0TestUnitConfig), 0o600); err != nil { + t.Fatalf("Can't create unit config file: %v", err) + } + + client := newTestClient() + nodeInfoProvider := newTestInfoProvider("node0", "type1") + + instance, err := unitconfig.New( + &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, client) + if err != nil { + t.Fatalf("Can't create unit config instance: %v", err) + } + + client.nodeConfigStatusChannel <- unitconfig.NodeConfigStatus{ + NodeID: "node0", + NodeType: "type1", + } + + node0 := "node0" + + for i := 0; i < 2; i++ { + select { + case nodeConfig := <-client.nodeConfigSetCheckChannel: + if !reflect.DeepEqual(nodeConfig, testNodeConfig{NodeID: "node0", NodeType: "type1", Version: "1.0.0"}) { + t.Errorf("Wrong node config: %v", nodeConfig) + } + + case curNodeConfig := <-instance.CurrentNodeConfigChannel(): + if !reflect.DeepEqual(curNodeConfig, cloudprotocol.NodeConfig{NodeID: &node0, NodeType: "type1"}) { + t.Errorf("Wrong node config: %v", curNodeConfig) + } + + case <-time.After(1 * time.Second): + t.Fatalf("Set node config timeout") + } + } +} + /*********************************************************************************************************************** * testClient **********************************************************************************************************************/ @@ -356,3 +422,15 @@ func (client *testClient) GetNodeConfigStatuses() ([]unitconfig.NodeConfigStatus func (client *testClient) NodeConfigStatusChannel() <-chan unitconfig.NodeConfigStatus { return client.nodeConfigStatusChannel } + +/*********************************************************************************************************************** + * testNodeInfoProvider + **********************************************************************************************************************/ + +func newTestInfoProvider(nodeID, nodeType string) *testNodeInfoProvider { + return &testNodeInfoProvider{nodeID: nodeID, nodeType: nodeType} +} + +func (provider *testNodeInfoProvider) GetCurrentNodeInfo() (cloudprotocol.NodeInfo, error) { + return cloudprotocol.NodeInfo{NodeID: provider.nodeID, NodeType: provider.nodeType}, nil +} From a7ea53e0e9296aa38b0d9c0ce9ad77391ff85f08 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Thu, 18 Jul 2024 13:58:59 +0300 Subject: [PATCH 072/146] [iamclient] Implement GetCurrentNodeInfo Signed-off-by: Mykola Kobets --- iamclient/iamclient.go | 5 +++++ iamclient/iamclient_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index f232f3a5..4e9c2dff 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -160,6 +160,11 @@ func (client *Client) GetSystemID() (systemID string) { return client.systemID } +// GetCurrentNodeInfo returns info for current node. +func (client *Client) GetCurrentNodeInfo() (nodeInfo cloudprotocol.NodeInfo, err error) { + return client.GetNodeInfo(client.GetNodeID()) +} + // GetNodeInfo returns node info. func (client *Client) GetNodeInfo(nodeID string) (nodeInfo cloudprotocol.NodeInfo, err error) { log.WithField("nodeID", nodeID).Debug("Get node info") diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index e29673b7..7b1eba17 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -378,6 +378,38 @@ func TestGetNodeInfo(t *testing.T) { } } +func TestGetCurrentNodeInfo(t *testing.T) { + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %v", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, &testSender{}, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %v", err) + } + defer client.Close() + + nodeInfo, err := client.GetCurrentNodeInfo() + if err != nil { + t.Errorf("Error is not expected: %v", err) + } + + if nodeInfo.NodeID != publicServer.currentID { + t.Errorf("Not expected NodeId: %s", nodeInfo.NodeID) + } + + if nodeInfo.Name != publicServer.currentNodeName { + t.Errorf("Not expected NodeId: %s", nodeInfo.Name) + } +} + func TestSubscribeNodeInfoChange(t *testing.T) { publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) if err != nil { From 6eb51819faad81a36b10849f1546e86e76e206eb Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 17 Jul 2024 22:09:05 +0300 Subject: [PATCH 073/146] [all] Fix build/lint issues Signed-off-by: Mykola Kobets --- communicationmanager.go | 15 ++++++++------- database/database.go | 2 ++ fcrypt/fcrypt_internal_test.go | 2 ++ fileserver/fileserver_test.go | 3 +-- iamclient/iamclient.go | 10 ++++++---- iamclient/iamclient_test.go | 15 +++++++++++---- imagemanager/imagemanager_test.go | 5 ++--- launcher/launcher.go | 23 ++++++++++++++++++----- launcher/launcher_test.go | 4 ++-- networkmanager/dnsserver.go | 5 ++--- networkmanager/ipamalloc.go | 4 +++- networkmanager/networkmanager.go | 6 +++--- smcontroller/smhandler.go | 6 +++--- storagestate/storagestate_test.go | 5 ++--- umcontroller/umcontroller.go | 8 ++++---- umcontroller/umcontroller_test.go | 20 ++++++++++---------- unitstatushandler/firmwaremanager.go | 2 +- unitstatushandler/timetable.go | 7 +++++-- 18 files changed, 85 insertions(+), 57 deletions(-) diff --git a/communicationmanager.go b/communicationmanager.go index 692e8212..846b8ee9 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -179,8 +179,8 @@ func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err } if cfg.Monitoring.MonitorConfig != nil { - if cm.resourcemonitor, err = resourcemonitor.New(cm.iam.GetNodeID(), *cfg.Monitoring.MonitorConfig, - cm.alerts, cm.monitorcontroller, nil); err != nil { + if cm.resourcemonitor, err = resourcemonitor.New(*cfg.Monitoring.MonitorConfig, cm.iam, cm.unitConfig, + nil, cm.alerts, cm.monitorcontroller); err != nil { return cm, aoserrors.Wrap(err) } } @@ -194,11 +194,11 @@ func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err return cm, aoserrors.Wrap(err) } - if cm.umController, err = umcontroller.New(cfg, cm.db, cm.iam, cm.cryptoContext, cm.crypt, false); err != nil { + if cm.umController, err = umcontroller.New(cfg, cm.db, cm.iam, cm.iam, cm.cryptoContext, cm.crypt, false); err != nil { return cm, aoserrors.Wrap(err) } - if cm.unitConfig, err = unitconfig.New(cfg, cm.smController); err != nil { + if cm.unitConfig, err = unitconfig.New(cfg, cm.iam, cm.smController); err != nil { return cm, aoserrors.Wrap(err) } @@ -215,12 +215,12 @@ func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err } if cm.launcher, err = launcher.New( - cfg, cm.db, cm.smController, cm.imagemanager, cm.unitConfig, cm.storageState, cm.network); err != nil { + cfg, cm.db, cm.iam, cm.smController, cm.imagemanager, cm.unitConfig, cm.storageState, cm.network); err != nil { return cm, aoserrors.Wrap(err) } - if cm.statusHandler, err = unitstatushandler.New(cfg, cm.unitConfig, cm.umController, cm.imagemanager, cm.launcher, - cm.downloader, cm.db, cm.amqp); err != nil { + if cm.statusHandler, err = unitstatushandler.New(cfg, cm.iam, cm.unitConfig, cm.umController, + cm.imagemanager, cm.launcher, cm.downloader, cm.db, cm.amqp, cm.smController); err != nil { return cm, aoserrors.Wrap(err) } @@ -331,6 +331,7 @@ func (cm *communicationManager) close() { } } +//nolint:funlen func (cm *communicationManager) processMessage(message amqp.Message) (err error) { switch data := message.(type) { case *cloudprotocol.DesiredStatus: diff --git a/database/database.go b/database/database.go index a8538a72..a73829ee 100644 --- a/database/database.go +++ b/database/database.go @@ -380,6 +380,7 @@ func (db *Database) GetServicesInfo() ([]imagemanager.ServiceInfo, error) { if err != nil { return nil, aoserrors.Wrap(err) } + if greater { maxVersionServices[service.ServiceID] = service } @@ -1066,6 +1067,7 @@ func (db *Database) getMaxServiceVersion(serviceID string) (version string, err if err != nil { return "", aoserrors.Wrap(err) } + defer rows.Close() if rows.Err() != nil { diff --git a/fcrypt/fcrypt_internal_test.go b/fcrypt/fcrypt_internal_test.go index a830f0a8..0cb4acca 100644 --- a/fcrypt/fcrypt_internal_test.go +++ b/fcrypt/fcrypt_internal_test.go @@ -911,6 +911,7 @@ func TestVerifySignOfComponent(t *testing.T) { if err != nil { t.Fatal("Cannot create temporary file", err) } + defer tmpFile.Close() defer os.Remove(tmpFile.Name()) @@ -938,6 +939,7 @@ func TestVerifySignOfComponent(t *testing.T) { t.Fatal("Cannot create temporary file", err) } defer tmpFile.Close() + defer os.Remove(tmpFile.Name()) if _, err = tmpFile.Write(data.FileData); err != nil { diff --git a/fileserver/fileserver_test.go b/fileserver/fileserver_test.go index e57c398c..0bae313e 100644 --- a/fileserver/fileserver_test.go +++ b/fileserver/fileserver_test.go @@ -21,7 +21,6 @@ package fileserver_test import ( "bytes" - "fmt" "io" "net/http" "os" @@ -110,7 +109,7 @@ func TestFileServer(t *testing.T) { t.Fatalf("Can't create package file: %s", err) } - outURL, err = fileServer.TranslateURL(false, fmt.Sprintf("file://%s", filepath.Join(serverDir, filename))) + outURL, err = fileServer.TranslateURL(false, "file://"+filepath.Join(serverDir, filename)) if err != nil { t.Errorf("Can't translate remote url: %s", err) } diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 4e9c2dff..f0b2be2d 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -194,10 +194,10 @@ func (client *Client) GetAllNodeIDs() (nodeIDs []string, err error) { return nil, aoserrors.Wrap(err) } - return response.Ids, err + return response.GetIds(), err } -// SubscribeNodeInfoChange subscribes client on NodeInfoChange events +// SubscribeNodeInfoChange subscribes client on NodeInfoChange events. func (client *Client) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { client.Lock() defer client.Unlock() @@ -624,7 +624,9 @@ func (client *Client) connectPublicNodeService() { } } -func (client *Client) subscribeNodeInfoChange() (listener pb.IAMPublicNodesService_SubscribeNodeChangedClient, err error) { +func (client *Client) subscribeNodeInfoChange() ( + listener pb.IAMPublicNodesService_SubscribeNodeChangedClient, err error, +) { client.Lock() defer client.Unlock() @@ -637,7 +639,7 @@ func (client *Client) subscribeNodeInfoChange() (listener pb.IAMPublicNodesServi return nil, aoserrors.Wrap(err) } - return listener, err + return listener, aoserrors.Wrap(err) } func (client *Client) getCertTypes(nodeID string) ([]string, error) { diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index 7b1eba17..95eabe28 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -440,6 +440,7 @@ func TestSubscribeNodeInfoChange(t *testing.T) { if secondaryNodeInfo.GetNodeId() != receivedNodeInfo.NodeID { t.Errorf("NodeInfo with not expected Id: %s", receivedNodeInfo.NodeID) } + if secondaryNodeInfo.GetName() != receivedNodeInfo.Name { t.Errorf("NodeInfo with not expected Name: %s", receivedNodeInfo.Name) } @@ -795,20 +796,26 @@ func (server *testPublicServer) GetNodeInfo(context context.Context, req *empty. return &pb.NodeInfo{}, nil } -func (server *testIAMPublicNodesServiceServer) GetAllNodeIDs(context context.Context, req *emptypb.Empty) (*pb.NodesID, error) { +func (server *testIAMPublicNodesServiceServer) GetAllNodeIDs(context context.Context, req *emptypb.Empty) ( + *pb.NodesID, error, +) { return &pb.NodesID{}, nil } -func (server *testIAMPublicNodesServiceServer) GetNodeInfo(context context.Context, req *pb.GetNodeInfoRequest) (*pb.NodeInfo, error) { +func (server *testIAMPublicNodesServiceServer) GetNodeInfo(context context.Context, req *pb.GetNodeInfoRequest) ( + *pb.NodeInfo, error, +) { return &pb.NodeInfo{NodeId: server.currentID, Name: server.currentNodeName}, nil } -func (server *testIAMPublicNodesServiceServer) SubscribeNodeChanged(empty *emptypb.Empty, stream pb.IAMPublicNodesService_SubscribeNodeChangedServer) error { +func (server *testIAMPublicNodesServiceServer) SubscribeNodeChanged( + empty *emptypb.Empty, stream pb.IAMPublicNodesService_SubscribeNodeChangedServer, +) error { log.Error("testIAMPublicNodesServiceServer SubscribeNodeChanged") nodeInfo := <-server.nodeInfo - return stream.Send(nodeInfo) + return aoserrors.Wrap(stream.Send(nodeInfo)) } func (server *testIAMPublicNodesServiceServer) RegisterNode(pb.IAMPublicNodesService_RegisterNodeServer) error { diff --git a/imagemanager/imagemanager_test.go b/imagemanager/imagemanager_test.go index a0a4cc74..432234d7 100644 --- a/imagemanager/imagemanager_test.go +++ b/imagemanager/imagemanager_test.go @@ -989,9 +989,8 @@ func TestFileServer(t *testing.T) { decryptFilePath := path.Join("layers", base64.URLEncoding.EncodeToString(layerInfo.Sha256)+".dec") - if layer.RemoteURL != fmt.Sprintf("http://localhost:8092/%s", decryptFilePath) || - layer.URL != fmt.Sprintf("file://%s", - path.Join(layersDir, base64.URLEncoding.EncodeToString(layerInfo.Sha256)+".dec")) { + if layer.RemoteURL != "http://localhost:8092/"+decryptFilePath || + layer.URL != "file://"+path.Join(layersDir, base64.URLEncoding.EncodeToString(layerInfo.Sha256)+".dec") { t.Fatalf("Unexpected urls") } diff --git a/launcher/launcher.go b/launcher/launcher.go index f69f7ed6..bd1059dd 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -142,7 +142,7 @@ type NodeInfoProvider interface { // ResourceManager provides node resources. type ResourceManager interface { - GetNodeConfig(nodeID, nodeType string) cloudprotocol.NodeConfig + GetNodeConfig(nodeID, nodeType string) (cloudprotocol.NodeConfig, error) } // StorageStateProvider instances storage state provider. @@ -381,13 +381,16 @@ func (launcher *Launcher) initNodeStatus(nodeID string) (*nodeStatus, error) { log.WithFields(log.Fields{"nodeID": nodeID}).Errorf("Can't load node run request") } - launcher.initNodeConfig(status) + err = launcher.initNodeConfig(status) - return status, nil + return status, err } -func (launcher *Launcher) initNodeConfig(nodeStatus *nodeStatus) { - nodeUnitConfig := launcher.resourceManager.GetNodeConfig(nodeStatus.nodeInfo.NodeID, nodeStatus.nodeInfo.NodeType) +func (launcher *Launcher) initNodeConfig(nodeStatus *nodeStatus) error { + nodeUnitConfig, err := launcher.resourceManager.GetNodeConfig(nodeStatus.nodeInfo.NodeID, nodeStatus.nodeInfo.NodeType) + if err != nil { + return aoserrors.Wrap(err) + } nodeStatus.priority = nodeUnitConfig.Priority nodeStatus.availableLabels = nodeUnitConfig.Labels @@ -416,6 +419,8 @@ func (launcher *Launcher) initNodeConfig(nodeStatus *nodeStatus) { instanceIdentLogFields(instance.InstanceIdent, nil)).Errorf("Can't allocate devices: %v", err) } } + + return nil } func (launcher *Launcher) resetDeviceAllocation() { @@ -871,6 +876,7 @@ func (launcher *Launcher) getNodesByDevices( return nodes, nil } +//nolint:unused func (launcher *Launcher) getNodeByMonitoringData(nodes []*nodeStatus, alertType string) (newNodes []*nodeStatus) { if len(nodes) == 1 { return nodes @@ -958,6 +964,7 @@ serviceDeviceLoop: return nil } +//nolint:unused func (launcher *Launcher) releaseDevices(node *nodeStatus, serviceDevices []aostypes.ServiceDevice) error { serviceDeviceLoop: for _, serviceDevice := range serviceDevices { @@ -1122,6 +1129,7 @@ layerLoopLabel: } } +//nolint:unused func (launcher *Launcher) removeInstanceFromNode(ident aostypes.InstanceIdent, node *nodeStatus) { log.WithFields(log.Fields{"ident": ident, "node": node.nodeInfo.NodeID}).Debug("Remove instance from node") @@ -1137,6 +1145,7 @@ func (launcher *Launcher) removeInstanceFromNode(ident aostypes.InstanceIdent, n node.currentRunRequest.Instances = node.currentRunRequest.Instances[:i] } +//nolint:unused func (launcher *Launcher) removeServiceFromNode(serviceID string, node *nodeStatus) { log.WithFields(log.Fields{"serviceID": serviceID, "node": node.nodeInfo.NodeID}).Debug("Remove service from node") @@ -1152,6 +1161,7 @@ func (launcher *Launcher) removeServiceFromNode(serviceID string, node *nodeStat node.currentRunRequest.Services = node.currentRunRequest.Services[:i] } +//nolint:unused func (launcher *Launcher) removeLayerFromNode(digest string, node *nodeStatus) { log.WithFields(log.Fields{"digest": digest, "node": node.nodeInfo.NodeID}).Debug("Remove layer from node") @@ -1167,6 +1177,7 @@ func (launcher *Launcher) removeLayerFromNode(digest string, node *nodeStatus) { node.currentRunRequest.Layers = node.currentRunRequest.Layers[:i] } +//nolint:unused func (launcher *Launcher) removeRunRequest(instance aostypes.InstanceInfo, node *nodeStatus) { launcher.removeInstanceFromNode(instance.InstanceIdent, node) @@ -1241,6 +1252,7 @@ func (launcher *Launcher) getNode(nodeID string) *nodeStatus { return nil } +//nolint:unused func (launcher *Launcher) getLowerPriorityNodes(node *nodeStatus) (nodes []*nodeStatus) { for _, currentNode := range launcher.nodes { if currentNode.priority > node.priority || currentNode.nodeInfo.NodeID == node.nodeInfo.NodeID { @@ -1253,6 +1265,7 @@ func (launcher *Launcher) getLowerPriorityNodes(node *nodeStatus) (nodes []*node return nodes } +//nolint:unused func (launcher *Launcher) getLabelsForInstance(ident aostypes.InstanceIdent) ([]string, error) { for _, instance := range launcher.currentDesiredInstances { if instance.ServiceID == ident.ServiceID && instance.SubjectID == ident.SubjectID { diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 0862c84a..86fc7fe2 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -1249,11 +1249,11 @@ func newTestResourceManager() *testResourceManager { return resourceManager } -func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType string) cloudprotocol.NodeConfig { +func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType string) (cloudprotocol.NodeConfig, error) { resource := resourceManager.nodeResources[nodeType] resource.NodeType = nodeType - return resource + return resource, nil } // testStorage diff --git a/networkmanager/dnsserver.go b/networkmanager/dnsserver.go index d81207b9..8c0ea688 100644 --- a/networkmanager/dnsserver.go +++ b/networkmanager/dnsserver.go @@ -21,7 +21,6 @@ package networkmanager import ( "bytes" - "fmt" "html/template" "os" "os/exec" @@ -154,7 +153,7 @@ func (dns *dnsServer) rewriteHostsFile() error { entry := ip for _, alias := range hosts { - entry += fmt.Sprintf("\t%s", alias) + entry += "\t" + alias } entry += "\n" @@ -251,7 +250,7 @@ func (dns *dnsServer) start() error { args := []string{ "-u", "root", - fmt.Sprintf("--conf-file=%s", dns.configFile), + "--conf-file=" + dns.configFile, } output, err := ExecContext(dns.binary, args...) diff --git a/networkmanager/ipamalloc.go b/networkmanager/ipamalloc.go index aed91ef6..55afc069 100644 --- a/networkmanager/ipamalloc.go +++ b/networkmanager/ipamalloc.go @@ -173,7 +173,9 @@ func (ipam *ipSubnet) getAvailableSubnet(networkID string) (*net.IPNet, error) { return subnet.ipNet, nil } -func (ipam *ipSubnet) removeAllocatedSubnets(networks []aostypes.NetworkParameters, networkInstances []InstanceNetworkInfo) { +func (ipam *ipSubnet) removeAllocatedSubnets(networks []aostypes.NetworkParameters, + networkInstances []InstanceNetworkInfo, +) { ipam.Lock() defer ipam.Unlock() diff --git a/networkmanager/networkmanager.go b/networkmanager/networkmanager.go index 301de5a2..c64a52fd 100644 --- a/networkmanager/networkmanager.go +++ b/networkmanager/networkmanager.go @@ -78,15 +78,15 @@ type NetworkManager struct { // FirewallRule represents firewall rule. type FirewallRule struct { - Protocol string - Port string + Protocol string `json:"protocol"` + Port string `json:"port"` } // InstanceNetworkInfo represents network info for instance. type InstanceNetworkInfo struct { aostypes.InstanceIdent aostypes.NetworkParameters - Rules []FirewallRule + Rules []FirewallRule `json:"rules"` } // NetworkParameters represents network parameters. diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 31dd59f4..e00fd247 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -539,9 +539,9 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { Part: data.GetPart(), Content: data.GetData(), ErrorInfo: &cloudprotocol.ErrorInfo{ - AosCode: int(data.GetError().AosCode), - ExitCode: int(data.GetError().ExitCode), - Message: data.GetError().Message, + AosCode: int(data.GetError().GetAosCode()), + ExitCode: int(data.GetError().GetExitCode()), + Message: data.GetError().GetMessage(), }, }); err != nil { log.Errorf("Can't send log: %v", err) diff --git a/storagestate/storagestate_test.go b/storagestate/storagestate_test.go index dc6506df..8dc5a806 100644 --- a/storagestate/storagestate_test.go +++ b/storagestate/storagestate_test.go @@ -20,7 +20,6 @@ package storagestate_test import ( "bytes" "encoding/hex" - "fmt" "os" "path" "testing" @@ -487,7 +486,7 @@ func TestUpdateState(t *testing.T) { } checkSumFromFile, err := getStateFileChecksum(path.Join( - stateDir, fmt.Sprintf("%s_state.dat", stateStorageInfo.InstanceID))) + stateDir, stateStorageInfo.InstanceID+"_state.dat")) if err != nil { t.Fatalf("Can't get checksum from state file: %v", err) } @@ -924,7 +923,7 @@ func TestStateAcceptance(t *testing.T) { t.Error("Can't found state storage info by instance ident") } - pathToStateFile := path.Join(stateDir, fmt.Sprintf("%s_state.dat", stateStorageInfo.InstanceID)) + pathToStateFile := path.Join(stateDir, stateStorageInfo.InstanceID+"_state.dat") if err := os.WriteFile(pathToStateFile, []byte(testData.stateData), 0o600); err != nil { t.Fatalf("Can't write state file: %v", err) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index dbbe0473..f71bf7ef 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -54,7 +54,7 @@ type Controller struct { server *umCtrlServer eventChannel chan umCtrlInternalMsg - nodeInfoChannel <-chan *cloudprotocol.NodeInfo + nodeInfoChannel <-chan cloudprotocol.NodeInfo stopChannel chan bool componentDir string @@ -147,8 +147,8 @@ type Decrypter interface { type NodeInfoProvider interface { GetNodeID() string GetAllNodeIDs() (nodeIds []string, err error) - GetNodeInfo(nodeID string) (nodeInfo *cloudprotocol.NodeInfo, err error) - SubscribeNodeInfoChange() <-chan *cloudprotocol.NodeInfo + GetNodeInfo(nodeID string) (nodeInfo cloudprotocol.NodeInfo, err error) + SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo } /*********************************************************************************************************************** @@ -1107,7 +1107,7 @@ func (umCtrl *Controller) createConnections(nodeInfoProvider NodeInfoProvider) e return nil } -func (umCtrl *Controller) handleNodeInfoChange(nodeInfo *cloudprotocol.NodeInfo) { +func (umCtrl *Controller) handleNodeInfoChange(nodeInfo cloudprotocol.NodeInfo) { if nodeInfo.Status == "unprovisioned" { return } diff --git a/umcontroller/umcontroller_test.go b/umcontroller/umcontroller_test.go index 27bd4c33..faf2b918 100644 --- a/umcontroller/umcontroller_test.go +++ b/umcontroller/umcontroller_test.go @@ -82,8 +82,8 @@ type testCryptoContext struct{} type testNodeInfoProvider struct { umcontroller.NodeInfoProvider - nodeInfo []*cloudprotocol.NodeInfo - nodeInfoListeners []chan *cloudprotocol.NodeInfo + nodeInfo []cloudprotocol.NodeInfo + nodeInfoListeners []chan cloudprotocol.NodeInfo } /*********************************************************************************************************************** @@ -112,12 +112,12 @@ func init() { func NewTestNodeInfoProvider(nodeIds []string) *testNodeInfoProvider { provider := &testNodeInfoProvider{ - nodeInfo: make([]*cloudprotocol.NodeInfo, 0), - nodeInfoListeners: make([]chan *cloudprotocol.NodeInfo, 0), + nodeInfo: make([]cloudprotocol.NodeInfo, 0), + nodeInfoListeners: make([]chan cloudprotocol.NodeInfo, 0), } for _, nodeID := range nodeIds { - nodeInfo := &cloudprotocol.NodeInfo{ + nodeInfo := cloudprotocol.NodeInfo{ NodeID: nodeID, Status: "provisioned", Attrs: map[string]interface{}{ @@ -144,25 +144,25 @@ func (provider *testNodeInfoProvider) GetAllNodeIDs() (nodesIds []string, err er return result, nil } -func (provider *testNodeInfoProvider) GetNodeInfo(nodeID string) (nodeInfo *cloudprotocol.NodeInfo, err error) { +func (provider *testNodeInfoProvider) GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) { for _, nodeInfo := range provider.nodeInfo { if nodeInfo.NodeID == nodeID { return nodeInfo, nil } } - return nil, aoserrors.Errorf("not found") + return cloudprotocol.NodeInfo{}, aoserrors.Errorf("not found") } -func (provider *testNodeInfoProvider) SubscribeNodeInfoChange() <-chan *cloudprotocol.NodeInfo { - listener := make(chan *cloudprotocol.NodeInfo) +func (provider *testNodeInfoProvider) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { + listener := make(chan cloudprotocol.NodeInfo) provider.nodeInfoListeners = append(provider.nodeInfoListeners, listener) return listener } func (provider *testNodeInfoProvider) addNode(nodeID string) { - nodeInfo := &cloudprotocol.NodeInfo{ + nodeInfo := cloudprotocol.NodeInfo{ NodeID: nodeID, Status: "provisioned", Attrs: map[string]interface{}{ diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index a918b28f..d8fb727c 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -629,7 +629,7 @@ func (manager *firmwareManager) updateComponents(ctx context.Context) (component case <-ctx.Done(): if err := ctx.Err(); err != nil { - return err + return aoserrors.Wrap(err) } return nil diff --git a/unitstatushandler/timetable.go b/unitstatushandler/timetable.go index 5a3bc2d8..9eefe273 100644 --- a/unitstatushandler/timetable.go +++ b/unitstatushandler/timetable.go @@ -29,7 +29,10 @@ import ( * Consts **********************************************************************************************************************/ -const maxAvailableTime = 1<<63 - 1 +const ( + maxAvailableTime = 1<<63 - 1 + daysInWeek = 7 +) /*********************************************************************************************************************** * Types @@ -85,7 +88,7 @@ func getAvailableTimetableTime( for _, entry := range timetable { // Convert to time.Weekday - entryWeekday := time.Weekday((entry.DayOfWeek) % 7) //nolint:gomnd + entryWeekday := time.Weekday((entry.DayOfWeek) % daysInWeek) fromWeekday := fromDate.Weekday() // Get num of days from weekday to entry weekday From 746d5d3c23586ad007d4fd3f6cee3a6d81d8bdca Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Thu, 18 Jul 2024 20:35:39 +0300 Subject: [PATCH 074/146] [all] Get rid of slices package Signed-off-by: Mykhailo Lohvynenko --- monitorcontroller/monitorcontroller.go | 48 +++++++++++---------- umcontroller/umcontroller.go | 58 +++++++++++++++----------- unitstatushandler/firmwaremanager.go | 10 ++--- unitstatushandler/unitstatushandler.go | 26 ++++++++---- 4 files changed, 81 insertions(+), 61 deletions(-) diff --git a/monitorcontroller/monitorcontroller.go b/monitorcontroller/monitorcontroller.go index 5de5d0fe..ee4dce1c 100644 --- a/monitorcontroller/monitorcontroller.go +++ b/monitorcontroller/monitorcontroller.go @@ -21,7 +21,6 @@ import ( "context" "encoding/json" "errors" - "slices" "sync" "time" @@ -206,40 +205,45 @@ func (monitor *MonitorController) addNodeMonitoring(nodeMonitoring aostypes.Node latestMessage := &monitor.offlineMessages[len(monitor.offlineMessages)-1] // add node monitoring data - nodeDataInd := slices.IndexFunc(latestMessage.Nodes, - func(item cloudprotocol.NodeMonitoringData) bool { return item.NodeID == nodeMonitoring.NodeID }, - ) + nodeDataFound := false - if nodeDataInd >= 0 { - nodeItems := &latestMessage.Nodes[nodeDataInd].Items - *nodeItems = append(*nodeItems, nodeMonitoring.NodeData) - } else { + for i, nodeData := range latestMessage.Nodes { + if nodeData.NodeID == nodeMonitoring.NodeID { + latestMessage.Nodes[i].Items = append(latestMessage.Nodes[i].Items, nodeMonitoring.NodeData) + nodeDataFound = true + + break + } + } + + if !nodeDataFound { latestMessage.Nodes = append(latestMessage.Nodes, cloudprotocol.NodeMonitoringData{ NodeID: nodeMonitoring.NodeID, Items: []aostypes.MonitoringData{nodeMonitoring.NodeData}, - }, - ) + }) } // add instance monitoring data for _, instanceData := range nodeMonitoring.InstancesData { - instanceDataInd := slices.IndexFunc(latestMessage.ServiceInstances, - func(item cloudprotocol.InstanceMonitoringData) bool { - return item.NodeID == nodeMonitoring.NodeID && item.InstanceIdent == instanceData.InstanceIdent - }, - ) - - if instanceDataInd >= 0 { - serviceInstanceItems := &latestMessage.ServiceInstances[instanceDataInd].Items - *serviceInstanceItems = append(*serviceInstanceItems, instanceData.MonitoringData) - } else { + instanceDataFound := false + + for i, item := range latestMessage.ServiceInstances { + if item.NodeID == nodeMonitoring.NodeID && item.InstanceIdent == instanceData.InstanceIdent { + latestMessage.ServiceInstances[i].Items = append(latestMessage.ServiceInstances[i].Items, + instanceData.MonitoringData) + instanceDataFound = true + + break + } + } + + if !instanceDataFound { latestMessage.ServiceInstances = append(latestMessage.ServiceInstances, cloudprotocol.InstanceMonitoringData{ NodeID: nodeMonitoring.NodeID, InstanceIdent: instanceData.InstanceIdent, Items: []aostypes.MonitoringData{instanceData.MonitoringData}, - }, - ) + }) } } } diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index f71bf7ef..e89310b3 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -25,7 +25,6 @@ import ( "os" "path" "path/filepath" - "slices" "sort" "sync" "time" @@ -1085,23 +1084,19 @@ func (umCtrl *Controller) createConnections(nodeInfoProvider NodeInfoProvider) e continue } - components, err := nodeInfo.GetAosComponents() + nodeHasUM, err := umCtrl.nodeHasUMComponent(nodeInfo) if err != nil { - log.WithFields(log.Fields{"err": err, "nodeID": nodeInfo.NodeID}).Error("Can't get aos components") - - continue + log.WithField("nodeID", nodeInfo.NodeID).Errorf("Failed to check UM component: %v", err) } - if !slices.Contains(components, cloudprotocol.AosComponentUM) { - continue + if nodeHasUM { + umCtrl.connections = append(umCtrl.connections, umConnection{ + umID: nodeInfo.NodeID, + isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, + updatePriority: lowestUpdatePriority, + handler: nil, + }) } - - umCtrl.connections = append(umCtrl.connections, umConnection{ - umID: nodeInfo.NodeID, - isLocalClient: nodeInfo.NodeID == umCtrl.currentNodeID, - updatePriority: lowestUpdatePriority, - handler: nil, - }) } return nil @@ -1112,23 +1107,19 @@ func (umCtrl *Controller) handleNodeInfoChange(nodeInfo cloudprotocol.NodeInfo) return } - components, err := nodeInfo.GetAosComponents() + nodeHasUM, err := umCtrl.nodeHasUMComponent(nodeInfo) if err != nil { - log.WithField("err", err).Error("Can't get aos components") - - return + log.WithField("nodeID", nodeInfo.NodeID).Errorf("Failed to check UM component: %v", err) } - if !slices.Contains(components, cloudprotocol.AosComponentUM) { + if !nodeHasUM { return } - connectionAdded := slices.ContainsFunc(umCtrl.connections, func(connection umConnection) bool { - return connection.umID == nodeInfo.NodeID - }) - - if connectionAdded { - return + for _, connection := range umCtrl.connections { + if connection.umID == nodeInfo.NodeID { + return + } } umCtrl.connections = append(umCtrl.connections, umConnection{ @@ -1166,3 +1157,20 @@ func (umCtrl *Controller) notifyNewComponents(umID string, componsStatus []syste umCtrl.newComponentsChannel <- newComponents } + +func (umCtrl *Controller) nodeHasUMComponent( + nodeInfo cloudprotocol.NodeInfo, +) (bool, error) { + components, err := nodeInfo.GetAosComponents() + if err != nil { + return false, aoserrors.Wrap(err) + } + + for _, component := range components { + if component == cloudprotocol.AosComponentUM { + return true, nil + } + } + + return false, nil +} diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index d8fb727c..160d1b83 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -23,7 +23,6 @@ import ( "errors" "net/url" "reflect" - "slices" "sync" "time" @@ -781,13 +780,14 @@ func handleDesiredComponentsWithNoID(componentsWithNoID []cloudprotocol.Componen newComponents := make(map[string]cloudprotocol.ComponentInfo) +installedLoop: for _, installedComponent := range installedComponents { componentID := installedComponent.ComponentID - if slices.ContainsFunc(update.Components, func(component cloudprotocol.ComponentInfo) bool { - return *component.ComponentID == componentID - }) { - continue + for _, updateComponent := range update.Components { + if updateComponent.ComponentID != nil && *updateComponent.ComponentID == componentID { + continue installedLoop + } } for _, component := range componentsWithNoID { diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 6a8c4e34..df762d69 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -21,7 +21,6 @@ import ( "context" "encoding/json" "errors" - "slices" "sync" "sync/atomic" "time" @@ -650,14 +649,19 @@ func (instance *Instance) updateNodeInfo(nodeInfo cloudprotocol.NodeInfo) { "status": nodeInfo.Status, }).Debug("Node info changed") - index := slices.IndexFunc(instance.unitStatus.nodes, func(curNodeInfo cloudprotocol.NodeInfo) bool { - return curNodeInfo.NodeID == nodeInfo.NodeID - }) + nodeInfoFound := false + + for i, curNodeInfo := range instance.unitStatus.nodes { + if curNodeInfo.NodeID == nodeInfo.NodeID { + instance.unitStatus.nodes[i] = nodeInfo + nodeInfoFound = true - if index == -1 { + break + } + } + + if !nodeInfoFound { instance.unitStatus.nodes = append(instance.unitStatus.nodes, nodeInfo) - } else { - instance.unitStatus.nodes[index] = nodeInfo } instance.statusChanged() @@ -831,12 +835,16 @@ func (instance *Instance) handleChannels() { return } - rebalancingParameters := []string{"cpu", "ram"} + for _, param := range []string{"cpu", "ram"} { + if param != systemQuotaAlert.Parameter { + continue + } - if slices.Contains(rebalancingParameters, systemQuotaAlert.Parameter) { if err := instance.softwareManager.requestRebalancing(); err != nil { log.Errorf("Can't perform rebalancing: %v", err) } + + break } } } From 96fe9a327bc2dee471214aad7231f5ec5b4e51c2 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 19 Jul 2024 16:24:38 +0300 Subject: [PATCH 075/146] [launcher] Get all node ids from iam Signed-off-by: Mykhailo Lohvynenko --- launcher/launcher.go | 14 +++++++++++--- launcher/launcher_test.go | 13 +++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index bd1059dd..fe71bc79 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -138,6 +138,7 @@ type NodeManager interface { type NodeInfoProvider interface { GetNodeID() string GetNodeInfo(nodeID string) (cloudprotocol.NodeInfo, error) + GetAllNodeIDs() (nodeIDs []string, err error) } // ResourceManager provides node resources. @@ -313,9 +314,16 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat log.Debugf("Received run status from nodeID: %s", runStatus.NodeID) + allNodeIDs, err := launcher.nodeInfoProvider.GetAllNodeIDs() + if err != nil { + log.Errorf("Can't get all nodeIDs: %v", err) + + return + } + currentStatus := launcher.getNode(runStatus.NodeID) if currentStatus == nil { - if !slices.Contains(launcher.config.SMController.NodeIDs, runStatus.NodeID) { + if !slices.Contains(allNodeIDs, runStatus.NodeID) { log.Errorf("Received status for unknown nodeID %s", runStatus.NodeID) return @@ -332,7 +340,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat launcher.nodes = append(launcher.nodes, currentStatus) - if len(launcher.nodes) == len(launcher.config.SMController.NodeIDs) { + if len(launcher.nodes) == len(allNodeIDs) { log.Debug("All clients connected") } @@ -348,7 +356,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat currentStatus.receivedRunInstances = runStatus.Instances currentStatus.waitStatus = false - if len(launcher.nodes) != len(launcher.config.SMController.NodeIDs) { + if len(launcher.nodes) != len(allNodeIDs) { return } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 86fc7fe2..ed5812c8 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -1155,6 +1155,19 @@ func newTestNodeInfoProvider(nodeID string) *testNodeInfoProvider { } } +func (provider *testNodeInfoProvider) GetAllNodeIDs() (nodeIDs []string, err error) { + if provider.nodeInfo == nil { + return nil, aoserrors.New("node info not found") + } + + nodeIDs = make([]string, 0, len(provider.nodeInfo)) + for nodeID := range provider.nodeInfo { + nodeIDs = append(nodeIDs, nodeID) + } + + return nodeIDs, nil +} + func (provider *testNodeInfoProvider) GetNodeID() string { return provider.nodeID } From d3f98adce18949ac48d1c34f2e8d5875c095e84c Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 19 Jul 2024 16:37:29 +0300 Subject: [PATCH 076/146] [config] Get rid of SMCController.NodeIDs field Signed-off-by: Mykhailo Lohvynenko --- config/config.go | 1 - config/config_test.go | 1 - launcher/launcher_test.go | 12 +++--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 00f9a616..26a05861 100644 --- a/config/config.go +++ b/config/config.go @@ -83,7 +83,6 @@ type Downloader struct { type SMController struct { FileServerURL string `json:"fileServerUrl"` CMServerURL string `json:"cmServerUrl"` - NodeIDs []string `json:"nodeIds"` NodesConnectionTimeout aostypes.Duration `json:"nodesConnectionTimeout"` UpdateTTL aostypes.Duration `json:"updateTtl"` } diff --git a/config/config_test.go b/config/config_test.go index 3ab6e16a..7c0d8cc4 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -270,7 +270,6 @@ func TestSMControllerConfig(t *testing.T) { originalConfig := config.SMController{ FileServerURL: "localhost:8094", CMServerURL: "localhost:8093", - NodeIDs: []string{"sm1", "sm2"}, NodesConnectionTimeout: aostypes.Duration{Duration: 100 * time.Second}, UpdateTTL: aostypes.Duration{Duration: 30 * time.Hour}, } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index ed5812c8..95fa6660 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -153,7 +153,6 @@ func TestInstancesWithRemovedServiceInfoAreRemovedOnStart(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } @@ -191,7 +190,6 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, ServiceTTLDays: 1, @@ -261,7 +259,6 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, ServiceTTLDays: 1, @@ -336,9 +333,9 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { func TestInitialStatus(t *testing.T) { var ( - cfg = &config.Config{ + nodeIDs = []string{nodeIDLocalSM, nodeIDRemoteSM1} + cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } @@ -355,7 +352,7 @@ func TestInitialStatus(t *testing.T) { } defer launcherInstance.Close() - for i, id := range cfg.SMController.NodeIDs { + for i, id := range nodeIDs { instances := []cloudprotocol.InstanceStatus{{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "s1", SubjectID: "subj1", Instance: uint64(i)}, ServiceVersion: "1.0", StateChecksum: magicSum, RunState: "running", @@ -390,7 +387,6 @@ func TestBalancing(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRemoteSM1, nodeIDRemoteSM2, nodeIDRunxSM}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } @@ -891,7 +887,6 @@ func TestServiceRevert(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } @@ -989,7 +984,6 @@ func TestStorageCleanup(t *testing.T) { var ( cfg = &config.Config{ SMController: config.SMController{ - NodeIDs: []string{nodeIDLocalSM, nodeIDRunxSM}, NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, }, } From a088b69cab1f948d801da9fc037499cfa4c51ac3 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 19 Jul 2024 19:26:00 +0300 Subject: [PATCH 077/146] [launcher] Proceed init node config on not found err Signed-off-by: Mykhailo Lohvynenko --- launcher/launcher.go | 3 ++- unitconfig/unitconfig.go | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index fe71bc79..284ffd30 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -36,6 +36,7 @@ import ( "github.com/aosedge/aos_communicationmanager/imagemanager" "github.com/aosedge/aos_communicationmanager/networkmanager" "github.com/aosedge/aos_communicationmanager/storagestate" + "github.com/aosedge/aos_communicationmanager/unitconfig" "github.com/aosedge/aos_communicationmanager/unitstatushandler" ) @@ -396,7 +397,7 @@ func (launcher *Launcher) initNodeStatus(nodeID string) (*nodeStatus, error) { func (launcher *Launcher) initNodeConfig(nodeStatus *nodeStatus) error { nodeUnitConfig, err := launcher.resourceManager.GetNodeConfig(nodeStatus.nodeInfo.NodeID, nodeStatus.nodeInfo.NodeType) - if err != nil { + if err != nil && !errors.Is(err, unitconfig.ErrNotFound) { return aoserrors.Wrap(err) } diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index a6649ad6..102d80c4 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -31,6 +31,13 @@ import ( "github.com/aosedge/aos_communicationmanager/config" ) +/********************************************************************************************************************** +* Consts +**********************************************************************************************************************/ + +// ErrNotFound error to detect that item not found. +var ErrNotFound = errors.New("not found") + /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -164,7 +171,7 @@ func (instance *Instance) GetNodeConfig(nodeID, nodeType string) (cloudprotocol. } } - return cloudprotocol.NodeConfig{}, aoserrors.New("not found") + return cloudprotocol.NodeConfig{}, ErrNotFound } // GetNodeConfig returns node config of the node with given id and type. From ca0819be0c4ce4e8213a8c9ef55460abb52e0031 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Fri, 19 Jul 2024 21:06:43 +0300 Subject: [PATCH 078/146] [vendor] Use node monitoring channel for resource monitor Signed-off-by: Oleksandr Grytsov --- go.mod | 2 +- go.sum | 4 ++-- .../resourcemonitor/resourcemonitor.go | 22 +++++++++++-------- vendor/modules.txt | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index d93fa1b9..cdbead15 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817 + github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21 github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 4ffdb764..363ba376 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817 h1:kH+sa+lG8ZVpiidELLbaLTslVKsxDgl9tavhwPPAaTA= -github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21 h1:Xi4GzbAw9Ont6qfHij2Pfpcy2pva1r2kyEpMM+uqJ7o= +github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index 8fba86d0..02a59fcf 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -49,6 +49,8 @@ const ( YearPeriod ) +const monitoringChannelSize = 16 + /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -82,11 +84,6 @@ type NodeConfigProvider interface { CurrentNodeConfigChannel() <-chan cloudprotocol.NodeConfig } -// MonitoringSender sends monitoring data. -type MonitoringSender interface { - SendNodeMonitoring(monitoringData aostypes.NodeMonitoring) -} - // TrafficMonitoring interface to get network traffic. type TrafficMonitoring interface { GetSystemTraffic() (inputTraffic, outputTraffic uint64, err error) @@ -107,10 +104,10 @@ type ResourceMonitor struct { nodeInfoProvider NodeInfoProvider nodeConfigProvider NodeConfigProvider alertSender AlertSender - monitoringSender MonitoringSender trafficMonitoring TrafficMonitoring sourceSystemUsage SystemUsageProvider + monitoringChannel chan aostypes.NodeMonitoring pollTimer *time.Ticker averageWindowCount uint64 nodeInfo cloudprotocol.NodeInfo @@ -179,7 +176,7 @@ var ( // New creates new resource monitor instance. func New( config Config, nodeInfoProvider NodeInfoProvider, nodeConfigProvider NodeConfigProvider, - trafficMonitoring TrafficMonitoring, alertsSender AlertSender, monitoringSender MonitoringSender) ( + trafficMonitoring TrafficMonitoring, alertsSender AlertSender) ( *ResourceMonitor, error, ) { log.Debug("Create monitor") @@ -188,9 +185,9 @@ func New( nodeInfoProvider: nodeInfoProvider, nodeConfigProvider: nodeConfigProvider, alertSender: alertsSender, - monitoringSender: monitoringSender, trafficMonitoring: trafficMonitoring, sourceSystemUsage: getSourceSystemUsage(config.Source), + monitoringChannel: make(chan aostypes.NodeMonitoring, monitoringChannelSize), } nodeInfo, err := nodeInfoProvider.GetCurrentNodeInfo() @@ -240,6 +237,8 @@ func (monitor *ResourceMonitor) Close() { if monitor.cancelFunction != nil { monitor.cancelFunction() } + + close(monitor.monitoringChannel) } // StartInstanceMonitor starts monitoring service. @@ -332,6 +331,11 @@ func (monitor *ResourceMonitor) GetAverageMonitoring() (aostypes.NodeMonitoring, return averageMonitoringData, nil } +// GetNodeMonitoringChannel return node monitoring channel. +func (monitor *ResourceMonitor) GetNodeMonitoringChannel() <-chan aostypes.NodeMonitoring { + return monitor.monitoringChannel +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -576,7 +580,7 @@ func (monitor *ResourceMonitor) sendMonitoringData() { instanceMonitoring.monitoring) } - monitor.monitoringSender.SendNodeMonitoring(nodeMonitoringData) + monitor.monitoringChannel <- nodeMonitoringData } func (monitor *ResourceMonitor) getCurrentSystemData() { diff --git a/vendor/modules.txt b/vendor/modules.txt index 9b81fbaa..77261133 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240717120318-74f28ac47817 +# github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21 ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From 00ff0f3ddb20f7414e2b39d4b5863727eb2e249f Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Fri, 19 Jul 2024 21:09:29 +0300 Subject: [PATCH 079/146] [main] Use monitoring channel to send node monitoring data Signed-off-by: Oleksandr Grytsov --- communicationmanager.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/communicationmanager.go b/communicationmanager.go index 846b8ee9..2e27af80 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -121,7 +121,7 @@ func init() { * CommunicationManager **********************************************************************************************************************/ -func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err error) { //nolint:funlen +func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err error) { //nolint:gocognit,funlen defer func() { if err != nil { cm.close() @@ -180,9 +180,20 @@ func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err if cfg.Monitoring.MonitorConfig != nil { if cm.resourcemonitor, err = resourcemonitor.New(*cfg.Monitoring.MonitorConfig, cm.iam, cm.unitConfig, - nil, cm.alerts, cm.monitorcontroller); err != nil { + nil, cm.alerts); err != nil { return cm, aoserrors.Wrap(err) } + + go func() { + for { + monitoringData, ok := <-cm.resourcemonitor.GetNodeMonitoringChannel() + if !ok { + return + } + + cm.monitorcontroller.SendNodeMonitoring(monitoringData) + } + }() } if cm.downloader, err = downloader.New("CM", cfg, cm.alerts, cm.db); err != nil { From 18df495d4c5f2426da12f14307a5dec65d433433 Mon Sep 17 00:00:00 2001 From: Mykola Date: Wed, 24 Jul 2024 15:55:54 +0300 Subject: [PATCH 080/146] [vendor] Update vendor Signed-off-by: Mykola --- go.mod | 2 +- go.sum | 4 +- .../aos_common/api/cloudprotocol/alerts.go | 25 ++-- .../api/cloudprotocol/cloudprotocol.go | 6 +- .../api/cloudprotocol/desiredstatus.go | 2 +- .../api/cloudprotocol/unitstatus.go | 2 +- .../aos_common/journalalerts/journalalerts.go | 43 ++++--- .../resourcemonitor/resourcemonitor.go | 49 ++++--- .../aos_common/utils/alertutils/alertutils.go | 121 ++++++++++++++++++ vendor/modules.txt | 3 +- 10 files changed, 196 insertions(+), 61 deletions(-) create mode 100644 vendor/github.com/aosedge/aos_common/utils/alertutils/alertutils.go diff --git a/go.mod b/go.mod index cdbead15..c8a8a3b0 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21 + github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 363ba376..b4cd49bd 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21 h1:Xi4GzbAw9Ont6qfHij2Pfpcy2pva1r2kyEpMM+uqJ7o= -github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc h1:v1I1sGcXwSmS4LNPQGYO8ZbKNdDcNrUAZZTE9zZqk+U= +github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go index c22418c8..a925d5b3 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/alerts.go @@ -53,14 +53,22 @@ const ( * Types **********************************************************************************************************************/ +// AlertItem common alert data. +type AlertItem struct { + Timestamp time.Time `json:"timestamp"` + Tag string `json:"tag"` +} + // SystemAlert system alert structure. type SystemAlert struct { + AlertItem NodeID string `json:"nodeId"` Message string `json:"message"` } // CoreAlert system alert structure. type CoreAlert struct { + AlertItem NodeID string `json:"nodeId"` CoreComponent string `json:"coreComponent"` Message string `json:"message"` @@ -68,6 +76,7 @@ type CoreAlert struct { // DownloadAlert download alert structure. type DownloadAlert struct { + AlertItem TargetType string `json:"targetType"` TargetID string `json:"targetId"` Version string `json:"version"` @@ -79,6 +88,7 @@ type DownloadAlert struct { // SystemQuotaAlert system quota alert structure. type SystemQuotaAlert struct { + AlertItem NodeID string `json:"nodeId"` Parameter string `json:"parameter"` Value uint64 `json:"value"` @@ -87,6 +97,7 @@ type SystemQuotaAlert struct { // InstanceQuotaAlert instance quota alert structure. type InstanceQuotaAlert struct { + AlertItem aostypes.InstanceIdent Parameter string `json:"parameter"` Value uint64 `json:"value"` @@ -95,6 +106,7 @@ type InstanceQuotaAlert struct { // DeviceAllocateAlert device allocate alert structure. type DeviceAllocateAlert struct { + AlertItem aostypes.InstanceIdent NodeID string `json:"nodeId"` Device string `json:"device"` @@ -103,6 +115,7 @@ type DeviceAllocateAlert struct { // ResourceValidateAlert resource validate alert structure. type ResourceValidateAlert struct { + AlertItem NodeID string `json:"nodeId"` Name string `json:"name"` Errors []ErrorInfo `json:"errors"` @@ -110,20 +123,14 @@ type ResourceValidateAlert struct { // ServiceInstanceAlert system alert structure. type ServiceInstanceAlert struct { + AlertItem aostypes.InstanceIdent ServiceVersion string `json:"version"` Message string `json:"message"` } -// AlertItem alert item structure. -type AlertItem struct { - Timestamp time.Time `json:"timestamp"` - Tag string `json:"tag"` - Payload interface{} `json:"payload"` -} - // Alerts alerts message structure. type Alerts struct { - MessageType string `json:"messageType"` - Items []AlertItem `json:"items"` + MessageType string `json:"messageType"` + Items []interface{} `json:"items"` } diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go index 60c1f744..531c8059 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/cloudprotocol.go @@ -17,6 +17,8 @@ package cloudprotocol +import "encoding/json" + /*********************************************************************************************************************** * Consts **********************************************************************************************************************/ @@ -30,8 +32,8 @@ const ProtocolVersion = 6 // ReceivedMessage structure for Aos incoming messages. type ReceivedMessage struct { - Header MessageHeader `json:"header"` - Data []byte `json:"data"` + Header MessageHeader `json:"header"` + Data json.RawMessage `json:"data"` } // Message structure for AOS messages. diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go index 50f2340a..caff4172 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/desiredstatus.go @@ -87,7 +87,7 @@ type NodeConfig struct { // UnitConfig unit configuration. type UnitConfig struct { - FormatVersion string `json:"formatVersion"` + FormatVersion interface{} `json:"formatVersion"` Version string `json:"version"` Nodes []NodeConfig `json:"nodes"` } diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go index ae4c1c29..da11fa08 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go @@ -142,7 +142,7 @@ type InstanceStatus struct { aostypes.InstanceIdent ServiceVersion string `json:"version"` StateChecksum string `json:"stateChecksum,omitempty"` - RunState string `json:"runState"` + Status string `json:"status"` NodeID string `json:"nodeId"` ErrorInfo *ErrorInfo `json:"errorInfo,omitempty"` } diff --git a/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go b/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go index 52110efa..78ac05c2 100644 --- a/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go +++ b/vendor/github.com/aosedge/aos_common/journalalerts/journalalerts.go @@ -55,7 +55,7 @@ const microSecondsInSecond = 1000000 // AlertSender alerts sender. type AlertSender interface { - SendAlert(alerts cloudprotocol.AlertItem) + SendAlert(alert interface{}) } // InstanceInfoProvider provides instance info. @@ -305,25 +305,18 @@ func (instance *JournalAlerts) processJournal() (err error) { unit = systemdCgroup } - alert := cloudprotocol.AlertItem{ - Timestamp: time.Unix(int64(entry.RealtimeTimestamp/microSecondsInSecond), - int64((entry.RealtimeTimestamp%microSecondsInSecond)*1000)), - } - - if payload := instance.getServiceInstanceAlert(entry, unit); payload != nil { - alert.Tag = cloudprotocol.AlertTagServiceInstance - alert.Payload = *payload - } else if payload := instance.getCoreComponentAlert(entry, unit); payload != nil { - alert.Tag = cloudprotocol.AlertTagAosCore - alert.Payload = *payload - } else if payload := instance.getSystemAlert(entry); payload != nil { - alert.Tag = cloudprotocol.AlertTagSystemError - alert.Payload = *payload + if alert := instance.getServiceInstanceAlert(entry, unit); alert != nil { + alert.AlertItem = createAlertItem(entry, cloudprotocol.AlertTagServiceInstance) + instance.sender.SendAlert(*alert) + } else if alert := instance.getCoreComponentAlert(entry, unit); alert != nil { + alert.AlertItem = createAlertItem(entry, cloudprotocol.AlertTagAosCore) + instance.sender.SendAlert(*alert) + } else if alert := instance.getSystemAlert(entry); alert != nil { + alert.AlertItem = createAlertItem(entry, cloudprotocol.AlertTagSystemError) + instance.sender.SendAlert(*alert) } else { continue } - - instance.sender.SendAlert(alert) } } @@ -359,9 +352,15 @@ func (instance *JournalAlerts) getServiceInstanceAlert( return nil } + alertItem := cloudprotocol.AlertItem{ + Timestamp: time.Now(), + Tag: cloudprotocol.AlertTagServiceInstance, + } + return &cloudprotocol.ServiceInstanceAlert{ - Message: entry.Fields[sdjournal.SD_JOURNAL_FIELD_MESSAGE], + AlertItem: alertItem, InstanceIdent: instanceIdent, + Message: entry.Fields[sdjournal.SD_JOURNAL_FIELD_MESSAGE], ServiceVersion: version, } } @@ -393,3 +392,11 @@ func (instance *JournalAlerts) getSystemAlert(entry *sdjournal.JournalEntry) *cl return &cloudprotocol.SystemAlert{Message: entry.Fields[sdjournal.SD_JOURNAL_FIELD_MESSAGE]} } + +func createAlertItem(entry *sdjournal.JournalEntry, tag string) cloudprotocol.AlertItem { + return cloudprotocol.AlertItem{ + Tag: tag, + Timestamp: time.Unix(int64(entry.RealtimeTimestamp/microSecondsInSecond), + int64((entry.RealtimeTimestamp%microSecondsInSecond)*1000)), + } +} diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index 02a59fcf..79bae762 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -70,7 +70,7 @@ type QuotaAlert struct { // AlertSender interface to send resource alerts. type AlertSender interface { - SendAlert(alert cloudprotocol.AlertItem) + SendAlert(alert interface{}) } // NodeInfoProvider interface to get node information. @@ -367,6 +367,8 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC monitor.Lock() defer monitor.Unlock() + nodeID := monitor.nodeInfo.NodeID + monitor.alertProcessors = list.New() if nodeConfig.AlertRules == nil || monitor.alertSender == nil { @@ -382,7 +384,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC "System CPU", &monitor.nodeMonitoring.CPU, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("cpu", time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "cpu", time, value, status)) }, rules)) } @@ -392,7 +394,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC "System RAM", &monitor.nodeMonitoring.RAM, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("ram", time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "ram", time, value, status)) }, *nodeConfig.AlertRules.RAM)) } @@ -411,7 +413,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC "Partition "+diskRule.Name, diskUsageValue, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem(diskRule.Name, time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, diskRule.Name, time, value, status)) }, diskRule.AlertRuleParam)) } @@ -421,7 +423,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC "IN Traffic", &monitor.nodeMonitoring.InTraffic, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("inTraffic", time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "inTraffic", time, value, status)) }, *nodeConfig.AlertRules.InTraffic)) } @@ -431,7 +433,7 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC "OUT Traffic", &monitor.nodeMonitoring.OutTraffic, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem("outTraffic", time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "outTraffic", time, value, status)) }, *nodeConfig.AlertRules.OutTraffic)) } @@ -732,31 +734,26 @@ func getInstanceDiskUsage(path string, uid, gid uint32) (diskUse uint64, err err } func prepareSystemAlertItem( - parameter string, timestamp time.Time, value uint64, status string, -) cloudprotocol.AlertItem { - return cloudprotocol.AlertItem{ - Timestamp: timestamp, - Tag: cloudprotocol.AlertTagSystemQuota, - Payload: cloudprotocol.SystemQuotaAlert{ - Parameter: parameter, - Value: value, - Status: status, - }, + nodeID, parameter string, timestamp time.Time, value uint64, status string, +) cloudprotocol.SystemQuotaAlert { + return cloudprotocol.SystemQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: cloudprotocol.AlertTagSystemQuota}, + NodeID: nodeID, + Parameter: parameter, + Value: value, + Status: status, } } func prepareInstanceAlertItem( instanceIndent aostypes.InstanceIdent, parameter string, timestamp time.Time, value uint64, status string, -) cloudprotocol.AlertItem { - return cloudprotocol.AlertItem{ - Timestamp: timestamp, - Tag: cloudprotocol.AlertTagInstanceQuota, - Payload: cloudprotocol.InstanceQuotaAlert{ - InstanceIdent: instanceIndent, - Parameter: parameter, - Value: value, - Status: status, - }, +) cloudprotocol.InstanceQuotaAlert { + return cloudprotocol.InstanceQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: cloudprotocol.AlertTagInstanceQuota}, + InstanceIdent: instanceIndent, + Parameter: parameter, + Value: value, + Status: status, } } diff --git a/vendor/github.com/aosedge/aos_common/utils/alertutils/alertutils.go b/vendor/github.com/aosedge/aos_common/utils/alertutils/alertutils.go new file mode 100644 index 00000000..f8c1e907 --- /dev/null +++ b/vendor/github.com/aosedge/aos_common/utils/alertutils/alertutils.go @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2024 Renesas Electronics Corporation. +// Copyright (C) 2024 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package alertutils + +import ( + "reflect" + + "github.com/aosedge/aos_common/api/cloudprotocol" +) + +// AlertsPayloadEqual compares alerts ignoring timestamp. +// +//nolint:funlen +func AlertsPayloadEqual(alert1, alert2 interface{}) bool { + switch alert1casted := alert1.(type) { + case cloudprotocol.SystemAlert: + alert2casted, ok := alert2.(cloudprotocol.SystemAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.CoreAlert: + alert2casted, ok := alert2.(cloudprotocol.CoreAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.DownloadAlert: + alert2casted, ok := alert2.(cloudprotocol.DownloadAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.SystemQuotaAlert: + alert2casted, ok := alert2.(cloudprotocol.SystemQuotaAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.InstanceQuotaAlert: + alert2casted, ok := alert2.(cloudprotocol.InstanceQuotaAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.DeviceAllocateAlert: + alert2casted, ok := alert2.(cloudprotocol.DeviceAllocateAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.ResourceValidateAlert: + alert2casted, ok := alert2.(cloudprotocol.ResourceValidateAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + + case cloudprotocol.ServiceInstanceAlert: + alert2casted, ok := alert2.(cloudprotocol.ServiceInstanceAlert) + if !ok { + return false + } + + newAlert1 := alert1casted + newAlert1.Timestamp = alert2casted.Timestamp + + return reflect.DeepEqual(newAlert1, alert2casted) + } + + return false +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 77261133..7879fbae 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240719174657-a45407039c21 +# github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes @@ -24,6 +24,7 @@ github.com/aosedge/aos_common/resourcemonitor github.com/aosedge/aos_common/spaceallocator github.com/aosedge/aos_common/tpmkey github.com/aosedge/aos_common/utils/action +github.com/aosedge/aos_common/utils/alertutils github.com/aosedge/aos_common/utils/contextreader github.com/aosedge/aos_common/utils/cryptutils github.com/aosedge/aos_common/utils/fs From c20834a5e127d01f515536df79625d487af42467 Mon Sep 17 00:00:00 2001 From: Mykola Date: Wed, 24 Jul 2024 15:52:18 +0300 Subject: [PATCH 081/146] [amqphandler] Fix ReceiveMessage unmarshal Signed-off-by: Mykola --- amqphandler/amqphandler.go | 10 +++++----- amqphandler/amqphandler_test.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index 1334864d..174a1334 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -678,16 +678,16 @@ func (handler *AmqpHandler) unmarshalReceiveData(data []byte) (Message, error) { return nil, aoserrors.New("AMQP unsupported message type") } - result := messageTypeFunc() + messageData := messageTypeFunc() - if err := json.Unmarshal(data, result); err != nil { + if err := json.Unmarshal(data, &messageData); err != nil { return nil, aoserrors.Wrap(err) } // print DesiredStatus message - desiredStatus, ok := result.(*cloudprotocol.DesiredStatus) + desiredStatus, ok := messageData.(*cloudprotocol.DesiredStatus) if !ok { - return result, nil + return messageData, nil } log.Debug("Decrypted data:") @@ -737,7 +737,7 @@ func (handler *AmqpHandler) unmarshalReceiveData(data []byte) (Message, error) { log.Debugf("Sota schedule: %s", schedule) } - return result, nil + return messageData, nil } func (handler *AmqpHandler) createCloudMessage(data interface{}) cloudprotocol.Message { diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 02229886..855b2ffe 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -168,14 +168,14 @@ func cleanup() { } func sendCloudMessage(msgType string, message interface{}) error { - rawJSON, err := json.Marshal(message) + jsonMsg, err := json.Marshal(message) if err != nil { return aoserrors.Wrap(err) } dataToSend := cloudprotocol.ReceivedMessage{ Header: cloudprotocol.MessageHeader{Version: cloudprotocol.ProtocolVersion}, - Data: rawJSON, + Data: jsonMsg, } dataJSON, err := json.Marshal(dataToSend) @@ -433,7 +433,7 @@ func TestSendMessages(t *testing.T) { instances := []cloudprotocol.InstanceStatus{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subj1", Instance: 1}, - ServiceVersion: "1.0", StateChecksum: "12345", RunState: "running", NodeID: "mainNode", + ServiceVersion: "1.0", StateChecksum: "12345", Status: "running", NodeID: "mainNode", }, } From 56c94f8899e46fb22ae78e71521d38b52b498b0d Mon Sep 17 00:00:00 2001 From: Mykola Date: Wed, 24 Jul 2024 15:54:12 +0300 Subject: [PATCH 082/146] [all] Rename InstanceStatus.runState to status Signed-off-by: Mykola --- launcher/launcher.go | 6 +++--- launcher/launcher_test.go | 8 ++++---- smcontroller/smcontroller_test.go | 16 ++++++++-------- smcontroller/smhandler.go | 2 +- unitstatushandler/softwaremanager.go | 2 +- unitstatushandler/unitstatushandler.go | 4 ++-- unitstatushandler/unitstatushandler_test.go | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 284ffd30..85a541c9 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -452,7 +452,7 @@ func (launcher *Launcher) sendCurrentStatus() { for _, errInstance := range node.currentRunRequest.Instances { runStatusToSend.Instances = append(runStatusToSend.Instances, cloudprotocol.InstanceStatus{ InstanceIdent: errInstance.InstanceIdent, - NodeID: node.nodeInfo.NodeID, RunState: cloudprotocol.InstanceStateFailed, + NodeID: node.nodeInfo.NodeID, Status: cloudprotocol.InstanceStateFailed, ErrorInfo: &cloudprotocol.ErrorInfo{Message: "wait run status timeout"}, }) } @@ -1232,14 +1232,14 @@ func (launcher *Launcher) removeRunRequest(instance aostypes.InstanceInfo, node } func createInstanceStatusFromInfo( - serviceID, subjectID string, instanceIndex uint64, serviceVersion string, runState, errorMsg string, + serviceID, subjectID string, instanceIndex uint64, serviceVersion string, status, errorMsg string, ) cloudprotocol.InstanceStatus { ident := aostypes.InstanceIdent{ ServiceID: serviceID, SubjectID: subjectID, Instance: instanceIndex, } instanceStatus := cloudprotocol.InstanceStatus{ - InstanceIdent: ident, ServiceVersion: serviceVersion, RunState: runState, + InstanceIdent: ident, ServiceVersion: serviceVersion, Status: status, } if errorMsg != "" { diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 95fa6660..8ed8fc97 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -355,7 +355,7 @@ func TestInitialStatus(t *testing.T) { for i, id := range nodeIDs { instances := []cloudprotocol.InstanceStatus{{ InstanceIdent: aostypes.InstanceIdent{ServiceID: "s1", SubjectID: "subj1", Instance: uint64(i)}, - ServiceVersion: "1.0", StateChecksum: magicSum, RunState: "running", + ServiceVersion: "1.0", StateChecksum: magicSum, Status: "running", NodeID: id, }} @@ -1203,7 +1203,7 @@ func (nodeManager *testNodeManager) RunInstances(nodeID string, successStatus.Instances[i] = cloudprotocol.InstanceStatus{ InstanceIdent: instance.InstanceIdent, ServiceVersion: "1.0", - RunState: cloudprotocol.InstanceStateActive, NodeID: nodeID, + Status: cloudprotocol.InstanceStateActive, NodeID: nodeID, } } @@ -1510,13 +1510,13 @@ func createLayerInfo(digest string, url string) aostypes.LayerInfo { func createInstanceStatus(ident aostypes.InstanceIdent, nodeID string, err error) cloudprotocol.InstanceStatus { status := cloudprotocol.InstanceStatus{ InstanceIdent: ident, - RunState: cloudprotocol.InstanceStateActive, + Status: cloudprotocol.InstanceStateActive, ServiceVersion: "1.0", NodeID: nodeID, } if err != nil { - status.RunState = cloudprotocol.InstanceStateFailed + status.Status = cloudprotocol.InstanceStateFailed status.ErrorInfo = &cloudprotocol.ErrorInfo{ Message: err.Error(), } diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 125ce36e..b6a5e957 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -108,11 +108,11 @@ func TestSMInstancesStatusNotifications(t *testing.T) { Instances: []*pbsm.InstanceStatus{ { Instance: &pbcommon.InstanceIdent{ServiceId: "serv1", SubjectId: "subj1", Instance: 1}, - ServiceVersion: "1.0.0", RunState: "running", + ServiceVersion: "1.0.0", Status: "running", }, { Instance: &pbcommon.InstanceIdent{ServiceId: "serv2", SubjectId: "subj2", Instance: 1}, - ServiceVersion: "1.0.0", RunState: "fail", + ServiceVersion: "1.0.0", Status: "fail", ErrorInfo: &pbcommon.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, @@ -122,11 +122,11 @@ func TestSMInstancesStatusNotifications(t *testing.T) { Instances: []cloudprotocol.InstanceStatus{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv1", SubjectID: "subj1", Instance: 1}, - ServiceVersion: "1.0.0", RunState: "running", NodeID: nodeID, + ServiceVersion: "1.0.0", Status: "running", NodeID: nodeID, }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv2", SubjectID: "subj2", Instance: 1}, - ServiceVersion: "1.0.0", RunState: "fail", NodeID: nodeID, + ServiceVersion: "1.0.0", Status: "fail", NodeID: nodeID, ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, @@ -140,13 +140,13 @@ func TestSMInstancesStatusNotifications(t *testing.T) { Instance: &pbcommon.InstanceIdent{ ServiceId: "serv1", SubjectId: "subj1", Instance: 1, }, - ServiceVersion: "1.0.0", RunState: "running", + ServiceVersion: "1.0.0", Status: "running", }, { Instance: &pbcommon.InstanceIdent{ ServiceId: "serv2", SubjectId: "subj2", Instance: 1, }, - ServiceVersion: "1.0.0", RunState: "fail", + ServiceVersion: "1.0.0", Status: "fail", ErrorInfo: &pbcommon.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, @@ -156,11 +156,11 @@ func TestSMInstancesStatusNotifications(t *testing.T) { expectedUpdateState = []cloudprotocol.InstanceStatus{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv1", SubjectID: "subj1", Instance: 1}, - ServiceVersion: "1.0.0", RunState: "running", NodeID: nodeID, + ServiceVersion: "1.0.0", Status: "running", NodeID: nodeID, }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "serv2", SubjectID: "subj2", Instance: 1}, - ServiceVersion: "1.0.0", RunState: "fail", NodeID: nodeID, + ServiceVersion: "1.0.0", Status: "fail", NodeID: nodeID, ErrorInfo: &cloudprotocol.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, } diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index e00fd247..743f9ecd 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -670,7 +670,7 @@ func instancesStatusFromPB(pbStatuses []*pb.InstanceStatus, nodeID string) []clo InstanceIdent: pbconvert.InstanceIdentFromPB(status.GetInstance()), NodeID: nodeID, ServiceVersion: status.GetServiceVersion(), - RunState: status.GetRunState(), + Status: status.GetRunState(), ErrorInfo: errorInfoFromPB(status.GetErrorInfo()), } } diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index a0dbdb07..19641d9b 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -1394,7 +1394,7 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr error manager.InstanceStatuses = append(manager.InstanceStatuses, cloudprotocol.InstanceStatus{ InstanceIdent: ident, ServiceVersion: version, - RunState: cloudprotocol.InstanceStateActivating, + Status: cloudprotocol.InstanceStateActivating, }) } } diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index df762d69..9149ed9e 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -610,12 +610,12 @@ foundLoop: "subjectID": instanceStatus.InstanceIdent.SubjectID, "instance": instanceStatus.InstanceIdent.Instance, "version": instanceStatus.ServiceVersion, - "runState": instanceStatus.RunState, + "status": instanceStatus.Status, "error": instanceStatus.ErrorInfo, }).Debug("Update instance status") instance.unitStatus.instances[i].StateChecksum = instanceStatus.StateChecksum - instance.unitStatus.instances[i].RunState = instanceStatus.RunState + instance.unitStatus.instances[i].Status = instanceStatus.Status instance.unitStatus.instances[i].ErrorInfo = instanceStatus.ErrorInfo continue foundLoop diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 07ca1966..aa0f3a75 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -831,7 +831,7 @@ func TestUpdateInstancesStatus(t *testing.T) { { InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0.0", - RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, + Status: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, @@ -849,7 +849,7 @@ func TestUpdateInstancesStatus(t *testing.T) { { InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0.0", - RunState: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, + Status: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, From acf1940e9809f2ec64fb88c6381eff7dfe679f0c Mon Sep 17 00:00:00 2001 From: Mykola Date: Wed, 24 Jul 2024 15:54:38 +0300 Subject: [PATCH 083/146] [unitstatushandler] Fix hang in desiredNodesLoop Signed-off-by: Mykola --- unitstatushandler/softwaremanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 19641d9b..ee2bc492 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -401,7 +401,7 @@ desiredNodesLoop: update.NodesStatus = append(update.NodesStatus, desiredNodeStatus) } - goto desiredNodesLoop + continue desiredNodesLoop } } From 68dc3d9d41fe387080777be7070999ec0347bc07 Mon Sep 17 00:00:00 2001 From: Mykola Date: Wed, 24 Jul 2024 15:56:28 +0300 Subject: [PATCH 084/146] [smcontroller] Hardcode PushLog status to OK Signed-off-by: Mykola --- smcontroller/smhandler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 743f9ecd..0cef98d0 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -543,6 +543,7 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { ExitCode: int(data.GetError().GetExitCode()), Message: data.GetError().GetMessage(), }, + Status: "ok", }); err != nil { log.Errorf("Can't send log: %v", err) } From e5567418a5b0ba6154b258a3828e863de7a51ddc Mon Sep 17 00:00:00 2001 From: Mykola Date: Thu, 25 Jul 2024 12:30:36 +0300 Subject: [PATCH 085/146] [all] AlertItem refactoring Signed-off-by: Mykola --- alerts/alerts.go | 14 +-- alerts/alerts_test.go | 35 +++---- amqphandler/amqphandler_test.go | 69 ++++++++----- downloader/downloader.go | 24 +++-- downloader/downloader_test.go | 4 +- smcontroller/smcontroller.go | 2 +- smcontroller/smcontroller_test.go | 155 +++++++++++++++++------------- smcontroller/smhandler.go | 53 +++++----- 8 files changed, 197 insertions(+), 159 deletions(-) diff --git a/alerts/alerts.go b/alerts/alerts.go index f666f2f8..94b7ecd2 100644 --- a/alerts/alerts.go +++ b/alerts/alerts.go @@ -21,7 +21,6 @@ package alerts import ( "context" "encoding/json" - "reflect" "sync" "time" @@ -29,6 +28,7 @@ import ( "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" + "github.com/aosedge/aos_common/utils/alertutils" "github.com/aosedge/aos_communicationmanager/amqphandler" "github.com/aosedge/aos_communicationmanager/config" ) @@ -56,7 +56,7 @@ type Sender interface { // Alerts instance. type Alerts struct { sync.RWMutex - alertsChannel chan cloudprotocol.AlertItem + alertsChannel chan interface{} alertsPackageChannel chan cloudprotocol.Alerts currentAlerts cloudprotocol.Alerts senderCancelFunction context.CancelFunc @@ -79,7 +79,7 @@ func New(config config.Alerts, sender Sender) (instance *Alerts, err error) { instance = &Alerts{ config: config, sender: sender, - alertsChannel: make(chan cloudprotocol.AlertItem, alertChannelSize), + alertsChannel: make(chan interface{}, alertChannelSize), alertsPackageChannel: make(chan cloudprotocol.Alerts, config.MaxOfflineMessages), } @@ -110,7 +110,7 @@ func (instance *Alerts) Close() { } // SendAlert sends alert. -func (instance *Alerts) SendAlert(alert cloudprotocol.AlertItem) { +func (instance *Alerts) SendAlert(alert interface{}) { select { case instance.alertsChannel <- alert: @@ -190,12 +190,12 @@ func (instance *Alerts) processAlertChannels(ctx context.Context) { } } -func (instance *Alerts) addAlert(item cloudprotocol.AlertItem) (bufferIsFull bool) { +func (instance *Alerts) addAlert(item interface{}) (bufferIsFull bool) { instance.Lock() defer instance.Unlock() if len(instance.currentAlerts.Items) != 0 && - reflect.DeepEqual(instance.currentAlerts.Items[len(instance.currentAlerts.Items)-1].Payload, item.Payload) { + alertutils.AlertsPayloadEqual(instance.currentAlerts.Items[len(instance.currentAlerts.Items)-1], item) { instance.duplicatedAlerts++ return } @@ -233,7 +233,7 @@ func (instance *Alerts) prepareAlertsPackage() { log.Warn("Skip sending alerts due to channel is full") } - instance.currentAlerts.Items = []cloudprotocol.AlertItem{} + instance.currentAlerts.Items = make([]interface{}, 0) instance.skippedAlerts = 0 instance.duplicatedAlerts = 0 instance.alertsSize = 0 diff --git a/alerts/alerts_test.go b/alerts/alerts_test.go index bb0556e5..52d7ddbc 100644 --- a/alerts/alerts_test.go +++ b/alerts/alerts_test.go @@ -89,10 +89,9 @@ func TestAlertsMaxMessageSize(t *testing.T) { for i := 0; i < 2; i++ { // alert size = header 96 + message length - alertItem := cloudprotocol.AlertItem{ - Timestamp: time.Now(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: cloudprotocol.SystemAlert{Message: randomString(200)}, + alertItem := cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: time.Now(), Tag: cloudprotocol.AlertTagSystemError}, + Message: randomString(200), } alertsHandler.SendAlert(alertItem) @@ -102,10 +101,9 @@ func TestAlertsMaxMessageSize(t *testing.T) { for i := 2; i < numMessages; i++ { // alert size = header 96 + message length - alertItem := cloudprotocol.AlertItem{ - Timestamp: time.Now(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: cloudprotocol.SystemAlert{Message: randomString(200)}, + alertItem := cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: time.Now(), Tag: cloudprotocol.AlertTagSystemError}, + Message: randomString(200), } alertsHandler.SendAlert(alertItem) @@ -139,10 +137,9 @@ func TestAlertsDuplicationMessages(t *testing.T) { expectedAlerts := cloudprotocol.Alerts{} - alertItem := cloudprotocol.AlertItem{ - Timestamp: time.Now(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: cloudprotocol.SystemAlert{Message: randomString(32)}, + alertItem := cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: time.Now(), Tag: cloudprotocol.AlertTagSystemError}, + Message: randomString(32), } expectedAlerts.Items = append(expectedAlerts.Items, alertItem) @@ -183,10 +180,9 @@ func TestAlertsOfflineMessages(t *testing.T) { expectedAlerts := cloudprotocol.Alerts{} for i := 0; i < numOfflineMessages; i++ { - alertItem := cloudprotocol.AlertItem{ - Timestamp: time.Now(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: cloudprotocol.SystemAlert{Message: randomString(200)}, + alertItem := cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: time.Now(), Tag: cloudprotocol.AlertTagSystemError}, + Message: randomString(200), } expectedAlerts.Items = append(expectedAlerts.Items, alertItem) @@ -195,10 +191,9 @@ func TestAlertsOfflineMessages(t *testing.T) { } for i := 0; i < numExtraMessages; i++ { - alertItem := cloudprotocol.AlertItem{ - Timestamp: time.Now(), - Tag: cloudprotocol.AlertTagAosCore, - Payload: cloudprotocol.SystemAlert{Message: randomString(200)}, + alertItem := cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: time.Now(), Tag: cloudprotocol.AlertTagAosCore}, + Message: randomString(200), } alertsHandler.SendAlert(alertItem) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 855b2ffe..cec7bedc 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -521,23 +521,25 @@ func TestSendMessages(t *testing.T) { }, } + now := time.Now().UTC() + nowFormatted := now.Format(time.RFC3339Nano) + alertsData := cloudprotocol.Alerts{ MessageType: cloudprotocol.AlertsMessageType, - Items: []cloudprotocol.AlertItem{ - { - Timestamp: time.Now().UTC(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: map[string]interface{}{"Message": "System error", "nodeId": "mainNode"}, + Items: []interface{}{ + cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: now, Tag: cloudprotocol.AlertTagSystemError}, + Message: "System error", NodeID: "mainNode", }, - { - Timestamp: time.Now().UTC(), - Tag: cloudprotocol.AlertTagSystemError, - Payload: map[string]interface{}{"Message": "Service crashed", "nodeId": "mainNode"}, + cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: now, Tag: cloudprotocol.AlertTagSystemError}, + Message: "Service crashed", NodeID: "mainNode", }, - { - Timestamp: time.Now().UTC(), - Tag: cloudprotocol.AlertTagResourceValidate, - Payload: map[string]interface{}{"Parameter": "cpu", "Value": float64(100), "nodeId": "mainNode"}, + cloudprotocol.SystemQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: now, Tag: cloudprotocol.AlertTagSystemQuota}, + NodeID: "mainNode", + Parameter: "cpu", + Value: 1000, }, }, } @@ -723,7 +725,23 @@ func TestSendMessages(t *testing.T) { SystemID: systemID, Version: cloudprotocol.ProtocolVersion, }, - Data: &alertsData, + Data: &cloudprotocol.Alerts{ + MessageType: cloudprotocol.AlertsMessageType, + Items: []interface{}{ + map[string]interface{}{ + "timestamp": nowFormatted, "tag": "systemAlert", + "nodeId": "mainNode", "message": "System error", + }, + map[string]interface{}{ + "timestamp": nowFormatted, "tag": "systemAlert", + "nodeId": "mainNode", "message": "Service crashed", + }, + map[string]interface{}{ + "timestamp": nowFormatted, "tag": "systemQuotaAlert", + "nodeId": "mainNode", "parameter": "cpu", "value": float64(1000), + }, + }, + }, }, getDataType: func() interface{} { return &cloudprotocol.Alerts{MessageType: cloudprotocol.AlertsMessageType} @@ -831,30 +849,31 @@ func TestSendMessages(t *testing.T) { select { case delivery := <-testClient.delivery: - var ( - rawData json.RawMessage - receiveData = cloudprotocol.Message{Data: &rawData} - ) + receivedHeader := cloudprotocol.Message{} - if err = json.Unmarshal(delivery.Body, &receiveData); err != nil { + if err = json.Unmarshal(delivery.Body, &receivedHeader); err != nil { t.Errorf("Error parsing message: %v", err) continue } - if !reflect.DeepEqual(receiveData.Header, message.data.Header) { - t.Errorf("Wrong Header received: %v != %v", receiveData.Header, message.data.Header) + if !reflect.DeepEqual(receivedHeader.Header, message.data.Header) { + t.Errorf("Wrong Header received: %v != %v", receivedHeader.Header, message.data.Header) continue } - decodedMsg := message.getDataType() + var receivedData struct { + Data interface{} `json:"data"` + } + + receivedData.Data = message.getDataType() - if err = json.Unmarshal(rawData, &decodedMsg); err != nil { + if err = json.Unmarshal(delivery.Body, &receivedData); err != nil { t.Errorf("Error parsing message: %v", err) continue } - if !reflect.DeepEqual(message.data.Data, decodedMsg) { - t.Errorf("Wrong data received: %v != %v", decodedMsg, message.data.Data) + if !reflect.DeepEqual(message.data.Data, receivedData.Data) { + t.Errorf("Wrong data received: %v != %v", receivedData.Data, message.data.Data) } case err = <-testClient.errChannel: diff --git a/downloader/downloader.go b/downloader/downloader.go index b11cfba4..216d6049 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -96,7 +96,7 @@ type Storage interface { // AlertSender provides alert sender interface. type AlertSender interface { - SendAlert(alert cloudprotocol.AlertItem) + SendAlert(alert interface{}) } var ( @@ -641,18 +641,16 @@ func (downloader *Downloader) download(url string, result *downloadResult) (err func (downloader *Downloader) prepareDownloadAlert( resp *grab.Response, result *downloadResult, msg string, -) cloudprotocol.AlertItem { - return cloudprotocol.AlertItem{ - Timestamp: time.Now(), Tag: cloudprotocol.AlertTagDownloadProgress, - Payload: cloudprotocol.DownloadAlert{ - TargetType: result.packageInfo.TargetType, - TargetID: result.packageInfo.TargetID, - Version: result.packageInfo.TargetVersion, - URL: resp.Request.HTTPRequest.URL.String(), - DownloadedBytes: bytefmt.ByteSize(uint64(resp.BytesComplete())), - TotalBytes: bytefmt.ByteSize(uint64(resp.Size())), - Message: msg, - }, +) cloudprotocol.DownloadAlert { + return cloudprotocol.DownloadAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: time.Now(), Tag: cloudprotocol.AlertTagDownloadProgress}, + TargetType: result.packageInfo.TargetType, + TargetID: result.packageInfo.TargetID, + Version: result.packageInfo.TargetVersion, + Message: msg, + URL: resp.Request.HTTPRequest.URL.String(), + DownloadedBytes: bytefmt.ByteSize(uint64(resp.BytesComplete())), + TotalBytes: bytefmt.ByteSize(uint64(resp.Size())), } } diff --git a/downloader/downloader_test.go b/downloader/downloader_test.go index 52eeb8ea..4f52c771 100644 --- a/downloader/downloader_test.go +++ b/downloader/downloader_test.go @@ -757,8 +757,8 @@ func TestReleaseByType(t *testing.T) { * Interfaces **********************************************************************************************************************/ -func (instance *testAlertSender) SendAlert(alert cloudprotocol.AlertItem) { - downloadAlert, ok := alert.Payload.(cloudprotocol.DownloadAlert) +func (instance *testAlertSender) SendAlert(alert interface{}) { + downloadAlert, ok := alert.(cloudprotocol.DownloadAlert) if !ok { log.Error("Received not download alert") } diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 0c050147..80284cf1 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -74,7 +74,7 @@ type Controller struct { // AlertSender sends alert. type AlertSender interface { - SendAlert(alert cloudprotocol.AlertItem) + SendAlert(alert interface{}) } // MonitoringSender sends monitoring data. diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index b6a5e957..1ed28bfb 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -29,6 +29,7 @@ import ( "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_common/resourcemonitor" + "github.com/aosedge/aos_common/utils/alertutils" "github.com/aosedge/aos_common/utils/pbconvert" pbcommon "github.com/aosedge/aos_common/api/common" @@ -74,7 +75,7 @@ type testMessageSender struct { } type testAlertSender struct { - messageChannel chan cloudprotocol.AlertItem + messageChannel chan interface{} } type testMonitoringSender struct { @@ -108,11 +109,11 @@ func TestSMInstancesStatusNotifications(t *testing.T) { Instances: []*pbsm.InstanceStatus{ { Instance: &pbcommon.InstanceIdent{ServiceId: "serv1", SubjectId: "subj1", Instance: 1}, - ServiceVersion: "1.0.0", Status: "running", + ServiceVersion: "1.0.0", RunState: "running", }, { Instance: &pbcommon.InstanceIdent{ServiceId: "serv2", SubjectId: "subj2", Instance: 1}, - ServiceVersion: "1.0.0", Status: "fail", + ServiceVersion: "1.0.0", RunState: "fail", ErrorInfo: &pbcommon.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, @@ -140,13 +141,13 @@ func TestSMInstancesStatusNotifications(t *testing.T) { Instance: &pbcommon.InstanceIdent{ ServiceId: "serv1", SubjectId: "subj1", Instance: 1, }, - ServiceVersion: "1.0.0", Status: "running", + ServiceVersion: "1.0.0", RunState: "running", }, { Instance: &pbcommon.InstanceIdent{ ServiceId: "serv2", SubjectId: "subj2", Instance: 1, }, - ServiceVersion: "1.0.0", Status: "fail", + ServiceVersion: "1.0.0", RunState: "fail", ErrorInfo: &pbcommon.ErrorInfo{AosCode: 200, ExitCode: 300, Message: "superError"}, }, }, @@ -340,48 +341,51 @@ func TestSMAlertNotifications(t *testing.T) { // Test alert notifications type testAlert struct { sendAlert *pbsm.Alert - expectedAlert cloudprotocol.AlertItem + expectedAlert interface{} } + now := time.Now().UTC() + testData := []testAlert{ { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagSystemError, - Payload: cloudprotocol.SystemAlert{Message: "SystemAlertMessage", NodeID: nodeID}, + expectedAlert: cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagSystemError, Timestamp: now}, + Message: "SystemAlertMessage", NodeID: nodeID, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagSystemError, + Tag: cloudprotocol.AlertTagSystemError, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_SystemAlert{ SystemAlert: &pbsm.SystemAlert{Message: "SystemAlertMessage"}, }, }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagAosCore, - Payload: cloudprotocol.CoreAlert{CoreComponent: "SM", Message: "CoreAlertMessage", NodeID: nodeID}, + expectedAlert: cloudprotocol.CoreAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagAosCore, Timestamp: now}, + CoreComponent: "SM", Message: "CoreAlertMessage", NodeID: nodeID, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagAosCore, + Tag: cloudprotocol.AlertTagAosCore, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_CoreAlert{ CoreAlert: &pbsm.CoreAlert{CoreComponent: "SM", Message: "CoreAlertMessage"}, }, }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagResourceValidate, - Payload: cloudprotocol.ResourceValidateAlert{ - NodeID: nodeID, - Name: "someName", - Errors: []cloudprotocol.ErrorInfo{ - {AosCode: 200, Message: "error1"}, - {AosCode: 300, Message: "error2"}, - }, + expectedAlert: cloudprotocol.ResourceValidateAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagResourceValidate, Timestamp: now}, + NodeID: nodeID, + Name: "someName", + Errors: []cloudprotocol.ErrorInfo{ + {AosCode: 200, Message: "error1"}, + {AosCode: 300, Message: "error2"}, }, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagResourceValidate, + Tag: cloudprotocol.AlertTagResourceValidate, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_ResourceValidateAlert{ ResourceValidateAlert: &pbsm.ResourceValidateAlert{ Name: "someName", @@ -394,16 +398,15 @@ func TestSMAlertNotifications(t *testing.T) { }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagDeviceAllocate, - Payload: cloudprotocol.DeviceAllocateAlert{ - InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, - Device: "someDevice", Message: "someMessage", - NodeID: nodeID, - }, + expectedAlert: cloudprotocol.DeviceAllocateAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagDeviceAllocate, Timestamp: now}, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, + Device: "someDevice", Message: "someMessage", + NodeID: nodeID, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagDeviceAllocate, + Tag: cloudprotocol.AlertTagDeviceAllocate, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_DeviceAllocateAlert{ DeviceAllocateAlert: &pbsm.DeviceAllocateAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, @@ -413,14 +416,13 @@ func TestSMAlertNotifications(t *testing.T) { }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagSystemQuota, - Payload: cloudprotocol.SystemQuotaAlert{ - Parameter: "cpu", Value: 42, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, - }, + expectedAlert: cloudprotocol.SystemQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagSystemQuota, Timestamp: now}, + Parameter: "cpu", Value: 42, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagSystemQuota, + Tag: cloudprotocol.AlertTagSystemQuota, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_SystemQuotaAlert{ SystemQuotaAlert: &pbsm.SystemQuotaAlert{ Parameter: "cpu", Value: 42, Status: resourcemonitor.AlertStatusRaise, @@ -429,14 +431,13 @@ func TestSMAlertNotifications(t *testing.T) { }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagSystemQuota, - Payload: cloudprotocol.SystemQuotaAlert{ - Parameter: "ram", Value: 99, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, - }, + expectedAlert: cloudprotocol.SystemQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagSystemQuota, Timestamp: now}, + Parameter: "ram", Value: 99, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagSystemQuota, + Tag: cloudprotocol.AlertTagSystemQuota, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_SystemQuotaAlert{ SystemQuotaAlert: &pbsm.SystemQuotaAlert{ Parameter: "ram", Value: 99, Status: resourcemonitor.AlertStatusRaise, @@ -445,15 +446,14 @@ func TestSMAlertNotifications(t *testing.T) { }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagInstanceQuota, - Payload: cloudprotocol.InstanceQuotaAlert{ - InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, - Parameter: "param1", Value: 42, Status: resourcemonitor.AlertStatusRaise, - }, + expectedAlert: cloudprotocol.InstanceQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagInstanceQuota, Timestamp: now}, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, + Parameter: "param1", Value: 42, Status: resourcemonitor.AlertStatusRaise, }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagInstanceQuota, + Tag: cloudprotocol.AlertTagInstanceQuota, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_InstanceQuotaAlert{ InstanceQuotaAlert: &pbsm.InstanceQuotaAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, @@ -463,15 +463,14 @@ func TestSMAlertNotifications(t *testing.T) { }, }, { - expectedAlert: cloudprotocol.AlertItem{ - Tag: cloudprotocol.AlertTagServiceInstance, - Payload: cloudprotocol.ServiceInstanceAlert{ - InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, - Message: "ServiceInstanceAlert", ServiceVersion: "42.0.0", - }, + expectedAlert: cloudprotocol.ServiceInstanceAlert{ + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagServiceInstance, Timestamp: now}, + InstanceIdent: aostypes.InstanceIdent{ServiceID: "id1", SubjectID: "s1", Instance: 1}, + Message: "ServiceInstanceAlert", ServiceVersion: "42.0.0", }, sendAlert: &pbsm.Alert{ - Tag: cloudprotocol.AlertTagServiceInstance, + Tag: cloudprotocol.AlertTagServiceInstance, + Timestamp: timestamppb.New(now), Payload: &pbsm.Alert_InstanceAlert{ InstanceAlert: &pbsm.InstanceAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, @@ -483,26 +482,28 @@ func TestSMAlertNotifications(t *testing.T) { } for _, testAlert := range testData { - currentTime := time.Now().UTC() - testAlert.expectedAlert.Timestamp = currentTime - testAlert.sendAlert.Timestamp = timestamppb.New(currentTime) - smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ SMOutgoingMessage: &pbsm.SMOutgoingMessages_Alert{Alert: testAlert.sendAlert}, } - if err := waitMessage(alertSender.messageChannel, testAlert.expectedAlert, messageTimeout); err != nil { + if err := waitAlerts(alertSender.messageChannel, testAlert.expectedAlert, messageTimeout); err != nil { t.Errorf("Incorrect alert notification: %v", err) } } expectedSystemLimitAlert := []cloudprotocol.SystemQuotaAlert{ - {Parameter: "cpu", Value: 42, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise}, - {Parameter: "ram", Value: 99, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise}, + { + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagSystemQuota}, + Parameter: "cpu", Value: 42, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, + }, + { + AlertItem: cloudprotocol.AlertItem{Tag: cloudprotocol.AlertTagSystemQuota}, + Parameter: "ram", Value: 99, NodeID: nodeID, Status: resourcemonitor.AlertStatusRaise, + }, } for _, limitAlert := range expectedSystemLimitAlert { - if err := waitMessage(controller.GetSystemQuoteAlertChannel(), limitAlert, messageTimeout); err != nil { + if err := waitAlerts(controller.GetSystemQuoteAlertChannel(), limitAlert, messageTimeout); err != nil { t.Errorf("Incorrect system limit alert: %v", err) } } @@ -814,6 +815,7 @@ func TestLogMessages(t *testing.T) { ErrorInfo: &cloudprotocol.ErrorInfo{ Message: "this is error", }, + Status: "ok", } smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ @@ -1302,10 +1304,10 @@ func TestConnectionStatus(t *testing.T) { **********************************************************************************************************************/ func newTestAlertSender() *testAlertSender { - return &testAlertSender{messageChannel: make(chan cloudprotocol.AlertItem, 1)} + return &testAlertSender{messageChannel: make(chan interface{}, 1)} } -func (sender *testAlertSender) SendAlert(alert cloudprotocol.AlertItem) { +func (sender *testAlertSender) SendAlert(alert interface{}) { sender.messageChannel <- alert } @@ -1345,6 +1347,23 @@ func (sender *testMessageSender) UnsubscribeFromConnectionEvents(consumer amqpha * Private **********************************************************************************************************************/ +func waitAlerts[T any](messageChannel <-chan T, expectedMsg interface{}, timeout time.Duration) error { + select { + case <-time.After(timeout): + return aoserrors.New("wait message timeout") + + case message := <-messageChannel: + if !alertutils.AlertsPayloadEqual(message, expectedMsg) { + log.Debugf("%v", message) + log.Debugf("%v", expectedMsg) + + return aoserrors.New("incorrect received message") + } + } + + return nil +} + func waitMessage[T any](messageChannel <-chan T, expectedMsg interface{}, timeout time.Duration) error { select { case <-time.After(timeout): diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 0cef98d0..c46a4b9f 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -440,40 +440,44 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { "tag": alert.GetTag(), }).Debug("Receive SM alert") - alertItem := cloudprotocol.AlertItem{ - Timestamp: alert.GetTimestamp().AsTime(), - Tag: alert.GetTag(), - } + timestamp := alert.GetTimestamp().AsTime() + tag := alert.GetTag() + + var alertItem interface{} switch data := alert.GetPayload().(type) { case *pb.Alert_SystemAlert: - alertItem.Payload = cloudprotocol.SystemAlert{ - Message: data.SystemAlert.GetMessage(), - NodeID: handler.nodeConfigStatus.NodeID, + alertItem = cloudprotocol.SystemAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, + Message: data.SystemAlert.GetMessage(), + NodeID: handler.nodeConfigStatus.NodeID, } case *pb.Alert_CoreAlert: - alertItem.Payload = cloudprotocol.CoreAlert{ + alertItem = cloudprotocol.CoreAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, CoreComponent: data.CoreAlert.GetCoreComponent(), Message: data.CoreAlert.GetMessage(), NodeID: handler.nodeConfigStatus.NodeID, } case *pb.Alert_ResourceValidateAlert: - resourceValidate := cloudprotocol.ResourceValidateAlert{ - Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), - NodeID: handler.nodeConfigStatus.NodeID, - Name: data.ResourceValidateAlert.GetName(), + concreteAlert := cloudprotocol.ResourceValidateAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, + Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), + NodeID: handler.nodeConfigStatus.NodeID, + Name: data.ResourceValidateAlert.GetName(), } for i, error := range data.ResourceValidateAlert.GetErrors() { - resourceValidate.Errors[i] = *pbconvert.ErrorInfoFromPB(error) + concreteAlert.Errors[i] = *pbconvert.ErrorInfoFromPB(error) } - alertItem.Payload = resourceValidate + alertItem = concreteAlert case *pb.Alert_DeviceAllocateAlert: - alertItem.Payload = cloudprotocol.DeviceAllocateAlert{ + alertItem = cloudprotocol.DeviceAllocateAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, InstanceIdent: pbconvert.InstanceIdentFromPB(data.DeviceAllocateAlert.GetInstance()), Device: data.DeviceAllocateAlert.GetDevice(), Message: data.DeviceAllocateAlert.GetMessage(), @@ -481,37 +485,40 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { } case *pb.Alert_SystemQuotaAlert: - alertPayload := cloudprotocol.SystemQuotaAlert{ + concreteAlert := cloudprotocol.SystemQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, Parameter: data.SystemQuotaAlert.GetParameter(), Value: data.SystemQuotaAlert.GetValue(), NodeID: handler.nodeConfigStatus.NodeID, Status: data.SystemQuotaAlert.GetStatus(), } - handler.systemQuotasAlertCh <- alertPayload + handler.systemQuotasAlertCh <- concreteAlert - if alertPayload.Status != resourcemonitor.AlertStatusRaise { + if concreteAlert.Status != resourcemonitor.AlertStatusRaise { return } - alertItem.Payload = alertPayload + alertItem = concreteAlert case *pb.Alert_InstanceQuotaAlert: - alertPayload := cloudprotocol.InstanceQuotaAlert{ + concreteAlert := cloudprotocol.InstanceQuotaAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, InstanceIdent: pbconvert.InstanceIdentFromPB(data.InstanceQuotaAlert.GetInstance()), Parameter: data.InstanceQuotaAlert.GetParameter(), Value: data.InstanceQuotaAlert.GetValue(), Status: data.InstanceQuotaAlert.GetStatus(), } - if alertPayload.Status != resourcemonitor.AlertStatusRaise { + if concreteAlert.Status != resourcemonitor.AlertStatusRaise { return } - alertItem.Payload = alertPayload + alertItem = concreteAlert case *pb.Alert_InstanceAlert: - alertItem.Payload = cloudprotocol.ServiceInstanceAlert{ + alertItem = cloudprotocol.ServiceInstanceAlert{ + AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, InstanceIdent: pbconvert.InstanceIdentFromPB(data.InstanceAlert.GetInstance()), ServiceVersion: data.InstanceAlert.GetServiceVersion(), Message: data.InstanceAlert.GetMessage(), From 7c02ed7087d4166ee167bfd1a7e2161fe5752828 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 26 Jul 2024 17:01:34 +0300 Subject: [PATCH 086/146] [unitconfig] Ignore version check on error cfg Signed-off-by: Mykhailo Lohvynenko --- unitconfig/unitconfig.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 102d80c4..5d3f32e0 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -130,8 +130,10 @@ func (instance *Instance) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) e instance.Lock() defer instance.Unlock() - if err := instance.checkVersion(unitConfig.Version); err != nil { - return err + if instance.unitConfigError != nil && instance.unitConfig.Version == "" { + log.Warnf("Skip unit config version check due to error: %v", instance.unitConfigError) + } else if err := instance.checkVersion(unitConfig.Version); err != nil { + return aoserrors.Wrap(err) } nodeConfigStatuses, err := instance.client.GetNodeConfigStatuses() @@ -189,8 +191,10 @@ func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) instance.Lock() defer instance.Unlock() - if err := instance.checkVersion(unitConfig.Version); err != nil { - return err + if instance.unitConfigError != nil && instance.unitConfig.Version == "" { + log.Warnf("Skip unit config version check due to error: %v", instance.unitConfigError) + } else if err := instance.checkVersion(unitConfig.Version); err != nil { + return aoserrors.Wrap(err) } instance.unitConfig = unitConfig From f29df2dcb02a74bbe4dfe5b0cb54f2da8cc391ed Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Fri, 26 Jul 2024 17:01:54 +0300 Subject: [PATCH 087/146] [unitstatushandler] Log component id value Signed-off-by: Mykhailo Lohvynenko --- unitstatushandler/firmwaremanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unitstatushandler/firmwaremanager.go b/unitstatushandler/firmwaremanager.go index 160d1b83..9590fc6f 100644 --- a/unitstatushandler/firmwaremanager.go +++ b/unitstatushandler/firmwaremanager.go @@ -212,7 +212,7 @@ desiredLoop: } log.WithFields(log.Fields{ - "id": desiredComponent.ComponentID, + "id": *desiredComponent.ComponentID, "type": desiredComponent.ComponentType, "version": desiredComponent.Version, }).Error("Desired component not found") From b77b7cb6e6c2cdbd7143e39f4dac8d0b174ae2df Mon Sep 17 00:00:00 2001 From: Mykola Solianko Date: Fri, 26 Jul 2024 14:12:49 +0300 Subject: [PATCH 088/146] [network] Remove instances when remove network Signed-off-by: Mykola Solianko --- networkmanager/networkmanager.go | 35 ++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/networkmanager/networkmanager.go b/networkmanager/networkmanager.go index c64a52fd..328e57e9 100644 --- a/networkmanager/networkmanager.go +++ b/networkmanager/networkmanager.go @@ -181,14 +181,16 @@ func New(storage Storage, nodeManager NodeManager, config *config.Config) (*Netw // RemoveInstanceNetworkConf removes stored instance network parameters. func (manager *NetworkManager) RemoveInstanceNetworkParameters(instanceIdent aostypes.InstanceIdent, networkID string) { + manager.Lock() + defer manager.Unlock() + networkParameters, found := manager.getNetworkParametersToCache(networkID, instanceIdent) if !found { return } - manager.deleteNetworkParametersFromCache(networkID, instanceIdent, net.IP(networkParameters.IP)) - - if err := manager.storage.RemoveNetworkInstanceInfo(instanceIdent); err != nil { + if err := manager.removeInstanceNetworkParameters( + networkID, instanceIdent, net.IP(networkParameters.IP)); err != nil { log.Errorf("Can't remove network info: %v", err) } } @@ -276,6 +278,18 @@ func (manager *NetworkManager) PrepareInstanceNetworkParameters( * Private **********************************************************************************************************************/ +func (manager *NetworkManager) removeInstanceNetworkParameters( + networkID string, instanceIdent aostypes.InstanceIdent, ip net.IP, +) error { + manager.deleteNetworkParametersFromCache(networkID, instanceIdent, ip) + + if err := manager.storage.RemoveNetworkInstanceInfo(instanceIdent); err != nil { + return aoserrors.Wrap(err) + } + + return nil +} + func (manager *NetworkManager) createNetwork( instanceIdent aostypes.InstanceIdent, networkID string, params NetworkParameters, ) (networkParameters aostypes.NetworkParameters, err error) { @@ -394,9 +408,6 @@ func checkIPInSubnet(subnet, ip string) (bool, error) { func (manager *NetworkManager) deleteNetworkParametersFromCache( networkID string, instanceIdent aostypes.InstanceIdent, ip net.IP, ) { - manager.Lock() - defer manager.Unlock() - delete(manager.instancesData[networkID], instanceIdent) delete(manager.dns.hosts, ip.String()) @@ -417,9 +428,6 @@ func (manager *NetworkManager) addNetworkParametersToCache(instanceNetworkInfo I func (manager *NetworkManager) getNetworkParametersToCache( networkID string, instanceIdent aostypes.InstanceIdent, ) (aostypes.NetworkParameters, bool) { - manager.RLock() - defer manager.RUnlock() - if instances, ok := manager.instancesData[networkID]; ok { if networkParameter, ok := instances[instanceIdent]; ok { return networkParameter.NetworkParameters, true @@ -438,6 +446,15 @@ next: } } + log.Debugf("Remove provider network %s", networkID) + + for instanceIdent, netInfo := range manager.instancesData[networkID] { + if err := manager.removeInstanceNetworkParameters( + networkID, instanceIdent, net.IP(netInfo.IP)); err != nil { + log.Errorf("Can't remove network info: %v", err) + } + } + delete(manager.providerNetworks, networkID) manager.ipamSubnet.releaseIPNetPool(networkID) From de8f5de4df15462eedfd88b0997eb060c6e7bd3d Mon Sep 17 00:00:00 2001 From: Mykhailo Lohvynenko Date: Mon, 29 Jul 2024 19:21:59 +0300 Subject: [PATCH 089/146] [smcontroller] Set node id/type fields Signed-off-by: Mykhailo Lohvynenko --- smcontroller/smcontroller.go | 11 +++-- smcontroller/smhandler.go | 81 +++++++++++++++++++++++------------- 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 80284cf1..5ae21d5f 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -326,7 +326,7 @@ func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) e message, err := stream.Recv() if err != nil { if handler != nil { - controller.handleCloseConnection(handler.nodeConfigStatus.NodeID) + controller.handleCloseConnection(handler.nodeID) } if !errors.Is(err, io.EOF) && codes.Canceled != status.Code(err) { @@ -346,12 +346,15 @@ func (controller *Controller) RegisterSM(stream pb.SMService_RegisterSMServer) e continue } + nodeID := nodeConfigStatus.NodeConfigStatus.GetNodeId() + nodeType := nodeConfigStatus.NodeConfigStatus.GetNodeType() + log.WithFields(log.Fields{ - "nodeID": nodeConfigStatus.NodeConfigStatus.GetNodeId(), - "nodeType": nodeConfigStatus.NodeConfigStatus.GetNodeType(), + "nodeID": nodeID, + "nodeType": nodeType, }).Debug("Register SM") - handler, err = newSMHandler(stream, controller.messageSender, controller.alertSender, + handler, err = newSMHandler(nodeID, nodeType, stream, controller.messageSender, controller.alertSender, controller.monitoringSender, controller.runInstancesStatusChan, controller.updateInstancesStatusChan, controller.systemQuotaAlertChan) if err != nil { diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index c46a4b9f..967891f1 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -49,6 +49,8 @@ const waitMessageTimeout = 5 * time.Second **********************************************************************************************************************/ type smHandler struct { + nodeID string + nodeType string stream pb.SMService_RegisterSMServer messageSender MessageSender alertSender AlertSender @@ -65,12 +67,15 @@ type smHandler struct { **********************************************************************************************************************/ func newSMHandler( + nodeID, nodeType string, stream pb.SMService_RegisterSMServer, messageSender MessageSender, alertSender AlertSender, monitoringSender MonitoringSender, runStatusCh chan<- launcher.NodeRunInstanceStatus, updateInstanceStatusCh chan<- []cloudprotocol.InstanceStatus, systemQuotasAlertCh chan<- cloudprotocol.SystemQuotaAlert, ) (*smHandler, error) { handler := smHandler{ + nodeID: nodeID, + nodeType: nodeType, stream: stream, messageSender: messageSender, alertSender: alertSender, @@ -103,7 +108,12 @@ func (handler *smHandler) getNodeConfigStatus() (unitconfig.NodeConfigStatus, er return unitconfig.NodeConfigStatus{}, aoserrors.New(pbStatus.NodeConfigStatus.GetError().GetMessage()) } - return nodeConfigStatusFromPB(pbStatus.NodeConfigStatus), nil + nodeConfigStatus := nodeConfigStatusFromPB(pbStatus.NodeConfigStatus) + + nodeConfigStatus.NodeID = handler.nodeID + nodeConfigStatus.NodeType = handler.nodeType + + return nodeConfigStatus, nil } func (handler *smHandler) checkNodeConfig(version string, unitConfig cloudprotocol.NodeConfig) error { @@ -154,7 +164,8 @@ func (handler *smHandler) setNodeConfig(version string, cfg cloudprotocol.NodeCo func (handler *smHandler) updateNetworks(networkParameters []aostypes.NetworkParameters) error { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, }).Debug("CM update networks") pbNetworkParameters := make([]*pb.NetworkParameters, len(networkParameters)) @@ -183,7 +194,8 @@ func (handler *smHandler) runInstances( services []aostypes.ServiceInfo, layers []aostypes.LayerInfo, instances []aostypes.InstanceInfo, forceRestart bool, ) error { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, }).Debug("SM run instances") pbRunInstances := &pb.RunInstances{ @@ -238,10 +250,11 @@ func (handler *smHandler) runInstances( func (handler *smHandler) getSystemLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, - "logID": logRequest.LogID, - "from": logRequest.Filter.From, - "till": logRequest.Filter.Till, + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, + "logID": logRequest.LogID, + "from": logRequest.Filter.From, + "till": logRequest.Filter.Till, }).Debug("Get SM system log") request := &pb.SystemLogRequest{LogId: logRequest.LogID} @@ -266,7 +279,8 @@ func (handler *smHandler) getSystemLog(logRequest cloudprotocol.RequestLog) (err //nolint:dupl func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, "logID": logRequest.LogID, "serviceID": logRequest.Filter.ServiceID, "from": logRequest.Filter.From, @@ -297,7 +311,8 @@ func (handler *smHandler) getInstanceLog(logRequest cloudprotocol.RequestLog) (e //nolint:dupl func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLog) (err error) { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, "logID": logRequest.LogID, "serviceID": logRequest.Filter.ServiceID, "from": logRequest.Filter.From, @@ -328,7 +343,10 @@ func (handler *smHandler) getInstanceCrashLog(logRequest cloudprotocol.RequestLo } func (handler *smHandler) overrideEnvVars(envVars cloudprotocol.OverrideEnvVars) (err error) { - log.WithFields(log.Fields{"nodeID": handler.nodeConfigStatus.NodeID}).Debug("Override env vars SM ") + log.WithFields(log.Fields{ + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, + }).Debug("Override env vars SM ") request := &pb.OverrideEnvVars{EnvVars: make([]*pb.OverrideInstanceEnvVar, len(envVars.Items))} @@ -376,7 +394,7 @@ func (handler *smHandler) getAverageMonitoring() (monitoring aostypes.NodeMonito } monitoring = averageMonitoringFromPB(pbMonitoring.AverageMonitoring) - monitoring.NodeID = handler.nodeConfigStatus.NodeID + monitoring.NodeID = handler.nodeID return monitoring, nil } @@ -419,25 +437,28 @@ func (handler *smHandler) processSMMessages(message *pb.SMOutgoingMessages) { func (handler *smHandler) processRunInstanceStatus(status *pb.RunInstancesStatus) { runStatus := launcher.NodeRunInstanceStatus{ - NodeID: handler.nodeConfigStatus.NodeID, - NodeType: handler.nodeConfigStatus.NodeType, - Instances: instancesStatusFromPB(status.GetInstances(), - handler.nodeConfigStatus.NodeID), + NodeID: handler.nodeID, + NodeType: handler.nodeType, + Instances: instancesStatusFromPB(status.GetInstances(), handler.nodeID), } handler.runStatusCh <- runStatus } func (handler *smHandler) processUpdateInstancesStatus(data *pb.UpdateInstancesStatus) { - log.WithFields(log.Fields{"nodeID": handler.nodeConfigStatus.NodeID}).Debug("Receive SM update instances status") + log.WithFields(log.Fields{ + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, + }).Debug("Receive SM update instances status") - handler.updateInstanceStatusCh <- instancesStatusFromPB(data.GetInstances(), handler.nodeConfigStatus.NodeID) + handler.updateInstanceStatusCh <- instancesStatusFromPB(data.GetInstances(), handler.nodeID) } func (handler *smHandler) processAlert(alert *pb.Alert) { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, - "tag": alert.GetTag(), + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, + "tag": alert.GetTag(), }).Debug("Receive SM alert") timestamp := alert.GetTimestamp().AsTime() @@ -450,7 +471,7 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { alertItem = cloudprotocol.SystemAlert{ AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, Message: data.SystemAlert.GetMessage(), - NodeID: handler.nodeConfigStatus.NodeID, + NodeID: handler.nodeID, } case *pb.Alert_CoreAlert: @@ -458,14 +479,14 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, CoreComponent: data.CoreAlert.GetCoreComponent(), Message: data.CoreAlert.GetMessage(), - NodeID: handler.nodeConfigStatus.NodeID, + NodeID: handler.nodeID, } case *pb.Alert_ResourceValidateAlert: concreteAlert := cloudprotocol.ResourceValidateAlert{ AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, Errors: make([]cloudprotocol.ErrorInfo, len(data.ResourceValidateAlert.GetErrors())), - NodeID: handler.nodeConfigStatus.NodeID, + NodeID: handler.nodeID, Name: data.ResourceValidateAlert.GetName(), } @@ -481,7 +502,7 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { InstanceIdent: pbconvert.InstanceIdentFromPB(data.DeviceAllocateAlert.GetInstance()), Device: data.DeviceAllocateAlert.GetDevice(), Message: data.DeviceAllocateAlert.GetMessage(), - NodeID: handler.nodeConfigStatus.NodeID, + NodeID: handler.nodeID, } case *pb.Alert_SystemQuotaAlert: @@ -489,7 +510,7 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, Parameter: data.SystemQuotaAlert.GetParameter(), Value: data.SystemQuotaAlert.GetValue(), - NodeID: handler.nodeConfigStatus.NodeID, + NodeID: handler.nodeID, Status: data.SystemQuotaAlert.GetStatus(), } @@ -533,14 +554,15 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { func (handler *smHandler) processLogMessage(data *pb.LogData) { log.WithFields(log.Fields{ - "nodeID": handler.nodeConfigStatus.NodeID, + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, "logID": data.GetLogId(), "part": data.GetPart(), "partCount": data.GetPartCount(), }).Debug("Receive SM push log") if err := handler.messageSender.SendLog(cloudprotocol.PushLog{ - NodeID: handler.nodeConfigStatus.NodeID, + NodeID: handler.nodeID, LogID: data.GetLogId(), PartsCount: data.GetPartCount(), Part: data.GetPart(), @@ -557,11 +579,14 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { } func (handler *smHandler) processInstantMonitoring(instantMonitoring *pb.InstantMonitoring) { - log.WithFields(log.Fields{"nodeID": handler.nodeConfigStatus.NodeID}).Debug("Receive SM monitoring") + log.WithFields(log.Fields{ + "nodeID": handler.nodeID, + "nodeType": handler.nodeType, + }).Debug("Receive SM monitoring") nodeMonitoring := instantMonitoringFromPB(instantMonitoring) - nodeMonitoring.NodeID = handler.nodeConfigStatus.NodeID + nodeMonitoring.NodeID = handler.nodeID handler.monitoringSender.SendNodeMonitoring(nodeMonitoring) } From 2667dec500640ad9c34314a7023db6fd27c6cba0 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Fri, 2 Aug 2024 21:04:46 +0300 Subject: [PATCH 090/146] [iamclient] Fix provision response tags Signed-off-by: Mykola Kobets --- iamclient/iamclient.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index f0b2be2d..195d3e54 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -358,7 +358,7 @@ func (client *Client) FinishProvisioning( defer func() { errSend := client.sender.SendFinishProvisioningResponse(cloudprotocol.FinishProvisioningResponse{ - MessageType: cloudprotocol.StartProvisioningResponseMessageType, + MessageType: cloudprotocol.FinishProvisioningResponseMessageType, NodeID: nodeID, ErrorInfo: errorInfo, }) @@ -388,7 +388,7 @@ func (client *Client) Deprovision(nodeID, password string) (err error) { defer func() { errSend := client.sender.SendDeprovisioningResponse(cloudprotocol.DeprovisioningResponse{ - MessageType: cloudprotocol.StartProvisioningResponseMessageType, + MessageType: cloudprotocol.DeprovisioningResponseMessageType, NodeID: nodeID, ErrorInfo: errorInfo, }) From 115e5795ebac648627c3e6d73b25809ca8ce0201 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Fri, 2 Aug 2024 21:09:10 +0300 Subject: [PATCH 091/146] [amqphandler] Remove redundant messageTag from scheduleMessage Signed-off-by: Mykola Kobets --- amqphandler/amqphandler.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/amqphandler/amqphandler.go b/amqphandler/amqphandler.go index 174a1334..d60459a3 100644 --- a/amqphandler/amqphandler.go +++ b/amqphandler/amqphandler.go @@ -236,7 +236,7 @@ func (handler *AmqpHandler) SendUnitStatus(unitStatus cloudprotocol.UnitStatus) unitStatus.MessageType = cloudprotocol.UnitStatusMessageType - return handler.scheduleMessage(cloudprotocol.UnitStatusMessageType, unitStatus, false) + return handler.scheduleMessage(unitStatus, false) } // SendMonitoringData sends monitoring data. @@ -246,7 +246,7 @@ func (handler *AmqpHandler) SendMonitoringData(monitoringData cloudprotocol.Moni monitoringData.MessageType = cloudprotocol.MonitoringMessageType - return handler.scheduleMessage(cloudprotocol.MonitoringMessageType, monitoringData, false) + return handler.scheduleMessage(monitoringData, false) } // SendServiceNewState sends new state message. @@ -256,7 +256,7 @@ func (handler *AmqpHandler) SendInstanceNewState(newState cloudprotocol.NewState newState.MessageType = cloudprotocol.NewStateMessageType - return handler.scheduleMessage(cloudprotocol.NewStateMessageType, newState, false) + return handler.scheduleMessage(newState, false) } // SendServiceStateRequest sends state request message. @@ -266,7 +266,7 @@ func (handler *AmqpHandler) SendInstanceStateRequest(request cloudprotocol.State request.MessageType = cloudprotocol.StateRequestMessageType - return handler.scheduleMessage(cloudprotocol.StateRequestMessageType, request, true) + return handler.scheduleMessage(request, true) } // SendLog sends system or service logs. @@ -276,7 +276,7 @@ func (handler *AmqpHandler) SendLog(serviceLog cloudprotocol.PushLog) error { serviceLog.MessageType = cloudprotocol.PushLogMessageType - return handler.scheduleMessage(cloudprotocol.PushLogMessageType, serviceLog, true) + return handler.scheduleMessage(serviceLog, true) } // SendAlerts sends alerts message. @@ -286,7 +286,7 @@ func (handler *AmqpHandler) SendAlerts(alerts cloudprotocol.Alerts) error { alerts.MessageType = cloudprotocol.AlertsMessageType - return handler.scheduleMessage(cloudprotocol.AlertsMessageType, alerts, true) + return handler.scheduleMessage(alerts, true) } // SendIssueUnitCerts sends request to issue new certificates. @@ -298,7 +298,7 @@ func (handler *AmqpHandler) SendIssueUnitCerts(requests []cloudprotocol.IssueCer MessageType: cloudprotocol.IssueUnitCertsMessageType, Requests: requests, } - return handler.scheduleMessage(cloudprotocol.IssueUnitCertsMessageType, issueUnitCerts, true) + return handler.scheduleMessage(issueUnitCerts, true) } // SendInstallCertsConfirmation sends install certificates confirmation. @@ -310,7 +310,7 @@ func (handler *AmqpHandler) SendInstallCertsConfirmation(confirmations []cloudpr MessageType: cloudprotocol.InstallUnitCertsConfirmationMessageType, Certificates: confirmations, } - return handler.scheduleMessage(cloudprotocol.InstallUnitCertsConfirmationMessageType, request, true) + return handler.scheduleMessage(request, true) } // SendOverrideEnvVarsStatus overrides env vars status. @@ -320,7 +320,7 @@ func (handler *AmqpHandler) SendOverrideEnvVarsStatus(envs cloudprotocol.Overrid envs.MessageType = cloudprotocol.OverrideEnvVarsStatusMessageType - return handler.scheduleMessage(cloudprotocol.OverrideEnvVarsStatusMessageType, envs, true) + return handler.scheduleMessage(envs, true) } // SendStartProvisioningResponse sends start provisioning response. @@ -328,7 +328,7 @@ func (handler *AmqpHandler) SendStartProvisioningResponse(response cloudprotocol handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.StartProvisioningResponseMessageType, response, true) + return handler.scheduleMessage(response, true) } // SendFinishProvisioningResponse sends finish provisioning response. @@ -336,7 +336,7 @@ func (handler *AmqpHandler) SendFinishProvisioningResponse(response cloudprotoco handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.FinishProvisioningResponseMessageType, response, true) + return handler.scheduleMessage(response, true) } // SendDeprovisioningResponse sends deprovisioning response. @@ -344,7 +344,7 @@ func (handler *AmqpHandler) SendDeprovisioningResponse(response cloudprotocol.De handler.Lock() defer handler.Unlock() - return handler.scheduleMessage(cloudprotocol.DeprovisioningResponseMessageType, response, true) + return handler.scheduleMessage(response, true) } // SubscribeForConnectionEvents subscribes for connection events. @@ -762,7 +762,7 @@ func (handler *AmqpHandler) notifyCloudDisconnected() { } } -func (handler *AmqpHandler) scheduleMessage(messageType string, data interface{}, important bool) error { +func (handler *AmqpHandler) scheduleMessage(data interface{}, important bool) error { if !important && !handler.isConnected { return ErrNotConnected } From 3b003f7591d822f236753e1fd1addee3fe47d225 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 5 Aug 2024 12:17:56 +0300 Subject: [PATCH 092/146] [iamclient] Don't deprovision main node Signed-off-by: Mykola Kobets --- iamclient/iamclient.go | 9 +++++++++ iamclient/iamclient_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 195d3e54..0aabc2b0 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -397,6 +397,15 @@ func (client *Client) Deprovision(nodeID, password string) (err error) { } }() + if nodeID == client.GetNodeID() { + err = aoserrors.New("Can't deprovision main node") + errorInfo = &cloudprotocol.ErrorInfo{ + Message: err.Error(), + } + + return err + } + ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) defer cancel() diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index 95eabe28..ab84f081 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -568,6 +568,32 @@ func TestDeprovisioning(t *testing.T) { } } +func TestFailDeprovisionMainNode(t *testing.T) { + sender := &testSender{} + + publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) + if err != nil { + t.Fatalf("Can't create test server: %s", err) + } + + defer publicServer.close() + defer protectedServer.close() + + client, err := iamclient.New(&config.Config{ + IAMProtectedServerURL: protectedServerURL, + IAMPublicServerURL: publicServerURL, + }, sender, nil, true) + if err != nil { + t.Fatalf("Can't create IAM client: %s", err) + } + defer client.Close() + + err = client.Deprovision(publicServer.currentID, "password") + if err == nil { + t.Errorf("Deprovisioning main node should fail") + } +} + func TestPauseNode(t *testing.T) { publicServer, protectedServer, err := newTestServer(publicServerURL, protectedServerURL) if err != nil { From 033fa4aba145fb91ce6c068f633b058fc1eea25d Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 5 Aug 2024 17:26:18 +0300 Subject: [PATCH 093/146] [umcontroller] Don't wait for disconnected nodes After deprovision finishes, CM cant handle any incoming cloud messages, because it hangs waiting for node to connect Signed-off-by: Mykola Kobets --- umcontroller/umcontroller.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index e89310b3..9521e02f 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -52,10 +52,11 @@ type Controller struct { storage storage server *umCtrlServer - eventChannel chan umCtrlInternalMsg - nodeInfoChannel <-chan cloudprotocol.NodeInfo - stopChannel chan bool - componentDir string + eventChannel chan umCtrlInternalMsg + nodeInfoProvider NodeInfoProvider + nodeInfoChannel <-chan cloudprotocol.NodeInfo + stopChannel chan bool + componentDir string decrypter Decrypter @@ -226,6 +227,7 @@ func New(config *config.Config, storage storage, certProvider CertificateProvide umCtrl = &Controller{ storage: storage, eventChannel: make(chan umCtrlInternalMsg), + nodeInfoProvider: nodeInfoProvider, nodeInfoChannel: nodeInfoProvider.SubscribeNodeInfoChange(), stopChannel: make(chan bool), componentDir: config.ComponentsDir, @@ -548,12 +550,19 @@ func (umCtrl *Controller) handleCloseConnection(umID string, reason closeReason) for i, value := range umCtrl.connections { if value.umID == umID { if reason == ConnectionClose { - umCtrl.connections[i].handler = nil + nodeInfo, err := umCtrl.nodeInfoProvider.GetNodeInfo(umID) + provisionedNode := err == nil && nodeInfo.Status != cloudprotocol.NodeStatusUnprovisioned - umCtrl.fsm.SetState(stateInit) - umCtrl.connectionMonitor.wg.Add(1) + if provisionedNode { + umCtrl.connections[i].handler = nil - go umCtrl.connectionMonitor.startConnectionTimer(len(umCtrl.connections)) + umCtrl.fsm.SetState(stateInit) + umCtrl.connectionMonitor.wg.Add(1) + + go umCtrl.connectionMonitor.startConnectionTimer(len(umCtrl.connections)) + } else { + umCtrl.connections = append(umCtrl.connections[:i], umCtrl.connections[i+1:]...) + } } return From 596cd01b1803e9b357c5c0065b4637ce30e7042b Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 23 Jul 2024 14:58:23 +0300 Subject: [PATCH 094/146] [unitstatushandler] Fix skipping rebalancing on update Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index ee2bc492..af783344 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -876,23 +876,19 @@ func (manager *softwareManager) newUpdate(update *softwareUpdate) (err error) { } default: - if manager.isUpdateEquals(update) { - if update.RebalanceRequest { - log.Debug("Skip rebalancing during update") + if update.RebalanceRequest { + log.Debug("Skip rebalancing during update") - return nil - } + return nil + } + if manager.isUpdateEquals(update) { if reflect.DeepEqual(update.Schedule, manager.CurrentUpdate.Schedule) { log.Debug("Skip update without changes") return nil } - if update.RebalanceRequest { - log.Debug("Skip rebalancing") - } - // Schedule changed: in ready to update state we can reschedule update. Except current update is forced type, // because in this case force update is already scheduled if manager.CurrentState == stateReadyToUpdate && (manager.CurrentUpdate.Schedule.Type != cloudprotocol.ForceUpdate) { From ac01993ec34b61d4d24172143d9290dbcd669fec Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 23 Jul 2024 14:59:09 +0300 Subject: [PATCH 095/146] [unitstatushandler] Schedule rebalancing on node info changed Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 9149ed9e..d52eece7 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -826,6 +826,10 @@ func (instance *Instance) handleChannels() { instance.updateNodeInfo(nodeInfo) + if err := instance.softwareManager.requestRebalancing(); err != nil { + log.Errorf("Can't perform rebalancing: %v", err) + } + case systemQuotaAlert, ok := <-instance.systemQuotaAlertChannel: if !ok { return From 8438947f445b7bab4104b39f23cf094798926984 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 23 Jul 2024 15:32:23 +0300 Subject: [PATCH 096/146] [unistatushandler] Optimize handleChannels function Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index d52eece7..f4321daa 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -25,6 +25,8 @@ import ( "sync/atomic" "time" + "golang.org/x/exp/slices" + "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/api/cloudprotocol" "github.com/aosedge/aos_common/resourcemonitor" @@ -839,16 +841,10 @@ func (instance *Instance) handleChannels() { return } - for _, param := range []string{"cpu", "ram"} { - if param != systemQuotaAlert.Parameter { - continue - } - + if slices.Contains([]string{"cpu", "ram"}, systemQuotaAlert.Parameter) { if err := instance.softwareManager.requestRebalancing(); err != nil { log.Errorf("Can't perform rebalancing: %v", err) } - - break } } } From 484dc0513822f75ea7dc78ad027cf92a0a82ae4a Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 23 Jul 2024 16:44:07 +0300 Subject: [PATCH 097/146] [database] Remove unused API Signed-off-by: Oleksandr Grytsov --- database/database.go | 51 +++--------------------------- database/database_internal_test.go | 46 --------------------------- 2 files changed, 4 insertions(+), 93 deletions(-) diff --git a/database/database.go b/database/database.go index a73829ee..b7cb191e 100644 --- a/database/database.go +++ b/database/database.go @@ -269,28 +269,7 @@ func (db *Database) GetSoftwareUpdateState() (state json.RawMessage, err error) return state, err } -// SetDesiredInstances sets desired instances status. -func (db *Database) SetDesiredInstances(instances json.RawMessage) (err error) { - if err = db.executeQuery(`UPDATE config SET desiredInstances = ?`, instances); err != nil { - return err - } - - return nil -} - -// GetDesiredInstances returns desired instances. -func (db *Database) GetDesiredInstances() (instances json.RawMessage, err error) { - if err = db.getDataFromQuery( - "SELECT desiredInstances FROM config", - []any{}, &instances); err != nil { - if errors.Is(err, errNotExist) { - return instances, launcher.ErrNotExist - } - } - - return instances, err -} - +// GetDownloadInfo returns download info by file path. func (db *Database) GetDownloadInfo(filePath string) (downloadInfo downloader.DownloadInfo, err error) { if err = db.getDataFromQuery( "SELECT * FROM download WHERE path = ?", @@ -304,6 +283,7 @@ func (db *Database) GetDownloadInfo(filePath string) (downloadInfo downloader.Do return downloadInfo, err } +// GetDownloadInfos returns all download info. func (db *Database) GetDownloadInfos() (downloadInfos []downloader.DownloadInfo, err error) { rows, err := db.sql.Query("SELECT * FROM download") if err != nil { @@ -330,6 +310,7 @@ func (db *Database) GetDownloadInfos() (downloadInfos []downloader.DownloadInfo, return downloadInfos, nil } +// RemoveDownloadInfo removes download info by file path. func (db *Database) RemoveDownloadInfo(filePath string) (err error) { if err = db.executeQuery("DELETE FROM download WHERE path = ?", filePath); errors.Is(err, errNotExist) { return nil @@ -338,6 +319,7 @@ func (db *Database) RemoveDownloadInfo(filePath string) (err error) { return err } +// SetDownloadInfo stores download info. func (db *Database) SetDownloadInfo(downloadInfo downloader.DownloadInfo) (err error) { var path string @@ -784,31 +766,6 @@ func (db *Database) GetNetworkInstancesInfo() (networkInfos []networkmanager.Ins return networkInfos, nil } -// SetNodeState stores node state. -func (db *Database) SetNodeState(nodeID string, state json.RawMessage) error { - if err := db.executeQuery("UPDATE nodes SET state = ? WHERE nodeID = ?", state, nodeID); errors.Is(err, errNotExist) { - return db.executeQuery("INSERT INTO nodes values(?, ?)", nodeID, state) - } else { - return err - } -} - -// GetNodeState retrieves node state. -func (db *Database) GetNodeState(nodeID string) (json.RawMessage, error) { - var state json.RawMessage - - if err := db.getDataFromQuery( - "SELECT state FROM nodes WHERE nodeID = ?", []any{nodeID}, &state); err != nil { - if errors.Is(err, errNotExist) { - return nil, launcher.ErrNotExist - } - - return nil, err - } - - return state, nil -} - // Close closes database. func (db *Database) Close() { db.sql.Close() diff --git a/database/database_internal_test.go b/database/database_internal_test.go index 9491759c..32fdcd3b 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -173,7 +173,6 @@ func TestComponentsUpdateInfo(t *testing.T) { func TestSotaFotaInstancesFields(t *testing.T) { fotaState := json.RawMessage("fotaState") sotaState := json.RawMessage("sotaState") - desiredInstances := json.RawMessage("desiredInstances") if err := testDB.SetFirmwareUpdateState(fotaState); err != nil { t.Fatalf("Can't set FOTA state: %v", err) @@ -183,10 +182,6 @@ func TestSotaFotaInstancesFields(t *testing.T) { t.Fatalf("Can't set SOTA state: %v", err) } - if err := testDB.SetDesiredInstances(desiredInstances); err != nil { - t.Fatalf("Can't set desired instances: %v", err) - } - retFota, err := testDB.GetFirmwareUpdateState() if err != nil { t.Fatalf("Can't get FOTA state: %v", err) @@ -204,15 +199,6 @@ func TestSotaFotaInstancesFields(t *testing.T) { if string(retSota) != string(sotaState) { t.Errorf("Incorrect SOTA state: %s", string(retSota)) } - - retInstances, err := testDB.GetDesiredInstances() - if err != nil { - t.Fatalf("Can't get desired instances state %v", err) - } - - if string(retInstances) != string(desiredInstances) { - t.Errorf("Incorrect desired instances: %s", string(retInstances)) - } } func TestMultiThread(t *testing.T) { @@ -1000,38 +986,6 @@ func TestStorageState(t *testing.T) { } } -func TestNodeState(t *testing.T) { - setNodeState := json.RawMessage("node state 1") - - if err := testDB.SetNodeState("nodeID", setNodeState); err != nil { - t.Fatalf("Can't set node state: %v", err) - } - - getNodeState, err := testDB.GetNodeState("nodeID") - if err != nil { - t.Errorf("Can't get node state: %v", err) - } - - if string(setNodeState) != string(getNodeState) { - t.Errorf("Wrong get node state: %s", string(getNodeState)) - } - - setNodeState = json.RawMessage("node state 2") - - if err := testDB.SetNodeState("nodeID", setNodeState); err != nil { - t.Fatalf("Can't set node state: %v", err) - } - - getNodeState, err = testDB.GetNodeState("nodeID") - if err != nil { - t.Errorf("Can't get node state: %v", err) - } - - if string(setNodeState) != string(getNodeState) { - t.Errorf("Wrong get node state: %s", string(getNodeState)) - } -} - func TestMigration(t *testing.T) { migrationDBName := filepath.Join(tmpDir, "test_migration.db") mergedMigrationDir := filepath.Join(tmpDir, "mergedMigration") From 1bbbb157f9a5305a01f196b765079aaa602d7edd Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 24 Jul 2024 12:15:05 +0300 Subject: [PATCH 098/146] [vendor] Update vendor Signed-off-by: Oleksandr Grytsov --- go.mod | 2 +- go.sum | 4 +- .../aosedge/aos_common/aostypes/aostypes.go | 51 +-- .../api/servicemanager/servicemanager.pb.go | 313 +++++++++--------- .../resourcemonitor/alertprocessor.go | 109 +++--- .../resourcemonitor/resourcemonitor.go | 186 ++++++----- vendor/golang.org/x/exp/maps/maps.go | 94 ++++++ vendor/modules.txt | 3 +- 8 files changed, 447 insertions(+), 315 deletions(-) create mode 100644 vendor/golang.org/x/exp/maps/maps.go diff --git a/go.mod b/go.mod index c8a8a3b0..1f03b889 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc + github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013 github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index b4cd49bd..3dbf5b3b 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc h1:v1I1sGcXwSmS4LNPQGYO8ZbKNdDcNrUAZZTE9zZqk+U= -github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc/go.mod h1:6piX5uuY/5CjMZwYB5nTc+dR+/rcZe40FSYRZ5mguJU= +github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013 h1:VlIBKRo12pu2i0O74Lb7lfJqMqhSKcHubNFKZpCPaww= +github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go index 08c9debc..71916847 100644 --- a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go +++ b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go @@ -165,33 +165,40 @@ type RunParameters struct { RestartInterval Duration `json:"restartInterval,omitempty"` } -// AlertRuleParam describes alert rule. -type AlertRuleParam struct { - Timeout Duration `json:"timeout"` - Low uint64 `json:"low"` - High uint64 `json:"high"` +// AlertRulePercents describes alert rule. +type AlertRulePercents struct { + MinTimeout Duration `json:"minTimeout"` + MinThreshold float64 `json:"minThreshold"` + MaxThreshold float64 `json:"maxThreshold"` } -// PartitionAlertRuleParam describes alert rule. -type PartitionAlertRuleParam struct { - AlertRuleParam +// AlertRulePoints describes alert rule. +type AlertRulePoints struct { + MinTimeout Duration `json:"minTimeout"` + MinThreshold uint64 `json:"minThreshold"` + MaxThreshold uint64 `json:"maxThreshold"` +} + +// PartitionAlertRule describes alert rule. +type PartitionAlertRule struct { + AlertRulePercents Name string `json:"name"` } // AlertRules define service monitoring alerts rules. type AlertRules struct { - RAM *AlertRuleParam `json:"ram,omitempty"` - CPU *AlertRuleParam `json:"cpu,omitempty"` - UsedDisks []PartitionAlertRuleParam `json:"usedDisks,omitempty"` - InTraffic *AlertRuleParam `json:"inTraffic,omitempty"` - OutTraffic *AlertRuleParam `json:"outTraffic,omitempty"` + RAM *AlertRulePercents `json:"ram,omitempty"` + CPU *AlertRulePercents `json:"cpu,omitempty"` + UsedDisks []PartitionAlertRule `json:"usedDisks,omitempty"` + Download *AlertRulePoints `json:"download,omitempty"` + Upload *AlertRulePoints `json:"upload,omitempty"` } // ResourceRatiosInfo resource ratios info. type ResourceRatiosInfo struct { - CPU float32 `json:"cpu"` - Mem float32 `json:"mem"` - Storage float32 `json:"storage"` + CPU *float64 `json:"cpu"` + RAM *float64 `json:"ram"` + Storage *float64 `json:"storage"` } // ServiceConfig Aos service configuration. @@ -221,12 +228,12 @@ type PartitionUsage struct { // MonitoringData monitoring data. type MonitoringData struct { - Timestamp time.Time `json:"timestamp"` - RAM uint64 `json:"ram"` - CPU uint64 `json:"cpu"` - InTraffic uint64 `json:"inTraffic"` - OutTraffic uint64 `json:"outTraffic"` - Disk []PartitionUsage `json:"disk"` + Timestamp time.Time `json:"timestamp"` + RAM uint64 `json:"ram"` + CPU uint64 `json:"cpu"` + Download uint64 `json:"download"` + Upload uint64 `json:"upload"` + Disk []PartitionUsage `json:"disk"` } type InstanceMonitoring struct { diff --git a/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go index 0600e23c..dd864834 100644 --- a/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go +++ b/vendor/github.com/aosedge/aos_common/api/servicemanager/servicemanager.pb.go @@ -2639,12 +2639,12 @@ type MonitoringData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Ram uint64 `protobuf:"varint,1,opt,name=ram,proto3" json:"ram,omitempty"` - Cpu uint64 `protobuf:"varint,2,opt,name=cpu,proto3" json:"cpu,omitempty"` - Disk []*PartitionUsage `protobuf:"bytes,3,rep,name=disk,proto3" json:"disk,omitempty"` - InTraffic uint64 `protobuf:"varint,4,opt,name=in_traffic,json=inTraffic,proto3" json:"in_traffic,omitempty"` - OutTraffic uint64 `protobuf:"varint,5,opt,name=out_traffic,json=outTraffic,proto3" json:"out_traffic,omitempty"` - Timestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Ram uint64 `protobuf:"varint,1,opt,name=ram,proto3" json:"ram,omitempty"` + Cpu uint64 `protobuf:"varint,2,opt,name=cpu,proto3" json:"cpu,omitempty"` + Disk []*PartitionUsage `protobuf:"bytes,3,rep,name=disk,proto3" json:"disk,omitempty"` + Download uint64 `protobuf:"varint,4,opt,name=download,proto3" json:"download,omitempty"` + Upload uint64 `protobuf:"varint,5,opt,name=upload,proto3" json:"upload,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *MonitoringData) Reset() { @@ -2700,16 +2700,16 @@ func (x *MonitoringData) GetDisk() []*PartitionUsage { return nil } -func (x *MonitoringData) GetInTraffic() uint64 { +func (x *MonitoringData) GetDownload() uint64 { if x != nil { - return x.InTraffic + return x.Download } return 0 } -func (x *MonitoringData) GetOutTraffic() uint64 { +func (x *MonitoringData) GetUpload() uint64 { if x != nil { - return x.OutTraffic + return x.Upload } return 0 } @@ -2838,7 +2838,7 @@ type Alert struct { Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Tag string `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"` - // Types that are assignable to Payload: + // Types that are assignable to AlertItem: // // *Alert_SystemQuotaAlert // *Alert_InstanceQuotaAlert @@ -2847,7 +2847,7 @@ type Alert struct { // *Alert_SystemAlert // *Alert_CoreAlert // *Alert_InstanceAlert - Payload isAlert_Payload `protobuf_oneof:"Payload"` + AlertItem isAlert_AlertItem `protobuf_oneof:"AlertItem"` } func (x *Alert) Reset() { @@ -2896,64 +2896,64 @@ func (x *Alert) GetTag() string { return "" } -func (m *Alert) GetPayload() isAlert_Payload { +func (m *Alert) GetAlertItem() isAlert_AlertItem { if m != nil { - return m.Payload + return m.AlertItem } return nil } func (x *Alert) GetSystemQuotaAlert() *SystemQuotaAlert { - if x, ok := x.GetPayload().(*Alert_SystemQuotaAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_SystemQuotaAlert); ok { return x.SystemQuotaAlert } return nil } func (x *Alert) GetInstanceQuotaAlert() *InstanceQuotaAlert { - if x, ok := x.GetPayload().(*Alert_InstanceQuotaAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_InstanceQuotaAlert); ok { return x.InstanceQuotaAlert } return nil } func (x *Alert) GetResourceValidateAlert() *ResourceValidateAlert { - if x, ok := x.GetPayload().(*Alert_ResourceValidateAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_ResourceValidateAlert); ok { return x.ResourceValidateAlert } return nil } func (x *Alert) GetDeviceAllocateAlert() *DeviceAllocateAlert { - if x, ok := x.GetPayload().(*Alert_DeviceAllocateAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_DeviceAllocateAlert); ok { return x.DeviceAllocateAlert } return nil } func (x *Alert) GetSystemAlert() *SystemAlert { - if x, ok := x.GetPayload().(*Alert_SystemAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_SystemAlert); ok { return x.SystemAlert } return nil } func (x *Alert) GetCoreAlert() *CoreAlert { - if x, ok := x.GetPayload().(*Alert_CoreAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_CoreAlert); ok { return x.CoreAlert } return nil } func (x *Alert) GetInstanceAlert() *InstanceAlert { - if x, ok := x.GetPayload().(*Alert_InstanceAlert); ok { + if x, ok := x.GetAlertItem().(*Alert_InstanceAlert); ok { return x.InstanceAlert } return nil } -type isAlert_Payload interface { - isAlert_Payload() +type isAlert_AlertItem interface { + isAlert_AlertItem() } type Alert_SystemQuotaAlert struct { @@ -2984,19 +2984,19 @@ type Alert_InstanceAlert struct { InstanceAlert *InstanceAlert `protobuf:"bytes,9,opt,name=instance_alert,json=instanceAlert,proto3,oneof"` } -func (*Alert_SystemQuotaAlert) isAlert_Payload() {} +func (*Alert_SystemQuotaAlert) isAlert_AlertItem() {} -func (*Alert_InstanceQuotaAlert) isAlert_Payload() {} +func (*Alert_InstanceQuotaAlert) isAlert_AlertItem() {} -func (*Alert_ResourceValidateAlert) isAlert_Payload() {} +func (*Alert_ResourceValidateAlert) isAlert_AlertItem() {} -func (*Alert_DeviceAllocateAlert) isAlert_Payload() {} +func (*Alert_DeviceAllocateAlert) isAlert_AlertItem() {} -func (*Alert_SystemAlert) isAlert_Payload() {} +func (*Alert_SystemAlert) isAlert_AlertItem() {} -func (*Alert_CoreAlert) isAlert_Payload() {} +func (*Alert_CoreAlert) isAlert_AlertItem() {} -func (*Alert_InstanceAlert) isAlert_Payload() {} +func (*Alert_InstanceAlert) isAlert_AlertItem() {} type ImageContentRequest struct { state protoimpl.MessageState @@ -3944,141 +3944,140 @@ var file_servicemanager_v4_servicemanager_proto_rawDesc = []byte{ 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x13, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x4d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xe5, 0x01, 0x0a, 0x0e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, + 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xd9, 0x01, 0x0a, 0x0e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x72, 0x61, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x35, 0x0a, 0x04, 0x64, 0x69, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, 0x64, - 0x69, 0x73, 0x6b, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x6e, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, - 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x69, 0x6e, 0x54, 0x72, 0x61, 0x66, 0x66, - 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, - 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x6f, 0x75, 0x74, 0x54, 0x72, 0x61, 0x66, - 0x66, 0x69, 0x63, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x41, 0x0a, - 0x0e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x75, 0x73, 0x65, 0x64, 0x53, 0x69, 0x7a, 0x65, - 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x4d, 0x6f, 0x6e, - 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x69, 0x73, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, + 0x16, 0x0a, 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x22, 0x41, 0x0a, 0x0e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x64, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x75, 0x73, 0x65, 0x64, + 0x53, 0x69, 0x7a, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x08, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x5f, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4d, + 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6d, + 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x22, 0xa1, 0x05, + 0x0a, 0x05, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x74, 0x61, 0x67, 0x12, 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x71, 0x75, + 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x23, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, + 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, + 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, + 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, + 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x12, 0x62, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, + 0x52, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x64, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, + 0x52, 0x13, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, + 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, + 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, + 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x63, 0x6f, + 0x72, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, + 0x76, 0x34, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x09, + 0x63, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x49, 0x0a, 0x0e, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, + 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, + 0x6c, 0x65, 0x72, 0x74, 0x42, 0x0b, 0x0a, 0x09, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x49, 0x74, 0x65, + 0x6d, 0x22, 0x69, 0x0a, 0x13, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x12, 0x0a, 0x10, + 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x5e, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, + 0x6c, 0x65, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, + 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x4a, 0x0a, - 0x0f, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x4d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0e, 0x6d, 0x6f, 0x6e, 0x69, 0x74, - 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, 0x74, 0x61, 0x22, 0x9f, 0x05, 0x0a, 0x05, 0x41, 0x6c, - 0x65, 0x72, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x10, 0x0a, - 0x03, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, - 0x53, 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, - 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, - 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, - 0x48, 0x00, 0x52, 0x10, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, - 0x6c, 0x65, 0x72, 0x74, 0x12, 0x59, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x61, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, - 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x12, 0x69, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, - 0x62, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x28, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x15, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, - 0x65, 0x72, 0x74, 0x12, 0x5c, 0x0a, 0x15, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x61, 0x6c, - 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, - 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x13, 0x64, 0x65, - 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, - 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x61, 0x6c, 0x65, 0x72, - 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x3d, 0x0a, 0x0a, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x61, - 0x6c, 0x65, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x43, - 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, 0x00, 0x52, 0x09, 0x63, 0x6f, 0x72, 0x65, - 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x49, 0x0a, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x5f, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x34, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x48, - 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, - 0x42, 0x09, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x69, 0x0a, 0x13, 0x49, - 0x6d, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x43, 0x6c, 0x6f, 0x63, 0x6b, 0x53, - 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x5e, 0x0a, 0x10, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x1c, - 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x51, 0x75, 0x6f, 0x74, 0x61, 0x41, 0x6c, 0x65, 0x72, - 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, - 0x65, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x22, 0x7d, 0x0a, 0x13, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, - 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x22, 0x59, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x2c, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x22, 0x27, 0x0a, - 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, 0x09, 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, - 0x65, 0x72, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, - 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, - 0x31, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, - 0x6d, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, - 0x10, 0x01, 0x32, 0x6d, 0x0a, 0x09, 0x53, 0x4d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x60, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x4d, 0x12, 0x25, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, - 0x34, 0x2e, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x73, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, - 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, - 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x7d, 0x0a, 0x13, 0x44, 0x65, 0x76, + 0x69, 0x63, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, + 0x12, 0x34, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x59, 0x0a, 0x15, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x6c, 0x65, 0x72, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x73, 0x22, 0x27, 0x0a, 0x0b, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x41, 0x6c, 0x65, + 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4c, 0x0a, 0x09, + 0x43, 0x6f, 0x72, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x72, + 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, + 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x0d, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, + 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2a, 0x31, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, + 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, + 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x01, 0x32, 0x6d, 0x0a, 0x09, 0x53, 0x4d, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x53, 0x4d, 0x12, 0x25, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, 0x4d, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2e, 0x76, 0x34, 0x2e, 0x53, + 0x4d, 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x73, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go index d2543d35..b5aa25f5 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/alertprocessor.go @@ -18,6 +18,7 @@ package resourcemonitor import ( + "math" "time" "github.com/aosedge/aos_common/aostypes" @@ -42,22 +43,48 @@ type alertCallback func(time time.Time, value uint64, status string) // alertProcessor object for detection alerts. type alertProcessor struct { - name string - source *uint64 - callback alertCallback - rule aostypes.AlertRuleParam - highThresholdTime time.Time - lowThresholdTime time.Time - alertCondition bool + name string + source *uint64 + callback alertCallback + + minTimeout time.Duration + minThreshold uint64 + maxThreshold uint64 + minThresholdTime time.Time + maxThresholdTime time.Time + alertCondition bool } -// createAlertProcessor creates alert processor based on configuration. -func createAlertProcessor(name string, source *uint64, - callback alertCallback, rule aostypes.AlertRuleParam, +// createAlertProcessorPercents creates alert processor based on percents configuration. +func createAlertProcessorPercents(name string, source *uint64, maxValue uint64, + callback alertCallback, rule aostypes.AlertRulePercents, ) (alert *alertProcessor) { - log.WithFields(log.Fields{"rule": rule, "name": name}).Debugf("Create alert processor") + log.WithFields(log.Fields{"rule": rule, "name": name}).Debugf("Create alert percents processor") + + return &alertProcessor{ + name: name, + source: source, + callback: callback, + minTimeout: rule.MinTimeout.Duration, + minThreshold: uint64(math.Round(float64(maxValue) * rule.MinThreshold / 100.0)), + maxThreshold: uint64(math.Round(float64(maxValue) * rule.MaxThreshold / 100.0)), + } +} - return &alertProcessor{name: name, source: source, callback: callback, rule: rule} +// createAlertProcessorPoints creates alert processor based on points configuration. +func createAlertProcessorPoints(name string, source *uint64, + callback alertCallback, rule aostypes.AlertRulePoints, +) (alert *alertProcessor) { + log.WithFields(log.Fields{"rule": rule, "name": name}).Debugf("Create alert points processor") + + return &alertProcessor{ + name: name, + source: source, + callback: callback, + minTimeout: rule.MinTimeout.Duration, + minThreshold: rule.MinThreshold, + maxThreshold: rule.MaxThreshold, + } } // checkAlertDetection checks if alert was detected. @@ -65,29 +92,29 @@ func (alert *alertProcessor) checkAlertDetection(currentTime time.Time) { value := *alert.source if !alert.alertCondition { - alert.handleHighThreshold(currentTime, value) + alert.handleMaxThreshold(currentTime, value) } else { - alert.handleLowThreshold(currentTime, value) + alert.handleMinThreshold(currentTime, value) } } -func (alert *alertProcessor) handleHighThreshold(currentTime time.Time, value uint64) { - if value >= alert.rule.High && alert.highThresholdTime.IsZero() { +func (alert *alertProcessor) handleMaxThreshold(currentTime time.Time, value uint64) { + if value >= alert.maxThreshold && alert.maxThresholdTime.IsZero() { log.WithFields(log.Fields{ - "name": alert.name, - "highThreshold": alert.rule.High, - "value": value, - "currentTime": currentTime.Format("Jan 2 15:04:05.000"), - }).Debugf("High threshold crossed") + "name": alert.name, + "maxThreshold": alert.maxThreshold, + "value": value, + "currentTime": currentTime.Format("Jan 2 15:04:05.000"), + }).Debugf("Max threshold crossed") - alert.highThresholdTime = currentTime + alert.maxThresholdTime = currentTime } - if value >= alert.rule.High && !alert.highThresholdTime.IsZero() && - currentTime.Sub(alert.highThresholdTime) >= alert.rule.Timeout.Duration && !alert.alertCondition { + if value >= alert.maxThreshold && !alert.maxThresholdTime.IsZero() && + currentTime.Sub(alert.maxThresholdTime) >= alert.minTimeout && !alert.alertCondition { alert.alertCondition = true - alert.highThresholdTime = currentTime - alert.lowThresholdTime = time.Time{} + alert.maxThresholdTime = currentTime + alert.minThresholdTime = time.Time{} log.WithFields(log.Fields{ "name": alert.name, @@ -99,17 +126,17 @@ func (alert *alertProcessor) handleHighThreshold(currentTime time.Time, value ui alert.callback(currentTime, value, AlertStatusRaise) } - if value < alert.rule.High && !alert.highThresholdTime.IsZero() { - alert.highThresholdTime = time.Time{} + if value < alert.maxThreshold && !alert.maxThresholdTime.IsZero() { + alert.maxThresholdTime = time.Time{} } } -func (alert *alertProcessor) handleLowThreshold(currentTime time.Time, value uint64) { - if value <= alert.rule.Low && !alert.lowThresholdTime.IsZero() && - currentTime.Sub(alert.lowThresholdTime) >= alert.rule.Timeout.Duration { +func (alert *alertProcessor) handleMinThreshold(currentTime time.Time, value uint64) { + if value <= alert.minThreshold && !alert.minThresholdTime.IsZero() && + currentTime.Sub(alert.minThresholdTime) >= alert.minTimeout { alert.alertCondition = false - alert.lowThresholdTime = currentTime - alert.highThresholdTime = time.Time{} + alert.minThresholdTime = currentTime + alert.maxThresholdTime = time.Time{} log.WithFields(log.Fields{ "name": alert.name, @@ -121,8 +148,8 @@ func (alert *alertProcessor) handleLowThreshold(currentTime time.Time, value uin alert.callback(currentTime, value, AlertStatusFall) } - if currentTime.Sub(alert.highThresholdTime) >= alert.rule.Timeout.Duration && alert.alertCondition { - alert.highThresholdTime = currentTime + if currentTime.Sub(alert.maxThresholdTime) >= alert.minTimeout && alert.alertCondition { + alert.maxThresholdTime = currentTime log.WithFields(log.Fields{ "name": alert.name, @@ -134,15 +161,15 @@ func (alert *alertProcessor) handleLowThreshold(currentTime time.Time, value uin alert.callback(currentTime, value, AlertStatusContinue) } - if value <= alert.rule.Low && alert.lowThresholdTime.IsZero() { + if value <= alert.minThreshold && alert.minThresholdTime.IsZero() { log.WithFields(log.Fields{ - "name": alert.name, "lowThreshold": alert.rule.Low, "value": value, - }).Debugf("Low threshold crossed") + "name": alert.name, "minThreshold": alert.minThreshold, "value": value, + }).Debugf("Min threshold crossed") - alert.lowThresholdTime = currentTime + alert.minThresholdTime = currentTime } - if value > alert.rule.Low && !alert.lowThresholdTime.IsZero() { - alert.lowThresholdTime = time.Time{} + if value > alert.maxThreshold && !alert.minThresholdTime.IsZero() { + alert.minThresholdTime = time.Time{} } } diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index 79bae762..0ebcd4f0 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -26,6 +26,8 @@ import ( "sync" "time" + "golang.org/x/exp/slices" + "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" @@ -146,11 +148,11 @@ type instanceMonitoring struct { } type averageMonitoring struct { - ram *averageCalc - cpu *averageCalc - inTraffic *averageCalc - outTraffic *averageCalc - disks map[string]*averageCalc + ram *averageCalc + cpu *averageCalc + download *averageCalc + upload *averageCalc + disks map[string]*averageCalc } /*********************************************************************************************************************** @@ -376,23 +378,21 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC } if nodeConfig.AlertRules.CPU != nil { - rules := *nodeConfig.AlertRules.CPU - rules.High = monitor.cpuToDMIPs(float64(rules.High)) - rules.Low = monitor.cpuToDMIPs(float64(rules.Low)) - - monitor.alertProcessors.PushBack(createAlertProcessor( + monitor.alertProcessors.PushBack(createAlertProcessorPercents( "System CPU", &monitor.nodeMonitoring.CPU, + monitor.nodeInfo.MaxDMIPs, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "cpu", time, value, status)) }, - rules)) + *nodeConfig.AlertRules.CPU)) } if nodeConfig.AlertRules.RAM != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( + monitor.alertProcessors.PushBack(createAlertProcessorPercents( "System RAM", &monitor.nodeMonitoring.RAM, + monitor.nodeInfo.TotalRAM, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "ram", time, value, status)) }, @@ -400,55 +400,62 @@ func (monitor *ResourceMonitor) setupSystemAlerts(nodeConfig cloudprotocol.NodeC } for _, diskRule := range nodeConfig.AlertRules.UsedDisks { - diskUsageValue, findErr := getDiskUsageValue(monitor.nodeMonitoring.Disk, diskRule.Name) + diskUsageValue, diskTotalSize, findErr := getDiskUsageValue( + diskRule.Name, monitor.nodeMonitoring.Disk, monitor.nodeInfo.Partitions) if findErr != nil && err == nil { err = findErr - - log.Errorf("Can't find disk: %s", diskRule.Name) - continue } - monitor.alertProcessors.PushBack(createAlertProcessor( + monitor.alertProcessors.PushBack(createAlertProcessorPercents( "Partition "+diskRule.Name, diskUsageValue, + diskTotalSize, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, diskRule.Name, time, value, status)) }, - diskRule.AlertRuleParam)) + diskRule.AlertRulePercents)) } - if nodeConfig.AlertRules.InTraffic != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( - "IN Traffic", - &monitor.nodeMonitoring.InTraffic, + if nodeConfig.AlertRules.Download != nil { + monitor.alertProcessors.PushBack(createAlertProcessorPoints( + "Download traffic", + &monitor.nodeMonitoring.Download, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "inTraffic", time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "download", time, value, status)) }, - *nodeConfig.AlertRules.InTraffic)) + *nodeConfig.AlertRules.Download)) } - if nodeConfig.AlertRules.OutTraffic != nil { - monitor.alertProcessors.PushBack(createAlertProcessor( - "OUT Traffic", - &monitor.nodeMonitoring.OutTraffic, + if nodeConfig.AlertRules.Upload != nil { + monitor.alertProcessors.PushBack(createAlertProcessorPoints( + "Upload traffic", + &monitor.nodeMonitoring.Upload, func(time time.Time, value uint64, status string) { - monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "outTraffic", time, value, status)) + monitor.alertSender.SendAlert(prepareSystemAlertItem(nodeID, "upload", time, value, status)) }, - *nodeConfig.AlertRules.OutTraffic)) + *nodeConfig.AlertRules.Upload)) } return err } -func getDiskUsageValue(disks []aostypes.PartitionUsage, name string) (*uint64, error) { - for i, disk := range disks { - if disk.Name == name { - return &disks[i].UsedSize, nil - } +func getDiskUsageValue( + name string, disksUsage []aostypes.PartitionUsage, disksInfo []cloudprotocol.PartitionInfo, +) (value *uint64, maxValue uint64, err error) { + valueIndex := slices.IndexFunc(disksUsage, func(disk aostypes.PartitionUsage) bool { + return disk.Name == name + }) + + maxValueIndex := slices.IndexFunc(disksInfo, func(disk cloudprotocol.PartitionInfo) bool { + return disk.Name == name + }) + + if valueIndex == -1 || maxValueIndex == -1 { + return nil, 0, aoserrors.Errorf("disk [%s] not found", name) } - return nil, aoserrors.Errorf("can't find disk %s", name) + return &disksUsage[valueIndex].UsedSize, disksInfo[maxValueIndex].TotalSize, nil } func getDiskPath(disks []cloudprotocol.PartitionInfo, name string) (string, error) { @@ -490,26 +497,24 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM instanceMonitoring.alertProcessorElements = make([]*list.Element, 0) if rules.CPU != nil { - rules := *rules.CPU - rules.High = monitor.cpuToDMIPs(float64(rules.High)) - rules.Low = monitor.cpuToDMIPs(float64(rules.Low)) - - e := monitor.alertProcessors.PushBack(createAlertProcessor( + e := monitor.alertProcessors.PushBack(createAlertProcessorPercents( instanceID+" CPU", &instanceMonitoring.monitoring.CPU, + monitor.nodeInfo.MaxDMIPs, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( instanceMonitoring.monitoring.InstanceIdent, "cpu", time, value, status)) - }, rules)) + }, *rules.CPU)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } if rules.RAM != nil { - e := monitor.alertProcessors.PushBack(createAlertProcessor( + e := monitor.alertProcessors.PushBack(createAlertProcessorPercents( instanceID+" RAM", &instanceMonitoring.monitoring.RAM, + monitor.nodeInfo.TotalRAM, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( @@ -520,49 +525,48 @@ func (monitor *ResourceMonitor) setupInstanceAlerts(instanceID string, instanceM } for _, diskRule := range rules.UsedDisks { - diskUsageValue, findErr := getDiskUsageValue(instanceMonitoring.monitoring.Disk, diskRule.Name) + diskUsageValue, diskTotalSize, findErr := getDiskUsageValue( + diskRule.Name, instanceMonitoring.monitoring.Disk, monitor.nodeInfo.Partitions) if findErr != nil && err == nil { - log.Errorf("Can't find disk: %s", diskRule.Name) - err = findErr - continue } - e := monitor.alertProcessors.PushBack(createAlertProcessor( + e := monitor.alertProcessors.PushBack(createAlertProcessorPercents( instanceID+" Partition "+diskRule.Name, diskUsageValue, + diskTotalSize, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( instanceMonitoring.monitoring.InstanceIdent, diskRule.Name, time, value, status)) - }, diskRule.AlertRuleParam)) + }, diskRule.AlertRulePercents)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } - if rules.InTraffic != nil { - e := monitor.alertProcessors.PushBack(createAlertProcessor( - instanceID+" Traffic IN", - &instanceMonitoring.monitoring.InTraffic, + if rules.Download != nil { + e := monitor.alertProcessors.PushBack(createAlertProcessorPoints( + instanceID+" download traffic", + &instanceMonitoring.monitoring.Download, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoring.InstanceIdent, "inTraffic", time, value, status)) - }, *rules.InTraffic)) + instanceMonitoring.monitoring.InstanceIdent, "download", time, value, status)) + }, *rules.Download)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } - if rules.OutTraffic != nil { - e := monitor.alertProcessors.PushBack(createAlertProcessor( - instanceID+" Traffic OUT", - &instanceMonitoring.monitoring.OutTraffic, + if rules.Upload != nil { + e := monitor.alertProcessors.PushBack(createAlertProcessorPoints( + instanceID+" upload traffic", + &instanceMonitoring.monitoring.Upload, func(time time.Time, value uint64, status string) { monitor.alertSender.SendAlert( prepareInstanceAlertItem( - instanceMonitoring.monitoring.InstanceIdent, "outTraffic", time, value, status)) - }, *rules.OutTraffic)) + instanceMonitoring.monitoring.InstanceIdent, "upload", time, value, status)) + }, *rules.Upload)) instanceMonitoring.alertProcessorElements = append(instanceMonitoring.alertProcessorElements, e) } @@ -615,23 +619,23 @@ func (monitor *ResourceMonitor) getCurrentSystemData() { } if monitor.trafficMonitoring != nil { - inTraffic, outTraffic, err := monitor.trafficMonitoring.GetSystemTraffic() + download, upload, err := monitor.trafficMonitoring.GetSystemTraffic() if err != nil { log.Errorf("Can't get system traffic value: %s", err) } - monitor.nodeMonitoring.InTraffic = inTraffic - monitor.nodeMonitoring.OutTraffic = outTraffic + monitor.nodeMonitoring.Download = download + monitor.nodeMonitoring.Upload = upload } monitor.nodeAverageData.updateMonitoringData(monitor.nodeMonitoring) log.WithFields(log.Fields{ - "CPU": monitor.nodeMonitoring.CPU, - "RAM": monitor.nodeMonitoring.RAM, - "Disk": monitor.nodeMonitoring.Disk, - "IN": monitor.nodeMonitoring.InTraffic, - "OUT": monitor.nodeMonitoring.OutTraffic, + "CPU": monitor.nodeMonitoring.CPU, + "RAM": monitor.nodeMonitoring.RAM, + "Disk": monitor.nodeMonitoring.Disk, + "Download": monitor.nodeMonitoring.Download, + "Upload": monitor.nodeMonitoring.Upload, }).Debug("Monitoring data") } @@ -656,24 +660,24 @@ func (monitor *ResourceMonitor) getCurrentInstancesData() { } if monitor.trafficMonitoring != nil { - inTraffic, outTraffic, err := monitor.trafficMonitoring.GetInstanceTraffic(instanceID) + download, upload, err := monitor.trafficMonitoring.GetInstanceTraffic(instanceID) if err != nil { log.Errorf("Can't get service traffic: %s", err) } - value.monitoring.InTraffic = inTraffic - value.monitoring.OutTraffic = outTraffic + value.monitoring.Download = download + value.monitoring.Upload = upload } value.averageData.updateMonitoringData(value.monitoring.MonitoringData) log.WithFields(log.Fields{ - "id": instanceID, - "CPU": value.monitoring.CPU, - "RAM": value.monitoring.RAM, - "Disk": value.monitoring.Disk, - "IN": value.monitoring.InTraffic, - "OUT": value.monitoring.OutTraffic, + "id": instanceID, + "CPU": value.monitoring.CPU, + "RAM": value.monitoring.RAM, + "Disk": value.monitoring.Disk, + "Download": value.monitoring.Download, + "Upload": value.monitoring.Upload, }).Debug("Instance monitoring data") } } @@ -775,11 +779,11 @@ func (monitor *ResourceMonitor) cpuToDMIPs(cpu float64) uint64 { func newAverageMonitoring(windowCount uint64, partitions []aostypes.PartitionUsage) *averageMonitoring { averageMonitoring := &averageMonitoring{ - ram: newAverageCalc(windowCount), - cpu: newAverageCalc(windowCount), - inTraffic: newAverageCalc(windowCount), - outTraffic: newAverageCalc(windowCount), - disks: make(map[string]*averageCalc), + ram: newAverageCalc(windowCount), + cpu: newAverageCalc(windowCount), + download: newAverageCalc(windowCount), + upload: newAverageCalc(windowCount), + disks: make(map[string]*averageCalc), } for _, partition := range partitions { @@ -791,12 +795,12 @@ func newAverageMonitoring(windowCount uint64, partitions []aostypes.PartitionUsa func (average *averageMonitoring) toMonitoringData(timestamp time.Time) aostypes.MonitoringData { data := aostypes.MonitoringData{ - CPU: average.cpu.getIntValue(), - RAM: average.ram.getIntValue(), - InTraffic: average.inTraffic.getIntValue(), - OutTraffic: average.outTraffic.getIntValue(), - Disk: make([]aostypes.PartitionUsage, 0, len(average.disks)), - Timestamp: timestamp, + CPU: average.cpu.getIntValue(), + RAM: average.ram.getIntValue(), + Download: average.download.getIntValue(), + Upload: average.upload.getIntValue(), + Disk: make([]aostypes.PartitionUsage, 0, len(average.disks)), + Timestamp: timestamp, } for name, diskUsage := range average.disks { @@ -811,8 +815,8 @@ func (average *averageMonitoring) toMonitoringData(timestamp time.Time) aostypes func (average *averageMonitoring) updateMonitoringData(data aostypes.MonitoringData) { average.cpu.calculate(float64(data.CPU)) average.ram.calculate(float64(data.RAM)) - average.inTraffic.calculate(float64(data.InTraffic)) - average.outTraffic.calculate(float64(data.OutTraffic)) + average.download.calculate(float64(data.Download)) + average.upload.calculate(float64(data.Upload)) for _, disk := range data.Disk { averageCalc, ok := average.disks[disk.Name] diff --git a/vendor/golang.org/x/exp/maps/maps.go b/vendor/golang.org/x/exp/maps/maps.go new file mode 100644 index 00000000..ecc0dabb --- /dev/null +++ b/vendor/golang.org/x/exp/maps/maps.go @@ -0,0 +1,94 @@ +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package maps defines various functions useful with maps of any type. +package maps + +// Keys returns the keys of the map m. +// The keys will be in an indeterminate order. +func Keys[M ~map[K]V, K comparable, V any](m M) []K { + r := make([]K, 0, len(m)) + for k := range m { + r = append(r, k) + } + return r +} + +// Values returns the values of the map m. +// The values will be in an indeterminate order. +func Values[M ~map[K]V, K comparable, V any](m M) []V { + r := make([]V, 0, len(m)) + for _, v := range m { + r = append(r, v) + } + return r +} + +// Equal reports whether two maps contain the same key/value pairs. +// Values are compared using ==. +func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool { + if len(m1) != len(m2) { + return false + } + for k, v1 := range m1 { + if v2, ok := m2[k]; !ok || v1 != v2 { + return false + } + } + return true +} + +// EqualFunc is like Equal, but compares values using eq. +// Keys are still compared with ==. +func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool { + if len(m1) != len(m2) { + return false + } + for k, v1 := range m1 { + if v2, ok := m2[k]; !ok || !eq(v1, v2) { + return false + } + } + return true +} + +// Clear removes all entries from m, leaving it empty. +func Clear[M ~map[K]V, K comparable, V any](m M) { + for k := range m { + delete(m, k) + } +} + +// Clone returns a copy of m. This is a shallow clone: +// the new keys and values are set using ordinary assignment. +func Clone[M ~map[K]V, K comparable, V any](m M) M { + // Preserve nil in case it matters. + if m == nil { + return nil + } + r := make(M, len(m)) + for k, v := range m { + r[k] = v + } + return r +} + +// Copy copies all key/value pairs in src adding them to dst. +// When a key in src is already present in dst, +// the value in dst will be overwritten by the value associated +// with the key in src. +func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) { + for k, v := range src { + dst[k] = v + } +} + +// DeleteFunc deletes any key/value pairs from m for which del returns true. +func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool) { + for k, v := range m { + if del(k, v) { + delete(m, k) + } + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 7879fbae..32b0c0e6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240726122926-1a65185db3cc +# github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013 ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes @@ -180,6 +180,7 @@ golang.org/x/crypto/sha3 # golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 ## explicit; go 1.18 golang.org/x/exp/constraints +golang.org/x/exp/maps golang.org/x/exp/slices # golang.org/x/net v0.23.0 ## explicit; go 1.18 From a931cd8bd2e61c516f04dec2657b42a09cd76256 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 24 Jul 2024 12:37:24 +0300 Subject: [PATCH 099/146] [launcher] Move node handling into private node handler interface Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 658 ++++---------------------------------- launcher/launcher_test.go | 28 +- launcher/nodehandler.go | 361 +++++++++++++++++++++ 3 files changed, 445 insertions(+), 602 deletions(-) create mode 100644 launcher/nodehandler.go diff --git a/launcher/launcher.go b/launcher/launcher.go index 85a541c9..3225969f 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -21,7 +21,6 @@ import ( "context" "encoding/json" "errors" - "reflect" "sort" "sync" "time" @@ -30,13 +29,12 @@ import ( "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" + "golang.org/x/exp/maps" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/imagemanager" "github.com/aosedge/aos_communicationmanager/networkmanager" "github.com/aosedge/aos_communicationmanager/storagestate" - "github.com/aosedge/aos_communicationmanager/unitconfig" "github.com/aosedge/aos_communicationmanager/unitstatushandler" ) @@ -64,16 +62,16 @@ type NodeRunInstanceStatus struct { type Launcher struct { sync.Mutex - config *config.Config - storage Storage - nodeInfoProvider NodeInfoProvider - nodeManager NodeManager - imageProvider ImageProvider - resourceManager ResourceManager - storageStateProvider StorageStateProvider - networkManager NetworkManager + config *config.Config + storage Storage + nodeManager NodeManager + imageProvider ImageProvider + resourceManager ResourceManager + storageStateProvider StorageStateProvider + networkManager NetworkManager + runStatusChannel chan unitstatushandler.RunInstancesStatus - nodes []*nodeStatus + nodes map[string]*nodeHandler currentDesiredInstances []cloudprotocol.InstanceInfo currentRunStatus []cloudprotocol.InstanceStatus currentErrorStatus []cloudprotocol.InstanceStatus @@ -155,29 +153,6 @@ type StorageStateProvider interface { GetInstanceCheckSum(instance aostypes.InstanceIdent) string } -type nodeStatus struct { - nodeInfo cloudprotocol.NodeInfo - availableResources []string - availableLabels []string - availableDevices []nodeDevice - priority uint32 - receivedRunInstances []cloudprotocol.InstanceStatus - currentRunRequest *runRequestInfo - waitStatus bool -} - -type nodeDevice struct { - name string - sharedCount int - allocatedCount int -} - -type runRequestInfo struct { - Services []aostypes.ServiceInfo `json:"services"` - Layers []aostypes.LayerInfo `json:"layers"` - Instances []aostypes.InstanceInfo `json:"instances"` -} - /*********************************************************************************************************************** * Public **********************************************************************************************************************/ @@ -191,11 +166,10 @@ func New( log.Debug("Create launcher") launcher = &Launcher{ - config: config, storage: storage, nodeManager: nodeManager, nodeInfoProvider: nodeInfoProvider, - imageProvider: imageProvider, resourceManager: resourceManager, storageStateProvider: storageStateProvider, - networkManager: networkManager, + config: config, storage: storage, nodeManager: nodeManager, imageProvider: imageProvider, + resourceManager: resourceManager, storageStateProvider: storageStateProvider, networkManager: networkManager, runStatusChannel: make(chan unitstatushandler.RunInstancesStatus, 10), - nodes: []*nodeStatus{}, + nodes: make(map[string]*nodeHandler), } if launcher.instanceManager, err = newInstanceManager(config, storage, storageStateProvider, @@ -211,6 +185,36 @@ func New( } } + nodes, err := nodeInfoProvider.GetAllNodeIDs() + if err != nil { + return nil, aoserrors.Wrap(err) + } + + for _, nodeID := range nodes { + nodeInfo, err := nodeInfoProvider.GetNodeInfo(nodeID) + if err != nil { + log.WithField("nodeID", nodeID).Errorf("Can't get node info: %v", err) + + continue + } + + if nodeInfo.Status == cloudprotocol.NodeStatusProvisioned { + log.WithField("nodeID", nodeID).Debug("Skip not provisioned node") + + continue + } + + nodeHandler, err := newNodeHandler( + nodeInfo, resourceManager, storage, nodeInfo.NodeID == nodeInfoProvider.GetNodeID()) + if err != nil { + log.WithField("nodeID", nodeID).Errorf("Can't create node handler: %v", err) + + continue + } + + launcher.nodes[nodeID] = nodeHandler + } + ctx, cancelFunction := context.WithCancel(context.Background()) launcher.cancelFunc = cancelFunction @@ -288,10 +292,10 @@ func (launcher *Launcher) processChannels(ctx context.Context) { } func (launcher *Launcher) sendRunInstances(forceRestart bool) (err error) { - for _, node := range launcher.nodes { + for _, node := range launcher.getNodesByPriorities() { node.waitStatus = true - if err := launcher.saveNodeRunRequest(node); err != nil { + if err := node.saveNodeRunRequest(); err != nil { log.WithFields(log.Fields{"nodeID": node.nodeInfo.NodeID}).Errorf("Can't save node run request: %v", err) } @@ -315,52 +319,16 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat log.Debugf("Received run status from nodeID: %s", runStatus.NodeID) - allNodeIDs, err := launcher.nodeInfoProvider.GetAllNodeIDs() - if err != nil { - log.Errorf("Can't get all nodeIDs: %v", err) - - return - } - currentStatus := launcher.getNode(runStatus.NodeID) if currentStatus == nil { - if !slices.Contains(allNodeIDs, runStatus.NodeID) { - log.Errorf("Received status for unknown nodeID %s", runStatus.NodeID) - - return - } - - var err error - - currentStatus, err = launcher.initNodeStatus(runStatus.NodeID) - if err != nil { - log.Errorf("Can't init node: %v", err) - - return - } - - launcher.nodes = append(launcher.nodes, currentStatus) + log.Errorf("Received status for unknown nodeID %s", runStatus.NodeID) - if len(launcher.nodes) == len(allNodeIDs) { - log.Debug("All clients connected") - } - - slices.SortFunc(launcher.nodes, func(a, b *nodeStatus) bool { - if a.priority == b.priority { - return a.nodeInfo.NodeID < b.nodeInfo.NodeID - } - - return a.priority > b.priority - }) + return } currentStatus.receivedRunInstances = runStatus.Instances currentStatus.waitStatus = false - if len(launcher.nodes) != len(allNodeIDs) { - return - } - for _, node := range launcher.nodes { if node.waitStatus { return @@ -374,64 +342,6 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat launcher.sendCurrentStatus() } -func (launcher *Launcher) initNodeStatus(nodeID string) (*nodeStatus, error) { - status := &nodeStatus{currentRunRequest: &runRequestInfo{}} - - log.WithFields(log.Fields{"nodeID": nodeID}).Debug("Init node status") - - nodeInfo, err := launcher.nodeInfoProvider.GetNodeInfo(nodeID) - if err != nil { - return nil, aoserrors.Errorf("can't get node configuration fot nodeID %s: %v", nodeID, err) - } - - status.nodeInfo = nodeInfo - - if err := launcher.loadNodeRunRequest(status); err != nil && !errors.Is(err, ErrNotExist) { - log.WithFields(log.Fields{"nodeID": nodeID}).Errorf("Can't load node run request") - } - - err = launcher.initNodeConfig(status) - - return status, err -} - -func (launcher *Launcher) initNodeConfig(nodeStatus *nodeStatus) error { - nodeUnitConfig, err := launcher.resourceManager.GetNodeConfig(nodeStatus.nodeInfo.NodeID, nodeStatus.nodeInfo.NodeType) - if err != nil && !errors.Is(err, unitconfig.ErrNotFound) { - return aoserrors.Wrap(err) - } - - nodeStatus.priority = nodeUnitConfig.Priority - nodeStatus.availableLabels = nodeUnitConfig.Labels - nodeStatus.availableResources = make([]string, len(nodeUnitConfig.Resources)) - nodeStatus.availableDevices = make([]nodeDevice, len(nodeUnitConfig.Devices)) - - for i, resource := range nodeUnitConfig.Resources { - nodeStatus.availableResources[i] = resource.Name - } - - for i, device := range nodeUnitConfig.Devices { - nodeStatus.availableDevices[i] = nodeDevice{ - name: device.Name, sharedCount: device.SharedCount, allocatedCount: 0, - } - } - - for _, instance := range nodeStatus.currentRunRequest.Instances { - serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) - if err != nil { - log.WithFields(log.Fields{"serviceID": instance.ServiceID}).Errorf("Can't get service info: %v", err) - continue - } - - if err = launcher.allocateDevices(nodeStatus, serviceInfo.Config.Devices); err != nil { - log.WithFields( - instanceIdentLogFields(instance.InstanceIdent, nil)).Errorf("Can't allocate devices: %v", err) - } - } - - return nil -} - func (launcher *Launcher) resetDeviceAllocation() { for _, node := range launcher.nodes { for i := range node.availableDevices { @@ -445,7 +355,7 @@ func (launcher *Launcher) sendCurrentStatus() { UnitSubjects: []string{}, Instances: []cloudprotocol.InstanceStatus{}, } - for _, node := range launcher.nodes { + for _, node := range launcher.getNodesByPriorities() { if node.waitStatus { node.waitStatus = false @@ -565,7 +475,7 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) return nil } -//nolint:funlen +//nolint:funlen,gocognit func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo, ) (errStatus []cloudprotocol.InstanceStatus) { for _, node := range launcher.nodes { @@ -618,7 +528,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc continue } - nodes, err := launcher.getNodesByStaticResources(launcher.nodes, serviceInfo, instance) + nodes, err := getNodesByStaticResources(launcher.getNodesByPriorities(), serviceInfo, instance) if err != nil { for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, @@ -631,7 +541,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc // createInstanceStatusFromInfo for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - nodeForInstance, err := launcher.getNodesByDevices(nodes, serviceInfo.Config.Devices) + nodeForInstance, err := getNodesByDevices(nodes, serviceInfo.Config.Devices) if err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) @@ -645,16 +555,16 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } - node := launcher.getMostPriorityNode(nodeForInstance) + node := getMostPriorityNode(nodeForInstance) - if err = launcher.allocateDevices(node, serviceInfo.Config.Devices); err != nil { + if err = node.allocateDevices(serviceInfo.Config.Devices); err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) continue } - launcher.addRunRequest(instanceInfo, serviceInfo, layers, node) + node.addRunRequest(instanceInfo, serviceInfo, layers) } } @@ -670,7 +580,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc } func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (errStatus []cloudprotocol.InstanceStatus) { - for _, node := range launcher.nodes { + for _, node := range launcher.getNodesByPriorities() { for i, instance := range node.currentRunRequest.Instances { serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) if err != nil { @@ -686,7 +596,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (err if instance.NetworkParameters, err = launcher.networkManager.PrepareInstanceNetworkParameters( instance.InstanceIdent, serviceInfo.ProviderID, - prepareNetworkParameters(instance, serviceInfo)); err != nil { + prepareNetworkParameters(serviceInfo)); err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, instance.Instance, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } @@ -698,9 +608,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (err return errStatus } -func prepareNetworkParameters( - instance aostypes.InstanceInfo, serviceInfo imagemanager.ServiceInfo, -) networkmanager.NetworkParameters { +func prepareNetworkParameters(serviceInfo imagemanager.ServiceInfo) networkmanager.NetworkParameters { var hosts []string if serviceInfo.Config.Hostname != nil { hosts = append(hosts, *serviceInfo.Config.Hostname) @@ -840,397 +748,20 @@ func (launcher *Launcher) prepareInstanceStartInfo(service imagemanager.ServiceI return instanceInfo, nil } -func (launcher *Launcher) getNodesByStaticResources(allNodes []*nodeStatus, - serviceInfo imagemanager.ServiceInfo, instanceInfo cloudprotocol.InstanceInfo, -) ([]*nodeStatus, error) { - nodes := launcher.getNodeByRunners(allNodes, serviceInfo.Config.Runners) - if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with runner: %s", serviceInfo.Config.Runners) - } - - nodes = launcher.getNodesByLabels(nodes, instanceInfo.Labels) - if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with labels %v", instanceInfo.Labels) - } - - nodes = launcher.getNodesByResources(nodes, serviceInfo.Config.Resources) - if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with resources %v", serviceInfo.Config.Resources) - } - - return nodes, nil -} - -func (launcher *Launcher) getNodesByDevices( - availableNodes []*nodeStatus, desiredDevices []aostypes.ServiceDevice, -) ([]*nodeStatus, error) { - if len(desiredDevices) == 0 { - return slices.Clone(availableNodes), nil - } - - nodes := make([]*nodeStatus, 0) - - for _, node := range availableNodes { - if !launcher.nodeHasDesiredDevices(node, desiredDevices) { - continue - } - - nodes = append(nodes, node) - } - - if len(nodes) == 0 { - return nodes, aoserrors.New("no available device found") - } - - return nodes, nil -} - -//nolint:unused -func (launcher *Launcher) getNodeByMonitoringData(nodes []*nodeStatus, alertType string) (newNodes []*nodeStatus) { - if len(nodes) == 1 { - return nodes - } +func (launcher *Launcher) getNodesByPriorities() []*nodeHandler { + nodes := maps.Values(launcher.nodes) - type freeNodeResources struct { - node *nodeStatus - freeRAM uint64 - freeCPU uint64 - } - - nodesResources := []freeNodeResources{} - - for _, node := range nodes { - monitoringData, err := launcher.nodeManager.GetAverageMonitoring(node.nodeInfo.NodeID) - if err != nil { - log.Errorf("Can't get node monitoring data: %v", err) + sort.Slice(nodes, func(i, j int) bool { + if nodes[i].priority == nodes[j].priority { + return nodes[i].nodeInfo.NodeID < nodes[j].nodeInfo.NodeID } - nodesResources = append(nodesResources, freeNodeResources{ - node: node, - freeRAM: node.nodeInfo.TotalRAM - monitoringData.NodeData.RAM, - freeCPU: uint64(len(node.nodeInfo.CPUs)*100) - monitoringData.NodeData.CPU, - }) - } - - if alertType == "cpu" { - slices.SortFunc(nodesResources, func(a, b freeNodeResources) bool { - return a.freeCPU > b.freeCPU - }) - } else { - slices.SortFunc(nodesResources, func(a, b freeNodeResources) bool { - return a.freeRAM > b.freeRAM - }) - } - - for _, sortedResources := range nodesResources { - newNodes = append(newNodes, sortedResources.node) - } - - return newNodes -} - -func (launcher *Launcher) nodeHasDesiredDevices(node *nodeStatus, desiredDevices []aostypes.ServiceDevice) bool { -devicesLoop: - for _, desiredDevice := range desiredDevices { - for _, nodeDevice := range node.availableDevices { - if desiredDevice.Name != nodeDevice.name { - continue - } - - if nodeDevice.sharedCount == 0 || nodeDevice.allocatedCount != nodeDevice.sharedCount { - continue devicesLoop - } - } - - return false - } - - return true -} - -func (launcher *Launcher) allocateDevices(node *nodeStatus, serviceDevices []aostypes.ServiceDevice) error { -serviceDeviceLoop: - for _, serviceDevice := range serviceDevices { - for i := range node.availableDevices { - if node.availableDevices[i].name != serviceDevice.Name { - continue - } - - if node.availableDevices[i].sharedCount != 0 { - if node.availableDevices[i].allocatedCount == node.availableDevices[i].sharedCount { - return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) - } - - node.availableDevices[i].allocatedCount++ - - continue serviceDeviceLoop - } - } - - return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) - } - - return nil -} - -//nolint:unused -func (launcher *Launcher) releaseDevices(node *nodeStatus, serviceDevices []aostypes.ServiceDevice) error { -serviceDeviceLoop: - for _, serviceDevice := range serviceDevices { - for i := range node.availableDevices { - if node.availableDevices[i].name != serviceDevice.Name { - continue - } - - if node.availableDevices[i].sharedCount != 0 { - if node.availableDevices[i].allocatedCount == 0 { - return aoserrors.Errorf("can't release device: %s", serviceDevice.Name) - } - - node.availableDevices[i].allocatedCount-- - - continue serviceDeviceLoop - } - } - - return aoserrors.Errorf("can't release device: %s", serviceDevice.Name) - } - - return nil -} - -func (launcher *Launcher) getNodesByResources(nodes []*nodeStatus, desiredResources []string) (newNodes []*nodeStatus) { - if len(desiredResources) == 0 { - return nodes - } - -nodeLoop: - for _, node := range nodes { - if len(node.availableResources) == 0 { - continue - } - - for _, resource := range desiredResources { - if !slices.Contains(node.availableResources, resource) { - continue nodeLoop - } - } - - newNodes = append(newNodes, node) - } - - return newNodes -} - -func (launcher *Launcher) getNodesByLabels(nodes []*nodeStatus, desiredLabels []string) (newNodes []*nodeStatus) { - if len(desiredLabels) == 0 { - return nodes - } - -nodeLoop: - for _, node := range nodes { - if len(node.availableLabels) == 0 { - continue - } - - for _, label := range desiredLabels { - if !slices.Contains(node.availableLabels, label) { - continue nodeLoop - } - } - - newNodes = append(newNodes, node) - } - - return newNodes -} - -func (launcher *Launcher) getNodeByRunners(allNodes []*nodeStatus, runners []string) (nodes []*nodeStatus) { - if len(runners) == 0 { - runners = defaultRunners - } - - for _, runner := range runners { - for _, node := range allNodes { - nodeRunners, err := node.nodeInfo.GetNodeRunners() - if err != nil { - log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't get node runners: %v", err) - - continue - } - - if (len(nodeRunners) == 0 && slices.Contains(defaultRunners, runner)) || - slices.Contains(nodeRunners, runner) { - nodes = append(nodes, node) - } - } - } + return nodes[i].priority > nodes[j].priority + }) return nodes } -func (launcher *Launcher) getMostPriorityNode(nodes []*nodeStatus) *nodeStatus { - if len(nodes) == 1 { - return nodes[0] - } - - maxNodePriorityIndex := 0 - - for i := 1; i < len(nodes); i++ { - if nodes[maxNodePriorityIndex].priority < nodes[i].priority { - maxNodePriorityIndex = i - } - } - - return nodes[maxNodePriorityIndex] -} - -func (launcher *Launcher) addRunRequest(instance aostypes.InstanceInfo, service imagemanager.ServiceInfo, - layers []imagemanager.LayerInfo, node *nodeStatus, -) { - log.WithFields(instanceIdentLogFields( - instance.InstanceIdent, log.Fields{"node": node.nodeInfo.NodeID})).Debug("Schedule instance on node") - - node.currentRunRequest.Instances = append(node.currentRunRequest.Instances, instance) - - serviceInfo := service.ServiceInfo - - if node.nodeInfo.NodeID != launcher.nodeInfoProvider.GetNodeID() { - serviceInfo.URL = service.RemoteURL - } - - isNewService := true - - for _, oldService := range node.currentRunRequest.Services { - if reflect.DeepEqual(oldService, serviceInfo) { - isNewService = false - break - } - } - - if isNewService { - log.WithFields(log.Fields{ - "serviceID": serviceInfo.ServiceID, "node": node.nodeInfo.NodeID, - }).Debug("Schedule service on node") - - node.currentRunRequest.Services = append(node.currentRunRequest.Services, serviceInfo) - } - -layerLoopLabel: - for _, layer := range layers { - newLayer := layer.LayerInfo - - if node.nodeInfo.NodeID != launcher.nodeInfoProvider.GetNodeID() { - newLayer.URL = layer.RemoteURL - } - - for _, oldLayer := range node.currentRunRequest.Layers { - if reflect.DeepEqual(newLayer, oldLayer) { - continue layerLoopLabel - } - } - - log.WithFields(log.Fields{ - "digest": newLayer.Digest, "node": node.nodeInfo.NodeID, - }).Debug("Schedule layer on node") - - node.currentRunRequest.Layers = append(node.currentRunRequest.Layers, newLayer) - } -} - -//nolint:unused -func (launcher *Launcher) removeInstanceFromNode(ident aostypes.InstanceIdent, node *nodeStatus) { - log.WithFields(log.Fields{"ident": ident, "node": node.nodeInfo.NodeID}).Debug("Remove instance from node") - - i := 0 - - for _, instance := range node.currentRunRequest.Instances { - if instance.InstanceIdent != ident { - node.currentRunRequest.Instances[i] = instance - i++ - } - } - - node.currentRunRequest.Instances = node.currentRunRequest.Instances[:i] -} - -//nolint:unused -func (launcher *Launcher) removeServiceFromNode(serviceID string, node *nodeStatus) { - log.WithFields(log.Fields{"serviceID": serviceID, "node": node.nodeInfo.NodeID}).Debug("Remove service from node") - - i := 0 - - for _, service := range node.currentRunRequest.Services { - if service.ServiceID != serviceID { - node.currentRunRequest.Services[i] = service - i++ - } - } - - node.currentRunRequest.Services = node.currentRunRequest.Services[:i] -} - -//nolint:unused -func (launcher *Launcher) removeLayerFromNode(digest string, node *nodeStatus) { - log.WithFields(log.Fields{"digest": digest, "node": node.nodeInfo.NodeID}).Debug("Remove layer from node") - - i := 0 - - for _, layer := range node.currentRunRequest.Layers { - if layer.Digest != digest { - node.currentRunRequest.Layers[i] = layer - i++ - } - } - - node.currentRunRequest.Layers = node.currentRunRequest.Layers[:i] -} - -//nolint:unused -func (launcher *Launcher) removeRunRequest(instance aostypes.InstanceInfo, node *nodeStatus) { - launcher.removeInstanceFromNode(instance.InstanceIdent, node) - - // check if we need to remove service - removeService := true - - for _, currentInstance := range node.currentRunRequest.Instances { - if currentInstance.ServiceID == instance.ServiceID { - removeService = false - } - } - - if removeService { - launcher.removeServiceFromNode(instance.ServiceID, node) - - currentServiceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) - if err != nil { - log.Errorf("Can't get service info: %v", err) - - return - } - - layerLoop: - for _, currentDigest := range currentServiceInfo.Layers { - for _, service := range node.currentRunRequest.Services { - serviceInfo, err := launcher.imageProvider.GetServiceInfo(service.ServiceID) - if err != nil { - log.Errorf("Can't get service info: %v", err) - - continue layerLoop - } - - for _, digest := range serviceInfo.Layers { - if currentDigest == digest { - continue layerLoop - } - } - } - - launcher.removeLayerFromNode(currentDigest, node) - } - } -} - func createInstanceStatusFromInfo( serviceID, subjectID string, instanceIndex uint64, serviceVersion string, status, errorMsg string, ) cloudprotocol.InstanceStatus { @@ -1251,38 +782,13 @@ func createInstanceStatusFromInfo( return instanceStatus } -func (launcher *Launcher) getNode(nodeID string) *nodeStatus { - for _, node := range launcher.nodes { - if node.nodeInfo.NodeID == nodeID { - return node - } +func (launcher *Launcher) getNode(nodeID string) *nodeHandler { + node, ok := launcher.nodes[nodeID] + if !ok { + return nil } - return nil -} - -//nolint:unused -func (launcher *Launcher) getLowerPriorityNodes(node *nodeStatus) (nodes []*nodeStatus) { - for _, currentNode := range launcher.nodes { - if currentNode.priority > node.priority || currentNode.nodeInfo.NodeID == node.nodeInfo.NodeID { - continue - } - - nodes = append(nodes, currentNode) - } - - return nodes -} - -//nolint:unused -func (launcher *Launcher) getLabelsForInstance(ident aostypes.InstanceIdent) ([]string, error) { - for _, instance := range launcher.currentDesiredInstances { - if instance.ServiceID == ident.ServiceID && instance.SubjectID == ident.SubjectID { - return instance.Labels, nil - } - } - - return nil, aoserrors.New("no labels for instance") + return node } func (launcher *Launcher) getLayersForService(digests []string) ([]imagemanager.LayerInfo, error) { @@ -1300,32 +806,6 @@ func (launcher *Launcher) getLayersForService(digests []string) ([]imagemanager. return layers, nil } -func (launcher *Launcher) loadNodeRunRequest(node *nodeStatus) error { - currentRunRequestJSON, err := launcher.storage.GetNodeState(node.nodeInfo.NodeID) - if err != nil { - return aoserrors.Wrap(err) - } - - if err = json.Unmarshal(currentRunRequestJSON, &node.currentRunRequest); err != nil { - return aoserrors.Wrap(err) - } - - return nil -} - -func (launcher *Launcher) saveNodeRunRequest(node *nodeStatus) error { - runRequestJSON, err := json.Marshal(node.currentRunRequest) - if err != nil { - return aoserrors.Wrap(err) - } - - if err := launcher.storage.SetNodeState(node.nodeInfo.NodeID, runRequestJSON); err != nil { - log.Errorf("Can't store desired instances: %v", err) - } - - return nil -} - func instanceIdentLogFields(instance aostypes.InstanceIdent, extraFields log.Fields) log.Fields { logFields := log.Fields{ "serviceID": instance.ServiceID, diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 8ed8fc97..23b153d0 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -345,6 +345,21 @@ func TestInitialStatus(t *testing.T) { imageManager = &testImageProvider{} ) + for _, id := range nodeIDs { + nodeInfo := cloudprotocol.NodeInfo{ + NodeID: id, NodeType: "nodeType", + TotalRAM: 100, + CPUs: []cloudprotocol.CPUInfo{ + {ModelName: "Intel(R) Core(TM) i7-1185G7"}, + }, + Partitions: []cloudprotocol.PartitionInfo{ + {Name: "id", TotalSize: 200}, + }, + } + + nodeInfoProvider.nodeInfo[id] = nodeInfo + } + launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, &testResourceManager{}, &testStateStorage{}, newTestNetworkManager("")) if err != nil { @@ -359,19 +374,6 @@ func TestInitialStatus(t *testing.T) { NodeID: id, }} - nodeInfo := cloudprotocol.NodeInfo{ - NodeID: id, NodeType: "nodeType", - TotalRAM: 100, - CPUs: []cloudprotocol.CPUInfo{ - {ModelName: "Intel(R) Core(TM) i7-1185G7"}, - }, - Partitions: []cloudprotocol.PartitionInfo{ - {Name: "id", TotalSize: 200}, - }, - } - - nodeInfoProvider.nodeInfo[id] = nodeInfo - expectedRunStatus.Instances = append(expectedRunStatus.Instances, instances...) nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{NodeID: id, Instances: instances} diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go new file mode 100644 index 00000000..aacefdce --- /dev/null +++ b/launcher/nodehandler.go @@ -0,0 +1,361 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright (C) 2022 Renesas Electronics Corporation. +// Copyright (C) 2022 EPAM Systems, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package launcher + +import ( + "encoding/json" + "errors" + "reflect" + "slices" + + "github.com/aosedge/aos_common/aoserrors" + "github.com/aosedge/aos_common/aostypes" + "github.com/aosedge/aos_common/api/cloudprotocol" + "github.com/aosedge/aos_communicationmanager/imagemanager" + "github.com/aosedge/aos_communicationmanager/unitconfig" + log "github.com/sirupsen/logrus" +) + +/*********************************************************************************************************************** + * Types + **********************************************************************************************************************/ + +type nodeDevice struct { + name string + sharedCount int + allocatedCount int +} + +type runRequestInfo struct { + Services []aostypes.ServiceInfo `json:"services"` + Layers []aostypes.LayerInfo `json:"layers"` + Instances []aostypes.InstanceInfo `json:"instances"` +} + +type nodeHandler struct { + storage Storage + nodeInfo cloudprotocol.NodeInfo + availableResources []string + availableLabels []string + availableDevices []nodeDevice + priority uint32 + receivedRunInstances []cloudprotocol.InstanceStatus + currentRunRequest *runRequestInfo + isLocalNode bool + waitStatus bool +} + +/*********************************************************************************************************************** + * Private + **********************************************************************************************************************/ + +func newNodeHandler( + nodeInfo cloudprotocol.NodeInfo, resourceManager ResourceManager, storage Storage, isLocalNode bool, +) (*nodeHandler, error) { + log.WithFields(log.Fields{"nodeID": nodeInfo.NodeID}).Debug("Init node handler") + + node := &nodeHandler{ + storage: storage, + nodeInfo: nodeInfo, + currentRunRequest: &runRequestInfo{}, + isLocalNode: isLocalNode, + waitStatus: true, + } + + if err := node.loadNodeRunRequest(); err != nil && !errors.Is(err, ErrNotExist) { + log.WithFields(log.Fields{"nodeID": nodeInfo.NodeID}).Errorf("Can't load node run request: %v", err) + } + + nodeConfig, err := resourceManager.GetNodeConfig(node.nodeInfo.NodeID, node.nodeInfo.NodeType) + if err != nil && !errors.Is(err, unitconfig.ErrNotFound) { + return nil, aoserrors.Wrap(err) + } + + node.initNodeConfig(nodeConfig) + + return node, nil +} + +func (node *nodeHandler) initNodeConfig(nodeConfig cloudprotocol.NodeConfig) { + node.priority = nodeConfig.Priority + node.availableLabels = nodeConfig.Labels + node.availableResources = make([]string, len(nodeConfig.Resources)) + node.availableDevices = make([]nodeDevice, len(nodeConfig.Devices)) + + for i, resource := range nodeConfig.Resources { + node.availableResources[i] = resource.Name + } + + for i, device := range nodeConfig.Devices { + node.availableDevices[i] = nodeDevice{ + name: device.Name, sharedCount: device.SharedCount, allocatedCount: 0, + } + } +} + +func (node *nodeHandler) loadNodeRunRequest() error { + currentRunRequestJSON, err := node.storage.GetNodeState(node.nodeInfo.NodeID) + if err != nil { + return aoserrors.Wrap(err) + } + + if err = json.Unmarshal(currentRunRequestJSON, &node.currentRunRequest); err != nil { + return aoserrors.Wrap(err) + } + + return nil +} + +func (node *nodeHandler) saveNodeRunRequest() error { + runRequestJSON, err := json.Marshal(node.currentRunRequest) + if err != nil { + return aoserrors.Wrap(err) + } + + if err := node.storage.SetNodeState(node.nodeInfo.NodeID, runRequestJSON); err != nil { + return aoserrors.Wrap(err) + } + + return nil +} + +func (node *nodeHandler) allocateDevices(serviceDevices []aostypes.ServiceDevice) error { +serviceDeviceLoop: + for _, serviceDevice := range serviceDevices { + for i := range node.availableDevices { + if node.availableDevices[i].name != serviceDevice.Name { + continue + } + + if node.availableDevices[i].sharedCount != 0 { + if node.availableDevices[i].allocatedCount == node.availableDevices[i].sharedCount { + return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) + } + + node.availableDevices[i].allocatedCount++ + + continue serviceDeviceLoop + } + } + + return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) + } + + return nil +} + +func (node *nodeHandler) nodeHasDesiredDevices(desiredDevices []aostypes.ServiceDevice) bool { +devicesLoop: + for _, desiredDevice := range desiredDevices { + for _, nodeDevice := range node.availableDevices { + if desiredDevice.Name != nodeDevice.name { + continue + } + + if nodeDevice.sharedCount == 0 || nodeDevice.allocatedCount != nodeDevice.sharedCount { + continue devicesLoop + } + } + + return false + } + + return true +} + +func (node *nodeHandler) addRunRequest( + instance aostypes.InstanceInfo, service imagemanager.ServiceInfo, layers []imagemanager.LayerInfo, +) { + log.WithFields(instanceIdentLogFields( + instance.InstanceIdent, log.Fields{"node": node.nodeInfo.NodeID})).Debug("Schedule instance on node") + + node.currentRunRequest.Instances = append(node.currentRunRequest.Instances, instance) + + serviceInfo := service.ServiceInfo + + if !node.isLocalNode { + serviceInfo.URL = service.RemoteURL + } + + isNewService := true + + for _, oldService := range node.currentRunRequest.Services { + if reflect.DeepEqual(oldService, serviceInfo) { + isNewService = false + break + } + } + + if isNewService { + log.WithFields(log.Fields{ + "serviceID": serviceInfo.ServiceID, "node": node.nodeInfo.NodeID, + }).Debug("Schedule service on node") + + node.currentRunRequest.Services = append(node.currentRunRequest.Services, serviceInfo) + } + +layerLoopLabel: + for _, layer := range layers { + newLayer := layer.LayerInfo + + if !node.isLocalNode { + newLayer.URL = layer.RemoteURL + } + + for _, oldLayer := range node.currentRunRequest.Layers { + if reflect.DeepEqual(newLayer, oldLayer) { + continue layerLoopLabel + } + } + + log.WithFields(log.Fields{ + "digest": newLayer.Digest, "node": node.nodeInfo.NodeID, + }).Debug("Schedule layer on node") + + node.currentRunRequest.Layers = append(node.currentRunRequest.Layers, newLayer) + } +} + +func getNodesByStaticResources(allNodes []*nodeHandler, + serviceInfo imagemanager.ServiceInfo, instanceInfo cloudprotocol.InstanceInfo, +) ([]*nodeHandler, error) { + nodes := getNodeByRunners(allNodes, serviceInfo.Config.Runners) + if len(nodes) == 0 { + return nodes, aoserrors.Errorf("no node with runner: %s", serviceInfo.Config.Runners) + } + + nodes = getNodesByLabels(nodes, instanceInfo.Labels) + if len(nodes) == 0 { + return nodes, aoserrors.Errorf("no node with labels %v", instanceInfo.Labels) + } + + nodes = getNodesByResources(nodes, serviceInfo.Config.Resources) + if len(nodes) == 0 { + return nodes, aoserrors.Errorf("no node with resources %v", serviceInfo.Config.Resources) + } + + return nodes, nil +} + +func getNodesByDevices(availableNodes []*nodeHandler, desiredDevices []aostypes.ServiceDevice) ([]*nodeHandler, error) { + if len(desiredDevices) == 0 { + return slices.Clone(availableNodes), nil + } + + nodes := make([]*nodeHandler, 0) + + for _, node := range availableNodes { + if !node.nodeHasDesiredDevices(desiredDevices) { + continue + } + + nodes = append(nodes, node) + } + + if len(nodes) == 0 { + return nodes, aoserrors.New("no available device found") + } + + return nodes, nil +} + +func getNodesByResources(nodes []*nodeHandler, desiredResources []string) (newNodes []*nodeHandler) { + if len(desiredResources) == 0 { + return nodes + } + +nodeLoop: + for _, node := range nodes { + if len(node.availableResources) == 0 { + continue + } + + for _, resource := range desiredResources { + if !slices.Contains(node.availableResources, resource) { + continue nodeLoop + } + } + + newNodes = append(newNodes, node) + } + + return newNodes +} + +func getNodesByLabels(nodes []*nodeHandler, desiredLabels []string) (newNodes []*nodeHandler) { + if len(desiredLabels) == 0 { + return nodes + } + +nodeLoop: + for _, node := range nodes { + if len(node.availableLabels) == 0 { + continue + } + + for _, label := range desiredLabels { + if !slices.Contains(node.availableLabels, label) { + continue nodeLoop + } + } + + newNodes = append(newNodes, node) + } + + return newNodes +} + +func getNodeByRunners(allNodes []*nodeHandler, runners []string) (nodes []*nodeHandler) { + if len(runners) == 0 { + runners = defaultRunners + } + + for _, runner := range runners { + for _, node := range allNodes { + nodeRunners, err := node.nodeInfo.GetNodeRunners() + if err != nil { + log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't get node runners: %v", err) + + continue + } + + if (len(nodeRunners) == 0 && slices.Contains(defaultRunners, runner)) || + slices.Contains(nodeRunners, runner) { + nodes = append(nodes, node) + } + } + } + + return nodes +} + +func getMostPriorityNode(nodes []*nodeHandler) *nodeHandler { + if len(nodes) == 1 { + return nodes[0] + } + + maxNodePriorityIndex := 0 + + for i := 1; i < len(nodes); i++ { + if nodes[maxNodePriorityIndex].priority < nodes[i].priority { + maxNodePriorityIndex = i + } + } + + return nodes[maxNodePriorityIndex] +} From ebd7da013d49f68e91091daa9c8046fe4d86ccfc Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 24 Jul 2024 12:53:06 +0300 Subject: [PATCH 100/146] [launcher] Remove unneeded for new balancing storage interfaces Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 45 +++++------------------ launcher/launcher_test.go | 77 ++++++++++++--------------------------- launcher/nodehandler.go | 35 +----------------- 3 files changed, 34 insertions(+), 123 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 3225969f..9e019447 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -19,7 +19,6 @@ package launcher import ( "context" - "encoding/json" "errors" "sort" "sync" @@ -70,12 +69,11 @@ type Launcher struct { storageStateProvider StorageStateProvider networkManager NetworkManager - runStatusChannel chan unitstatushandler.RunInstancesStatus - nodes map[string]*nodeHandler - currentDesiredInstances []cloudprotocol.InstanceInfo - currentRunStatus []cloudprotocol.InstanceStatus - currentErrorStatus []cloudprotocol.InstanceStatus - pendingNewServices []string + runStatusChannel chan unitstatushandler.RunInstancesStatus + nodes map[string]*nodeHandler + currentRunStatus []cloudprotocol.InstanceStatus + currentErrorStatus []cloudprotocol.InstanceStatus + pendingNewServices []string cancelFunc context.CancelFunc connectionTimer *time.Timer @@ -98,10 +96,6 @@ type Storage interface { GetInstanceUID(instance aostypes.InstanceIdent) (int, error) GetInstances() ([]InstanceInfo, error) GetServiceInfo(serviceID string) (imagemanager.ServiceInfo, error) - GetDesiredInstances() (json.RawMessage, error) - SetDesiredInstances(instances json.RawMessage) error - SetNodeState(nodeID string, state json.RawMessage) error - GetNodeState(nodeID string) (json.RawMessage, error) } // NetworkManager network manager interface. @@ -177,14 +171,6 @@ func New( return nil, aoserrors.Wrap(err) } - if rawDesiredInstances, err := launcher.storage.GetDesiredInstances(); err != nil { - log.Errorf("Can't get desired instances: %v", err) - } else { - if err = json.Unmarshal(rawDesiredInstances, &launcher.currentDesiredInstances); err != nil { - log.Debugf("Can't parse desire instances: %v", err) - } - } - nodes, err := nodeInfoProvider.GetAllNodeIDs() if err != nil { return nil, aoserrors.Wrap(err) @@ -205,7 +191,7 @@ func New( } nodeHandler, err := newNodeHandler( - nodeInfo, resourceManager, storage, nodeInfo.NodeID == nodeInfoProvider.GetNodeID()) + nodeInfo, resourceManager, nodeInfo.NodeID == nodeInfoProvider.GetNodeID()) if err != nil { log.WithField("nodeID", nodeID).Errorf("Can't create node handler: %v", err) @@ -247,19 +233,10 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, n launcher.connectionTimer = time.AfterFunc( launcher.config.SMController.NodesConnectionTimeout.Duration, launcher.sendCurrentStatus) - if rawDesiredInstances, err := json.Marshal(instances); err != nil { - log.Errorf("Can't marshall desired instances: %v", err) - } else { - if err := launcher.storage.SetDesiredInstances(rawDesiredInstances); err != nil { - log.Errorf("Can't store desired instances: %v", err) - } - } - if err := launcher.updateNetworks(instances); err != nil { log.Errorf("Can't update networks: %v", err) } - launcher.currentDesiredInstances = instances launcher.pendingNewServices = newServices launcher.currentErrorStatus = launcher.performNodeBalancing(instances) @@ -295,10 +272,6 @@ func (launcher *Launcher) sendRunInstances(forceRestart bool) (err error) { for _, node := range launcher.getNodesByPriorities() { node.waitStatus = true - if err := node.saveNodeRunRequest(); err != nil { - log.WithFields(log.Fields{"nodeID": node.nodeInfo.NodeID}).Errorf("Can't save node run request: %v", err) - } - if runErr := launcher.nodeManager.RunInstances( node.nodeInfo.NodeID, node.currentRunRequest.Services, node.currentRunRequest.Layers, node.currentRunRequest.Instances, forceRestart); runErr != nil { @@ -505,14 +478,16 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", + errStatus = append(errStatus, createInstanceStatusFromInfo( + instance.ServiceID, instance.SubjectID, 0, "0.0.0", cloudprotocol.InstanceStateFailed, err.Error())) continue } if serviceInfo.Cached { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", + errStatus = append(errStatus, createInstanceStatusFromInfo( + instance.ServiceID, instance.SubjectID, 0, "0.0.0", cloudprotocol.InstanceStateFailed, "service deleted")) continue diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 23b153d0..156a795a 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -18,7 +18,6 @@ package launcher_test import ( - "encoding/json" "errors" "net" "os" @@ -114,10 +113,8 @@ type testResourceManager struct { } type testStorage struct { - instanceInfo []launcher.InstanceInfo - desiredInstances json.RawMessage - nodeState map[string]json.RawMessage - services map[string][]imagemanager.ServiceInfo + instanceInfo map[aostypes.InstanceIdent]*launcher.InstanceInfo + services map[string][]imagemanager.ServiceInfo } type testStateStorage struct { @@ -1269,89 +1266,61 @@ func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType strin func newTestStorage() *testStorage { return &testStorage{ - desiredInstances: json.RawMessage("[]"), - nodeState: make(map[string]json.RawMessage), - services: make(map[string][]imagemanager.ServiceInfo), + instanceInfo: make(map[aostypes.InstanceIdent]*launcher.InstanceInfo), + services: make(map[string][]imagemanager.ServiceInfo), } } func (storage *testStorage) AddInstance(instanceInfo launcher.InstanceInfo) error { - for _, uid := range storage.instanceInfo { - if uid.InstanceIdent == instanceInfo.InstanceIdent { - return aoserrors.New("uid for instance already exist") - } + if _, ok := storage.instanceInfo[instanceInfo.InstanceIdent]; ok { + return aoserrors.New("instance already exist") } - storage.instanceInfo = append(storage.instanceInfo, instanceInfo) + storage.instanceInfo[instanceInfo.InstanceIdent] = &instanceInfo return nil } func (storage *testStorage) GetInstanceUID(instance aostypes.InstanceIdent) (int, error) { - for _, instanceInfo := range storage.instanceInfo { - if instanceInfo.InstanceIdent == instance { - return instanceInfo.UID, nil - } + instanceInfo, ok := storage.instanceInfo[instance] + if !ok { + return 0, launcher.ErrNotExist } - return 0, launcher.ErrNotExist + return instanceInfo.UID, nil } func (storage *testStorage) GetInstances() ([]launcher.InstanceInfo, error) { - instances := make([]launcher.InstanceInfo, len(storage.instanceInfo)) - copy(instances, storage.instanceInfo) + instances := make([]launcher.InstanceInfo, 0, len(storage.instanceInfo)) + + for _, instanceInfo := range storage.instanceInfo { + instances = append(instances, *instanceInfo) + } return instances, nil } func (storage *testStorage) RemoveInstance(instanceIdent aostypes.InstanceIdent) error { - for i, instanceInfo := range storage.instanceInfo { - if instanceInfo.InstanceIdent == instanceIdent { - storage.instanceInfo = append(storage.instanceInfo[:i], storage.instanceInfo[i+1:]...) - - return nil - } + if _, ok := storage.instanceInfo[instanceIdent]; !ok { + return launcher.ErrNotExist } - return launcher.ErrNotExist -} + delete(storage.instanceInfo, instanceIdent) -func (storage *testStorage) SetDesiredInstances(instances json.RawMessage) error { - storage.desiredInstances = instances return nil } func (storage *testStorage) SetInstanceCached(instance aostypes.InstanceIdent, cached bool) error { - for i, instanceInfo := range storage.instanceInfo { - if instanceInfo.InstanceIdent == instance { - storage.instanceInfo[i].Cached = cached - - return nil - } + instanceInfo, ok := storage.instanceInfo[instance] + if !ok { + return launcher.ErrNotExist } - return launcher.ErrNotExist -} - -func (storage *testStorage) GetDesiredInstances() (instances json.RawMessage, err error) { - return storage.desiredInstances, nil -} - -func (storage *testStorage) SetNodeState(nodeID string, runRequest json.RawMessage) error { - storage.nodeState[nodeID] = runRequest + instanceInfo.Cached = cached return nil } -func (storage *testStorage) GetNodeState(nodeID string) (json.RawMessage, error) { - runRequestJSON, ok := storage.nodeState[nodeID] - if !ok { - return nil, launcher.ErrNotExist - } - - return runRequestJSON, nil -} - func (storage *testStorage) GetServiceInfo(serviceID string) (imagemanager.ServiceInfo, error) { services, ok := storage.services[serviceID] if !ok { diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index aacefdce..92511165 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -18,7 +18,6 @@ package launcher import ( - "encoding/json" "errors" "reflect" "slices" @@ -48,7 +47,6 @@ type runRequestInfo struct { } type nodeHandler struct { - storage Storage nodeInfo cloudprotocol.NodeInfo availableResources []string availableLabels []string @@ -65,22 +63,17 @@ type nodeHandler struct { **********************************************************************************************************************/ func newNodeHandler( - nodeInfo cloudprotocol.NodeInfo, resourceManager ResourceManager, storage Storage, isLocalNode bool, + nodeInfo cloudprotocol.NodeInfo, resourceManager ResourceManager, isLocalNode bool, ) (*nodeHandler, error) { log.WithFields(log.Fields{"nodeID": nodeInfo.NodeID}).Debug("Init node handler") node := &nodeHandler{ - storage: storage, nodeInfo: nodeInfo, currentRunRequest: &runRequestInfo{}, isLocalNode: isLocalNode, waitStatus: true, } - if err := node.loadNodeRunRequest(); err != nil && !errors.Is(err, ErrNotExist) { - log.WithFields(log.Fields{"nodeID": nodeInfo.NodeID}).Errorf("Can't load node run request: %v", err) - } - nodeConfig, err := resourceManager.GetNodeConfig(node.nodeInfo.NodeID, node.nodeInfo.NodeType) if err != nil && !errors.Is(err, unitconfig.ErrNotFound) { return nil, aoserrors.Wrap(err) @@ -108,32 +101,6 @@ func (node *nodeHandler) initNodeConfig(nodeConfig cloudprotocol.NodeConfig) { } } -func (node *nodeHandler) loadNodeRunRequest() error { - currentRunRequestJSON, err := node.storage.GetNodeState(node.nodeInfo.NodeID) - if err != nil { - return aoserrors.Wrap(err) - } - - if err = json.Unmarshal(currentRunRequestJSON, &node.currentRunRequest); err != nil { - return aoserrors.Wrap(err) - } - - return nil -} - -func (node *nodeHandler) saveNodeRunRequest() error { - runRequestJSON, err := json.Marshal(node.currentRunRequest) - if err != nil { - return aoserrors.Wrap(err) - } - - if err := node.storage.SetNodeState(node.nodeInfo.NodeID, runRequestJSON); err != nil { - return aoserrors.Wrap(err) - } - - return nil -} - func (node *nodeHandler) allocateDevices(serviceDevices []aostypes.ServiceDevice) error { serviceDeviceLoop: for _, serviceDevice := range serviceDevices { From cf221594a6cb301433644b519538c4c7f6c7739a Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 24 Jul 2024 21:26:07 +0300 Subject: [PATCH 101/146] [launcher] Store node config instead of using separate fields Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 7 ++----- launcher/nodehandler.go | 39 ++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 9e019447..2a09c0b9 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -43,9 +43,6 @@ import ( var ErrNotExist = errors.New("entry not exist") -//nolint:gochecknoglobals -var defaultRunners = []string{"crun", "runc"} - /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -727,11 +724,11 @@ func (launcher *Launcher) getNodesByPriorities() []*nodeHandler { nodes := maps.Values(launcher.nodes) sort.Slice(nodes, func(i, j int) bool { - if nodes[i].priority == nodes[j].priority { + if nodes[i].nodeConfig.Priority == nodes[j].nodeConfig.Priority { return nodes[i].nodeInfo.NodeID < nodes[j].nodeInfo.NodeID } - return nodes[i].priority > nodes[j].priority + return nodes[i].nodeConfig.Priority > nodes[j].nodeConfig.Priority }) return nodes diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 92511165..7de1ddca 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -48,16 +48,21 @@ type runRequestInfo struct { type nodeHandler struct { nodeInfo cloudprotocol.NodeInfo - availableResources []string - availableLabels []string + nodeConfig cloudprotocol.NodeConfig availableDevices []nodeDevice - priority uint32 receivedRunInstances []cloudprotocol.InstanceStatus currentRunRequest *runRequestInfo isLocalNode bool waitStatus bool } +/*********************************************************************************************************************** + * Vars + **********************************************************************************************************************/ + +//nolint:gochecknoglobals +var defaultRunners = []string{"crun", "runc"} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -79,22 +84,16 @@ func newNodeHandler( return nil, aoserrors.Wrap(err) } - node.initNodeConfig(nodeConfig) + node.nodeConfig = nodeConfig + node.initDevices() return node, nil } -func (node *nodeHandler) initNodeConfig(nodeConfig cloudprotocol.NodeConfig) { - node.priority = nodeConfig.Priority - node.availableLabels = nodeConfig.Labels - node.availableResources = make([]string, len(nodeConfig.Resources)) - node.availableDevices = make([]nodeDevice, len(nodeConfig.Devices)) - - for i, resource := range nodeConfig.Resources { - node.availableResources[i] = resource.Name - } +func (node *nodeHandler) initDevices() { + node.availableDevices = make([]nodeDevice, len(node.nodeConfig.Devices)) - for i, device := range nodeConfig.Devices { + for i, device := range node.nodeConfig.Devices { node.availableDevices[i] = nodeDevice{ name: device.Name, sharedCount: device.SharedCount, allocatedCount: 0, } @@ -248,12 +247,14 @@ func getNodesByResources(nodes []*nodeHandler, desiredResources []string) (newNo nodeLoop: for _, node := range nodes { - if len(node.availableResources) == 0 { + if len(node.nodeConfig.Resources) == 0 { continue } for _, resource := range desiredResources { - if !slices.Contains(node.availableResources, resource) { + if !slices.ContainsFunc(node.nodeConfig.Resources, func(info cloudprotocol.ResourceInfo) bool { + return info.Name == resource + }) { continue nodeLoop } } @@ -271,12 +272,12 @@ func getNodesByLabels(nodes []*nodeHandler, desiredLabels []string) (newNodes [] nodeLoop: for _, node := range nodes { - if len(node.availableLabels) == 0 { + if len(node.nodeConfig.Labels) == 0 { continue } for _, label := range desiredLabels { - if !slices.Contains(node.availableLabels, label) { + if !slices.Contains(node.nodeConfig.Labels, label) { continue nodeLoop } } @@ -319,7 +320,7 @@ func getMostPriorityNode(nodes []*nodeHandler) *nodeHandler { maxNodePriorityIndex := 0 for i := 1; i < len(nodes); i++ { - if nodes[maxNodePriorityIndex].priority < nodes[i].priority { + if nodes[maxNodePriorityIndex].nodeConfig.Priority < nodes[i].nodeConfig.Priority { maxNodePriorityIndex = i } } From 21845d219702ddfee8afa27634cbb0ce84a3bd71 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 24 Jul 2024 21:28:43 +0300 Subject: [PATCH 102/146] [launcher] Access currentRunRequest in node handler by value Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 2 +- launcher/nodehandler.go | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 2a09c0b9..4c138cae 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -449,7 +449,7 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo, ) (errStatus []cloudprotocol.InstanceStatus) { for _, node := range launcher.nodes { - node.currentRunRequest = &runRequestInfo{} + node.currentRunRequest = runRequest{} } launcher.resetDeviceAllocation() diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 7de1ddca..84175a38 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -40,7 +40,7 @@ type nodeDevice struct { allocatedCount int } -type runRequestInfo struct { +type runRequest struct { Services []aostypes.ServiceInfo `json:"services"` Layers []aostypes.LayerInfo `json:"layers"` Instances []aostypes.InstanceInfo `json:"instances"` @@ -51,7 +51,7 @@ type nodeHandler struct { nodeConfig cloudprotocol.NodeConfig availableDevices []nodeDevice receivedRunInstances []cloudprotocol.InstanceStatus - currentRunRequest *runRequestInfo + currentRunRequest runRequest isLocalNode bool waitStatus bool } @@ -73,10 +73,9 @@ func newNodeHandler( log.WithFields(log.Fields{"nodeID": nodeInfo.NodeID}).Debug("Init node handler") node := &nodeHandler{ - nodeInfo: nodeInfo, - currentRunRequest: &runRequestInfo{}, - isLocalNode: isLocalNode, - waitStatus: true, + nodeInfo: nodeInfo, + isLocalNode: isLocalNode, + waitStatus: true, } nodeConfig, err := resourceManager.GetNodeConfig(node.nodeInfo.NodeID, node.nodeInfo.NodeType) From e87d473e5e06e09f09afe5f04f93f2caa677bff3 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 24 Jul 2024 21:50:15 +0300 Subject: [PATCH 103/146] [launcher] Refactor: rename fields and simplify data processing Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 119 +++++++++++++++++++------------------- launcher/launcher_test.go | 22 ++++--- launcher/nodehandler.go | 78 +++++++++---------------- 3 files changed, 100 insertions(+), 119 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 4c138cae..e24b0914 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -60,6 +60,7 @@ type Launcher struct { config *config.Config storage Storage + nodeInfoProvider NodeInfoProvider nodeManager NodeManager imageProvider ImageProvider resourceManager ResourceManager @@ -157,45 +158,18 @@ func New( log.Debug("Create launcher") launcher = &Launcher{ - config: config, storage: storage, nodeManager: nodeManager, imageProvider: imageProvider, - resourceManager: resourceManager, storageStateProvider: storageStateProvider, networkManager: networkManager, - runStatusChannel: make(chan unitstatushandler.RunInstancesStatus, 10), - nodes: make(map[string]*nodeHandler), + config: config, storage: storage, nodeInfoProvider: nodeInfoProvider, nodeManager: nodeManager, + imageProvider: imageProvider, resourceManager: resourceManager, storageStateProvider: storageStateProvider, + networkManager: networkManager, runStatusChannel: make(chan unitstatushandler.RunInstancesStatus, 10), } if launcher.instanceManager, err = newInstanceManager(config, storage, storageStateProvider, launcher.imageProvider.GetRemoveServiceChannel()); err != nil { - return nil, aoserrors.Wrap(err) + return nil, err } - nodes, err := nodeInfoProvider.GetAllNodeIDs() - if err != nil { - return nil, aoserrors.Wrap(err) - } - - for _, nodeID := range nodes { - nodeInfo, err := nodeInfoProvider.GetNodeInfo(nodeID) - if err != nil { - log.WithField("nodeID", nodeID).Errorf("Can't get node info: %v", err) - - continue - } - - if nodeInfo.Status == cloudprotocol.NodeStatusProvisioned { - log.WithField("nodeID", nodeID).Debug("Skip not provisioned node") - - continue - } - - nodeHandler, err := newNodeHandler( - nodeInfo, resourceManager, nodeInfo.NodeID == nodeInfoProvider.GetNodeID()) - if err != nil { - log.WithField("nodeID", nodeID).Errorf("Can't create node handler: %v", err) - - continue - } - - launcher.nodes[nodeID] = nodeHandler + if err := launcher.initNodes(); err != nil { + return nil, err } ctx, cancelFunction := context.WithCancel(context.Background()) @@ -227,13 +201,17 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, n log.Debug("Run instances") - launcher.connectionTimer = time.AfterFunc( - launcher.config.SMController.NodesConnectionTimeout.Duration, launcher.sendCurrentStatus) + if err := launcher.initNodes(); err != nil { + log.Errorf("Can't init nodes: %v", err) + } if err := launcher.updateNetworks(instances); err != nil { log.Errorf("Can't update networks: %v", err) } + launcher.cacheRemovedInstances(instances) + launcher.removeInstanceNetworkParameters(instances) + launcher.pendingNewServices = newServices launcher.currentErrorStatus = launcher.performNodeBalancing(instances) @@ -253,6 +231,42 @@ func (launcher *Launcher) GetRunStatusesChannel() <-chan unitstatushandler.RunIn * Private **********************************************************************************************************************/ +func (launcher *Launcher) initNodes() error { + launcher.nodes = make(map[string]*nodeHandler) + + nodes, err := launcher.nodeInfoProvider.GetAllNodeIDs() + if err != nil { + return aoserrors.Wrap(err) + } + + for _, nodeID := range nodes { + nodeInfo, err := launcher.nodeInfoProvider.GetNodeInfo(nodeID) + if err != nil { + log.WithField("nodeID", nodeID).Errorf("Can't get node info: %v", err) + + continue + } + + if nodeInfo.Status != cloudprotocol.NodeStatusProvisioned { + log.WithField("nodeID", nodeID).Debug("Skip not provisioned node") + + continue + } + + nodeHandler, err := newNodeHandler( + nodeInfo, launcher.resourceManager, nodeInfo.NodeID == launcher.nodeInfoProvider.GetNodeID()) + if err != nil { + log.WithField("nodeID", nodeID).Errorf("Can't create node handler: %v", err) + + continue + } + + launcher.nodes[nodeID] = nodeHandler + } + + return nil +} + func (launcher *Launcher) processChannels(ctx context.Context) { for { select { @@ -270,9 +284,9 @@ func (launcher *Launcher) sendRunInstances(forceRestart bool) (err error) { node.waitStatus = true if runErr := launcher.nodeManager.RunInstances( - node.nodeInfo.NodeID, node.currentRunRequest.Services, node.currentRunRequest.Layers, - node.currentRunRequest.Instances, forceRestart); runErr != nil { - log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't run instances %v", runErr) + node.nodeInfo.NodeID, node.runRequest.Services, node.runRequest.Layers, + node.runRequest.Instances, forceRestart); runErr != nil { + log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't run instances: %v", runErr) if err == nil { err = runErr @@ -296,7 +310,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat return } - currentStatus.receivedRunInstances = runStatus.Instances + currentStatus.runStatus = runStatus.Instances currentStatus.waitStatus = false for _, node := range launcher.nodes { @@ -312,14 +326,6 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat launcher.sendCurrentStatus() } -func (launcher *Launcher) resetDeviceAllocation() { - for _, node := range launcher.nodes { - for i := range node.availableDevices { - node.availableDevices[i].allocatedCount = 0 - } - } -} - func (launcher *Launcher) sendCurrentStatus() { runStatusToSend := unitstatushandler.RunInstancesStatus{ UnitSubjects: []string{}, Instances: []cloudprotocol.InstanceStatus{}, @@ -329,7 +335,7 @@ func (launcher *Launcher) sendCurrentStatus() { if node.waitStatus { node.waitStatus = false - for _, errInstance := range node.currentRunRequest.Instances { + for _, errInstance := range node.runRequest.Instances { runStatusToSend.Instances = append(runStatusToSend.Instances, cloudprotocol.InstanceStatus{ InstanceIdent: errInstance.InstanceIdent, NodeID: node.nodeInfo.NodeID, Status: cloudprotocol.InstanceStateFailed, @@ -337,7 +343,7 @@ func (launcher *Launcher) sendCurrentStatus() { }) } } else { - runStatusToSend.Instances = append(runStatusToSend.Instances, node.receivedRunInstances...) + runStatusToSend.Instances = append(runStatusToSend.Instances, node.runStatus...) } } @@ -448,12 +454,6 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) //nolint:funlen,gocognit func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo, ) (errStatus []cloudprotocol.InstanceStatus) { - for _, node := range launcher.nodes { - node.currentRunRequest = runRequest{} - } - - launcher.resetDeviceAllocation() - sort.Slice(instances, func(i, j int) bool { if instances[i].Priority == instances[j].Priority { return instances[i].ServiceID < instances[j].ServiceID @@ -462,9 +462,6 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc return instances[i].Priority > instances[j].Priority }) - launcher.cacheInstances(instances) - launcher.removeInstanceNetworkParameters(instances) - for _, instance := range instances { log.WithFields(log.Fields{ "serviceID": instance.ServiceID, @@ -553,7 +550,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (errStatus []cloudprotocol.InstanceStatus) { for _, node := range launcher.getNodesByPriorities() { - for i, instance := range node.currentRunRequest.Instances { + for i, instance := range node.runRequest.Instances { serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) if err != nil { errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", @@ -573,7 +570,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (err instance.Instance, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) } - node.currentRunRequest.Instances[i] = instance + node.runRequest.Instances[i] = instance } } @@ -628,7 +625,7 @@ nextNetInstance: } } -func (launcher *Launcher) cacheInstances(instances []cloudprotocol.InstanceInfo) { +func (launcher *Launcher) cacheRemovedInstances(instances []cloudprotocol.InstanceInfo) { storeInstances, err := launcher.storage.GetInstances() if err != nil { log.Errorf("Can't get instances from storage: %v", err) diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 156a795a..ef24d9e9 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -345,6 +345,7 @@ func TestInitialStatus(t *testing.T) { for _, id := range nodeIDs { nodeInfo := cloudprotocol.NodeInfo{ NodeID: id, NodeType: "nodeType", + Status: cloudprotocol.NodeStatusProvisioned, TotalRAM: 100, CPUs: []cloudprotocol.CPUInfo{ {ModelName: "Intel(R) Core(TM) i7-1185G7"}, @@ -398,19 +399,23 @@ func TestBalancing(t *testing.T) { nodeInfoProvider.nodeInfo = map[string]cloudprotocol.NodeInfo{ nodeIDLocalSM: { NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, }, nodeIDRemoteSM1: { NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, }, nodeIDRemoteSM2: { NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, }, nodeIDRunxSM: { NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, }, } @@ -897,7 +902,8 @@ func TestServiceRevert(t *testing.T) { nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } imageManager.services = map[string]imagemanager.ServiceInfo{ service1: { @@ -995,13 +1001,15 @@ func TestStorageCleanup(t *testing.T) { nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{Priority: 100} nodeInfoProvider.nodeInfo[nodeIDRunxSM] = cloudprotocol.NodeInfo{ NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, } resourceManager.nodeResources[nodeTypeRunxSM] = cloudprotocol.NodeConfig{Priority: 0} diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 84175a38..ecad6781 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -34,12 +34,6 @@ import ( * Types **********************************************************************************************************************/ -type nodeDevice struct { - name string - sharedCount int - allocatedCount int -} - type runRequest struct { Services []aostypes.ServiceInfo `json:"services"` Layers []aostypes.LayerInfo `json:"layers"` @@ -47,13 +41,13 @@ type runRequest struct { } type nodeHandler struct { - nodeInfo cloudprotocol.NodeInfo - nodeConfig cloudprotocol.NodeConfig - availableDevices []nodeDevice - receivedRunInstances []cloudprotocol.InstanceStatus - currentRunRequest runRequest - isLocalNode bool - waitStatus bool + nodeInfo cloudprotocol.NodeInfo + nodeConfig cloudprotocol.NodeConfig + deviceAllocations map[string]int + runStatus []cloudprotocol.InstanceStatus + runRequest runRequest + isLocalNode bool + waitStatus bool } /*********************************************************************************************************************** @@ -84,60 +78,42 @@ func newNodeHandler( } node.nodeConfig = nodeConfig - node.initDevices() + node.resetDeviceAllocations() return node, nil } -func (node *nodeHandler) initDevices() { - node.availableDevices = make([]nodeDevice, len(node.nodeConfig.Devices)) +func (node *nodeHandler) resetDeviceAllocations() { + node.deviceAllocations = make(map[string]int) - for i, device := range node.nodeConfig.Devices { - node.availableDevices[i] = nodeDevice{ - name: device.Name, sharedCount: device.SharedCount, allocatedCount: 0, - } + for _, device := range node.nodeConfig.Devices { + node.deviceAllocations[device.Name] = device.SharedCount } } func (node *nodeHandler) allocateDevices(serviceDevices []aostypes.ServiceDevice) error { -serviceDeviceLoop: for _, serviceDevice := range serviceDevices { - for i := range node.availableDevices { - if node.availableDevices[i].name != serviceDevice.Name { - continue - } - - if node.availableDevices[i].sharedCount != 0 { - if node.availableDevices[i].allocatedCount == node.availableDevices[i].sharedCount { - return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) - } - - node.availableDevices[i].allocatedCount++ + count, ok := node.deviceAllocations[serviceDevice.Name] + if !ok { + return aoserrors.Errorf("device not found: %s", serviceDevice.Name) + } - continue serviceDeviceLoop - } + if count == 0 { + return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) } - return aoserrors.Errorf("can't allocate device: %s", serviceDevice.Name) + node.deviceAllocations[serviceDevice.Name] = count - 1 } return nil } func (node *nodeHandler) nodeHasDesiredDevices(desiredDevices []aostypes.ServiceDevice) bool { -devicesLoop: for _, desiredDevice := range desiredDevices { - for _, nodeDevice := range node.availableDevices { - if desiredDevice.Name != nodeDevice.name { - continue - } - - if nodeDevice.sharedCount == 0 || nodeDevice.allocatedCount != nodeDevice.sharedCount { - continue devicesLoop - } + count, ok := node.deviceAllocations[desiredDevice.Name] + if !ok || count == 0 { + return false } - - return false } return true @@ -149,7 +125,7 @@ func (node *nodeHandler) addRunRequest( log.WithFields(instanceIdentLogFields( instance.InstanceIdent, log.Fields{"node": node.nodeInfo.NodeID})).Debug("Schedule instance on node") - node.currentRunRequest.Instances = append(node.currentRunRequest.Instances, instance) + node.runRequest.Instances = append(node.runRequest.Instances, instance) serviceInfo := service.ServiceInfo @@ -159,7 +135,7 @@ func (node *nodeHandler) addRunRequest( isNewService := true - for _, oldService := range node.currentRunRequest.Services { + for _, oldService := range node.runRequest.Services { if reflect.DeepEqual(oldService, serviceInfo) { isNewService = false break @@ -171,7 +147,7 @@ func (node *nodeHandler) addRunRequest( "serviceID": serviceInfo.ServiceID, "node": node.nodeInfo.NodeID, }).Debug("Schedule service on node") - node.currentRunRequest.Services = append(node.currentRunRequest.Services, serviceInfo) + node.runRequest.Services = append(node.runRequest.Services, serviceInfo) } layerLoopLabel: @@ -182,7 +158,7 @@ layerLoopLabel: newLayer.URL = layer.RemoteURL } - for _, oldLayer := range node.currentRunRequest.Layers { + for _, oldLayer := range node.runRequest.Layers { if reflect.DeepEqual(newLayer, oldLayer) { continue layerLoopLabel } @@ -192,7 +168,7 @@ layerLoopLabel: "digest": newLayer.Digest, "node": node.nodeInfo.NodeID, }).Debug("Schedule layer on node") - node.currentRunRequest.Layers = append(node.currentRunRequest.Layers, newLayer) + node.runRequest.Layers = append(node.runRequest.Layers, newLayer) } } From 79efd8a828313ded41ca10914e85bc376c5c193d Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 25 Jul 2024 18:40:38 +0300 Subject: [PATCH 104/146] [storagestate] Add initial state watching Signed-off-by: Oleksandr Grytsov --- storagestate/storagestate.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/storagestate/storagestate.go b/storagestate/storagestate.go index c9f9de63..c6b1da5f 100644 --- a/storagestate/storagestate.go +++ b/storagestate/storagestate.go @@ -178,6 +178,10 @@ func New(cfg *config.Config, messageSender MessageSender, storage Storage) (stor storageState.isSamePartition = storageMountPoint == stateMountPoint + if err = storageState.initStateWatching(); err != nil { + log.Errorf("Can't init state watching: %v", err) + } + go storageState.processWatcher() return storageState, nil @@ -398,6 +402,22 @@ func (storageState *StorageState) GetInstanceCheckSum(instanceIdent aostypes.Ins * Private **********************************************************************************************************************/ +func (storageState *StorageState) initStateWatching() error { + infos, err := storageState.storage.GetAllStorageStateInfo() + if err != nil { + return aoserrors.Wrap(err) + } + + for _, info := range infos { + if err = storageState.startStateWatching(info.InstanceIdent, info.InstanceID, + storageState.getStatePath(info.InstanceID), info.StateQuota); err != nil { + log.WithField("instanceID", info.InstanceID).Errorf("Can't setup state watching: %v", err) + } + } + + return nil +} + func (storageState *StorageState) prepareState( instanceID string, params SetupParams, checksum []byte, ) (stateFilePath string, err error) { @@ -484,7 +504,8 @@ func (storageState *StorageState) setupStateWatching(instanceID, stateFilePath s return aoserrors.Wrap(err) } - if err := storageState.startStateWatching(instanceID, stateFilePath, params); err != nil { + if err := storageState.startStateWatching( + params.InstanceIdent, instanceID, stateFilePath, params.StateQuota); err != nil { return aoserrors.Wrap(err) } @@ -492,16 +513,16 @@ func (storageState *StorageState) setupStateWatching(instanceID, stateFilePath s } func (storageState *StorageState) startStateWatching( - instanceID string, stateFilePath string, params SetupParams, + instanceIdent aostypes.InstanceIdent, instanceID string, stateFilePath string, quota uint64, ) (err error) { if err = storageState.watcher.Add(stateFilePath); err != nil { return aoserrors.Wrap(err) } - storageState.statesMap[params.InstanceIdent] = &stateParams{ + storageState.statesMap[instanceIdent] = &stateParams{ instanceID: instanceID, stateFilePath: stateFilePath, - quota: params.StateQuota, + quota: quota, changeTimerChannel: make(chan bool, 1), } From 93cac82e21b0d2e3537cd98913de8f2265ad643b Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 25 Jul 2024 19:33:10 +0300 Subject: [PATCH 105/146] [launcher] Combine all cleanup methods into processRemovedInstances Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 122 +++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 81 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index e24b0914..b7e5897c 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -20,6 +20,7 @@ package launcher import ( "context" "errors" + "slices" "sort" "sync" "time" @@ -69,7 +70,6 @@ type Launcher struct { runStatusChannel chan unitstatushandler.RunInstancesStatus nodes map[string]*nodeHandler - currentRunStatus []cloudprotocol.InstanceStatus currentErrorStatus []cloudprotocol.InstanceStatus pendingNewServices []string @@ -205,13 +205,14 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, n log.Errorf("Can't init nodes: %v", err) } + if err := launcher.processRemovedInstances(instances); err != nil { + log.Errorf("Can't process removed instances: %v", err) + } + if err := launcher.updateNetworks(instances); err != nil { log.Errorf("Can't update networks: %v", err) } - launcher.cacheRemovedInstances(instances) - launcher.removeInstanceNetworkParameters(instances) - launcher.pendingNewServices = newServices launcher.currentErrorStatus = launcher.performNodeBalancing(instances) @@ -327,7 +328,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat } func (launcher *Launcher) sendCurrentStatus() { - runStatusToSend := unitstatushandler.RunInstancesStatus{ + runStatus := unitstatushandler.RunInstancesStatus{ UnitSubjects: []string{}, Instances: []cloudprotocol.InstanceStatus{}, } @@ -336,33 +337,27 @@ func (launcher *Launcher) sendCurrentStatus() { node.waitStatus = false for _, errInstance := range node.runRequest.Instances { - runStatusToSend.Instances = append(runStatusToSend.Instances, cloudprotocol.InstanceStatus{ + runStatus.Instances = append(runStatus.Instances, cloudprotocol.InstanceStatus{ InstanceIdent: errInstance.InstanceIdent, NodeID: node.nodeInfo.NodeID, Status: cloudprotocol.InstanceStateFailed, ErrorInfo: &cloudprotocol.ErrorInfo{Message: "wait run status timeout"}, }) } - } else { - runStatusToSend.Instances = append(runStatusToSend.Instances, node.runStatus...) - } - } - - errorInstances := []aostypes.InstanceIdent{} - - for i := range runStatusToSend.Instances { - if runStatusToSend.Instances[i].ErrorInfo != nil { - errorInstances = append(errorInstances, runStatusToSend.Instances[i].InstanceIdent) continue } - runStatusToSend.Instances[i].StateChecksum = launcher.storageStateProvider.GetInstanceCheckSum( - runStatusToSend.Instances[i].InstanceIdent) + runStatus.Instances = append(runStatus.Instances, node.runStatus...) + } + + for i := range runStatus.Instances { + runStatus.Instances[i].StateChecksum = launcher.storageStateProvider.GetInstanceCheckSum( + runStatus.Instances[i].InstanceIdent) } newServicesLoop: for _, newService := range launcher.pendingNewServices { - for _, instance := range runStatusToSend.Instances { + for _, instance := range runStatus.Instances { if instance.ServiceID == newService && instance.ErrorInfo == nil { continue newServicesLoop } @@ -380,7 +375,7 @@ newServicesLoop: errorService.ErrorInfo.Message = "can't run any instances" } - runStatusToSend.ErrorServices = append(runStatusToSend.ErrorServices, errorService) + runStatus.ErrorServices = append(runStatus.ErrorServices, errorService) if err := launcher.imageProvider.RevertService(newService); err != nil { log.WithField("serviceID:", newService).Errorf("Can't revert service: %v", err) @@ -389,45 +384,43 @@ newServicesLoop: launcher.pendingNewServices = []string{} - launcher.processStoppedInstances(runStatusToSend.Instances, errorInstances) + runStatus.Instances = append(runStatus.Instances, launcher.currentErrorStatus...) + launcher.runStatusChannel <- runStatus + launcher.currentErrorStatus = []cloudprotocol.InstanceStatus{} +} - runStatusToSend.Instances = append(runStatusToSend.Instances, launcher.currentErrorStatus...) +func (launcher *Launcher) processRemovedInstances(newInstances []cloudprotocol.InstanceInfo) error { + launcher.removeInstanceNetworkParameters(newInstances) - launcher.runStatusChannel <- runStatusToSend + curInstances, err := launcher.storage.GetInstances() + if err != nil { + return aoserrors.Wrap(err) + } - launcher.currentRunStatus = runStatusToSend.Instances - launcher.currentErrorStatus = []cloudprotocol.InstanceStatus{} -} + for _, curInstance := range curInstances { + if curInstance.Cached { + continue + } -func (launcher *Launcher) processStoppedInstances( - newStatus []cloudprotocol.InstanceStatus, errorInstances []aostypes.InstanceIdent, -) { - stoppedInstances := errorInstances + if !slices.ContainsFunc(newInstances, func(info cloudprotocol.InstanceInfo) bool { + return curInstance.ServiceID == info.ServiceID && curInstance.SubjectID == info.SubjectID && + curInstance.Instance < info.NumInstances + }) { + log.WithFields(instanceIdentLogFields(curInstance.InstanceIdent, nil)).Debug("Remove instance") -currentInstancesLoop: - for _, currentStatus := range launcher.currentRunStatus { - for _, newStatus := range newStatus { - if currentStatus.InstanceIdent != newStatus.InstanceIdent { - continue + if err := launcher.storageStateProvider.Cleanup(curInstance.InstanceIdent); err != nil { + log.WithFields(instanceIdentLogFields(curInstance.InstanceIdent, nil)).Errorf( + "Can't cleanup instance state/storage: %v", err) } - if newStatus.ErrorInfo != nil && currentStatus.ErrorInfo == nil { - stoppedInstances = append(stoppedInstances, currentStatus.InstanceIdent) + if err := launcher.storage.SetInstanceCached(curInstance.InstanceIdent, true); err != nil { + log.WithFields(instanceIdentLogFields(curInstance.InstanceIdent, nil)).Errorf( + "Can't mark instance as cached: %v", err) } - - continue currentInstancesLoop - } - - if currentStatus.ErrorInfo == nil { - stoppedInstances = append(stoppedInstances, currentStatus.InstanceIdent) } } - for _, stopIdent := range stoppedInstances { - if err := launcher.storageStateProvider.Cleanup(stopIdent); err != nil { - log.Errorf("Can't cleanup state storage for instance: %v", err) - } - } + return nil } func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) error { @@ -625,37 +618,6 @@ nextNetInstance: } } -func (launcher *Launcher) cacheRemovedInstances(instances []cloudprotocol.InstanceInfo) { - storeInstances, err := launcher.storage.GetInstances() - if err != nil { - log.Errorf("Can't get instances from storage: %v", err) - return - } - -nextStoreInstance: - for _, storeInstance := range storeInstances { - for _, instance := range instances { - for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - instanceIdent := aostypes.InstanceIdent{ - ServiceID: instance.ServiceID, SubjectID: instance.SubjectID, - Instance: instanceIndex, - } - - if storeInstance.InstanceIdent == instanceIdent { - continue nextStoreInstance - } - } - } - - log.WithFields(instanceIdentLogFields(storeInstance.InstanceIdent, nil)).Debug("Cache instance") - - if err := launcher.storage.SetInstanceCached(storeInstance.InstanceIdent, true); err != nil { - log.WithFields( - instanceIdentLogFields(storeInstance.InstanceIdent, nil)).Errorf("Can't mark instance as cached: %v", err) - } - } -} - func (launcher *Launcher) prepareInstanceStartInfo(service imagemanager.ServiceInfo, instance cloudprotocol.InstanceInfo, index uint64, ) (aostypes.InstanceInfo, error) { @@ -701,8 +663,6 @@ func (launcher *Launcher) prepareInstanceStartInfo(service imagemanager.ServiceI instanceInfo.StoragePath, instanceInfo.StatePath, err = launcher.storageStateProvider.Setup(stateStorageParams) if err != nil { - _ = launcher.instanceManager.releaseUID(uid) - return instanceInfo, aoserrors.Wrap(err) } From 57ad79a8fd8e15d7e623697181d41b3fb2e9a3dc Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 25 Jul 2024 20:01:49 +0300 Subject: [PATCH 106/146] [launcher] Remove revert service handling This functionality should be done in software manager. Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 63 ++----- launcher/launcher_test.go | 377 +++++++++++++------------------------- 2 files changed, 137 insertions(+), 303 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index b7e5897c..71fbd39b 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -35,7 +35,6 @@ import ( "github.com/aosedge/aos_communicationmanager/imagemanager" "github.com/aosedge/aos_communicationmanager/networkmanager" "github.com/aosedge/aos_communicationmanager/storagestate" - "github.com/aosedge/aos_communicationmanager/unitstatushandler" ) /********************************************************************************************************************** @@ -68,10 +67,9 @@ type Launcher struct { storageStateProvider StorageStateProvider networkManager NetworkManager - runStatusChannel chan unitstatushandler.RunInstancesStatus - nodes map[string]*nodeHandler + runStatusChannel chan []cloudprotocol.InstanceStatus currentErrorStatus []cloudprotocol.InstanceStatus - pendingNewServices []string + nodes map[string]*nodeHandler cancelFunc context.CancelFunc connectionTimer *time.Timer @@ -111,7 +109,6 @@ type NetworkManager interface { type ImageProvider interface { GetServiceInfo(serviceID string) (imagemanager.ServiceInfo, error) GetLayerInfo(digest string) (imagemanager.LayerInfo, error) - RevertService(serviceID string) error GetRemoveServiceChannel() (channel <-chan string) } @@ -160,7 +157,7 @@ func New( launcher = &Launcher{ config: config, storage: storage, nodeInfoProvider: nodeInfoProvider, nodeManager: nodeManager, imageProvider: imageProvider, resourceManager: resourceManager, storageStateProvider: storageStateProvider, - networkManager: networkManager, runStatusChannel: make(chan unitstatushandler.RunInstancesStatus, 10), + networkManager: networkManager, runStatusChannel: make(chan []cloudprotocol.InstanceStatus, 10), } if launcher.instanceManager, err = newInstanceManager(config, storage, storageStateProvider, @@ -195,7 +192,7 @@ func (launcher *Launcher) Close() { } // RunInstances performs run service instances. -func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, newServices []string) error { +func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo) error { launcher.Lock() defer launcher.Unlock() @@ -213,7 +210,6 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, n log.Errorf("Can't update networks: %v", err) } - launcher.pendingNewServices = newServices launcher.currentErrorStatus = launcher.performNodeBalancing(instances) if err := launcher.networkManager.RestartDNSServer(); err != nil { @@ -224,7 +220,7 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, n } // GetRunStatusesChannel gets channel with run status instances status. -func (launcher *Launcher) GetRunStatusesChannel() <-chan unitstatushandler.RunInstancesStatus { +func (launcher *Launcher) GetRunStatusesChannel() <-chan []cloudprotocol.InstanceStatus { return launcher.runStatusChannel } @@ -328,16 +324,14 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat } func (launcher *Launcher) sendCurrentStatus() { - runStatus := unitstatushandler.RunInstancesStatus{ - UnitSubjects: []string{}, Instances: []cloudprotocol.InstanceStatus{}, - } + var instancesStatus []cloudprotocol.InstanceStatus for _, node := range launcher.getNodesByPriorities() { if node.waitStatus { node.waitStatus = false for _, errInstance := range node.runRequest.Instances { - runStatus.Instances = append(runStatus.Instances, cloudprotocol.InstanceStatus{ + instancesStatus = append(instancesStatus, cloudprotocol.InstanceStatus{ InstanceIdent: errInstance.InstanceIdent, NodeID: node.nodeInfo.NodeID, Status: cloudprotocol.InstanceStateFailed, ErrorInfo: &cloudprotocol.ErrorInfo{Message: "wait run status timeout"}, @@ -347,46 +341,17 @@ func (launcher *Launcher) sendCurrentStatus() { continue } - runStatus.Instances = append(runStatus.Instances, node.runStatus...) - } - - for i := range runStatus.Instances { - runStatus.Instances[i].StateChecksum = launcher.storageStateProvider.GetInstanceCheckSum( - runStatus.Instances[i].InstanceIdent) + instancesStatus = append(instancesStatus, node.runStatus...) } -newServicesLoop: - for _, newService := range launcher.pendingNewServices { - for _, instance := range runStatus.Instances { - if instance.ServiceID == newService && instance.ErrorInfo == nil { - continue newServicesLoop - } - } - - errorService := cloudprotocol.ServiceStatus{ - ServiceID: newService, Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{}, - } - - service, err := launcher.imageProvider.GetServiceInfo(newService) - if err != nil { - errorService.ErrorInfo.Message = err.Error() - } else { - errorService.Version = service.Version - errorService.ErrorInfo.Message = "can't run any instances" - } - - runStatus.ErrorServices = append(runStatus.ErrorServices, errorService) - - if err := launcher.imageProvider.RevertService(newService); err != nil { - log.WithField("serviceID:", newService).Errorf("Can't revert service: %v", err) - } + for i := range instancesStatus { + instancesStatus[i].StateChecksum = launcher.storageStateProvider.GetInstanceCheckSum( + instancesStatus[i].InstanceIdent) } - launcher.pendingNewServices = []string{} - - runStatus.Instances = append(runStatus.Instances, launcher.currentErrorStatus...) - launcher.runStatusChannel <- runStatus - launcher.currentErrorStatus = []cloudprotocol.InstanceStatus{} + instancesStatus = append(instancesStatus, launcher.currentErrorStatus...) + launcher.runStatusChannel <- instancesStatus + launcher.currentErrorStatus = nil } func (launcher *Launcher) processRemovedInstances(newInstances []cloudprotocol.InstanceInfo) error { diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index ef24d9e9..60f38148 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -38,7 +38,6 @@ import ( "github.com/aosedge/aos_communicationmanager/launcher" "github.com/aosedge/aos_communicationmanager/networkmanager" "github.com/aosedge/aos_communicationmanager/storagestate" - "github.com/aosedge/aos_communicationmanager/unitstatushandler" ) /*********************************************************************************************************************** @@ -104,7 +103,6 @@ type testNodeManager struct { type testImageProvider struct { services map[string]imagemanager.ServiceInfo layers map[string]imagemanager.LayerInfo - revertedServices []string removeServiceInstancesChannel chan string } @@ -338,7 +336,7 @@ func TestInitialStatus(t *testing.T) { } nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() - expectedRunStatus = unitstatushandler.RunInstancesStatus{} + expectedRunStatus = []cloudprotocol.InstanceStatus{} imageManager = &testImageProvider{} ) @@ -372,7 +370,7 @@ func TestInitialStatus(t *testing.T) { NodeID: id, }} - expectedRunStatus.Instances = append(expectedRunStatus.Instances, instances...) + expectedRunStatus = append(expectedRunStatus, instances...) nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{NodeID: id, Instances: instances} } @@ -452,7 +450,7 @@ func TestBalancing(t *testing.T) { serviceConfigs map[string]aostypes.ServiceConfig desiredInstances []cloudprotocol.InstanceInfo expectedRunRequests map[string]runRequest - expectedRunStatus unitstatushandler.RunInstancesStatus + expectedRunStatus []cloudprotocol.InstanceStatus } testItems := []testData{ @@ -522,27 +520,25 @@ func TestBalancing(t *testing.T) { }, }, }, - expectedRunStatus: unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDRunxSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, nodeIDRunxSM, nil), - }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, nodeIDRunxSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, nodeIDRunxSM, nil), }, }, // Check labels: label low priority service to run on high priority node @@ -601,27 +597,25 @@ func TestBalancing(t *testing.T) { instances: []aostypes.InstanceInfo{}, }, }, - expectedRunStatus: unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 - }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 }, }, // Check available resources @@ -689,27 +683,25 @@ func TestBalancing(t *testing.T) { instances: []aostypes.InstanceInfo{}, }, }, - expectedRunStatus: unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 - }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 }, }, // Check available devices @@ -806,36 +798,34 @@ func TestBalancing(t *testing.T) { instances: []aostypes.InstanceInfo{}, }, }, - expectedRunStatus: unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 2, - }, nodeIDRemoteSM2, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 3, - }, "", errors.New("no available device found")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 2, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no available device found")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no available device found")), //nolint:goerr113 - }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, nodeIDRemoteSM2, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, "", errors.New("no available device found")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 2, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, "", errors.New("no available device found")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, "", errors.New("no available device found")), //nolint:goerr113 }, }, } @@ -864,13 +854,13 @@ func TestBalancing(t *testing.T) { } if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { + launcherInstance.GetRunStatusesChannel(), []cloudprotocol.InstanceStatus{}, time.Second); err != nil { t.Errorf("Incorrect run status: %v", err) } // Run instances - if err := launcherInstance.RunInstances(testItem.desiredInstances, nil); err != nil { + if err := launcherInstance.RunInstances(testItem.desiredInstances); err != nil { t.Fatalf("Can't run instances %v", err) } @@ -887,104 +877,6 @@ func TestBalancing(t *testing.T) { } } -func TestServiceRevert(t *testing.T) { - var ( - cfg = &config.Config{ - SMController: config.SMController{ - NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, - }, - } - nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) - nodeManager = newTestNodeManager() - imageManager = &testImageProvider{} - resourceManager = newTestResourceManager() - ) - - nodeInfoProvider.nodeInfo[nodeIDLocalSM] = cloudprotocol.NodeInfo{ - NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Status: cloudprotocol.NodeStatusProvisioned, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, - } - imageManager.services = map[string]imagemanager.ServiceInfo{ - service1: { - ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), - RemoteURL: service1RemoteURL, - Layers: []string{layer1}, - }, - service2: { - ServiceInfo: createServiceInfo(service2, 5001, service2LocalURL), - RemoteURL: service2RemoteURL, - Layers: []string{layer2}, - }, - } - - imageManager.layers = map[string]imagemanager.LayerInfo{ - layer1: { - LayerInfo: createLayerInfo(layer1, layer1LocalURL), - RemoteURL: layer1RemoteURL, - }, - } - - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, - resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) - if err != nil { - t.Fatalf("Can't create launcher %v", err) - } - - // Wait initial run status - - for nodeID, info := range nodeInfoProvider.nodeInfo { - nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ - NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, - } - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - // Run instances - - desiredInstances := []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, - {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2}, - } - - if err := launcherInstance.RunInstances(desiredInstances, []string{service2}); err != nil { - t.Fatalf("Can't run instances %v", err) - } - - expectedRunStatus := unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, "", errors.New("layer does't exist")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, "", errors.New("layer does't exist")), //nolint:goerr113 - }, - ErrorServices: []cloudprotocol.ServiceStatus{ - {ServiceID: service2, Version: "1.0", Status: cloudprotocol.ErrorStatus}, - }, - } - - if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), expectedRunStatus, time.Second); err != nil { - t.Errorf("Incorrect run status: %v", err) - } - - if !reflect.DeepEqual([]string{service2}, imageManager.revertedServices) { - t.Errorf("Incorrect reverted services: %v", imageManager.revertedServices) - } -} - func TestStorageCleanup(t *testing.T) { var ( cfg = &config.Config{ @@ -1042,7 +934,7 @@ func TestStorageCleanup(t *testing.T) { } if err := waitRunInstancesStatus( - launcherInstance.GetRunStatusesChannel(), unitstatushandler.RunInstancesStatus{}, time.Second); err != nil { + launcherInstance.GetRunStatusesChannel(), []cloudprotocol.InstanceStatus{}, time.Second); err != nil { t.Errorf("Incorrect run status: %v", err) } @@ -1052,7 +944,7 @@ func TestStorageCleanup(t *testing.T) { {ServiceID: service3, SubjectID: subject1, Priority: 100, NumInstances: 1}, } - if err := launcherInstance.RunInstances(desiredInstances, nil); err != nil { + if err := launcherInstance.RunInstances(desiredInstances); err != nil { t.Fatalf("Can't run instances %v", err) } @@ -1087,21 +979,19 @@ func TestStorageCleanup(t *testing.T) { }, } - expectedRunStatus := unitstatushandler.RunInstancesStatus{ - Instances: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDRunxSM, nil), - }, + expectedRunStatus := []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, nodeIDRunxSM, nil), } if err := waitRunInstancesStatus( @@ -1117,7 +1007,7 @@ func TestStorageCleanup(t *testing.T) { {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1}, } - expectedRunStatus.Instances = []cloudprotocol.InstanceStatus{ + expectedRunStatus = []cloudprotocol.InstanceStatus{ createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service1, SubjectID: subject1, Instance: 0, }, nodeIDLocalSM, nil), @@ -1129,7 +1019,7 @@ func TestStorageCleanup(t *testing.T) { {ServiceID: service3, SubjectID: subject1, Instance: 0}, } - if err := launcherInstance.RunInstances(desiredInstances, []string{}); err != nil { + if err := launcherInstance.RunInstances(desiredInstances); err != nil { t.Fatalf("Can't run instances %v", err) } @@ -1396,12 +1286,6 @@ func (testProvider *testImageProvider) GetRemoveServiceChannel() (channel <-chan return testProvider.removeServiceInstancesChannel } -func (testProvider *testImageProvider) RevertService(serviceID string) error { - testProvider.revertedServices = append(testProvider.revertedServices, serviceID) - - return nil -} - // testNetworkManager func newTestNetworkManager(network string) *testNetworkManager { @@ -1519,46 +1403,43 @@ func createInstanceInfo(uid uint32, ip int, ident aostypes.InstanceIdent, priori } } -func waitRunInstancesStatus( - messageChannel <-chan unitstatushandler.RunInstancesStatus, expectedMsg unitstatushandler.RunInstancesStatus, - timeout time.Duration, -) (err error) { - var message unitstatushandler.RunInstancesStatus - +func waitRunInstancesStatus(runStatusChannel <-chan []cloudprotocol.InstanceStatus, + expectedStatus []cloudprotocol.InstanceStatus, timeout time.Duration, +) error { select { case <-time.After(timeout): return aoserrors.New("wait message timeout") - case message = <-messageChannel: - if len(message.Instances) != len(expectedMsg.Instances) { + case receivedStatus := <-runStatusChannel: + if len(receivedStatus) != len(expectedStatus) { return aoserrors.New("incorrect length") } topLoop: - for _, receivedEl := range message.Instances { - for _, expectedEl := range expectedMsg.Instances { - if receivedEl.ErrorInfo == nil && expectedEl.ErrorInfo != nil { + for _, receivedItem := range receivedStatus { + for _, expectedItem := range expectedStatus { + if receivedItem.ErrorInfo == nil && expectedItem.ErrorInfo != nil { continue } - if receivedEl.ErrorInfo != nil && expectedEl.ErrorInfo == nil { + if receivedItem.ErrorInfo != nil && expectedItem.ErrorInfo == nil { continue } - if receivedEl.ErrorInfo != nil && expectedEl.ErrorInfo != nil { - if receivedEl.ErrorInfo.AosCode != expectedEl.ErrorInfo.AosCode || - receivedEl.ErrorInfo.ExitCode != expectedEl.ErrorInfo.ExitCode || - !strings.Contains(receivedEl.ErrorInfo.Message, expectedEl.ErrorInfo.Message) { + if receivedItem.ErrorInfo != nil && expectedItem.ErrorInfo != nil { + if receivedItem.ErrorInfo.AosCode != expectedItem.ErrorInfo.AosCode || + receivedItem.ErrorInfo.ExitCode != expectedItem.ErrorInfo.ExitCode || + !strings.Contains(receivedItem.ErrorInfo.Message, expectedItem.ErrorInfo.Message) { continue } } - receivedForCheck := receivedEl + receivedForCheck := receivedItem receivedForCheck.ErrorInfo = nil - expectedEl.ErrorInfo = nil + expectedItem.ErrorInfo = nil - if reflect.DeepEqual(receivedForCheck, expectedEl) { + if reflect.DeepEqual(receivedForCheck, expectedItem) { continue topLoop } } @@ -1566,18 +1447,6 @@ func waitRunInstancesStatus( return aoserrors.New("incorrect instances in run status") } - if err := deepSlicesCompare(expectedMsg.UnitSubjects, message.UnitSubjects); err != nil { - return aoserrors.New("incorrect subjects in run status") - } - - for i := range message.ErrorServices { - message.ErrorServices[i].ErrorInfo = nil - } - - if err := deepSlicesCompare(expectedMsg.ErrorServices, message.ErrorServices); err != nil { - return aoserrors.New("incorrect error services in run status") - } - return nil } } From 6ed0b044afd47d998ede3cf0e3b321dc44921ad3 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 25 Jul 2024 21:16:06 +0300 Subject: [PATCH 107/146] [launcher] Refactor performNodeBalancing function Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 175 +++++++++++++++++++++------------------- launcher/nodehandler.go | 19 ++--- 2 files changed, 96 insertions(+), 98 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 71fbd39b..dc4db2ca 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -67,9 +67,9 @@ type Launcher struct { storageStateProvider StorageStateProvider networkManager NetworkManager - runStatusChannel chan []cloudprotocol.InstanceStatus - currentErrorStatus []cloudprotocol.InstanceStatus - nodes map[string]*nodeHandler + runStatusChannel chan []cloudprotocol.InstanceStatus + errorStatus []cloudprotocol.InstanceStatus + nodes map[string]*nodeHandler cancelFunc context.CancelFunc connectionTimer *time.Timer @@ -210,7 +210,7 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo) e log.Errorf("Can't update networks: %v", err) } - launcher.currentErrorStatus = launcher.performNodeBalancing(instances) + launcher.performNodeBalancing(instances) if err := launcher.networkManager.RestartDNSServer(); err != nil { log.Errorf("Can't restart DNS server: %v", err) @@ -277,6 +277,9 @@ func (launcher *Launcher) processChannels(ctx context.Context) { } func (launcher *Launcher) sendRunInstances(forceRestart bool) (err error) { + launcher.connectionTimer = time.AfterFunc( + launcher.config.SMController.NodesConnectionTimeout.Duration, launcher.sendCurrentStatus) + for _, node := range launcher.getNodesByPriorities() { node.waitStatus = true @@ -349,9 +352,9 @@ func (launcher *Launcher) sendCurrentStatus() { instancesStatus[i].InstanceIdent) } - instancesStatus = append(instancesStatus, launcher.currentErrorStatus...) + instancesStatus = append(instancesStatus, launcher.errorStatus...) launcher.runStatusChannel <- instancesStatus - launcher.currentErrorStatus = nil + launcher.errorStatus = nil } func (launcher *Launcher) processRemovedInstances(newInstances []cloudprotocol.InstanceInfo) error { @@ -409,9 +412,7 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) return nil } -//nolint:funlen,gocognit -func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo, -) (errStatus []cloudprotocol.InstanceStatus) { +func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo) { sort.Slice(instances, func(i, j int) bool { if instances[i].Priority == instances[j].Priority { return instances[i].ServiceID < instances[j].ServiceID @@ -428,115 +429,117 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc "priority": instance.Priority, }).Debug("Balance instances") - serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) - if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo( - instance.ServiceID, instance.SubjectID, 0, "0.0.0", - cloudprotocol.InstanceStateFailed, err.Error())) - - continue - } - - if serviceInfo.Cached { - errStatus = append(errStatus, createInstanceStatusFromInfo( - instance.ServiceID, instance.SubjectID, 0, "0.0.0", - cloudprotocol.InstanceStateFailed, "service deleted")) - - continue - } - - layers, err := launcher.getLayersForService(serviceInfo.Layers) + service, layers, err := launcher.getServiceLayers(instance) if err != nil { - for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) + for i := uint64(0); i < instance.NumInstances; i++ { + launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus( + instance.ServiceID, instance.SubjectID, i, service.Version, + cloudprotocol.InstanceStateFailed, err)) } continue } - nodes, err := getNodesByStaticResources(launcher.getNodesByPriorities(), serviceInfo, instance) + nodes, err := getNodesByStaticResources(launcher.getNodesByPriorities(), service, instance) if err != nil { - for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) + for i := uint64(0); i < instance.NumInstances; i++ { + launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus( + instance.ServiceID, instance.SubjectID, i, service.Version, + cloudprotocol.InstanceStateFailed, err)) } continue } - // createInstanceStatusFromInfo - for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - nodeForInstance, err := getNodesByDevices(nodes, serviceInfo.Config.Devices) + node, err := getInstanceNode(service, nodes) if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) + launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, + instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) continue } - instanceInfo, err := launcher.prepareInstanceStartInfo(serviceInfo, instance, instanceIndex) + instanceInfo, err := launcher.prepareInstanceStartInfo(instance, instanceIndex, service) if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) - } + launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, + instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) - node := getMostPriorityNode(nodeForInstance) + continue + } - if err = node.allocateDevices(serviceInfo.Config.Devices); err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instanceIndex, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) + if err = node.allocateDevices(service.Config.Devices); err != nil { + launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, + instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) continue } - node.addRunRequest(instanceInfo, serviceInfo, layers) + node.addRunRequest(instanceInfo, service, layers) + } } // first prepare network for instance which have exposed ports - errNetworkStatus := launcher.prepareNetworkForInstances(true) - errStatus = append(errStatus, errNetworkStatus...) + launcher.prepareNetworkForInstances(true) // then prepare network for rest of instances - errNetworkStatus = launcher.prepareNetworkForInstances(false) - errStatus = append(errStatus, errNetworkStatus...) + launcher.prepareNetworkForInstances(false) +} - return errStatus +func (launcher *Launcher) getServiceLayers(instance cloudprotocol.InstanceInfo) ( + imagemanager.ServiceInfo, []imagemanager.LayerInfo, error, +) { + service, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) + if err != nil { + return service, nil, aoserrors.Wrap(err) + } + + if service.Cached { + return service, nil, aoserrors.New("service deleted") + } + + layers, err := launcher.getLayersForService(service.Layers) + if err != nil { + return service, layers, err + } + + return service, layers, nil } -func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) (errStatus []cloudprotocol.InstanceStatus) { +func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) { for _, node := range launcher.getNodesByPriorities() { for i, instance := range node.runRequest.Instances { - serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) - if err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, 0, "0.0", - cloudprotocol.InstanceStateFailed, err.Error())) + if err := func() error { + serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) + if err != nil { + return aoserrors.Wrap(err) + } - continue - } + if onlyExposedPorts && len(serviceInfo.ExposedPorts) == 0 { + return nil + } - if onlyExposedPorts && len(serviceInfo.ExposedPorts) == 0 { - continue - } + if instance.NetworkParameters, err = launcher.networkManager.PrepareInstanceNetworkParameters( + instance.InstanceIdent, serviceInfo.ProviderID, + prepareNetworkParameters(serviceInfo)); err != nil { + return aoserrors.Wrap(err) + } - if instance.NetworkParameters, err = launcher.networkManager.PrepareInstanceNetworkParameters( - instance.InstanceIdent, serviceInfo.ProviderID, - prepareNetworkParameters(serviceInfo)); err != nil { - errStatus = append(errStatus, createInstanceStatusFromInfo(instance.ServiceID, instance.SubjectID, - instance.Instance, serviceInfo.Version, cloudprotocol.InstanceStateFailed, err.Error())) - } + node.runRequest.Instances[i] = instance - node.runRequest.Instances[i] = instance + return nil + }(); err != nil { + launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus( + instance.ServiceID, instance.SubjectID, 0, "", cloudprotocol.InstanceStateFailed, err)) + } } } - - return errStatus } func prepareNetworkParameters(serviceInfo imagemanager.ServiceInfo) networkmanager.NetworkParameters { var hosts []string + if serviceInfo.Config.Hostname != nil { hosts = append(hosts, *serviceInfo.Config.Hostname) } @@ -583,8 +586,8 @@ nextNetInstance: } } -func (launcher *Launcher) prepareInstanceStartInfo(service imagemanager.ServiceInfo, - instance cloudprotocol.InstanceInfo, index uint64, +func (launcher *Launcher) prepareInstanceStartInfo( + instance cloudprotocol.InstanceInfo, index uint64, service imagemanager.ServiceInfo, ) (aostypes.InstanceInfo, error) { instanceInfo := aostypes.InstanceInfo{InstanceIdent: aostypes.InstanceIdent{ ServiceID: instance.ServiceID, SubjectID: instance.SubjectID, @@ -631,7 +634,6 @@ func (launcher *Launcher) prepareInstanceStartInfo(service imagemanager.ServiceI return instanceInfo, aoserrors.Wrap(err) } - // make sure that instance is not cached if err := launcher.storage.SetInstanceCached(instanceInfo.InstanceIdent, false); err != nil { log.WithFields(instanceIdentLogFields(instanceInfo.InstanceIdent, nil)).Errorf("Can't mark instance as not cached: %v", err) @@ -656,21 +658,24 @@ func (launcher *Launcher) getNodesByPriorities() []*nodeHandler { return nodes } -func createInstanceStatusFromInfo( - serviceID, subjectID string, instanceIndex uint64, serviceVersion string, status, errorMsg string, +func createInstanceStatus( + serviceID, subjectID string, instance uint64, serviceVersion, status string, err error, ) cloudprotocol.InstanceStatus { - ident := aostypes.InstanceIdent{ - ServiceID: serviceID, SubjectID: subjectID, Instance: instanceIndex, - } - instanceStatus := cloudprotocol.InstanceStatus{ - InstanceIdent: ident, ServiceVersion: serviceVersion, Status: status, + InstanceIdent: aostypes.InstanceIdent{ + ServiceID: serviceID, + SubjectID: subjectID, + Instance: instance, + }, + ServiceVersion: serviceVersion, + Status: status, } - if errorMsg != "" { - log.WithFields(instanceIdentLogFields(ident, nil)).Errorf("Can't schedule instance: %s", errorMsg) + if err != nil { + log.WithFields(instanceIdentLogFields(instanceStatus.InstanceIdent, nil)).Errorf( + "Can't schedule instance: %v", err) - instanceStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: errorMsg} + instanceStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: err.Error()} } return instanceStatus diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index ecad6781..0f4de470 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -195,7 +195,7 @@ func getNodesByStaticResources(allNodes []*nodeHandler, func getNodesByDevices(availableNodes []*nodeHandler, desiredDevices []aostypes.ServiceDevice) ([]*nodeHandler, error) { if len(desiredDevices) == 0 { - return slices.Clone(availableNodes), nil + return availableNodes, nil } nodes := make([]*nodeHandler, 0) @@ -287,18 +287,11 @@ func getNodeByRunners(allNodes []*nodeHandler, runners []string) (nodes []*nodeH return nodes } -func getMostPriorityNode(nodes []*nodeHandler) *nodeHandler { - if len(nodes) == 1 { - return nodes[0] +func getInstanceNode(service imagemanager.ServiceInfo, nodes []*nodeHandler) (*nodeHandler, error) { + nodes, err := getNodesByDevices(nodes, service.Config.Devices) + if err != nil { + return nil, err } - maxNodePriorityIndex := 0 - - for i := 1; i < len(nodes); i++ { - if nodes[maxNodePriorityIndex].nodeConfig.Priority < nodes[i].nodeConfig.Priority { - maxNodePriorityIndex = i - } - } - - return nodes[maxNodePriorityIndex] + return nodes[0], nil } From 0f8c5a0970085054fbb94e672598fb30f1f461a0 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sun, 28 Jul 2024 21:06:19 +0300 Subject: [PATCH 108/146] [launcher] Move instance handling to instance manager Signed-off-by: Oleksandr Grytsov --- launcher/instancemanager.go | 126 +++++++++++++++++++++++++++++++-- launcher/launcher.go | 136 ++++++------------------------------ launcher/launcher_test.go | 41 +++-------- launcher/nodehandler.go | 16 +++-- 4 files changed, 166 insertions(+), 153 deletions(-) diff --git a/launcher/instancemanager.go b/launcher/instancemanager.go index 9b5e6be1..e89749cc 100644 --- a/launcher/instancemanager.go +++ b/launcher/instancemanager.go @@ -20,13 +20,17 @@ package launcher import ( "context" "errors" + "slices" "time" "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" + "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" "github.com/aosedge/aos_communicationmanager/config" + "github.com/aosedge/aos_communicationmanager/imagemanager" + "github.com/aosedge/aos_communicationmanager/storagestate" "github.com/aosedge/aos_communicationmanager/utils/uidgidpool" ) @@ -40,10 +44,27 @@ const removePeriod = time.Hour * 24 * Types **********************************************************************************************************************/ +type InstanceInfo struct { + aostypes.InstanceIdent + UID int + Timestamp time.Time + Cached bool +} + +// Storage storage interface. +type Storage interface { + AddInstance(instanceInfo InstanceInfo) error + RemoveInstance(instanceIdent aostypes.InstanceIdent) error + SetInstanceCached(instance aostypes.InstanceIdent, cached bool) error + GetInstanceUID(instance aostypes.InstanceIdent) (int, error) + GetInstances() ([]InstanceInfo, error) +} + type instanceManager struct { config *config.Config - storage Storage + imageProvider ImageProvider storageStateProvider StorageStateProvider + storage Storage cancelFunc context.CancelFunc uidPool *uidgidpool.IdentifierPool removeServiceChannel <-chan string @@ -53,13 +74,14 @@ type instanceManager struct { * Private **********************************************************************************************************************/ -func newInstanceManager(config *config.Config, storage Storage, storageStateProvider StorageStateProvider, - removeServiceChannel <-chan string, +func newInstanceManager(config *config.Config, imageProvider ImageProvider, storageStateProvider StorageStateProvider, + storage Storage, removeServiceChannel <-chan string, ) (im *instanceManager, err error) { im = &instanceManager{ config: config, - storage: storage, + imageProvider: imageProvider, storageStateProvider: storageStateProvider, + storage: storage, removeServiceChannel: removeServiceChannel, uidPool: uidgidpool.NewUserIDPool(), } @@ -91,6 +113,100 @@ func newInstanceManager(config *config.Config, storage Storage, storageStateProv return im, nil } +func (im *instanceManager) getCurrentInstances() ([]InstanceInfo, error) { + instances, err := im.storage.GetInstances() + if err != nil { + return nil, aoserrors.Wrap(err) + } + + return slices.DeleteFunc(instances, func(instance InstanceInfo) bool { + return instance.Cached + }), nil +} + +func (im *instanceManager) setupInstance( + instance cloudprotocol.InstanceInfo, index uint64, service imagemanager.ServiceInfo, +) (aostypes.InstanceInfo, error) { + instanceInfo := aostypes.InstanceInfo{ + InstanceIdent: aostypes.InstanceIdent{ + ServiceID: instance.ServiceID, SubjectID: instance.SubjectID, Instance: index, + }, + Priority: instance.Priority, + } + + uid, err := im.storage.GetInstanceUID(instanceInfo.InstanceIdent) + if err != nil { + if !errors.Is(err, ErrNotExist) { + return aostypes.InstanceInfo{}, aoserrors.Wrap(err) + } + + uid, err = im.acquireUID() + if err != nil { + return aostypes.InstanceInfo{}, err + } + + if err := im.storage.AddInstance(InstanceInfo{ + InstanceIdent: instanceInfo.InstanceIdent, + UID: uid, + Timestamp: time.Now(), + }); err != nil { + log.Errorf("Can't store uid: %v", err) + } + } + + instanceInfo.UID = uint32(uid) + + if err = im.setupInstanceStateStorage(&instanceInfo, service); err != nil { + return aostypes.InstanceInfo{}, err + } + + return instanceInfo, nil +} + +func (im *instanceManager) getInstanceCheckSum(instance aostypes.InstanceIdent) string { + return im.storageStateProvider.GetInstanceCheckSum(instance) +} + +func (im *instanceManager) setupInstanceStateStorage( + instanceInfo *aostypes.InstanceInfo, serviceInfo imagemanager.ServiceInfo, +) error { + stateStorageParams := storagestate.SetupParams{ + InstanceIdent: instanceInfo.InstanceIdent, + UID: int(instanceInfo.UID), GID: int(serviceInfo.GID), + } + + if serviceInfo.Config.Quotas.StateLimit != nil { + stateStorageParams.StateQuota = *serviceInfo.Config.Quotas.StateLimit + } + + if serviceInfo.Config.Quotas.StorageLimit != nil { + stateStorageParams.StorageQuota = *serviceInfo.Config.Quotas.StorageLimit + } + + var err error + + instanceInfo.StoragePath, instanceInfo.StatePath, err = im.storageStateProvider.Setup(stateStorageParams) + if err != nil { + return aoserrors.Wrap(err) + } + + return nil +} + +func (im *instanceManager) cacheInstance(instanceInfo InstanceInfo) error { + log.WithFields(instanceIdentLogFields(instanceInfo.InstanceIdent, nil)).Debug("Cache instance") + + if err := im.storageStateProvider.Cleanup(instanceInfo.InstanceIdent); err != nil { + return aoserrors.Wrap(err) + } + + if err := im.storage.SetInstanceCached(instanceInfo.InstanceIdent, true); err != nil { + return aoserrors.Wrap(err) + } + + return nil +} + func (im *instanceManager) acquireUID() (int, error) { uid, err := im.uidPool.GetFreeID() if err != nil { @@ -177,7 +293,7 @@ func (im *instanceManager) clearInstancesWithDeletedService() error { } for _, instance := range instances { - if _, err := im.storage.GetServiceInfo(instance.ServiceID); err == nil { + if _, err := im.imageProvider.GetServiceInfo(instance.ServiceID); err == nil { continue } diff --git a/launcher/launcher.go b/launcher/launcher.go index dc4db2ca..2cc0256e 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -58,14 +58,12 @@ type NodeRunInstanceStatus struct { type Launcher struct { sync.Mutex - config *config.Config - storage Storage - nodeInfoProvider NodeInfoProvider - nodeManager NodeManager - imageProvider ImageProvider - resourceManager ResourceManager - storageStateProvider StorageStateProvider - networkManager NetworkManager + config *config.Config + nodeInfoProvider NodeInfoProvider + nodeManager NodeManager + imageProvider ImageProvider + resourceManager ResourceManager + networkManager NetworkManager runStatusChannel chan []cloudprotocol.InstanceStatus errorStatus []cloudprotocol.InstanceStatus @@ -77,23 +75,6 @@ type Launcher struct { instanceManager *instanceManager } -type InstanceInfo struct { - aostypes.InstanceIdent - UID int - Timestamp time.Time - Cached bool -} - -// Storage storage interface. -type Storage interface { - AddInstance(instanceInfo InstanceInfo) error - RemoveInstance(instanceIdent aostypes.InstanceIdent) error - SetInstanceCached(instance aostypes.InstanceIdent, cached bool) error - GetInstanceUID(instance aostypes.InstanceIdent) (int, error) - GetInstances() ([]InstanceInfo, error) - GetServiceInfo(serviceID string) (imagemanager.ServiceInfo, error) -} - // NetworkManager network manager interface. type NetworkManager interface { PrepareInstanceNetworkParameters( @@ -155,12 +136,12 @@ func New( log.Debug("Create launcher") launcher = &Launcher{ - config: config, storage: storage, nodeInfoProvider: nodeInfoProvider, nodeManager: nodeManager, - imageProvider: imageProvider, resourceManager: resourceManager, storageStateProvider: storageStateProvider, - networkManager: networkManager, runStatusChannel: make(chan []cloudprotocol.InstanceStatus, 10), + config: config, nodeInfoProvider: nodeInfoProvider, nodeManager: nodeManager, imageProvider: imageProvider, + resourceManager: resourceManager, networkManager: networkManager, + runStatusChannel: make(chan []cloudprotocol.InstanceStatus, 10), } - if launcher.instanceManager, err = newInstanceManager(config, storage, storageStateProvider, + if launcher.instanceManager, err = newInstanceManager(config, imageProvider, storageStateProvider, storage, launcher.imageProvider.GetRemoveServiceChannel()); err != nil { return nil, err } @@ -212,6 +193,12 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo) e launcher.performNodeBalancing(instances) + // first prepare network for instance which have exposed ports + launcher.prepareNetworkForInstances(true) + + // then prepare network for rest of instances + launcher.prepareNetworkForInstances(false) + if err := launcher.networkManager.RestartDNSServer(); err != nil { log.Errorf("Can't restart DNS server: %v", err) } @@ -348,7 +335,7 @@ func (launcher *Launcher) sendCurrentStatus() { } for i := range instancesStatus { - instancesStatus[i].StateChecksum = launcher.storageStateProvider.GetInstanceCheckSum( + instancesStatus[i].StateChecksum = launcher.instanceManager.getInstanceCheckSum( instancesStatus[i].InstanceIdent) } @@ -360,30 +347,19 @@ func (launcher *Launcher) sendCurrentStatus() { func (launcher *Launcher) processRemovedInstances(newInstances []cloudprotocol.InstanceInfo) error { launcher.removeInstanceNetworkParameters(newInstances) - curInstances, err := launcher.storage.GetInstances() + curInstances, err := launcher.instanceManager.getCurrentInstances() if err != nil { return aoserrors.Wrap(err) } for _, curInstance := range curInstances { - if curInstance.Cached { - continue - } - if !slices.ContainsFunc(newInstances, func(info cloudprotocol.InstanceInfo) bool { return curInstance.ServiceID == info.ServiceID && curInstance.SubjectID == info.SubjectID && curInstance.Instance < info.NumInstances }) { - log.WithFields(instanceIdentLogFields(curInstance.InstanceIdent, nil)).Debug("Remove instance") - - if err := launcher.storageStateProvider.Cleanup(curInstance.InstanceIdent); err != nil { + if err := launcher.instanceManager.cacheInstance(curInstance); err != nil { log.WithFields(instanceIdentLogFields(curInstance.InstanceIdent, nil)).Errorf( - "Can't cleanup instance state/storage: %v", err) - } - - if err := launcher.storage.SetInstanceCached(curInstance.InstanceIdent, true); err != nil { - log.WithFields(instanceIdentLogFields(curInstance.InstanceIdent, nil)).Errorf( - "Can't mark instance as cached: %v", err) + "Can't cache instance: %v", err) } } } @@ -412,6 +388,7 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) return nil } +//nolint:gocognit func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo) { sort.Slice(instances, func(i, j int) bool { if instances[i].Priority == instances[j].Priority { @@ -460,7 +437,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc continue } - instanceInfo, err := launcher.prepareInstanceStartInfo(instance, instanceIndex, service) + instanceInfo, err := launcher.instanceManager.setupInstance(instance, instanceIndex, service) if err != nil { launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) @@ -468,23 +445,14 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc continue } - if err = node.allocateDevices(service.Config.Devices); err != nil { + if err = node.addRunRequest(instanceInfo, service, layers); err != nil { launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) continue } - - node.addRunRequest(instanceInfo, service, layers) - } } - - // first prepare network for instance which have exposed ports - launcher.prepareNetworkForInstances(true) - - // then prepare network for rest of instances - launcher.prepareNetworkForInstances(false) } func (launcher *Launcher) getServiceLayers(instance cloudprotocol.InstanceInfo) ( @@ -586,64 +554,6 @@ nextNetInstance: } } -func (launcher *Launcher) prepareInstanceStartInfo( - instance cloudprotocol.InstanceInfo, index uint64, service imagemanager.ServiceInfo, -) (aostypes.InstanceInfo, error) { - instanceInfo := aostypes.InstanceInfo{InstanceIdent: aostypes.InstanceIdent{ - ServiceID: instance.ServiceID, SubjectID: instance.SubjectID, - Instance: index, - }, Priority: instance.Priority} - - uid, err := launcher.storage.GetInstanceUID(instanceInfo.InstanceIdent) - if err != nil { - if !errors.Is(err, ErrNotExist) { - return instanceInfo, aoserrors.Wrap(err) - } - - uid, err = launcher.instanceManager.acquireUID() - if err != nil { - return instanceInfo, aoserrors.Wrap(err) - } - - if err := launcher.storage.AddInstance(InstanceInfo{ - InstanceIdent: instanceInfo.InstanceIdent, - UID: uid, - Timestamp: time.Now(), - }); err != nil { - log.Errorf("Can't store uid: %v", err) - } - } - - instanceInfo.UID = uint32(uid) - - stateStorageParams := storagestate.SetupParams{ - InstanceIdent: instanceInfo.InstanceIdent, - UID: uid, GID: int(service.GID), - } - - if service.Config.Quotas.StateLimit != nil { - stateStorageParams.StateQuota = *service.Config.Quotas.StateLimit - } - - if service.Config.Quotas.StorageLimit != nil { - stateStorageParams.StorageQuota = *service.Config.Quotas.StorageLimit - } - - instanceInfo.StoragePath, instanceInfo.StatePath, err = launcher.storageStateProvider.Setup(stateStorageParams) - if err != nil { - return instanceInfo, aoserrors.Wrap(err) - } - - if err := launcher.storage.SetInstanceCached(instanceInfo.InstanceIdent, false); err != nil { - log.WithFields(instanceIdentLogFields(instanceInfo.InstanceIdent, - nil)).Errorf("Can't mark instance as not cached: %v", err) - - return instanceInfo, aoserrors.Wrap(err) - } - - return instanceInfo, nil -} - func (launcher *Launcher) getNodesByPriorities() []*nodeHandler { nodes := maps.Values(launcher.nodes) diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 60f38148..2fa03f8b 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -112,7 +112,6 @@ type testResourceManager struct { type testStorage struct { instanceInfo map[aostypes.InstanceIdent]*launcher.InstanceInfo - services map[string][]imagemanager.ServiceInfo } type testStateStorage struct { @@ -153,7 +152,7 @@ func TestInstancesWithRemovedServiceInfoAreRemovedOnStart(t *testing.T) { } nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() - imageManager = &testImageProvider{} + imageManager = newTestImageProvider() testStorage = newTestStorage() ) @@ -191,7 +190,7 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { } nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() - imageManager = &testImageProvider{} + imageManager = newTestImageProvider() testStorage = newTestStorage() testStateStorage = &testStateStorage{} ) @@ -215,11 +214,13 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { } // add a service to the storage - testStorage.services[service1] = make([]imagemanager.ServiceInfo, 1) - testStorage.services[service1][0].ServiceInfo.ServiceID = service1 - testStorage.services[service2] = make([]imagemanager.ServiceInfo, 1) - testStorage.services[service2][0].ServiceInfo.ServiceID = service2 + imageManager.services[service1] = imagemanager.ServiceInfo{ + ServiceInfo: createServiceInfo(service1, 0, ""), + } + imageManager.services[service2] = imagemanager.ServiceInfo{ + ServiceInfo: createServiceInfo(service2, 0, ""), + } launcherInstance, err := launcher.New(cfg, testStorage, nodeInfoProvider, nodeManager, imageManager, &testResourceManager{}, testStateStorage, newTestNetworkManager("")) @@ -273,10 +274,6 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { t.Fatalf("Can't add instance %v", err) } - // add a service to the storage - testStorage.services[service1] = make([]imagemanager.ServiceInfo, 1) - testStorage.services[service1][0].ServiceInfo.ServiceID = service1 - launcherInstance, err := launcher.New(cfg, testStorage, nodeInfoProvider, nodeManager, testImageManager, &testResourceManager{}, testStateStorage, newTestNetworkManager("")) if err != nil { @@ -284,8 +281,6 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { } defer launcherInstance.Close() - defer testImageManager.close() - testImageManager.removeServiceInstancesChannel <- service1 instancesWereRemoved := false @@ -337,7 +332,7 @@ func TestInitialStatus(t *testing.T) { nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() expectedRunStatus = []cloudprotocol.InstanceStatus{} - imageManager = &testImageProvider{} + imageManager = newTestImageProvider() ) for _, id := range nodeIDs { @@ -391,7 +386,7 @@ func TestBalancing(t *testing.T) { nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} + imageManager = newTestImageProvider() ) nodeInfoProvider.nodeInfo = map[string]cloudprotocol.NodeInfo{ @@ -887,7 +882,7 @@ func TestStorageCleanup(t *testing.T) { nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() resourceManager = newTestResourceManager() - imageManager = &testImageProvider{} + imageManager = newTestImageProvider() stateStorageProvider = &testStateStorage{} ) @@ -1165,7 +1160,6 @@ func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType strin func newTestStorage() *testStorage { return &testStorage{ instanceInfo: make(map[aostypes.InstanceIdent]*launcher.InstanceInfo), - services: make(map[string][]imagemanager.ServiceInfo), } } @@ -1219,15 +1213,6 @@ func (storage *testStorage) SetInstanceCached(instance aostypes.InstanceIdent, c return nil } -func (storage *testStorage) GetServiceInfo(serviceID string) (imagemanager.ServiceInfo, error) { - services, ok := storage.services[serviceID] - if !ok { - return imagemanager.ServiceInfo{}, imagemanager.ErrNotExist - } - - return services[len(services)-1], nil -} - // testStateStorage func (provider *testStateStorage) Setup( @@ -1262,10 +1247,6 @@ func newTestImageProvider() *testImageProvider { } } -func (testProvider *testImageProvider) close() { - close(testProvider.removeServiceInstancesChannel) -} - func (testProvider *testImageProvider) GetServiceInfo(serviceID string) (imagemanager.ServiceInfo, error) { if service, ok := testProvider.services[serviceID]; ok { return service, nil diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 0f4de470..d96cb365 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -119,13 +119,17 @@ func (node *nodeHandler) nodeHasDesiredDevices(desiredDevices []aostypes.Service return true } -func (node *nodeHandler) addRunRequest( - instance aostypes.InstanceInfo, service imagemanager.ServiceInfo, layers []imagemanager.LayerInfo, -) { +func (node *nodeHandler) addRunRequest(instanceInfo aostypes.InstanceInfo, service imagemanager.ServiceInfo, + layers []imagemanager.LayerInfo, +) error { log.WithFields(instanceIdentLogFields( - instance.InstanceIdent, log.Fields{"node": node.nodeInfo.NodeID})).Debug("Schedule instance on node") + instanceInfo.InstanceIdent, log.Fields{"node": node.nodeInfo.NodeID})).Debug("Schedule instance on node") - node.runRequest.Instances = append(node.runRequest.Instances, instance) + if err := node.allocateDevices(service.Config.Devices); err != nil { + return err + } + + node.runRequest.Instances = append(node.runRequest.Instances, instanceInfo) serviceInfo := service.ServiceInfo @@ -170,6 +174,8 @@ layerLoopLabel: node.runRequest.Layers = append(node.runRequest.Layers, newLayer) } + + return nil } func getNodesByStaticResources(allNodes []*nodeHandler, From 4c878bd283e0d7bf7efad57d0dfd71b9209b8888 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 29 Jul 2024 13:39:04 +0300 Subject: [PATCH 109/146] [launcher] Implement instance balancing according to policy Signed-off-by: Oleksandr Grytsov --- launcher/instancemanager.go | 103 ++++++++++++++++++++++--- launcher/launcher.go | 148 +++++++++++++++++++++++------------- launcher/launcher_test.go | 88 +++++++++++---------- 3 files changed, 236 insertions(+), 103 deletions(-) diff --git a/launcher/instancemanager.go b/launcher/instancemanager.go index e89749cc..8a5db564 100644 --- a/launcher/instancemanager.go +++ b/launcher/instancemanager.go @@ -27,6 +27,7 @@ import ( "github.com/aosedge/aos_common/aostypes" "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" + "golang.org/x/exp/maps" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/imagemanager" @@ -46,6 +47,7 @@ const removePeriod = time.Hour * 24 type InstanceInfo struct { aostypes.InstanceIdent + NodeID string UID int Timestamp time.Time Cached bool @@ -54,9 +56,9 @@ type InstanceInfo struct { // Storage storage interface. type Storage interface { AddInstance(instanceInfo InstanceInfo) error + UpdateInstance(instanceInfo InstanceInfo) error RemoveInstance(instanceIdent aostypes.InstanceIdent) error - SetInstanceCached(instance aostypes.InstanceIdent, cached bool) error - GetInstanceUID(instance aostypes.InstanceIdent) (int, error) + GetInstance(instanceIdent aostypes.InstanceIdent) (InstanceInfo, error) GetInstances() ([]InstanceInfo, error) } @@ -67,6 +69,8 @@ type instanceManager struct { storage Storage cancelFunc context.CancelFunc uidPool *uidgidpool.IdentifierPool + errorStatus map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus + instances map[aostypes.InstanceIdent]aostypes.InstanceInfo removeServiceChannel <-chan string } @@ -113,6 +117,11 @@ func newInstanceManager(config *config.Config, imageProvider ImageProvider, stor return im, nil } +func (im *instanceManager) initInstances() { + im.instances = make(map[aostypes.InstanceIdent]aostypes.InstanceInfo) + im.errorStatus = make(map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus) +} + func (im *instanceManager) getCurrentInstances() ([]InstanceInfo, error) { instances, err := im.storage.GetInstances() if err != nil { @@ -125,7 +134,7 @@ func (im *instanceManager) getCurrentInstances() ([]InstanceInfo, error) { } func (im *instanceManager) setupInstance( - instance cloudprotocol.InstanceInfo, index uint64, service imagemanager.ServiceInfo, + instance cloudprotocol.InstanceInfo, index uint64, nodeID string, service imagemanager.ServiceInfo, ) (aostypes.InstanceInfo, error) { instanceInfo := aostypes.InstanceInfo{ InstanceIdent: aostypes.InstanceIdent{ @@ -134,35 +143,98 @@ func (im *instanceManager) setupInstance( Priority: instance.Priority, } - uid, err := im.storage.GetInstanceUID(instanceInfo.InstanceIdent) + if _, ok := im.instances[instanceInfo.InstanceIdent]; ok { + return aostypes.InstanceInfo{}, aoserrors.Errorf("instance already set up") + } + + storedInstance, err := im.storage.GetInstance(instanceInfo.InstanceIdent) if err != nil { if !errors.Is(err, ErrNotExist) { return aostypes.InstanceInfo{}, aoserrors.Wrap(err) } - uid, err = im.acquireUID() + uid, err := im.acquireUID() if err != nil { return aostypes.InstanceInfo{}, err } - if err := im.storage.AddInstance(InstanceInfo{ + storedInstance = InstanceInfo{ InstanceIdent: instanceInfo.InstanceIdent, + NodeID: nodeID, UID: uid, Timestamp: time.Now(), - }); err != nil { - log.Errorf("Can't store uid: %v", err) + } + + if err := im.storage.AddInstance(storedInstance); err != nil { + log.Errorf("Can't add instance: %v", err) + } + } else { + storedInstance.NodeID = nodeID + storedInstance.Timestamp = time.Now() + storedInstance.Cached = false + + err = im.storage.UpdateInstance(storedInstance) + if err != nil { + log.Errorf("Can't update instance: %v", err) } } - instanceInfo.UID = uint32(uid) + instanceInfo.UID = uint32(storedInstance.UID) if err = im.setupInstanceStateStorage(&instanceInfo, service); err != nil { return aostypes.InstanceInfo{}, err } + im.instances[instanceInfo.InstanceIdent] = instanceInfo + return instanceInfo, nil } +func createInstanceIdent(instance cloudprotocol.InstanceInfo, instanceIndex uint64) aostypes.InstanceIdent { + return aostypes.InstanceIdent{ + ServiceID: instance.ServiceID, SubjectID: instance.SubjectID, Instance: instanceIndex, + } +} + +func (im *instanceManager) setInstanceError( + instanceIdent aostypes.InstanceIdent, serviceVersion string, err error, +) { + instanceStatus := cloudprotocol.InstanceStatus{ + InstanceIdent: instanceIdent, + ServiceVersion: serviceVersion, + Status: cloudprotocol.InstanceStateFailed, + } + + if err != nil { + log.WithFields(instanceIdentLogFields(instanceStatus.InstanceIdent, nil)).Errorf( + "Schedule instance error: %v", err) + + instanceStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: err.Error()} + } + + im.errorStatus[instanceStatus.InstanceIdent] = instanceStatus +} + +func (im *instanceManager) setAllInstanceError( + instance cloudprotocol.InstanceInfo, serviceVersion string, err error, +) { + for i := uint64(0); i < instance.NumInstances; i++ { + im.setInstanceError(createInstanceIdent(instance, i), serviceVersion, err) + } +} + +func (im *instanceManager) isInstanceScheduled(instanceIdent aostypes.InstanceIdent) bool { + if _, ok := im.instances[instanceIdent]; ok { + return true + } + + if _, ok := im.errorStatus[instanceIdent]; ok { + return true + } + + return false +} + func (im *instanceManager) getInstanceCheckSum(instance aostypes.InstanceIdent) string { return im.storageStateProvider.GetInstanceCheckSum(instance) } @@ -196,11 +268,14 @@ func (im *instanceManager) setupInstanceStateStorage( func (im *instanceManager) cacheInstance(instanceInfo InstanceInfo) error { log.WithFields(instanceIdentLogFields(instanceInfo.InstanceIdent, nil)).Debug("Cache instance") - if err := im.storageStateProvider.Cleanup(instanceInfo.InstanceIdent); err != nil { - return aoserrors.Wrap(err) + instanceInfo.Cached = true + instanceInfo.NodeID = "" + + if err := im.storage.UpdateInstance(instanceInfo); err != nil { + log.Errorf("Can't update instance: %v", err) } - if err := im.storage.SetInstanceCached(instanceInfo.InstanceIdent, true); err != nil { + if err := im.storageStateProvider.Cleanup(instanceInfo.InstanceIdent); err != nil { return aoserrors.Wrap(err) } @@ -305,6 +380,10 @@ func (im *instanceManager) clearInstancesWithDeletedService() error { return nil } +func (im *instanceManager) getErrorInstanceStatuses() []cloudprotocol.InstanceStatus { + return maps.Values(im.errorStatus) +} + func (im *instanceManager) instanceRemover(ctx context.Context) { removeTicker := time.NewTicker(removePeriod) defer removeTicker.Stop() diff --git a/launcher/launcher.go b/launcher/launcher.go index 2cc0256e..a420e1ba 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -66,7 +66,6 @@ type Launcher struct { networkManager NetworkManager runStatusChannel chan []cloudprotocol.InstanceStatus - errorStatus []cloudprotocol.InstanceStatus nodes map[string]*nodeHandler cancelFunc context.CancelFunc @@ -173,7 +172,7 @@ func (launcher *Launcher) Close() { } // RunInstances performs run service instances. -func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo) error { +func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, rebalancing bool) error { launcher.Lock() defer launcher.Unlock() @@ -183,6 +182,8 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo) e log.Errorf("Can't init nodes: %v", err) } + launcher.instanceManager.initInstances() + if err := launcher.processRemovedInstances(instances); err != nil { log.Errorf("Can't process removed instances: %v", err) } @@ -191,6 +192,10 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo) e log.Errorf("Can't update networks: %v", err) } + if rebalancing { + launcher.performPolicyBalancing(instances) + } + launcher.performNodeBalancing(instances) // first prepare network for instance which have exposed ports @@ -339,9 +344,8 @@ func (launcher *Launcher) sendCurrentStatus() { instancesStatus[i].InstanceIdent) } - instancesStatus = append(instancesStatus, launcher.errorStatus...) + instancesStatus = append(instancesStatus, launcher.instanceManager.getErrorInstanceStatuses()...) launcher.runStatusChannel <- instancesStatus - launcher.errorStatus = nil } func (launcher *Launcher) processRemovedInstances(newInstances []cloudprotocol.InstanceInfo) error { @@ -388,7 +392,75 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) return nil } -//nolint:gocognit +func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.InstanceInfo) { + curInstances, err := launcher.instanceManager.getCurrentInstances() + if err != nil { + log.Errorf("Can't get current instances: %v", err) + return + } + + for _, instance := range instances { + log.WithFields(log.Fields{ + "serviceID": instance.ServiceID, + "subjectID": instance.SubjectID, + "numInstances": instance.NumInstances, + "priority": instance.Priority, + }).Debug("Check balancing policy") + + service, layers, err := launcher.getServiceLayers(instance) + if err != nil { + launcher.instanceManager.setAllInstanceError(instance, service.Version, err) + + continue + } + + if service.Config.BalancingPolicy != aostypes.BalancingDisabled { + continue + } + + for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { + curIndex := slices.IndexFunc(curInstances, func(curInstance InstanceInfo) bool { + return curInstance.ServiceID == instance.ServiceID && + curInstance.SubjectID == instance.SubjectID && + curInstance.Instance == instanceIndex + }) + + if curIndex == -1 { + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), + service.Version, aoserrors.Errorf("instance not found")) + + continue + } + + node := launcher.getNode(curInstances[curIndex].NodeID) + if node == nil { + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), + service.Version, aoserrors.Errorf("node not found")) + + continue + } + + instanceInfo, err := launcher.instanceManager.setupInstance( + instance, instanceIndex, node.nodeInfo.NodeID, service) + if err != nil { + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), service.Version, err) + + continue + } + + if err = node.addRunRequest(instanceInfo, service, layers); err != nil { + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), service.Version, err) + + continue + } + } + } +} + func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo) { sort.Slice(instances, func(i, j int) bool { if instances[i].Priority == instances[j].Priority { @@ -408,47 +480,39 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc service, layers, err := launcher.getServiceLayers(instance) if err != nil { - for i := uint64(0); i < instance.NumInstances; i++ { - launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus( - instance.ServiceID, instance.SubjectID, i, service.Version, - cloudprotocol.InstanceStateFailed, err)) - } - + launcher.instanceManager.setAllInstanceError(instance, service.Version, err) continue } nodes, err := getNodesByStaticResources(launcher.getNodesByPriorities(), service, instance) if err != nil { - for i := uint64(0); i < instance.NumInstances; i++ { - launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus( - instance.ServiceID, instance.SubjectID, i, service.Version, - cloudprotocol.InstanceStateFailed, err)) - } - + launcher.instanceManager.setAllInstanceError(instance, service.Version, err) continue } for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { + if launcher.instanceManager.isInstanceScheduled(createInstanceIdent(instance, instanceIndex)) { + continue + } + node, err := getInstanceNode(service, nodes) if err != nil { - launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, - instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) - + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), service.Version, err) continue } - instanceInfo, err := launcher.instanceManager.setupInstance(instance, instanceIndex, service) + instanceInfo, err := launcher.instanceManager.setupInstance( + instance, instanceIndex, node.nodeInfo.NodeID, service) if err != nil { - launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, - instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) - + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), service.Version, err) continue } if err = node.addRunRequest(instanceInfo, service, layers); err != nil { - launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus(instance.ServiceID, instance.SubjectID, - instanceIndex, service.Version, cloudprotocol.InstanceStateFailed, err)) - + launcher.instanceManager.setInstanceError( + createInstanceIdent(instance, instanceIndex), service.Version, err) continue } } @@ -478,12 +542,16 @@ func (launcher *Launcher) getServiceLayers(instance cloudprotocol.InstanceInfo) func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) { for _, node := range launcher.getNodesByPriorities() { for i, instance := range node.runRequest.Instances { + serviceVersion := "" + if err := func() error { serviceInfo, err := launcher.imageProvider.GetServiceInfo(instance.ServiceID) if err != nil { return aoserrors.Wrap(err) } + serviceVersion = serviceInfo.Version + if onlyExposedPorts && len(serviceInfo.ExposedPorts) == 0 { return nil } @@ -498,8 +566,7 @@ func (launcher *Launcher) prepareNetworkForInstances(onlyExposedPorts bool) { return nil }(); err != nil { - launcher.errorStatus = append(launcher.errorStatus, createInstanceStatus( - instance.ServiceID, instance.SubjectID, 0, "", cloudprotocol.InstanceStateFailed, err)) + launcher.instanceManager.setInstanceError(instance.InstanceIdent, serviceVersion, err) } } } @@ -568,29 +635,6 @@ func (launcher *Launcher) getNodesByPriorities() []*nodeHandler { return nodes } -func createInstanceStatus( - serviceID, subjectID string, instance uint64, serviceVersion, status string, err error, -) cloudprotocol.InstanceStatus { - instanceStatus := cloudprotocol.InstanceStatus{ - InstanceIdent: aostypes.InstanceIdent{ - ServiceID: serviceID, - SubjectID: subjectID, - Instance: instance, - }, - ServiceVersion: serviceVersion, - Status: status, - } - - if err != nil { - log.WithFields(instanceIdentLogFields(instanceStatus.InstanceIdent, nil)).Errorf( - "Can't schedule instance: %v", err) - - instanceStatus.ErrorInfo = &cloudprotocol.ErrorInfo{Message: err.Error()} - } - - return instanceStatus -} - func (launcher *Launcher) getNode(nodeID string) *nodeHandler { node, ok := launcher.nodes[nodeID] if !ok { diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 2fa03f8b..3cfd0831 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -107,7 +107,7 @@ type testImageProvider struct { } type testResourceManager struct { - nodeResources map[string]cloudprotocol.NodeConfig + nodeConfigs map[string]cloudprotocol.NodeConfig } type testStorage struct { @@ -153,7 +153,7 @@ func TestInstancesWithRemovedServiceInfoAreRemovedOnStart(t *testing.T) { nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() imageManager = newTestImageProvider() - testStorage = newTestStorage() + testStorage = newTestStorage(nil) ) err := testStorage.AddInstance(launcher.InstanceInfo{ @@ -191,7 +191,7 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() imageManager = newTestImageProvider() - testStorage = newTestStorage() + testStorage = newTestStorage(nil) testStateStorage = &testStateStorage{} ) @@ -262,7 +262,7 @@ func TestInstancesAreRemovedViaChannel(t *testing.T) { nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) nodeManager = newTestNodeManager() testImageManager = newTestImageProvider() - testStorage = newTestStorage() + testStorage = newTestStorage(nil) testStateStorage = &testStateStorage{} ) @@ -351,7 +351,7 @@ func TestInitialStatus(t *testing.T) { nodeInfoProvider.nodeInfo[id] = nodeInfo } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + launcherInstance, err := launcher.New(cfg, newTestStorage(nil), nodeInfoProvider, nodeManager, imageManager, &testResourceManager{}, &testStateStorage{}, newTestNetworkManager("")) if err != nil { t.Fatalf("Can't create launcher %v", err) @@ -441,18 +441,20 @@ func TestBalancing(t *testing.T) { } type testData struct { - nodeResources map[string]cloudprotocol.NodeConfig + nodeConfigs map[string]cloudprotocol.NodeConfig serviceConfigs map[string]aostypes.ServiceConfig desiredInstances []cloudprotocol.InstanceInfo + storedInstances []launcher.InstanceInfo expectedRunRequests map[string]runRequest expectedRunStatus []cloudprotocol.InstanceStatus + rebalancing bool } testItems := []testData{ // Check node priority and runner: all service instances should be start on higher priority node according to // supported runner { - nodeResources: map[string]cloudprotocol.NodeConfig{ + nodeConfigs: map[string]cloudprotocol.NodeConfig{ nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, @@ -538,7 +540,7 @@ func TestBalancing(t *testing.T) { }, // Check labels: label low priority service to run on high priority node { - nodeResources: map[string]cloudprotocol.NodeConfig{ + nodeConfigs: map[string]cloudprotocol.NodeConfig{ nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Labels: []string{"label1"}}, nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}}, nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, @@ -615,7 +617,7 @@ func TestBalancing(t *testing.T) { }, // Check available resources { - nodeResources: map[string]cloudprotocol.NodeConfig{ + nodeConfigs: map[string]cloudprotocol.NodeConfig{ nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Resources: []cloudprotocol.ResourceInfo{ {Name: "resource1"}, {Name: "resource3"}, @@ -701,7 +703,7 @@ func TestBalancing(t *testing.T) { }, // Check available devices { - nodeResources: map[string]cloudprotocol.NodeConfig{ + nodeConfigs: map[string]cloudprotocol.NodeConfig{ nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Devices: []cloudprotocol.DeviceInfo{ {Name: "dev1", SharedCount: 1}, {Name: "dev2", SharedCount: 2}, @@ -826,7 +828,7 @@ func TestBalancing(t *testing.T) { } for _, testItem := range testItems { - resourceManager.nodeResources = testItem.nodeResources + resourceManager.nodeConfigs = testItem.nodeConfigs for serviceID, config := range testItem.serviceConfigs { service := imageManager.services[serviceID] @@ -834,7 +836,9 @@ func TestBalancing(t *testing.T) { imageManager.services[serviceID] = service } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + storage := newTestStorage(testItem.storedInstances) + + launcherInstance, err := launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) @@ -855,7 +859,7 @@ func TestBalancing(t *testing.T) { // Run instances - if err := launcherInstance.RunInstances(testItem.desiredInstances); err != nil { + if err := launcherInstance.RunInstances(testItem.desiredInstances, testItem.rebalancing); err != nil { t.Fatalf("Can't run instances %v", err) } @@ -891,14 +895,14 @@ func TestStorageCleanup(t *testing.T) { Status: cloudprotocol.NodeStatusProvisioned, Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, } - resourceManager.nodeResources[nodeTypeLocalSM] = cloudprotocol.NodeConfig{Priority: 100} + resourceManager.nodeConfigs[nodeTypeLocalSM] = cloudprotocol.NodeConfig{Priority: 100} nodeInfoProvider.nodeInfo[nodeIDRunxSM] = cloudprotocol.NodeInfo{ NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM, Status: cloudprotocol.NodeStatusProvisioned, Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, } - resourceManager.nodeResources[nodeTypeRunxSM] = cloudprotocol.NodeConfig{Priority: 0} + resourceManager.nodeConfigs[nodeTypeRunxSM] = cloudprotocol.NodeConfig{Priority: 0} imageManager.services = map[string]imagemanager.ServiceInfo{ service1: { @@ -915,7 +919,7 @@ func TestStorageCleanup(t *testing.T) { }, } - launcherInstance, err := launcher.New(cfg, newTestStorage(), nodeInfoProvider, nodeManager, imageManager, + launcherInstance, err := launcher.New(cfg, newTestStorage(nil), nodeInfoProvider, nodeManager, imageManager, resourceManager, stateStorageProvider, newTestNetworkManager("172.17.0.1/16")) if err != nil { t.Fatalf("Can't create launcher %v", err) @@ -939,7 +943,7 @@ func TestStorageCleanup(t *testing.T) { {ServiceID: service3, SubjectID: subject1, Priority: 100, NumInstances: 1}, } - if err := launcherInstance.RunInstances(desiredInstances); err != nil { + if err := launcherInstance.RunInstances(desiredInstances, false); err != nil { t.Fatalf("Can't run instances %v", err) } @@ -1014,7 +1018,7 @@ func TestStorageCleanup(t *testing.T) { {ServiceID: service3, SubjectID: subject1, Instance: 0}, } - if err := launcherInstance.RunInstances(desiredInstances); err != nil { + if err := launcherInstance.RunInstances(desiredInstances, false); err != nil { t.Fatalf("Can't run instances %v", err) } @@ -1023,8 +1027,8 @@ func TestStorageCleanup(t *testing.T) { t.Errorf("Incorrect run status: %v", err) } - if !reflect.DeepEqual(expectedCleanInstances, stateStorageProvider.cleanedInstances) { - t.Errorf("Incorrect state storage cleanup: %v", stateStorageProvider.cleanedInstances) + if err := deepSlicesCompare(expectedCleanInstances, stateStorageProvider.cleanedInstances); err != nil { + t.Errorf("Incorrect state storage cleanup: %v", err) } } @@ -1142,14 +1146,14 @@ func (nodeManager *testNodeManager) compareRunRequests(expectedRunRequests map[s func newTestResourceManager() *testResourceManager { resourceManager := &testResourceManager{ - nodeResources: make(map[string]cloudprotocol.NodeConfig), + nodeConfigs: make(map[string]cloudprotocol.NodeConfig), } return resourceManager } func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType string) (cloudprotocol.NodeConfig, error) { - resource := resourceManager.nodeResources[nodeType] + resource := resourceManager.nodeConfigs[nodeType] resource.NodeType = nodeType return resource, nil @@ -1157,10 +1161,17 @@ func (resourceManager *testResourceManager) GetNodeConfig(nodeID, nodeType strin // testStorage -func newTestStorage() *testStorage { - return &testStorage{ +func newTestStorage(instances []launcher.InstanceInfo) *testStorage { + storage := &testStorage{ instanceInfo: make(map[aostypes.InstanceIdent]*launcher.InstanceInfo), } + + for _, instance := range instances { + storage.instanceInfo[instance.InstanceIdent] = &launcher.InstanceInfo{} + *storage.instanceInfo[instance.InstanceIdent] = instance + } + + return storage } func (storage *testStorage) AddInstance(instanceInfo launcher.InstanceInfo) error { @@ -1173,13 +1184,23 @@ func (storage *testStorage) AddInstance(instanceInfo launcher.InstanceInfo) erro return nil } -func (storage *testStorage) GetInstanceUID(instance aostypes.InstanceIdent) (int, error) { - instanceInfo, ok := storage.instanceInfo[instance] +func (storage *testStorage) UpdateInstance(instanceInfo launcher.InstanceInfo) error { + if _, ok := storage.instanceInfo[instanceInfo.InstanceIdent]; !ok { + return launcher.ErrNotExist + } + + storage.instanceInfo[instanceInfo.InstanceIdent] = &instanceInfo + + return nil +} + +func (storage *testStorage) GetInstance(instanceIdent aostypes.InstanceIdent) (launcher.InstanceInfo, error) { + instanceInfo, ok := storage.instanceInfo[instanceIdent] if !ok { - return 0, launcher.ErrNotExist + return launcher.InstanceInfo{}, launcher.ErrNotExist } - return instanceInfo.UID, nil + return *instanceInfo, nil } func (storage *testStorage) GetInstances() ([]launcher.InstanceInfo, error) { @@ -1202,17 +1223,6 @@ func (storage *testStorage) RemoveInstance(instanceIdent aostypes.InstanceIdent) return nil } -func (storage *testStorage) SetInstanceCached(instance aostypes.InstanceIdent, cached bool) error { - instanceInfo, ok := storage.instanceInfo[instance] - if !ok { - return launcher.ErrNotExist - } - - instanceInfo.Cached = cached - - return nil -} - // testStateStorage func (provider *testStateStorage) Setup( From 5dc3e32d5f4b6f7f696c3794f93ac95e5c09c842 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 29 Jul 2024 16:39:45 +0300 Subject: [PATCH 110/146] [launcher] Add state/storage size calculation for instance scheduling Signed-off-by: Oleksandr Grytsov --- launcher/instancemanager.go | 47 +- launcher/launcher.go | 54 ++- launcher/launcher_test.go | 927 +++++++++++++++++++++--------------- launcher/nodehandler.go | 12 + 4 files changed, 636 insertions(+), 404 deletions(-) diff --git a/launcher/instancemanager.go b/launcher/instancemanager.go index 8a5db564..a28a24a0 100644 --- a/launcher/instancemanager.go +++ b/launcher/instancemanager.go @@ -63,15 +63,16 @@ type Storage interface { } type instanceManager struct { - config *config.Config - imageProvider ImageProvider - storageStateProvider StorageStateProvider - storage Storage - cancelFunc context.CancelFunc - uidPool *uidgidpool.IdentifierPool - errorStatus map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus - instances map[aostypes.InstanceIdent]aostypes.InstanceInfo - removeServiceChannel <-chan string + config *config.Config + imageProvider ImageProvider + storageStateProvider StorageStateProvider + storage Storage + cancelFunc context.CancelFunc + uidPool *uidgidpool.IdentifierPool + errorStatus map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus + instances map[aostypes.InstanceIdent]aostypes.InstanceInfo + removeServiceChannel <-chan string + availableStorage, availableState uint64 } /*********************************************************************************************************************** @@ -122,6 +123,10 @@ func (im *instanceManager) initInstances() { im.errorStatus = make(map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus) } +func (im *instanceManager) resetStorageStateUsage(storageSize, stateSize uint64) { + im.availableStorage, im.availableState = storageSize, stateSize +} + func (im *instanceManager) getCurrentInstances() ([]InstanceInfo, error) { instances, err := im.storage.GetInstances() if err != nil { @@ -134,7 +139,7 @@ func (im *instanceManager) getCurrentInstances() ([]InstanceInfo, error) { } func (im *instanceManager) setupInstance( - instance cloudprotocol.InstanceInfo, index uint64, nodeID string, service imagemanager.ServiceInfo, + instance cloudprotocol.InstanceInfo, index uint64, node *nodeHandler, service imagemanager.ServiceInfo, ) (aostypes.InstanceInfo, error) { instanceInfo := aostypes.InstanceInfo{ InstanceIdent: aostypes.InstanceIdent{ @@ -160,7 +165,7 @@ func (im *instanceManager) setupInstance( storedInstance = InstanceInfo{ InstanceIdent: instanceInfo.InstanceIdent, - NodeID: nodeID, + NodeID: node.nodeInfo.NodeID, UID: uid, Timestamp: time.Now(), } @@ -169,7 +174,7 @@ func (im *instanceManager) setupInstance( log.Errorf("Can't add instance: %v", err) } } else { - storedInstance.NodeID = nodeID + storedInstance.NodeID = node.nodeInfo.NodeID storedInstance.Timestamp = time.Now() storedInstance.Cached = false @@ -181,7 +186,8 @@ func (im *instanceManager) setupInstance( instanceInfo.UID = uint32(storedInstance.UID) - if err = im.setupInstanceStateStorage(&instanceInfo, service); err != nil { + if err = im.setupInstanceStateStorage(&instanceInfo, service, + getStorageRequestRatio(service.Config.ResourceRatios, node.nodeConfig.ResourceRatios)); err != nil { return aostypes.InstanceInfo{}, err } @@ -241,6 +247,7 @@ func (im *instanceManager) getInstanceCheckSum(instance aostypes.InstanceIdent) func (im *instanceManager) setupInstanceStateStorage( instanceInfo *aostypes.InstanceInfo, serviceInfo imagemanager.ServiceInfo, + requestRation float64, ) error { stateStorageParams := storagestate.SetupParams{ InstanceIdent: instanceInfo.InstanceIdent, @@ -255,6 +262,17 @@ func (im *instanceManager) setupInstanceStateStorage( stateStorageParams.StorageQuota = *serviceInfo.Config.Quotas.StorageLimit } + requestedStorage := uint64(float64(stateStorageParams.StorageQuota)*requestRation + 0.5) + requestedState := uint64(float64(stateStorageParams.StateQuota)*requestRation + 0.5) + + if requestedStorage > im.availableStorage { + return aoserrors.Errorf("not enough storage space") + } + + if requestedState > im.availableState { + return aoserrors.Errorf("not enough state space") + } + var err error instanceInfo.StoragePath, instanceInfo.StatePath, err = im.storageStateProvider.Setup(stateStorageParams) @@ -262,6 +280,9 @@ func (im *instanceManager) setupInstanceStateStorage( return aoserrors.Wrap(err) } + im.availableStorage -= requestedStorage + im.availableState -= requestedState + return nil } diff --git a/launcher/launcher.go b/launcher/launcher.go index a420e1ba..60be4b6a 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -43,6 +43,8 @@ import ( var ErrNotExist = errors.New("entry not exist") +const defaultResourceRation = 50.0 + /*********************************************************************************************************************** * Types **********************************************************************************************************************/ @@ -178,11 +180,7 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, r log.Debug("Run instances") - if err := launcher.initNodes(); err != nil { - log.Errorf("Can't init nodes: %v", err) - } - - launcher.instanceManager.initInstances() + launcher.prepareBalancing() if err := launcher.processRemovedInstances(instances); err != nil { log.Errorf("Can't process removed instances: %v", err) @@ -220,6 +218,24 @@ func (launcher *Launcher) GetRunStatusesChannel() <-chan []cloudprotocol.Instanc * Private **********************************************************************************************************************/ +func (launcher *Launcher) prepareBalancing() { + if err := launcher.initNodes(); err != nil { + log.Errorf("Can't init nodes: %v", err) + } + + launcher.instanceManager.initInstances() + + localNode := launcher.getLocalNode() + + if localNode != nil { + launcher.instanceManager.resetStorageStateUsage( + localNode.getPartitionSize(aostypes.StoragesPartition), + localNode.getPartitionSize(aostypes.StatesPartition)) + } else { + log.Errorf("Local node not found") + } +} + func (launcher *Launcher) initNodes() error { launcher.nodes = make(map[string]*nodeHandler) @@ -443,7 +459,7 @@ func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.Insta } instanceInfo, err := launcher.instanceManager.setupInstance( - instance, instanceIndex, node.nodeInfo.NodeID, service) + instance, instanceIndex, node, service) if err != nil { launcher.instanceManager.setInstanceError( createInstanceIdent(instance, instanceIndex), service.Version, err) @@ -503,7 +519,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc } instanceInfo, err := launcher.instanceManager.setupInstance( - instance, instanceIndex, node.nodeInfo.NodeID, service) + instance, instanceIndex, node, service) if err != nil { launcher.instanceManager.setInstanceError( createInstanceIdent(instance, instanceIndex), service.Version, err) @@ -644,6 +660,16 @@ func (launcher *Launcher) getNode(nodeID string) *nodeHandler { return node } +func (launcher *Launcher) getLocalNode() *nodeHandler { + for _, node := range launcher.nodes { + if node.isLocalNode { + return node + } + } + + return nil +} + func (launcher *Launcher) getLayersForService(digests []string) ([]imagemanager.LayerInfo, error) { layers := make([]imagemanager.LayerInfo, len(digests)) @@ -659,6 +685,20 @@ func (launcher *Launcher) getLayersForService(digests []string) ([]imagemanager. return layers, nil } +func getStorageRequestRatio( + serviceRatios *aostypes.ResourceRatiosInfo, nodeRatios *aostypes.ResourceRatiosInfo, +) float64 { + if serviceRatios != nil && serviceRatios.Storage != nil { + return float64(*serviceRatios.Storage) / 100 + } + + if nodeRatios != nil && nodeRatios.Storage != nil { + return float64(*nodeRatios.Storage) / 100 + } + + return defaultResourceRation / 100 +} + func instanceIdentLogFields(instance aostypes.InstanceIdent, extraFields log.Fields) log.Fields { logFields := log.Fields{ "serviceID": instance.ServiceID, diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 3cfd0831..d6077f4b 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -125,6 +125,17 @@ type testNetworkManager struct { networkInfo map[string]map[aostypes.InstanceIdent]struct{} } +type testData struct { + testCaseName string + nodeConfigs map[string]cloudprotocol.NodeConfig + serviceConfigs map[string]aostypes.ServiceConfig + desiredInstances []cloudprotocol.InstanceInfo + storedInstances []launcher.InstanceInfo + expectedRunRequests map[string]runRequest + expectedRunStatus []cloudprotocol.InstanceStatus + rebalancing bool +} + /*********************************************************************************************************************** * Init **********************************************************************************************************************/ @@ -394,6 +405,10 @@ func TestBalancing(t *testing.T) { NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, Status: cloudprotocol.NodeStatusProvisioned, Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Partitions: []cloudprotocol.PartitionInfo{ + {Name: "storages", Types: []string{aostypes.StoragesPartition}, TotalSize: 1024}, + {Name: "states", Types: []string{aostypes.StatesPartition}, TotalSize: 1024}, + }, }, nodeIDRemoteSM1: { NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, @@ -440,394 +455,18 @@ func TestBalancing(t *testing.T) { }, } - type testData struct { - nodeConfigs map[string]cloudprotocol.NodeConfig - serviceConfigs map[string]aostypes.ServiceConfig - desiredInstances []cloudprotocol.InstanceInfo - storedInstances []launcher.InstanceInfo - expectedRunRequests map[string]runRequest - expectedRunStatus []cloudprotocol.InstanceStatus - rebalancing bool - } - testItems := []testData{ - // Check node priority and runner: all service instances should be start on higher priority node according to - // supported runner - { - nodeConfigs: map[string]cloudprotocol.NodeConfig{ - nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, - nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, - nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, - }, - serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runners: []string{runnerRunc}}, - service2: {Runners: []string{runnerRunc}}, - service3: {Runners: []string{runnerRunx}}, - }, - desiredInstances: []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, - {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2}, - }, - expectedRunRequests: map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - createServiceInfo(service2, 5001, service2LocalURL), - }, - layers: []aostypes.LayerInfo{ - createLayerInfo(layer1, layer1LocalURL), - createLayerInfo(layer2, layer2LocalURL), - }, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5001, 3, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, 100), - createInstanceInfo(5002, 4, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 50), - createInstanceInfo(5003, 5, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, 50), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - nodeIDRemoteSM2: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - nodeIDRunxSM: { - services: []aostypes.ServiceInfo{createServiceInfo(service3, 5002, service3RemoteURL)}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5004, 6, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, 0), - createInstanceInfo(5005, 7, aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, 0), - }, - }, - }, - expectedRunStatus: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, nodeIDRunxSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, nodeIDRunxSM, nil), - }, - }, - // Check labels: label low priority service to run on high priority node - { - nodeConfigs: map[string]cloudprotocol.NodeConfig{ - nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Labels: []string{"label1"}}, - nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}}, - nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, - }, - serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runners: []string{runnerRunc}}, - service2: {Runners: []string{runnerRunc}}, - service3: {Runners: []string{runnerRunx}}, - }, - desiredInstances: []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2, Labels: []string{"label2"}}, - {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2, Labels: []string{"label1"}}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2, Labels: []string{"label1"}}, - }, - expectedRunRequests: map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{createServiceInfo(service2, 5001, service2LocalURL)}, - layers: []aostypes.LayerInfo{createLayerInfo(layer1, layer1LocalURL)}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5002, 2, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 50), - createInstanceInfo(5003, 3, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, 50), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{createServiceInfo(service1, 5000, service1RemoteURL)}, - layers: []aostypes.LayerInfo{ - createLayerInfo(layer1, layer1RemoteURL), - createLayerInfo(layer2, layer2RemoteURL), - }, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 4, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5001, 5, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, 100), - }, - }, - nodeIDRemoteSM2: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - nodeIDRunxSM: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - }, - expectedRunStatus: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 - }, - }, - // Check available resources - { - nodeConfigs: map[string]cloudprotocol.NodeConfig{ - nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Resources: []cloudprotocol.ResourceInfo{ - {Name: "resource1"}, - {Name: "resource3"}, - }}, - nodeTypeRemoteSM: { - NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}, - Resources: []cloudprotocol.ResourceInfo{ - {Name: "resource1"}, - {Name: "resource2"}, - }, - }, - nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, - }, - serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: {Runners: []string{runnerRunc}, Resources: []string{"resource1", "resource2"}}, - service2: {Runners: []string{runnerRunc}, Resources: []string{"resource1"}}, - service3: {Runners: []string{runnerRunc}, Resources: []string{"resource3"}}, - }, - desiredInstances: []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, - {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2, Labels: []string{"label2"}}, - }, - expectedRunRequests: map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{createServiceInfo(service2, 5001, service2LocalURL)}, - layers: []aostypes.LayerInfo{createLayerInfo(layer1, layer1LocalURL)}, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5002, 2, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 50), - createInstanceInfo(5003, 3, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, 50), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{createServiceInfo(service1, 5000, service1RemoteURL)}, - layers: []aostypes.LayerInfo{ - createLayerInfo(layer1, layer1RemoteURL), - createLayerInfo(layer2, layer2RemoteURL), - }, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 4, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5001, 5, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, 100), - }, - }, - nodeIDRemoteSM2: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - nodeIDRunxSM: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - }, - expectedRunStatus: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 - }, - }, - // Check available devices - { - nodeConfigs: map[string]cloudprotocol.NodeConfig{ - nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Devices: []cloudprotocol.DeviceInfo{ - {Name: "dev1", SharedCount: 1}, - {Name: "dev2", SharedCount: 2}, - {Name: "dev3"}, - }}, - nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Devices: []cloudprotocol.DeviceInfo{ - {Name: "dev1", SharedCount: 1}, - {Name: "dev2", SharedCount: 3}, - }, Labels: []string{"label2"}}, - nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0, Devices: []cloudprotocol.DeviceInfo{ - {Name: "dev1", SharedCount: 1}, - {Name: "dev2", SharedCount: 2}, - }}, - }, - serviceConfigs: map[string]aostypes.ServiceConfig{ - service1: { - Runners: []string{runnerRunc}, - Devices: []aostypes.ServiceDevice{{Name: "dev1"}, {Name: "dev2"}}, - }, - service2: { - Runners: []string{runnerRunc}, - Devices: []aostypes.ServiceDevice{{Name: "dev2"}}, - }, - service3: { - Runners: []string{runnerRunc}, - Devices: []aostypes.ServiceDevice{{Name: "dev3"}}, - }, - }, - desiredInstances: []cloudprotocol.InstanceInfo{ - {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 4}, - {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 3}, - {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2, Labels: []string{"label2"}}, - }, - expectedRunRequests: map[string]runRequest{ - nodeIDLocalSM: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1LocalURL), - createServiceInfo(service2, 5001, service2LocalURL), - }, - layers: []aostypes.LayerInfo{ - createLayerInfo(layer1, layer1LocalURL), - createLayerInfo(layer2, layer2LocalURL), - }, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5000, 2, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, 100), - createInstanceInfo(5003, 3, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, 50), - }, - }, - nodeIDRemoteSM1: { - services: []aostypes.ServiceInfo{ - createServiceInfo(service1, 5000, service1RemoteURL), - createServiceInfo(service2, 5001, service2RemoteURL), - }, - layers: []aostypes.LayerInfo{ - createLayerInfo(layer1, layer1RemoteURL), - createLayerInfo(layer2, layer2RemoteURL), - }, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5001, 4, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, 100), - createInstanceInfo(5004, 5, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, 50), - createInstanceInfo(5005, 6, aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 2, - }, 50), - }, - }, - nodeIDRemoteSM2: { - services: []aostypes.ServiceInfo{createServiceInfo(service1, 5000, service1RemoteURL)}, - layers: []aostypes.LayerInfo{ - createLayerInfo(layer1, layer1RemoteURL), - createLayerInfo(layer2, layer2RemoteURL), - }, - instances: []aostypes.InstanceInfo{ - createInstanceInfo(5002, 7, aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 2, - }, 100), - }, - }, - nodeIDRunxSM: { - services: []aostypes.ServiceInfo{}, - layers: []aostypes.LayerInfo{}, - instances: []aostypes.InstanceInfo{}, - }, - }, - expectedRunStatus: []cloudprotocol.InstanceStatus{ - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 2, - }, nodeIDRemoteSM2, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service1, SubjectID: subject1, Instance: 3, - }, "", errors.New("no available device found")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 0, - }, nodeIDLocalSM, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 1, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service2, SubjectID: subject1, Instance: 2, - }, nodeIDRemoteSM1, nil), - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no available device found")), //nolint:goerr113 - createInstanceStatus(aostypes.InstanceIdent{ - ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no available device found")), //nolint:goerr113 - }, - }, + testItemNodePriority(), + testItemLabels(), + testItemResources(), + testItemDevices(), + testItemStorageRatio(), + testItemStateRatio(), } for _, testItem := range testItems { + t.Logf("Test case: %s", testItem.testCaseName) + resourceManager.nodeConfigs = testItem.nodeConfigs for serviceID, config := range testItem.serviceConfigs { @@ -1340,6 +979,519 @@ func (network *testNetworkManager) RestartDNSServer() error { return nil } +/*********************************************************************************************************************** + * Balancing test items + **********************************************************************************************************************/ + +func testItemNodePriority() testData { + return testData{ + testCaseName: "node priority", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, + nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: {Runners: []string{runnerRunc}}, + service2: {Runners: []string{runnerRunc}}, + service3: {Runners: []string{runnerRunx}}, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + createServiceInfo(service2, 5001, service2LocalURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1LocalURL), + createLayerInfo(layer2, layer2LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 3, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + createInstanceInfo(5002, 4, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + createInstanceInfo(5003, 5, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, 50), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + nodeIDRunxSM: { + services: []aostypes.ServiceInfo{createServiceInfo(service3, 5002, service3RemoteURL)}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5004, 6, aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, 0), + createInstanceInfo(5005, 7, aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, 0), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, nodeIDRunxSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, nodeIDRunxSM, nil), + }, + } +} + +func testItemLabels() testData { + return testData{ + testCaseName: "labels", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Labels: []string{"label1"}}, + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}}, + nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: {Runners: []string{runnerRunc}}, + service2: {Runners: []string{runnerRunc}}, + service3: {Runners: []string{runnerRunx}}, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2, Labels: []string{"label2"}}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2, Labels: []string{"label1"}}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2, Labels: []string{"label1"}}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{createServiceInfo(service2, 5001, service2LocalURL)}, + layers: []aostypes.LayerInfo{createLayerInfo(layer1, layer1LocalURL)}, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 2, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + createInstanceInfo(5003, 3, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, 50), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{createServiceInfo(service1, 5000, service1RemoteURL)}, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 5, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + nodeIDRunxSM: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 + }, + } +} + +func testItemResources() testData { + return testData{ + testCaseName: "resources", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Resources: []cloudprotocol.ResourceInfo{ + {Name: "resource1"}, + {Name: "resource3"}, + }}, + nodeTypeRemoteSM: { + NodeType: nodeTypeRemoteSM, Priority: 50, Labels: []string{"label2"}, + Resources: []cloudprotocol.ResourceInfo{ + {Name: "resource1"}, + {Name: "resource2"}, + }, + }, + nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: {Runners: []string{runnerRunc}, Resources: []string{"resource1", "resource2"}}, + service2: {Runners: []string{runnerRunc}, Resources: []string{"resource1"}}, + service3: {Runners: []string{runnerRunc}, Resources: []string{"resource3"}}, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 2}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 2}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2, Labels: []string{"label2"}}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{createServiceInfo(service2, 5001, service2LocalURL)}, + layers: []aostypes.LayerInfo{createLayerInfo(layer1, layer1LocalURL)}, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 2, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + createInstanceInfo(5003, 3, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, 50), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{createServiceInfo(service1, 5000, service1RemoteURL)}, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 5, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + nodeIDRunxSM: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 + }, + } +} + +func testItemDevices() testData { + return testData{ + testCaseName: "devices", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100, Devices: []cloudprotocol.DeviceInfo{ + {Name: "dev1", SharedCount: 1}, + {Name: "dev2", SharedCount: 2}, + {Name: "dev3"}, + }}, + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50, Devices: []cloudprotocol.DeviceInfo{ + {Name: "dev1", SharedCount: 1}, + {Name: "dev2", SharedCount: 3}, + }, Labels: []string{"label2"}}, + nodeTypeRunxSM: {NodeType: nodeTypeRunxSM, Priority: 0, Devices: []cloudprotocol.DeviceInfo{ + {Name: "dev1", SharedCount: 1}, + {Name: "dev2", SharedCount: 2}, + }}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Runners: []string{runnerRunc}, + Devices: []aostypes.ServiceDevice{{Name: "dev1"}, {Name: "dev2"}}, + }, + service2: { + Runners: []string{runnerRunc}, + Devices: []aostypes.ServiceDevice{{Name: "dev2"}}, + }, + service3: { + Runners: []string{runnerRunc}, + Devices: []aostypes.ServiceDevice{{Name: "dev3"}}, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 4}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 3}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 2, Labels: []string{"label2"}}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + createServiceInfo(service2, 5001, service2LocalURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1LocalURL), + createLayerInfo(layer2, layer2LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5003, 3, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1RemoteURL), + createServiceInfo(service2, 5001, service2RemoteURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5001, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + createInstanceInfo(5004, 5, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, 50), + createInstanceInfo(5005, 6, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 2, + }, 50), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{createServiceInfo(service1, 5000, service1RemoteURL)}, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 7, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, 100), + }, + }, + nodeIDRunxSM: { + services: []aostypes.ServiceInfo{}, + layers: []aostypes.LayerInfo{}, + instances: []aostypes.InstanceInfo{}, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, nodeIDRemoteSM2, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, "", errors.New("no available device found")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 1, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 2, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, "", errors.New("no available device found")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 1, + }, "", errors.New("no available device found")), //nolint:goerr113 + }, + } +} + +func testItemStorageRatio() testData { + return testData{ + testCaseName: "storage ratio", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + StorageLimit: newQuota(500), + }, + Runners: []string{runnerRunc}, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 5}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1LocalURL), + createLayerInfo(layer2, layer2LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 3, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + createInstanceInfo(5002, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, 100), + createInstanceInfo(5003, 5, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, 100), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 4, + }, "", errors.New("not enough storage space")), //nolint:goerr113 + }, + } +} + +func testItemStateRatio() testData { + return testData{ + testCaseName: "state ratio", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + StateLimit: newQuota(500), + }, + Runners: []string{runnerRunc}, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 5}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1LocalURL), + createLayerInfo(layer2, layer2LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 3, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + createInstanceInfo(5002, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, 100), + createInstanceInfo(5003, 5, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, 100), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 4, + }, "", errors.New("not enough state space")), //nolint:goerr113 + }, + } +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -1435,6 +1587,9 @@ func waitRunInstancesStatus(runStatusChannel <-chan []cloudprotocol.InstanceStat } } + log.Debug(receivedStatus) + log.Debug(expectedStatus) + return aoserrors.New("incorrect instances in run status") } @@ -1460,3 +1615,7 @@ topLabel: return nil } + +func newQuota(value uint64) *uint64 { + return &value +} diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index d96cb365..ae597e82 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -178,6 +178,18 @@ layerLoopLabel: return nil } +func (node *nodeHandler) getPartitionSize(partitionType string) uint64 { + partitionIndex := slices.IndexFunc(node.nodeInfo.Partitions, func(partition cloudprotocol.PartitionInfo) bool { + return slices.Contains(partition.Types, partitionType) + }) + + if partitionIndex == -1 { + return 0 + } + + return node.nodeInfo.Partitions[partitionIndex].TotalSize +} + func getNodesByStaticResources(allNodes []*nodeHandler, serviceInfo imagemanager.ServiceInfo, instanceInfo cloudprotocol.InstanceInfo, ) ([]*nodeHandler, error) { From f64ca16bf5d9b0ee2c7fb464e8c32efcbb6149fd Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 29 Jul 2024 18:50:49 +0300 Subject: [PATCH 111/146] [launcher] Add scheduling service instances by available CPU and RAM Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 32 ++++- launcher/launcher_test.go | 241 +++++++++++++++++++++++++++++++++++--- launcher/nodehandler.go | 235 +++++++++++++++++++++++++++---------- 3 files changed, 426 insertions(+), 82 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 60be4b6a..c2a6b5eb 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -500,7 +500,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc continue } - nodes, err := getNodesByStaticResources(launcher.getNodesByPriorities(), service, instance) + nodes, err := getNodesByStaticResources(launcher.getNodesByPriorities(), service.Config, instance) if err != nil { launcher.instanceManager.setAllInstanceError(instance, service.Version, err) continue @@ -511,7 +511,7 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc continue } - node, err := getInstanceNode(service, nodes) + node, err := getInstanceNode(nodes, service.Config) if err != nil { launcher.instanceManager.setInstanceError( createInstanceIdent(instance, instanceIndex), service.Version, err) @@ -699,6 +699,34 @@ func getStorageRequestRatio( return defaultResourceRation / 100 } +func getCPURequestRatio( + serviceRatios *aostypes.ResourceRatiosInfo, nodeRatios *aostypes.ResourceRatiosInfo, +) float64 { + if serviceRatios != nil && serviceRatios.CPU != nil { + return float64(*serviceRatios.CPU) / 100 + } + + if nodeRatios != nil && nodeRatios.CPU != nil { + return float64(*nodeRatios.CPU) / 100 + } + + return defaultResourceRation / 100 +} + +func getRAMRequestRatio( + serviceRatios *aostypes.ResourceRatiosInfo, nodeRatios *aostypes.ResourceRatiosInfo, +) float64 { + if serviceRatios != nil && serviceRatios.RAM != nil { + return float64(*serviceRatios.RAM) / 100 + } + + if nodeRatios != nil && nodeRatios.CPU != nil { + return float64(*nodeRatios.CPU) / 100 + } + + return defaultResourceRation / 100 +} + func instanceIdentLogFields(instance aostypes.InstanceIdent, extraFields log.Fields) log.Fields { logFields := log.Fields{ "serviceID": instance.ServiceID, diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index d6077f4b..259254b5 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -403,8 +403,10 @@ func TestBalancing(t *testing.T) { nodeInfoProvider.nodeInfo = map[string]cloudprotocol.NodeInfo{ nodeIDLocalSM: { NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, - Status: cloudprotocol.NodeStatusProvisioned, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + MaxDMIPs: 1000, + TotalRAM: 1024, Partitions: []cloudprotocol.PartitionInfo{ {Name: "storages", Types: []string{aostypes.StoragesPartition}, TotalSize: 1024}, {Name: "states", Types: []string{aostypes.StatesPartition}, TotalSize: 1024}, @@ -412,18 +414,24 @@ func TestBalancing(t *testing.T) { }, nodeIDRemoteSM1: { NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, - Status: cloudprotocol.NodeStatusProvisioned, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + MaxDMIPs: 1000, + TotalRAM: 1024, }, nodeIDRemoteSM2: { NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM, - Status: cloudprotocol.NodeStatusProvisioned, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + MaxDMIPs: 1000, + TotalRAM: 1024, }, nodeIDRunxSM: { NodeID: nodeIDRunxSM, NodeType: nodeTypeRunxSM, - Status: cloudprotocol.NodeStatusProvisioned, - Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunx}, + MaxDMIPs: 1000, + TotalRAM: 1024, }, } @@ -462,6 +470,8 @@ func TestBalancing(t *testing.T) { testItemDevices(), testItemStorageRatio(), testItemStateRatio(), + testItemCPURatio(), + testItemRAMRatio(), } for _, testItem := range testItems { @@ -1144,10 +1154,10 @@ func testItemLabels() testData { }, nodeIDLocalSM, nil), createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 + }, "", errors.New("no nodes with labels [label1]")), //nolint:goerr113 createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no node with labels [label1]")), //nolint:goerr113 + }, "", errors.New("no nodes with labels [label1]")), //nolint:goerr113 }, } } @@ -1233,10 +1243,10 @@ func testItemResources() testData { }, nodeIDLocalSM, nil), createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 + }, "", errors.New("no nodes with resources [resource3]")), //nolint:goerr113 createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no node with resources [resource3]")), //nolint:goerr113 + }, "", errors.New("no nodes with resources [resource3]")), //nolint:goerr113 }, } } @@ -1348,7 +1358,7 @@ func testItemDevices() testData { }, nodeIDRemoteSM2, nil), createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service1, SubjectID: subject1, Instance: 3, - }, "", errors.New("no available device found")), //nolint:goerr113 + }, "", errors.New("no nodes with devices")), //nolint:goerr113 createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service2, SubjectID: subject1, Instance: 0, }, nodeIDLocalSM, nil), @@ -1360,10 +1370,10 @@ func testItemDevices() testData { }, nodeIDRemoteSM1, nil), createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service3, SubjectID: subject1, Instance: 0, - }, "", errors.New("no available device found")), //nolint:goerr113 + }, "", errors.New("no nodes with devices")), //nolint:goerr113 createInstanceStatus(aostypes.InstanceIdent{ ServiceID: service3, SubjectID: subject1, Instance: 1, - }, "", errors.New("no available device found")), //nolint:goerr113 + }, "", errors.New("no nodes with devices")), //nolint:goerr113 }, } } @@ -1492,6 +1502,204 @@ func testItemStateRatio() testData { } } +func testItemCPURatio() testData { + return testData{ + testCaseName: "CPU ratio", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + Runners: []string{runnerRunc}, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 8}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1LocalURL), + createLayerInfo(layer2, layer2LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 3, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1RemoteURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, 100), + createInstanceInfo(5004, 5, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 4, + }, 100), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1RemoteURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5003, 6, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, 100), + createInstanceInfo(5005, 7, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 5, + }, 100), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, nodeIDRemoteSM2, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 4, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 5, + }, nodeIDRemoteSM2, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 6, + }, "", errors.New("no nodes with available CPU")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 7, + }, "", errors.New("no nodes with available CPU")), //nolint:goerr113 + }, + } +} + +func testItemRAMRatio() testData { + return testData{ + testCaseName: "RAM ratio", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: {NodeType: nodeTypeLocalSM, Priority: 100}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + RAMLimit: newQuota(1024), + }, + Runners: []string{runnerRunc}, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 8}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1LocalURL), + createLayerInfo(layer2, layer2LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + createInstanceInfo(5001, 3, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, 100), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1RemoteURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 4, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, 100), + createInstanceInfo(5003, 5, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, 100), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1RemoteURL), + }, + layers: []aostypes.LayerInfo{ + createLayerInfo(layer1, layer1RemoteURL), + createLayerInfo(layer2, layer2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5004, 6, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 4, + }, 100), + createInstanceInfo(5005, 7, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 5, + }, 100), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 1, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 2, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 3, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 4, + }, nodeIDRemoteSM2, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 5, + }, nodeIDRemoteSM2, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 6, + }, "", errors.New("no nodes with available RAM")), //nolint:goerr113 + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 7, + }, "", errors.New("no nodes with available RAM")), //nolint:goerr113 + }, + } +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ @@ -1587,9 +1795,6 @@ func waitRunInstancesStatus(runStatusChannel <-chan []cloudprotocol.InstanceStat } } - log.Debug(receivedStatus) - log.Debug(expectedStatus) - return aoserrors.New("incorrect instances in run status") } diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index ae597e82..6d72fa73 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -19,7 +19,6 @@ package launcher import ( "errors" - "reflect" "slices" "github.com/aosedge/aos_common/aoserrors" @@ -48,6 +47,8 @@ type nodeHandler struct { runRequest runRequest isLocalNode bool waitStatus bool + availableCPU uint64 + availableRAM uint64 } /*********************************************************************************************************************** @@ -80,6 +81,9 @@ func newNodeHandler( node.nodeConfig = nodeConfig node.resetDeviceAllocations() + node.availableCPU = node.nodeInfo.MaxDMIPs + node.availableRAM = node.nodeInfo.TotalRAM + return node, nil } @@ -131,51 +135,65 @@ func (node *nodeHandler) addRunRequest(instanceInfo aostypes.InstanceInfo, servi node.runRequest.Instances = append(node.runRequest.Instances, instanceInfo) + node.addService(service) + node.addLayers(layers) + + requestedCPU := node.getRequestedCPU(service.Config) + if requestedCPU > node.availableCPU { + return aoserrors.Errorf("not enough CPU") + } + + requestedRAM := node.getRequestedRAM(service.Config) + if requestedRAM > node.availableRAM { + return aoserrors.Errorf("not enough CPU") + } + + node.availableCPU -= requestedCPU + node.availableRAM -= requestedRAM + + return nil +} + +func (node *nodeHandler) addService(service imagemanager.ServiceInfo) { serviceInfo := service.ServiceInfo if !node.isLocalNode { serviceInfo.URL = service.RemoteURL } - isNewService := true - - for _, oldService := range node.runRequest.Services { - if reflect.DeepEqual(oldService, serviceInfo) { - isNewService = false - break - } + if slices.ContainsFunc(node.runRequest.Services, func(info aostypes.ServiceInfo) bool { + return info.ServiceID == serviceInfo.ServiceID + }) { + return } - if isNewService { - log.WithFields(log.Fields{ - "serviceID": serviceInfo.ServiceID, "node": node.nodeInfo.NodeID, - }).Debug("Schedule service on node") + log.WithFields(log.Fields{ + "serviceID": serviceInfo.ServiceID, "node": node.nodeInfo.NodeID, + }).Debug("Schedule service on node") - node.runRequest.Services = append(node.runRequest.Services, serviceInfo) - } + node.runRequest.Services = append(node.runRequest.Services, serviceInfo) +} -layerLoopLabel: +func (node *nodeHandler) addLayers(layers []imagemanager.LayerInfo) { for _, layer := range layers { - newLayer := layer.LayerInfo + layerInfo := layer.LayerInfo if !node.isLocalNode { - newLayer.URL = layer.RemoteURL + layerInfo.URL = layer.RemoteURL } - for _, oldLayer := range node.runRequest.Layers { - if reflect.DeepEqual(newLayer, oldLayer) { - continue layerLoopLabel - } + if slices.ContainsFunc(node.runRequest.Layers, func(info aostypes.LayerInfo) bool { + return info.Digest == layerInfo.Digest + }) { + continue } log.WithFields(log.Fields{ - "digest": newLayer.Digest, "node": node.nodeInfo.NodeID, + "digest": layerInfo.Digest, "node": node.nodeInfo.NodeID, }).Debug("Schedule layer on node") - node.runRequest.Layers = append(node.runRequest.Layers, newLayer) + node.runRequest.Layers = append(node.runRequest.Layers, layerInfo) } - - return nil } func (node *nodeHandler) getPartitionSize(partitionType string) uint64 { @@ -190,54 +208,74 @@ func (node *nodeHandler) getPartitionSize(partitionType string) uint64 { return node.nodeInfo.Partitions[partitionIndex].TotalSize } -func getNodesByStaticResources(allNodes []*nodeHandler, - serviceInfo imagemanager.ServiceInfo, instanceInfo cloudprotocol.InstanceInfo, +func (node *nodeHandler) getRequestedCPU(serviceConfig aostypes.ServiceConfig) uint64 { + requestedCPU := uint64(0) + + if serviceConfig.Quotas.CPULimit != nil { + requestedCPU = uint64(float64(*serviceConfig.Quotas.CPULimit)*getCPURequestRatio( + serviceConfig.ResourceRatios, node.nodeConfig.ResourceRatios) + 0.5) + } + + return requestedCPU +} + +func (node *nodeHandler) getRequestedRAM(serviceConfig aostypes.ServiceConfig) uint64 { + requestedRAM := uint64(0) + + if serviceConfig.Quotas.RAMLimit != nil { + requestedRAM = uint64(float64(*serviceConfig.Quotas.RAMLimit)*getRAMRequestRatio( + serviceConfig.ResourceRatios, node.nodeConfig.ResourceRatios) + 0.5) + } + + return requestedRAM +} + +func getNodesByStaticResources(nodes []*nodeHandler, + serviceConfig aostypes.ServiceConfig, instanceInfo cloudprotocol.InstanceInfo, ) ([]*nodeHandler, error) { - nodes := getNodeByRunners(allNodes, serviceInfo.Config.Runners) - if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with runner: %s", serviceInfo.Config.Runners) + resultNodes := getNodeByRunners(nodes, serviceConfig.Runners) + if len(resultNodes) == 0 { + return resultNodes, aoserrors.Errorf("no nodes with runner: %s", serviceConfig.Runners) } - nodes = getNodesByLabels(nodes, instanceInfo.Labels) - if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with labels %v", instanceInfo.Labels) + resultNodes = getNodesByLabels(resultNodes, instanceInfo.Labels) + if len(resultNodes) == 0 { + return resultNodes, aoserrors.Errorf("no nodes with labels %v", instanceInfo.Labels) } - nodes = getNodesByResources(nodes, serviceInfo.Config.Resources) - if len(nodes) == 0 { - return nodes, aoserrors.Errorf("no node with resources %v", serviceInfo.Config.Resources) + resultNodes = getNodesByResources(resultNodes, serviceConfig.Resources) + if len(resultNodes) == 0 { + return resultNodes, aoserrors.Errorf("no nodes with resources %v", serviceConfig.Resources) } - return nodes, nil + return resultNodes, nil } -func getNodesByDevices(availableNodes []*nodeHandler, desiredDevices []aostypes.ServiceDevice) ([]*nodeHandler, error) { +func getNodesByDevices(nodes []*nodeHandler, desiredDevices []aostypes.ServiceDevice) []*nodeHandler { if len(desiredDevices) == 0 { - return availableNodes, nil + return nodes } - nodes := make([]*nodeHandler, 0) + resultNodes := make([]*nodeHandler, 0) - for _, node := range availableNodes { + for _, node := range nodes { if !node.nodeHasDesiredDevices(desiredDevices) { continue } - nodes = append(nodes, node) - } - - if len(nodes) == 0 { - return nodes, aoserrors.New("no available device found") + resultNodes = append(resultNodes, node) } - return nodes, nil + return resultNodes } -func getNodesByResources(nodes []*nodeHandler, desiredResources []string) (newNodes []*nodeHandler) { +func getNodesByResources(nodes []*nodeHandler, desiredResources []string) []*nodeHandler { if len(desiredResources) == 0 { return nodes } + resultNodes := make([]*nodeHandler, 0) + nodeLoop: for _, node := range nodes { if len(node.nodeConfig.Resources) == 0 { @@ -252,17 +290,19 @@ nodeLoop: } } - newNodes = append(newNodes, node) + resultNodes = append(resultNodes, node) } - return newNodes + return resultNodes } -func getNodesByLabels(nodes []*nodeHandler, desiredLabels []string) (newNodes []*nodeHandler) { +func getNodesByLabels(nodes []*nodeHandler, desiredLabels []string) []*nodeHandler { if len(desiredLabels) == 0 { return nodes } + resultNodes := make([]*nodeHandler, 0) + nodeLoop: for _, node := range nodes { if len(node.nodeConfig.Labels) == 0 { @@ -275,19 +315,21 @@ nodeLoop: } } - newNodes = append(newNodes, node) + resultNodes = append(resultNodes, node) } - return newNodes + return resultNodes } -func getNodeByRunners(allNodes []*nodeHandler, runners []string) (nodes []*nodeHandler) { +func getNodeByRunners(nodes []*nodeHandler, runners []string) []*nodeHandler { if len(runners) == 0 { runners = defaultRunners } + resultNodes := make([]*nodeHandler, 0) + for _, runner := range runners { - for _, node := range allNodes { + for _, node := range nodes { nodeRunners, err := node.nodeInfo.GetNodeRunners() if err != nil { log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't get node runners: %v", err) @@ -297,19 +339,88 @@ func getNodeByRunners(allNodes []*nodeHandler, runners []string) (nodes []*nodeH if (len(nodeRunners) == 0 && slices.Contains(defaultRunners, runner)) || slices.Contains(nodeRunners, runner) { - nodes = append(nodes, node) + resultNodes = append(resultNodes, node) } } } - return nodes + return resultNodes } -func getInstanceNode(service imagemanager.ServiceInfo, nodes []*nodeHandler) (*nodeHandler, error) { - nodes, err := getNodesByDevices(nodes, service.Config.Devices) - if err != nil { - return nil, err +func getNodesByCPU(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) []*nodeHandler { + resultNodes := make([]*nodeHandler, 0) + + for _, node := range nodes { + if node.availableCPU >= node.getRequestedCPU(serviceConfig) { + resultNodes = append(resultNodes, node) + } + } + + return resultNodes +} + +func getNodesByRAM(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) []*nodeHandler { + resultNodes := make([]*nodeHandler, 0) + + for _, node := range nodes { + if node.availableRAM >= node.getRequestedRAM(serviceConfig) { + resultNodes = append(resultNodes, node) + } } - return nodes[0], nil + return resultNodes +} + +func getTopPriorityNodes(nodes []*nodeHandler) []*nodeHandler { + if len(nodes) == 0 { + return nodes + } + + topPriority := nodes[0].nodeConfig.Priority + + resultNodes := make([]*nodeHandler, 0) + + for _, node := range nodes { + if node.nodeConfig.Priority == topPriority { + resultNodes = append(resultNodes, node) + } + } + + return resultNodes +} + +func getInstanceNode(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) (*nodeHandler, error) { + resultNodes := getNodesByDevices(nodes, serviceConfig.Devices) + if len(resultNodes) == 0 { + return nil, aoserrors.Errorf("no nodes with devices %v", serviceConfig.Devices) + } + + resultNodes = getNodesByCPU(resultNodes, serviceConfig) + if len(resultNodes) == 0 { + return nil, aoserrors.Errorf("no nodes with available CPU") + } + + resultNodes = getNodesByRAM(resultNodes, serviceConfig) + if len(resultNodes) == 0 { + return nil, aoserrors.Errorf("no nodes with available RAM") + } + + resultNodes = getTopPriorityNodes(resultNodes) + if len(resultNodes) == 0 { + return nil, aoserrors.Errorf("can't get top priority nodes") + } + + slices.SortStableFunc(resultNodes, func(node1, node2 *nodeHandler) int { + if node1.availableCPU < node2.availableCPU { + return 1 + } + + if node1.availableCPU > node2.availableCPU { + return -1 + } + + return 0 + }) + + return resultNodes[0], nil } From bfbe2994c128d4f1b6ec1f7ca064ab9cad58fd8f Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 31 Jul 2024 13:20:36 +0300 Subject: [PATCH 112/146] [launcher] Implement node rebalancing Signed-off-by: Oleksandr Grytsov --- launcher/instancemanager.go | 59 +++-- launcher/launcher.go | 107 ++++---- launcher/launcher_test.go | 473 ++++++++++++++++++++++++++++++++++++ launcher/nodehandler.go | 176 ++++++++++++-- 4 files changed, 735 insertions(+), 80 deletions(-) diff --git a/launcher/instancemanager.go b/launcher/instancemanager.go index a28a24a0..8315aeb2 100644 --- a/launcher/instancemanager.go +++ b/launcher/instancemanager.go @@ -20,7 +20,6 @@ package launcher import ( "context" "errors" - "slices" "time" "github.com/aosedge/aos_common/aoserrors" @@ -28,6 +27,7 @@ import ( "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" "golang.org/x/exp/maps" + "golang.org/x/exp/slices" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/imagemanager" @@ -47,10 +47,11 @@ const removePeriod = time.Hour * 24 type InstanceInfo struct { aostypes.InstanceIdent - NodeID string - UID int - Timestamp time.Time - Cached bool + NodeID string + PrevNodeID string + UID int + Timestamp time.Time + Cached bool } // Storage storage interface. @@ -72,6 +73,7 @@ type instanceManager struct { errorStatus map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus instances map[aostypes.InstanceIdent]aostypes.InstanceInfo removeServiceChannel <-chan string + curInstances []InstanceInfo availableStorage, availableState uint64 } @@ -121,25 +123,48 @@ func newInstanceManager(config *config.Config, imageProvider ImageProvider, stor func (im *instanceManager) initInstances() { im.instances = make(map[aostypes.InstanceIdent]aostypes.InstanceInfo) im.errorStatus = make(map[aostypes.InstanceIdent]cloudprotocol.InstanceStatus) -} -func (im *instanceManager) resetStorageStateUsage(storageSize, stateSize uint64) { - im.availableStorage, im.availableState = storageSize, stateSize -} + var err error -func (im *instanceManager) getCurrentInstances() ([]InstanceInfo, error) { instances, err := im.storage.GetInstances() if err != nil { - return nil, aoserrors.Wrap(err) + log.Errorf("Can't get current instances: %v", err) + } + + im.curInstances = make([]InstanceInfo, 0, len(instances)) + + for _, instance := range instances { + if instance.Cached { + continue + } + + im.curInstances = append(im.curInstances, instance) + } +} + +func (im *instanceManager) getCurrentInstances() []InstanceInfo { + return im.curInstances +} + +func (im *instanceManager) getCurrentInstance(instanceIdent aostypes.InstanceIdent) (InstanceInfo, error) { + curIndex := slices.IndexFunc(im.curInstances, func(curInstance InstanceInfo) bool { + return curInstance.InstanceIdent == instanceIdent + }) + + if curIndex == -1 { + return InstanceInfo{}, aoserrors.Wrap(ErrNotExist) } - return slices.DeleteFunc(instances, func(instance InstanceInfo) bool { - return instance.Cached - }), nil + return im.curInstances[curIndex], nil +} + +func (im *instanceManager) resetStorageStateUsage(storageSize, stateSize uint64) { + im.availableStorage, im.availableState = storageSize, stateSize } func (im *instanceManager) setupInstance( instance cloudprotocol.InstanceInfo, index uint64, node *nodeHandler, service imagemanager.ServiceInfo, + rebalancing bool, ) (aostypes.InstanceInfo, error) { instanceInfo := aostypes.InstanceInfo{ InstanceIdent: aostypes.InstanceIdent{ @@ -174,6 +199,12 @@ func (im *instanceManager) setupInstance( log.Errorf("Can't add instance: %v", err) } } else { + if rebalancing { + storedInstance.PrevNodeID = storedInstance.NodeID + } else { + storedInstance.PrevNodeID = "" + } + storedInstance.NodeID = node.nodeInfo.NodeID storedInstance.Timestamp = time.Now() storedInstance.Cached = false diff --git a/launcher/launcher.go b/launcher/launcher.go index c2a6b5eb..9d3b6602 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -20,7 +20,6 @@ package launcher import ( "context" "errors" - "slices" "sort" "sync" "time" @@ -30,6 +29,7 @@ import ( "github.com/aosedge/aos_common/api/cloudprotocol" log "github.com/sirupsen/logrus" "golang.org/x/exp/maps" + "golang.org/x/exp/slices" "github.com/aosedge/aos_communicationmanager/config" "github.com/aosedge/aos_communicationmanager/imagemanager" @@ -147,7 +147,7 @@ func New( return nil, err } - if err := launcher.initNodes(); err != nil { + if err := launcher.initNodes(false); err != nil { return nil, err } @@ -178,9 +178,17 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, r launcher.Lock() defer launcher.Unlock() - log.Debug("Run instances") + log.WithField("rebalancing", rebalancing).Debug("Run instances") - launcher.prepareBalancing() + sort.Slice(instances, func(i, j int) bool { + if instances[i].Priority == instances[j].Priority { + return instances[i].ServiceID < instances[j].ServiceID + } + + return instances[i].Priority > instances[j].Priority + }) + + launcher.prepareBalancing(rebalancing) if err := launcher.processRemovedInstances(instances); err != nil { log.Errorf("Can't process removed instances: %v", err) @@ -194,7 +202,7 @@ func (launcher *Launcher) RunInstances(instances []cloudprotocol.InstanceInfo, r launcher.performPolicyBalancing(instances) } - launcher.performNodeBalancing(instances) + launcher.performNodeBalancing(instances, rebalancing) // first prepare network for instance which have exposed ports launcher.prepareNetworkForInstances(true) @@ -218,8 +226,8 @@ func (launcher *Launcher) GetRunStatusesChannel() <-chan []cloudprotocol.Instanc * Private **********************************************************************************************************************/ -func (launcher *Launcher) prepareBalancing() { - if err := launcher.initNodes(); err != nil { +func (launcher *Launcher) prepareBalancing(rebalancing bool) { + if err := launcher.initNodes(rebalancing); err != nil { log.Errorf("Can't init nodes: %v", err) } @@ -236,7 +244,7 @@ func (launcher *Launcher) prepareBalancing() { } } -func (launcher *Launcher) initNodes() error { +func (launcher *Launcher) initNodes(rebalancing bool) error { launcher.nodes = make(map[string]*nodeHandler) nodes, err := launcher.nodeInfoProvider.GetAllNodeIDs() @@ -259,7 +267,8 @@ func (launcher *Launcher) initNodes() error { } nodeHandler, err := newNodeHandler( - nodeInfo, launcher.resourceManager, nodeInfo.NodeID == launcher.nodeInfoProvider.GetNodeID()) + nodeInfo, launcher.nodeManager, launcher.resourceManager, + nodeInfo.NodeID == launcher.nodeInfoProvider.GetNodeID(), rebalancing) if err != nil { log.WithField("nodeID", nodeID).Errorf("Can't create node handler: %v", err) @@ -364,16 +373,11 @@ func (launcher *Launcher) sendCurrentStatus() { launcher.runStatusChannel <- instancesStatus } -func (launcher *Launcher) processRemovedInstances(newInstances []cloudprotocol.InstanceInfo) error { - launcher.removeInstanceNetworkParameters(newInstances) - - curInstances, err := launcher.instanceManager.getCurrentInstances() - if err != nil { - return aoserrors.Wrap(err) - } +func (launcher *Launcher) processRemovedInstances(instances []cloudprotocol.InstanceInfo) error { + launcher.removeInstanceNetworkParameters(instances) - for _, curInstance := range curInstances { - if !slices.ContainsFunc(newInstances, func(info cloudprotocol.InstanceInfo) bool { + for _, curInstance := range launcher.instanceManager.getCurrentInstances() { + if !slices.ContainsFunc(instances, func(info cloudprotocol.InstanceInfo) bool { return curInstance.ServiceID == info.ServiceID && curInstance.SubjectID == info.SubjectID && curInstance.Instance < info.NumInstances }) { @@ -409,12 +413,6 @@ func (launcher *Launcher) updateNetworks(instances []cloudprotocol.InstanceInfo) } func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.InstanceInfo) { - curInstances, err := launcher.instanceManager.getCurrentInstances() - if err != nil { - log.Errorf("Can't get current instances: %v", err) - return - } - for _, instance := range instances { log.WithFields(log.Fields{ "serviceID": instance.ServiceID, @@ -435,21 +433,17 @@ func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.Insta } for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - curIndex := slices.IndexFunc(curInstances, func(curInstance InstanceInfo) bool { - return curInstance.ServiceID == instance.ServiceID && - curInstance.SubjectID == instance.SubjectID && - curInstance.Instance == instanceIndex - }) - - if curIndex == -1 { + curInstance, err := launcher.instanceManager.getCurrentInstance( + createInstanceIdent(instance, instanceIndex)) + if err != nil { launcher.instanceManager.setInstanceError( createInstanceIdent(instance, instanceIndex), - service.Version, aoserrors.Errorf("instance not found")) + service.Version, err) continue } - node := launcher.getNode(curInstances[curIndex].NodeID) + node := launcher.getNode(curInstance.NodeID) if node == nil { launcher.instanceManager.setInstanceError( createInstanceIdent(instance, instanceIndex), @@ -459,7 +453,7 @@ func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.Insta } instanceInfo, err := launcher.instanceManager.setupInstance( - instance, instanceIndex, node, service) + instance, instanceIndex, node, service, true) if err != nil { launcher.instanceManager.setInstanceError( createInstanceIdent(instance, instanceIndex), service.Version, err) @@ -477,15 +471,8 @@ func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.Insta } } -func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo) { - sort.Slice(instances, func(i, j int) bool { - if instances[i].Priority == instances[j].Priority { - return instances[i].ServiceID < instances[j].ServiceID - } - - return instances[i].Priority > instances[j].Priority - }) - +//nolint:gocognit +func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo, rebalancing bool) { for _, instance := range instances { log.WithFields(log.Fields{ "serviceID": instance.ServiceID, @@ -507,28 +494,44 @@ func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.Instanc } for instanceIndex := uint64(0); instanceIndex < instance.NumInstances; instanceIndex++ { - if launcher.instanceManager.isInstanceScheduled(createInstanceIdent(instance, instanceIndex)) { + instanceIdent := createInstanceIdent(instance, instanceIndex) + + if launcher.instanceManager.isInstanceScheduled(instanceIdent) { continue } - node, err := getInstanceNode(nodes, service.Config) + if rebalancing { + curInstance, err := launcher.instanceManager.getCurrentInstance(instanceIdent) + if err != nil { + launcher.instanceManager.setInstanceError(instanceIdent, service.Version, err) + continue + } + + if curInstance.PrevNodeID != "" && curInstance.PrevNodeID != curInstance.NodeID { + nodes = excludeNodes(nodes, []string{curInstance.PrevNodeID}) + if len(nodes) == 0 { + launcher.instanceManager.setInstanceError(instanceIdent, service.Version, + aoserrors.Errorf("can't find node for rebalancing")) + continue + } + } + } + + node, err := getInstanceNode(nodes, instanceIdent, service.Config) if err != nil { - launcher.instanceManager.setInstanceError( - createInstanceIdent(instance, instanceIndex), service.Version, err) + launcher.instanceManager.setInstanceError(instanceIdent, service.Version, err) continue } instanceInfo, err := launcher.instanceManager.setupInstance( - instance, instanceIndex, node, service) + instance, instanceIndex, node, service, rebalancing) if err != nil { - launcher.instanceManager.setInstanceError( - createInstanceIdent(instance, instanceIndex), service.Version, err) + launcher.instanceManager.setInstanceError(instanceIdent, service.Version, err) continue } if err = node.addRunRequest(instanceInfo, service, layers); err != nil { - launcher.instanceManager.setInstanceError( - createInstanceIdent(instance, instanceIndex), service.Version, err) + launcher.instanceManager.setInstanceError(instanceIdent, service.Version, err) continue } } diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 259254b5..235d5bd9 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -98,6 +98,7 @@ type testNodeInfoProvider struct { type testNodeManager struct { runStatusChan chan launcher.NodeRunInstanceStatus runRequest map[string]runRequest + monitoring map[string]aostypes.NodeMonitoring } type testImageProvider struct { @@ -133,6 +134,7 @@ type testData struct { storedInstances []launcher.InstanceInfo expectedRunRequests map[string]runRequest expectedRunStatus []cloudprotocol.InstanceStatus + monitoring map[string]aostypes.NodeMonitoring rebalancing bool } @@ -210,6 +212,7 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { InstanceIdent: aostypes.InstanceIdent{ServiceID: service1}, Cached: true, Timestamp: time.Now().Add(-time.Hour * 25).UTC(), + UID: 5000, }) if err != nil { t.Fatalf("Can't add instance %v", err) @@ -219,6 +222,7 @@ func TestInstancesWithOutdatedTTLRemovedOnStart(t *testing.T) { InstanceIdent: aostypes.InstanceIdent{ServiceID: service2}, Cached: true, Timestamp: time.Now().UTC(), + UID: 5001, }) if err != nil { t.Fatalf("Can't add instance %v", err) @@ -525,6 +529,120 @@ func TestBalancing(t *testing.T) { } } +func TestRebalancing(t *testing.T) { + var ( + cfg = &config.Config{ + SMController: config.SMController{ + NodesConnectionTimeout: aostypes.Duration{Duration: time.Second}, + }, + } + nodeInfoProvider = newTestNodeInfoProvider(nodeIDLocalSM) + nodeManager = newTestNodeManager() + resourceManager = newTestResourceManager() + imageManager = newTestImageProvider() + ) + + nodeInfoProvider.nodeInfo = map[string]cloudprotocol.NodeInfo{ + nodeIDLocalSM: { + NodeID: nodeIDLocalSM, NodeType: nodeTypeLocalSM, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + MaxDMIPs: 1000, + TotalRAM: 1024, + Partitions: []cloudprotocol.PartitionInfo{ + {Name: "storages", Types: []string{aostypes.StoragesPartition}, TotalSize: 1024}, + {Name: "states", Types: []string{aostypes.StatesPartition}, TotalSize: 1024}, + }, + }, + nodeIDRemoteSM1: { + NodeID: nodeIDRemoteSM1, NodeType: nodeTypeRemoteSM, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + MaxDMIPs: 1000, + TotalRAM: 1024, + }, + nodeIDRemoteSM2: { + NodeID: nodeIDRemoteSM2, NodeType: nodeTypeRemoteSM, + Status: cloudprotocol.NodeStatusProvisioned, + Attrs: map[string]interface{}{cloudprotocol.NodeAttrRunners: runnerRunc}, + MaxDMIPs: 1000, + TotalRAM: 1024, + }, + } + + imageManager.services = map[string]imagemanager.ServiceInfo{ + service1: { + ServiceInfo: createServiceInfo(service1, 5000, service1LocalURL), + RemoteURL: service1RemoteURL, + }, + service2: { + ServiceInfo: createServiceInfo(service2, 5001, service2LocalURL), + RemoteURL: service2RemoteURL, + }, + service3: { + ServiceInfo: createServiceInfo(service3, 5002, service3LocalURL), + RemoteURL: service3RemoteURL, + }, + } + + testItems := []testData{ + testItemRebalancing(), + testItemRebalancingPolicy(), + testItemRebalancingPrevNode(), + } + + for _, testItem := range testItems { + t.Logf("Test case: %s", testItem.testCaseName) + + resourceManager.nodeConfigs = testItem.nodeConfigs + nodeManager.monitoring = testItem.monitoring + + for serviceID, config := range testItem.serviceConfigs { + service := imageManager.services[serviceID] + service.Config = config + imageManager.services[serviceID] = service + } + + storage := newTestStorage(testItem.storedInstances) + + launcherInstance, err := launcher.New(cfg, storage, nodeInfoProvider, nodeManager, imageManager, + resourceManager, &testStateStorage{}, newTestNetworkManager("172.17.0.1/16")) + if err != nil { + t.Fatalf("Can't create launcher %v", err) + } + + // Wait initial run status + + for nodeID, info := range nodeInfoProvider.nodeInfo { + nodeManager.runStatusChan <- launcher.NodeRunInstanceStatus{ + NodeID: nodeID, NodeType: info.NodeType, Instances: []cloudprotocol.InstanceStatus{}, + } + } + + if err := waitRunInstancesStatus( + launcherInstance.GetRunStatusesChannel(), []cloudprotocol.InstanceStatus{}, time.Second); err != nil { + t.Errorf("Incorrect run status: %v", err) + } + + // Run instances + + if err := launcherInstance.RunInstances(testItem.desiredInstances, testItem.rebalancing); err != nil { + t.Fatalf("Can't run instances %v", err) + } + + if err := waitRunInstancesStatus( + launcherInstance.GetRunStatusesChannel(), testItem.expectedRunStatus, time.Second); err != nil { + t.Errorf("Incorrect run status: %v", err) + } + + if err := nodeManager.compareRunRequests(testItem.expectedRunRequests); err != nil { + t.Errorf("Incorrect run request: %v", err) + } + + launcherInstance.Close() + } +} + func TestStorageCleanup(t *testing.T) { var ( cfg = &config.Config{ @@ -726,6 +844,7 @@ func newTestNodeManager() *testNodeManager { nodeManager := &testNodeManager{ runStatusChan: make(chan launcher.NodeRunInstanceStatus, 10), runRequest: make(map[string]runRequest), + monitoring: make(map[string]aostypes.NodeMonitoring), } return nodeManager @@ -766,6 +885,11 @@ func (nodeManager *testNodeManager) GetUpdateInstancesStatusChannel() <-chan []c } func (nodeManager *testNodeManager) GetAverageMonitoring(nodeID string) (aostypes.NodeMonitoring, error) { + monitoring, ok := nodeManager.monitoring[nodeID] + if ok { + return monitoring, nil + } + return aostypes.NodeMonitoring{}, nil } @@ -1700,6 +1824,355 @@ func testItemRAMRatio() testData { } } +func testItemRebalancing() testData { + return testData{ + testCaseName: "rebalancing", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: { + NodeType: nodeTypeLocalSM, Priority: 100, + AlertRules: &aostypes.AlertRules{ + CPU: &aostypes.AlertRulePercents{ + MinThreshold: 75.0, MaxThreshold: 85.0, + }, + }, + }, + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + service2: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + service3: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + }, + monitoring: map[string]aostypes.NodeMonitoring{ + nodeIDLocalSM: { + NodeData: aostypes.MonitoringData{CPU: 1000}, + InstancesData: []aostypes.InstanceMonitoring{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service1, SubjectID: subject1, Instance: 0}, + MonitoringData: aostypes.MonitoringData{CPU: 500}, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service2, SubjectID: subject1, Instance: 0}, + MonitoringData: aostypes.MonitoringData{CPU: 500}, + }, + }, + }, + }, + storedInstances: []launcher.InstanceInfo{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service1, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDLocalSM, + UID: 5000, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service2, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDLocalSM, + UID: 5001, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service3, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDRemoteSM1, + UID: 5002, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 1}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 1}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service2, 5001, service2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5001, 3, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service3, 5002, service3RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 4, aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, 0), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM2, nil), + }, + rebalancing: true, + } +} + +func testItemRebalancingPolicy() testData { + return testData{ + testCaseName: "rebalancing policy", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: { + NodeType: nodeTypeLocalSM, Priority: 100, + AlertRules: &aostypes.AlertRules{ + CPU: &aostypes.AlertRulePercents{ + MinThreshold: 75.0, MaxThreshold: 85.0, + }, + }, + }, + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + service2: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + service3: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + BalancingPolicy: aostypes.BalancingDisabled, + }, + }, + monitoring: map[string]aostypes.NodeMonitoring{ + nodeIDLocalSM: { + NodeData: aostypes.MonitoringData{CPU: 1000}, + InstancesData: []aostypes.InstanceMonitoring{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service1, SubjectID: subject1, Instance: 0}, + MonitoringData: aostypes.MonitoringData{CPU: 500}, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service2, SubjectID: subject1, Instance: 0}, + MonitoringData: aostypes.MonitoringData{CPU: 500}, + }, + }, + }, + }, + storedInstances: []launcher.InstanceInfo{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service1, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDLocalSM, + UID: 5000, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service2, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDLocalSM, + UID: 5001, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service3, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDRemoteSM1, + UID: 5002, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 1}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 1}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service3, 5002, service3RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 3, aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, 0), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service2, 5001, service2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5001, 4, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM2, nil), + }, + rebalancing: true, + } +} + +func testItemRebalancingPrevNode() testData { + return testData{ + testCaseName: "rebalancing prev node", + nodeConfigs: map[string]cloudprotocol.NodeConfig{ + nodeTypeLocalSM: { + NodeType: nodeTypeLocalSM, Priority: 100, + AlertRules: &aostypes.AlertRules{ + CPU: &aostypes.AlertRulePercents{ + MinThreshold: 75.0, MaxThreshold: 85.0, + }, + }, + }, + nodeTypeRemoteSM: {NodeType: nodeTypeRemoteSM, Priority: 50}, + }, + serviceConfigs: map[string]aostypes.ServiceConfig{ + service1: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + service2: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + service3: { + Quotas: aostypes.ServiceQuotas{ + CPULimit: newQuota(1000), + }, + }, + }, + monitoring: map[string]aostypes.NodeMonitoring{ + nodeIDLocalSM: { + NodeData: aostypes.MonitoringData{CPU: 1000}, + InstancesData: []aostypes.InstanceMonitoring{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service1, SubjectID: subject1, Instance: 0}, + MonitoringData: aostypes.MonitoringData{CPU: 500}, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service2, SubjectID: subject1, Instance: 0}, + MonitoringData: aostypes.MonitoringData{CPU: 500}, + }, + }, + }, + }, + storedInstances: []launcher.InstanceInfo{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service1, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDLocalSM, + UID: 5000, + PrevNodeID: nodeIDLocalSM, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service2, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDLocalSM, + UID: 5001, + PrevNodeID: nodeIDRemoteSM1, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: service3, SubjectID: subject1, Instance: 0}, + NodeID: nodeIDRemoteSM1, + UID: 5002, + PrevNodeID: nodeIDRemoteSM2, + }, + }, + desiredInstances: []cloudprotocol.InstanceInfo{ + {ServiceID: service1, SubjectID: subject1, Priority: 100, NumInstances: 1}, + {ServiceID: service2, SubjectID: subject1, Priority: 50, NumInstances: 1}, + {ServiceID: service3, SubjectID: subject1, Priority: 0, NumInstances: 1}, + }, + expectedRunRequests: map[string]runRequest{ + nodeIDLocalSM: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service1, 5000, service1LocalURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5000, 2, aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, 100), + }, + }, + nodeIDRemoteSM1: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service3, 5002, service3RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5002, 3, aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, 0), + }, + }, + nodeIDRemoteSM2: { + services: []aostypes.ServiceInfo{ + createServiceInfo(service2, 5001, service2RemoteURL), + }, + instances: []aostypes.InstanceInfo{ + createInstanceInfo(5001, 4, aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, 50), + }, + }, + }, + expectedRunStatus: []cloudprotocol.InstanceStatus{ + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service1, SubjectID: subject1, Instance: 0, + }, nodeIDLocalSM, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service3, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM1, nil), + createInstanceStatus(aostypes.InstanceIdent{ + ServiceID: service2, SubjectID: subject1, Instance: 0, + }, nodeIDRemoteSM2, nil), + }, + rebalancing: true, + } +} + /*********************************************************************************************************************** * Private **********************************************************************************************************************/ diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 6d72fa73..42d20829 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -19,6 +19,7 @@ package launcher import ( "errors" + "math" "slices" "github.com/aosedge/aos_common/aoserrors" @@ -47,6 +48,8 @@ type nodeHandler struct { runRequest runRequest isLocalNode bool waitStatus bool + averageMonitoring aostypes.NodeMonitoring + needRebalancing bool availableCPU uint64 availableRAM uint64 } @@ -63,7 +66,8 @@ var defaultRunners = []string{"crun", "runc"} **********************************************************************************************************************/ func newNodeHandler( - nodeInfo cloudprotocol.NodeInfo, resourceManager ResourceManager, isLocalNode bool, + nodeInfo cloudprotocol.NodeInfo, nodeManager NodeManager, resourceManager ResourceManager, + isLocalNode bool, rebalancing bool, ) (*nodeHandler, error) { log.WithFields(log.Fields{"nodeID": nodeInfo.NodeID}).Debug("Init node handler") @@ -81,12 +85,102 @@ func newNodeHandler( node.nodeConfig = nodeConfig node.resetDeviceAllocations() - node.availableCPU = node.nodeInfo.MaxDMIPs - node.availableRAM = node.nodeInfo.TotalRAM + node.initAvailableResources(nodeManager, rebalancing) return node, nil } +func (node *nodeHandler) initAvailableResources(nodeManager NodeManager, rebalancing bool) { + var err error + + if rebalancing && node.nodeConfig.AlertRules != nil && + (node.nodeConfig.AlertRules.CPU != nil || node.nodeConfig.AlertRules.RAM != nil) { + node.averageMonitoring, err = nodeManager.GetAverageMonitoring(node.nodeInfo.NodeID) + if err != nil { + log.WithField("nodeID", node.nodeInfo.NodeID).Errorf("Can't get average monitoring: %v", err) + } + + if (node.nodeConfig.AlertRules.CPU != nil && + node.averageMonitoring.NodeData.CPU > + uint64(math.Round(float64(node.nodeInfo.MaxDMIPs)* + node.nodeConfig.AlertRules.CPU.MaxThreshold/100.0))) || + (node.nodeConfig.AlertRules.RAM != nil && + node.averageMonitoring.NodeData.RAM > + uint64(math.Round(float64(node.nodeInfo.TotalRAM)* + node.nodeConfig.AlertRules.RAM.MaxThreshold/100.0))) { + node.needRebalancing = true + } + } + + nodeCPU := node.getNodeCPU() + nodeRAM := node.getNodeRAM() + totalCPU := node.nodeInfo.MaxDMIPs + totalRAM := node.nodeInfo.TotalRAM + + // For nodes required rebalancing, we need to increase resource consumption below the low threshold + if node.needRebalancing { + if node.nodeConfig.AlertRules.CPU != nil { + totalCPU = uint64(math.Round(float64(node.nodeInfo.MaxDMIPs) * + node.nodeConfig.AlertRules.CPU.MinThreshold / 100.0)) + } + + if node.nodeConfig.AlertRules.RAM != nil { + totalRAM = uint64(math.Round(float64(node.nodeInfo.TotalRAM) * + node.nodeConfig.AlertRules.RAM.MinThreshold / 100.0)) + } + } + + if nodeCPU > totalCPU { + node.availableCPU = 0 + } else { + node.availableCPU = totalCPU - nodeCPU + } + + if nodeRAM > totalRAM { + node.availableRAM = 0 + } else { + node.availableRAM = totalRAM - nodeRAM + } + + if node.needRebalancing { + log.WithFields(log.Fields{ + "nodeID": node.nodeInfo.NodeID, "RAM": nodeRAM, "CPU": nodeCPU, + }).Debug("Node resources usage") + } + + log.WithFields(log.Fields{ + "nodeID": node.nodeInfo.NodeID, "RAM": node.availableRAM, "CPU": node.availableCPU, + }).Debug("Available resources on node") +} + +func (node *nodeHandler) getNodeCPU() uint64 { + instancesCPU := uint64(0) + + for _, instance := range node.averageMonitoring.InstancesData { + instancesCPU += instance.CPU + } + + if instancesCPU > node.averageMonitoring.NodeData.CPU { + return 0 + } + + return node.averageMonitoring.NodeData.CPU - instancesCPU +} + +func (node *nodeHandler) getNodeRAM() uint64 { + instancesRAM := uint64(0) + + for _, instance := range node.averageMonitoring.InstancesData { + instancesRAM += instance.RAM + } + + if instancesRAM > node.averageMonitoring.NodeData.RAM { + return 0 + } + + return node.averageMonitoring.NodeData.RAM - instancesRAM +} + func (node *nodeHandler) resetDeviceAllocations() { node.deviceAllocations = make(map[string]int) @@ -138,12 +232,12 @@ func (node *nodeHandler) addRunRequest(instanceInfo aostypes.InstanceInfo, servi node.addService(service) node.addLayers(layers) - requestedCPU := node.getRequestedCPU(service.Config) + requestedCPU := node.getRequestedCPU(instanceInfo.InstanceIdent, service.Config) if requestedCPU > node.availableCPU { return aoserrors.Errorf("not enough CPU") } - requestedRAM := node.getRequestedRAM(service.Config) + requestedRAM := node.getRequestedRAM(instanceInfo.InstanceIdent, service.Config) if requestedRAM > node.availableRAM { return aoserrors.Errorf("not enough CPU") } @@ -151,6 +245,10 @@ func (node *nodeHandler) addRunRequest(instanceInfo aostypes.InstanceInfo, servi node.availableCPU -= requestedCPU node.availableRAM -= requestedRAM + log.WithFields(log.Fields{ + "nodeID": node.nodeInfo.NodeID, "RAM": node.availableRAM, "CPU": node.availableCPU, + }).Debug("Remaining resources on node") + return nil } @@ -208,7 +306,9 @@ func (node *nodeHandler) getPartitionSize(partitionType string) uint64 { return node.nodeInfo.Partitions[partitionIndex].TotalSize } -func (node *nodeHandler) getRequestedCPU(serviceConfig aostypes.ServiceConfig) uint64 { +func (node *nodeHandler) getRequestedCPU( + instanceIdent aostypes.InstanceIdent, serviceConfig aostypes.ServiceConfig, +) uint64 { requestedCPU := uint64(0) if serviceConfig.Quotas.CPULimit != nil { @@ -216,10 +316,24 @@ func (node *nodeHandler) getRequestedCPU(serviceConfig aostypes.ServiceConfig) u serviceConfig.ResourceRatios, node.nodeConfig.ResourceRatios) + 0.5) } + if node.needRebalancing { + index := slices.IndexFunc(node.averageMonitoring.InstancesData, func(instance aostypes.InstanceMonitoring) bool { + return instance.InstanceIdent == instanceIdent + }) + + if index != -1 { + if node.averageMonitoring.InstancesData[index].CPU > requestedCPU { + return node.averageMonitoring.InstancesData[index].CPU + } + } + } + return requestedCPU } -func (node *nodeHandler) getRequestedRAM(serviceConfig aostypes.ServiceConfig) uint64 { +func (node *nodeHandler) getRequestedRAM( + instanceIdent aostypes.InstanceIdent, serviceConfig aostypes.ServiceConfig, +) uint64 { requestedRAM := uint64(0) if serviceConfig.Quotas.RAMLimit != nil { @@ -227,6 +341,18 @@ func (node *nodeHandler) getRequestedRAM(serviceConfig aostypes.ServiceConfig) u serviceConfig.ResourceRatios, node.nodeConfig.ResourceRatios) + 0.5) } + if node.needRebalancing { + index := slices.IndexFunc(node.averageMonitoring.InstancesData, func(instance aostypes.InstanceMonitoring) bool { + return instance.InstanceIdent == instanceIdent + }) + + if index != -1 { + if node.averageMonitoring.InstancesData[index].RAM > requestedRAM { + return node.averageMonitoring.InstancesData[index].RAM + } + } + } + return requestedRAM } @@ -347,11 +473,13 @@ func getNodeByRunners(nodes []*nodeHandler, runners []string) []*nodeHandler { return resultNodes } -func getNodesByCPU(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) []*nodeHandler { +func getNodesByCPU( + nodes []*nodeHandler, instanceIdent aostypes.InstanceIdent, serviceConfig aostypes.ServiceConfig, +) []*nodeHandler { resultNodes := make([]*nodeHandler, 0) for _, node := range nodes { - if node.availableCPU >= node.getRequestedCPU(serviceConfig) { + if node.availableCPU >= node.getRequestedCPU(instanceIdent, serviceConfig) { resultNodes = append(resultNodes, node) } } @@ -359,11 +487,13 @@ func getNodesByCPU(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) [ return resultNodes } -func getNodesByRAM(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) []*nodeHandler { +func getNodesByRAM( + nodes []*nodeHandler, instanceIdent aostypes.InstanceIdent, serviceConfig aostypes.ServiceConfig, +) []*nodeHandler { resultNodes := make([]*nodeHandler, 0) for _, node := range nodes { - if node.availableRAM >= node.getRequestedRAM(serviceConfig) { + if node.availableRAM >= node.getRequestedRAM(instanceIdent, serviceConfig) { resultNodes = append(resultNodes, node) } } @@ -389,18 +519,36 @@ func getTopPriorityNodes(nodes []*nodeHandler) []*nodeHandler { return resultNodes } -func getInstanceNode(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig) (*nodeHandler, error) { +func excludeNodes(nodes []*nodeHandler, excludeNodes []string) []*nodeHandler { + if len(excludeNodes) == 0 { + return nodes + } + + resultNodes := make([]*nodeHandler, 0) + + for _, node := range nodes { + if !slices.Contains(excludeNodes, node.nodeInfo.NodeID) { + resultNodes = append(resultNodes, node) + } + } + + return resultNodes +} + +func getInstanceNode( + nodes []*nodeHandler, instanceIdent aostypes.InstanceIdent, serviceConfig aostypes.ServiceConfig, +) (*nodeHandler, error) { resultNodes := getNodesByDevices(nodes, serviceConfig.Devices) if len(resultNodes) == 0 { return nil, aoserrors.Errorf("no nodes with devices %v", serviceConfig.Devices) } - resultNodes = getNodesByCPU(resultNodes, serviceConfig) + resultNodes = getNodesByCPU(resultNodes, instanceIdent, serviceConfig) if len(resultNodes) == 0 { return nil, aoserrors.Errorf("no nodes with available CPU") } - resultNodes = getNodesByRAM(resultNodes, serviceConfig) + resultNodes = getNodesByRAM(resultNodes, instanceIdent, serviceConfig) if len(resultNodes) == 0 { return nil, aoserrors.Errorf("no nodes with available RAM") } From 5903b448e4b530f33c6bad8794217f63aa33c052 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 31 Jul 2024 19:58:59 +0300 Subject: [PATCH 113/146] [database] Update database to new launcher interface Signed-off-by: Oleksandr Grytsov --- database/database.go | 57 +++++++++++++-------- database/database_internal_test.go | 79 ++++++++++++++++-------------- 2 files changed, 77 insertions(+), 59 deletions(-) diff --git a/database/database.go b/database/database.go index b7cb191e..07b901c2 100644 --- a/database/database.go +++ b/database/database.go @@ -25,7 +25,6 @@ import ( "os" "path/filepath" "sort" - "time" "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" @@ -514,26 +513,47 @@ func (db *Database) RemoveLayer(digest string) (err error) { return err } -// AddInstance adds instanace with uid. +// AddInstance adds instanace info. func (db *Database) AddInstance(instanceInfo launcher.InstanceInfo) error { - return db.executeQuery("INSERT INTO instances values(?, ?, ?, ?, ?, 0)", - instanceInfo.ServiceID, instanceInfo.SubjectID, instanceInfo.Instance, instanceInfo.UID, instanceInfo.Timestamp) + return db.executeQuery("INSERT INTO instances values(?, ?, ?, ?, ?, ?, ?, ?)", + instanceInfo.ServiceID, instanceInfo.SubjectID, instanceInfo.Instance, instanceInfo.NodeID, + instanceInfo.PrevNodeID, instanceInfo.UID, instanceInfo.Timestamp, instanceInfo.Cached) } -// GetInstanceUID gets uid by instanace ident. -func (db *Database) GetInstanceUID(instance aostypes.InstanceIdent) (int, error) { - var uid int +// UpdateInstance updates instance info. +func (db *Database) UpdateInstance(instanceInfo launcher.InstanceInfo) error { + if err := db.executeQuery("UPDATE instances SET "+ + "nodeID = ? prevNodeID = ? uid = ? timestamp = ? cached = ? "+ + "WHERE serviceId = ? AND subjectId = ? AND instance = ?", + instanceInfo.NodeID, instanceInfo.PrevNodeID, instanceInfo.UID, instanceInfo.Timestamp, instanceInfo.Cached, + instanceInfo.ServiceID, instanceInfo.SubjectID, instanceInfo.Instance); err != nil { + if errors.Is(err, errNotExist) { + return launcher.ErrNotExist + } + } + + return nil +} + +// GetInstance returns instance by instance ident. +func (db *Database) GetInstance(instance aostypes.InstanceIdent) (launcher.InstanceInfo, error) { + instanceInfo := launcher.InstanceInfo{ + InstanceIdent: instance, + } - if err := db.getDataFromQuery("SELECT uid FROM instances WHERE serviceId = ? AND subjectId = ? AND instance = ?", - []any{instance.ServiceID, instance.SubjectID, instance.Instance}, &uid); err != nil { + if err := db.getDataFromQuery("SELECT nodeID, prevNodeID, uid, timestamp, cached "+ + "FROM instances WHERE serviceId = ? AND subjectId = ? AND instance = ?", + []any{instance.ServiceID, instance.SubjectID, instance.Instance}, + &instanceInfo.NodeID, &instanceInfo.PrevNodeID, &instanceInfo.UID, + &instanceInfo.Timestamp, &instanceInfo.Cached); err != nil { if errors.Is(err, errNotExist) { - return uid, launcher.ErrNotExist + return instanceInfo, launcher.ErrNotExist } - return uid, err + return instanceInfo, err } - return uid, nil + return instanceInfo, nil } // GetInstances gets all instances. @@ -554,8 +574,8 @@ func (db *Database) GetInstances() ([]launcher.InstanceInfo, error) { for rows.Next() { var instance launcher.InstanceInfo - if err = rows.Scan(&instance.ServiceID, &instance.SubjectID, &instance.Instance, &instance.UID, - &instance.Timestamp, &instance.Cached); err != nil { + if err = rows.Scan(&instance.ServiceID, &instance.SubjectID, &instance.Instance, &instance.NodeID, + &instance.PrevNodeID, &instance.UID, &instance.Timestamp, &instance.Cached); err != nil { return nil, aoserrors.Wrap(err) } @@ -571,13 +591,6 @@ func (db *Database) RemoveInstance(instance aostypes.InstanceIdent) error { instance.ServiceID, instance.SubjectID, instance.Instance) } -// SetInstanceCached sets cached status for the instance. -func (db *Database) SetInstanceCached(instance aostypes.InstanceIdent, cached bool) error { - return db.executeQuery( - "UPDATE instances SET cached = ?, timestamp = ? WHERE serviceId = ? AND subjectId = ? AND instance = ?", - cached, time.Now().UTC(), instance.ServiceID, instance.SubjectID, instance.Instance) -} - // GetStorageStateInfo returns storage and state info by instance ident. func (db *Database) GetStorageStateInfo( instanceIdent aostypes.InstanceIdent, @@ -873,6 +886,8 @@ func (db *Database) createInstancesTable() (err error) { _, err = db.sql.Exec(`CREATE TABLE IF NOT EXISTS instances (serviceId TEXT, subjectId TEXT, instance INTEGER, + nodeID TEXT, + prevNodeID TEXT, uid integer, timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, cached INTEGER DEFAULT 0, diff --git a/database/database_internal_test.go b/database/database_internal_test.go index 32fdcd3b..afa14619 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -792,7 +792,7 @@ func TestInstance(t *testing.T) { t.Error("Incorrect empty instances") } - if _, err := testDB.GetInstanceUID(aostypes.InstanceIdent{ + if _, err := testDB.GetInstance(aostypes.InstanceIdent{ ServiceID: "notexist", SubjectID: "notexist", Instance: 0, }); !errors.Is(err, launcher.ErrNotExist) { t.Errorf("Incorrect error: %v, should be %v", err, launcher.ErrNotExist) @@ -800,10 +800,12 @@ func TestInstance(t *testing.T) { for i := 100; i < 105; i++ { instanceInfo := launcher.InstanceInfo{ - InstanceIdent: aostypes.InstanceIdent{ - ServiceID: servicePrefix + strconv.Itoa(i), SubjectID: subjectPrefix + strconv.Itoa(i), Instance: 0, - }, - UID: i, + InstanceIdent: createInstanceIdent(i), + NodeID: fmt.Sprintf("node%d", i+1), + PrevNodeID: fmt.Sprintf("node%d", i), + Timestamp: time.Now().UTC(), + UID: i, + Cached: i%2 == 0, } if err := testDB.AddInstance(instanceInfo); err != nil { @@ -813,18 +815,16 @@ func TestInstance(t *testing.T) { expectedInstances = append(expectedInstances, instanceInfo) } - expectedUID := 103 + expectedIndex := 103 - uid, err := testDB.GetInstanceUID(aostypes.InstanceIdent{ - ServiceID: servicePrefix + strconv.Itoa(expectedUID), - SubjectID: subjectPrefix + strconv.Itoa(expectedUID), Instance: 0, - }) + instanceInfo, err := testDB.GetInstance(createInstanceIdent(expectedIndex)) if err != nil { - t.Errorf("Can't get instance uid: %v", err) + t.Fatalf("Can't get instance: %v", err) } - if uid != expectedUID { - t.Error("Incorrect uid for instance") + if !reflect.DeepEqual(instanceInfo, expectedInstances[expectedIndex-100]) { + t.Errorf("Incorrect result for get instance: %v, expected: %v", instanceInfo, + expectedInstances[expectedIndex-100]) } instances, err = testDB.GetInstances() @@ -836,42 +836,37 @@ func TestInstance(t *testing.T) { t.Errorf("Incorrect result for get instances: %v, expected: %v", instances, expectedInstances) } - expectedCachedInstanceIdent := aostypes.InstanceIdent{ - ServiceID: servicePrefix + strconv.Itoa(expectedUID), - SubjectID: subjectPrefix + strconv.Itoa(expectedUID), Instance: 0, - } + updatedIndex := 102 - if err := testDB.SetInstanceCached(expectedCachedInstanceIdent, true); err != nil { - t.Errorf("Can't set instance cached: %v", err) + updatedInstance := launcher.InstanceInfo{ + InstanceIdent: createInstanceIdent(updatedIndex), + NodeID: "updatedNode", + PrevNodeID: "prevUpdatedNode", + Timestamp: time.Now().UTC(), + UID: 5000, + Cached: true, } - instances, err = testDB.GetInstances() - if err != nil { - t.Errorf("Can't get all instances: %v", err) + if err := testDB.UpdateInstance(updatedInstance); err != nil { + t.Errorf("Can't update instance: %v", err) } - for _, instance := range instances { - cached := instance.Cached - if instance.InstanceIdent == expectedCachedInstanceIdent { - if !cached { - t.Error("Instance expected to be cached") - } + if instanceInfo, err = testDB.GetInstance(createInstanceIdent(expectedIndex)); err != nil { + t.Fatalf("Can't get instance: %v", err) + } - break - } + if !reflect.DeepEqual(instanceInfo, expectedInstances[expectedIndex-100]) { + t.Errorf("Incorrect result for get instance: %v, expected: %v", instanceInfo, + expectedInstances[expectedIndex-100]) } - if err := testDB.RemoveInstance(aostypes.InstanceIdent{ - ServiceID: servicePrefix + strconv.Itoa(expectedUID), - SubjectID: subjectPrefix + strconv.Itoa(expectedUID), Instance: 0, - }); err != nil { + removedInstance := 104 + + if err := testDB.RemoveInstance(createInstanceIdent(removedInstance)); err != nil { t.Errorf("Can't remove instance: %v", err) } - if _, err := testDB.GetInstanceUID(aostypes.InstanceIdent{ - ServiceID: servicePrefix + strconv.Itoa(expectedUID), - SubjectID: subjectPrefix + strconv.Itoa(expectedUID), Instance: 0, - }); !errors.Is(err, launcher.ErrNotExist) { + if _, err := testDB.GetInstance(createInstanceIdent(removedInstance)); !errors.Is(err, launcher.ErrNotExist) { t.Errorf("Incorrect error: %v, should be %v", err, launcher.ErrNotExist) } } @@ -1196,3 +1191,11 @@ func isTableExist(sqlite *sql.DB, tableName string) (bool, error) { return false, aoserrors.Wrap(rows.Err()) } + +func createInstanceIdent(index int) aostypes.InstanceIdent { + return aostypes.InstanceIdent{ + ServiceID: servicePrefix + strconv.Itoa(index), + SubjectID: subjectPrefix + strconv.Itoa(index), + Instance: uint64(index), + } +} From 14396db5c346db6bde1efcb90d38d4bb3d3fe232 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 1 Aug 2024 13:49:39 +0300 Subject: [PATCH 114/146] [unitstatushandler] Add service revert if all instances failed Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 103 ++++++++-- unitstatushandler/unitstatushandler.go | 20 +- .../unitstatushandler_internal_test.go | 34 ++-- unitstatushandler/unitstatushandler_test.go | 176 ++++++++++++++---- 4 files changed, 248 insertions(+), 85 deletions(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index af783344..6ccd76d5 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -79,7 +79,7 @@ type softwareUpdate struct { type softwareManager struct { sync.Mutex - runCond *sync.Cond + runStatusCV *sync.Cond statusChannel chan cmserver.UpdateSOTAStatus @@ -96,6 +96,9 @@ type softwareManager struct { statusMutex sync.RWMutex pendingUpdate *softwareUpdate + newServices []string + revertServices []string + LayerStatuses map[string]*cloudprotocol.LayerStatus `json:"layerStatuses,omitempty"` ServiceStatuses map[string]*cloudprotocol.ServiceStatus `json:"serviceStatuses,omitempty"` InstanceStatuses []cloudprotocol.InstanceStatus `json:"instanceStatuses,omitempty"` @@ -128,7 +131,7 @@ func newSoftwareManager(statusHandler softwareStatusHandler, downloader software CurrentState: stateNoUpdate, } - manager.runCond = sync.NewCond(&manager.Mutex) + manager.runStatusCV = sync.NewCond(&manager.Mutex) if err = manager.loadState(); err != nil { return nil, aoserrors.Wrap(err) @@ -162,7 +165,8 @@ func (manager *softwareManager) close() (err error) { log.Debug("Close software manager") - manager.runCond.Broadcast() + manager.runStatusCV.Signal() + close(manager.statusChannel) manager.Unlock() @@ -215,22 +219,20 @@ func (manager *softwareManager) getCurrentStatus() (status cmserver.UpdateSOTASt return status } -func (manager *softwareManager) processRunStatus(status RunInstancesStatus) { +func (manager *softwareManager) processRunStatus(instances []cloudprotocol.InstanceStatus) bool { manager.Lock() defer manager.Unlock() - manager.InstanceStatuses = status.Instances + manager.InstanceStatuses = instances - for _, errStatus := range status.ErrorServices { - if _, ok := manager.ServiceStatuses[errStatus.ServiceID]; !ok { - status := errStatus - manager.ServiceStatuses[errStatus.ServiceID] = &status - } - - manager.updateServiceStatusByID(errStatus.ServiceID, errStatus.Status, errStatus.ErrorInfo) + if len(manager.newServices) != 0 && len(manager.CurrentUpdate.RunInstances) != 0 { + manager.checkNewServices() + manager.newServices = nil } - manager.runCond.Broadcast() + manager.runStatusCV.Signal() + + return len(manager.revertServices) == 0 } func (manager *softwareManager) processDesiredStatus(desiredStatus cloudprotocol.DesiredStatus) error { @@ -815,6 +817,9 @@ func (manager *softwareManager) update(ctx context.Context) { updateErr = err } + manager.newServices = newServices + manager.revertServices = nil + if err := manager.removeLayers(); err != nil && updateErr == nil { updateErr = err } @@ -823,11 +828,72 @@ func (manager *softwareManager) update(ctx context.Context) { updateErr = err } - if err := manager.runInstances(newServices); err != nil && updateErr == nil { + if err := manager.runInstances(); err != nil && updateErr == nil { updateErr = err } - manager.runCond.Wait() + manager.runStatusCV.Wait() + + if len(manager.revertServices) != 0 { + manager.doRevertServices() + manager.revertServices = nil + + if err := manager.runInstances(); err != nil && updateErr == nil { + updateErr = err + } + + manager.runStatusCV.Wait() + } +} + +func (manager *softwareManager) doRevertServices() { + for _, serviceID := range manager.revertServices { + log.WithField("id", serviceID).Debug("Revert service") + + manager.actionHandler.Execute(serviceID, func(serviceID string) error { + err := manager.softwareUpdater.RevertService(serviceID) + if err != nil { + log.WithField("id", serviceID).Errorf("Can't revert service: %v", err) + + return aoserrors.Wrap(err) + } + + log.WithField("id", serviceID).Debug("Service reverted") + + return nil + }) + } + + manager.actionHandler.Wait() +} + +func (manager *softwareManager) checkNewServices() { +serviceLoop: + for _, serviceID := range manager.newServices { + for _, instanceStatus := range manager.InstanceStatuses { + if instanceStatus.ServiceID == serviceID && instanceStatus.Status != cloudprotocol.InstanceStateFailed { + continue serviceLoop + } + } + + log.WithField("serviceID", serviceID).Error("Can't run any instances of service") + + updateErr := aoserrors.New("can't run any instances of service") + + if _, ok := manager.ServiceStatuses[serviceID]; !ok { + log.Errorf("Service status not found: %s", serviceID) + + manager.ServiceStatuses[serviceID] = &cloudprotocol.ServiceStatus{ + ServiceID: serviceID, + } + } + + manager.ServiceStatuses[serviceID].Status = cloudprotocol.ErrorStatus + manager.updateServiceStatusByID(serviceID, cloudprotocol.ErrorStatus, + &cloudprotocol.ErrorInfo{Message: updateErr.Error()}) + + manager.revertServices = append(manager.revertServices, serviceID) + } } func (manager *softwareManager) updateTimeout() { @@ -840,7 +906,7 @@ func (manager *softwareManager) updateTimeout() { } } - manager.runCond.Broadcast() + manager.runStatusCV.Signal() } /*********************************************************************************************************************** @@ -1370,7 +1436,7 @@ func (manager *softwareManager) removeServices() (removeErr error) { return removeErr } -func (manager *softwareManager) runInstances(newServices []string) (runErr error) { +func (manager *softwareManager) runInstances() (runErr error) { manager.InstanceStatuses = []cloudprotocol.InstanceStatus{} for _, instance := range manager.CurrentUpdate.RunInstances { @@ -1397,7 +1463,8 @@ func (manager *softwareManager) runInstances(newServices []string) (runErr error manager.statusHandler.setInstancesStatus(manager.InstanceStatuses) - if err := manager.instanceRunner.RunInstances(manager.CurrentUpdate.RunInstances, newServices); err != nil { + if err := manager.instanceRunner.RunInstances( + manager.CurrentUpdate.RunInstances, manager.CurrentUpdate.RebalanceRequest); err != nil { return aoserrors.Wrap(err) } diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index f4321daa..166ae79b 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -81,7 +81,7 @@ type FirmwareUpdater interface { // InstanceRunner instances runner. type InstanceRunner interface { - RunInstances(instances []cloudprotocol.InstanceInfo, newServices []string) error + RunInstances(instances []cloudprotocol.InstanceInfo, rebalancing bool) error } // SystemQuotaAlertProvider provides system quota alerts. @@ -96,6 +96,7 @@ type SoftwareUpdater interface { InstallService(serviceInfo cloudprotocol.ServiceInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate) error RestoreService(serviceID string) error + RevertService(serviceID string) error RemoveService(serviceID string) error InstallLayer(layerInfo cloudprotocol.LayerInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate) error @@ -123,13 +124,6 @@ type LayerStatus struct { Cached bool } -// RunInstancesStatus run instances status. -type RunInstancesStatus struct { - UnitSubjects []string - Instances []cloudprotocol.InstanceStatus - ErrorServices []cloudprotocol.ServiceStatus -} - // Instance instance of unit status handler. type Instance struct { sync.Mutex @@ -265,16 +259,19 @@ func (instance *Instance) SendUnitStatus() error { } // ProcessRunStatus process current run instances status. -func (instance *Instance) ProcessRunStatus(status RunInstancesStatus) error { +func (instance *Instance) ProcessRunStatus(instances []cloudprotocol.InstanceStatus) error { instance.Lock() defer instance.Unlock() + if !instance.softwareManager.processRunStatus(instances) { + return nil + } + if err := instance.initCurrentStatus(); err != nil { return aoserrors.Wrap(err) } - instance.unitStatus.subjects = status.UnitSubjects - instance.unitStatus.instances = status.Instances + instance.unitStatus.instances = instances nodesInfo, err := instance.getAllNodesInfo() if err != nil { @@ -283,7 +280,6 @@ func (instance *Instance) ProcessRunStatus(status RunInstancesStatus) error { instance.unitStatus.nodes = nodesInfo - instance.softwareManager.processRunStatus(status) instance.sendCurrentStatus() return nil diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 5056fc6a..73b2c5d6 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -21,8 +21,6 @@ import ( "context" "encoding/json" "os" - "reflect" - "sort" "strings" "testing" "time" @@ -78,14 +76,14 @@ type TestFirmwareUpdater struct { } type TestSoftwareUpdater struct { - AllServices []ServiceStatus - AllLayers []LayerStatus - UpdateError error + AllServices []ServiceStatus + AllLayers []LayerStatus + RevertedServices []string + UpdateError error } type TestInstanceRunner struct { runInstanceChan chan []cloudprotocol.InstanceInfo - newServices []string } type TestSystemQuotaAlertProvider struct { @@ -924,7 +922,6 @@ func TestSoftwareManager(t *testing.T) { triggerUpdate bool updateError error updateWaitStatuses []cmserver.UpdateStatus - newServices []string requestRebalancing bool } @@ -984,7 +981,6 @@ func TestSoftwareManager(t *testing.T) { {State: cmserver.Updating}, {State: cmserver.NoUpdate}, }, - newServices: []string{"service1", "service2"}, }, { testID: "new services", @@ -1042,7 +1038,6 @@ func TestSoftwareManager(t *testing.T) { {State: cmserver.Updating}, {State: cmserver.NoUpdate}, }, - newServices: []string{"service3", "service4"}, }, { testID: "one item download error", @@ -1353,17 +1348,7 @@ func TestSoftwareManager(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } - if item.newServices != nil { - sort.Slice(instanceRunner.newServices, func(i, j int) bool { - return instanceRunner.newServices[j] > instanceRunner.newServices[i] - }) - - if !reflect.DeepEqual(instanceRunner.newServices, item.newServices) { - t.Errorf("Wrong new services: %v", instanceRunner.newServices) - } - } - - softwareManager.processRunStatus(RunInstancesStatus{}) + softwareManager.processRunStatus(nil) } if err = waitForSOTAUpdateStatus(softwareManager.statusChannel, expectedStatus); err != nil { @@ -1850,6 +1835,12 @@ func (updater *TestSoftwareUpdater) RemoveService(serviceID string) error { return updater.UpdateError } +func (updater *TestSoftwareUpdater) RevertService(serviceID string) error { + updater.RevertedServices = append(updater.RevertedServices, serviceID) + + return updater.UpdateError +} + func (updater *TestSoftwareUpdater) InstallLayer(layerInfo cloudprotocol.LayerInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate, ) error { @@ -1872,8 +1863,7 @@ func NewTestInstanceRunner() *TestInstanceRunner { return &TestInstanceRunner{runInstanceChan: make(chan []cloudprotocol.InstanceInfo, 1)} } -func (runner *TestInstanceRunner) RunInstances(instances []cloudprotocol.InstanceInfo, newServices []string) error { - runner.newServices = newServices +func (runner *TestInstanceRunner) RunInstances(instances []cloudprotocol.InstanceInfo, rebalancing bool) error { runner.runInstanceChan <- instances return nil diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index aa0f3a75..7f046ed2 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -124,8 +124,7 @@ func TestSendInitialStatus(t *testing.T) { t.Fatalf("Can't send unit status: %v", err) } - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{UnitSubjects: []string{"subject1"}}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -140,8 +139,7 @@ func TestSendInitialStatus(t *testing.T) { sender.Consumer.CloudDisconnected() - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{UnitSubjects: []string{"subject10"}}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -171,7 +169,7 @@ func TestUpdateUnitConfig(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -198,7 +196,7 @@ func TestUpdateUnitConfig(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -228,7 +226,7 @@ func TestUpdateUnitConfig(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -266,7 +264,7 @@ func TestUpdateComponents(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -373,7 +371,7 @@ func TestUpdateLayers(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -417,7 +415,7 @@ func TestUpdateLayers(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -531,7 +529,7 @@ func TestUpdateServices(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -574,7 +572,7 @@ func TestUpdateServices(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -690,8 +688,7 @@ func TestRunInstances(t *testing.T) { }, } - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{Instances: initialInstancesStatus}); err != nil { + if err := statusHandler.ProcessRunStatus(initialInstancesStatus); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -753,8 +750,7 @@ func TestRunInstances(t *testing.T) { }, } - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{Instances: updatedInstancesStatus}); err != nil { + if err := statusHandler.ProcessRunStatus(updatedInstancesStatus); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -782,7 +778,7 @@ func TestRunInstances(t *testing.T) { } } -func TestUpdateInstancesStatus(t *testing.T) { +func TestRevertServices(t *testing.T) { unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) @@ -803,21 +799,134 @@ func TestUpdateInstancesStatus(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{ - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, - ServiceVersion: "1.0.0", - }, + if err := statusHandler.ProcessRunStatus(nil); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + + if _, err = sender.WaitForStatus(waitStatusTimeout); err != nil { + t.Fatalf("Can't receive unit status: %v", err) + } + + // success run + + expectedRunInstances := []cloudprotocol.InstanceInfo{ + {ServiceID: "service0", SubjectID: "subject0", NumInstances: 3}, + } + + statusHandler.ProcessDesiredStatus(cloudprotocol.DesiredStatus{ + Instances: expectedRunInstances, + Services: []cloudprotocol.ServiceInfo{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, - ServiceVersion: "1.0.0", + ServiceID: "service0", Version: "1.0.0", + DownloadInfo: cloudprotocol.DownloadInfo{Sha256: []byte{0}}, }, + }, + }) + + instancesStatus := []cloudprotocol.InstanceStatus{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subject0", Instance: 0}, + ServiceVersion: "1.0.0", + Status: cloudprotocol.InstanceStateFailed, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subject0", Instance: 1}, + ServiceVersion: "1.0.0", + Status: cloudprotocol.InstanceStateFailed, + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: "service0", SubjectID: "subject0", Instance: 2}, + ServiceVersion: "1.0.0", + Status: cloudprotocol.InstanceStateFailed, + }, + } + + receivedRunInstances, err := instanceRunner.WaitForRunInstance(waitRunInstanceTimeout) + if err != nil { + t.Fatalf("Can't receive run instances: %v", err) + } + + if !reflect.DeepEqual(receivedRunInstances, expectedRunInstances) { + t.Error("Incorrect run instances") + } + + if err := statusHandler.ProcessRunStatus(instancesStatus); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + + receivedRunInstances, err = instanceRunner.WaitForRunInstance(waitRunInstanceTimeout) + if err != nil { + t.Fatalf("Can't receive run instances: %v", err) + } + + if !reflect.DeepEqual(receivedRunInstances, expectedRunInstances) { + t.Error("Incorrect run instances") + } + + if err := statusHandler.ProcessRunStatus(instancesStatus); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + + receivedUnitStatus, err := sender.WaitForStatus(waitStatusTimeout) + if err != nil { + t.Fatalf("Can't receive unit status: %v", err) + } + + expectedUnitStatus := cloudprotocol.UnitStatus{ + UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, + Services: []cloudprotocol.ServiceStatus{ { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, - ServiceVersion: "1.0.0", + ServiceID: "service0", Version: "1.0.0", Status: cloudprotocol.ErrorStatus, + ErrorInfo: &cloudprotocol.ErrorInfo{Message: "can't run any instances of service"}, }, - }}); err != nil { + }, + Instances: instancesStatus, + } + + if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { + t.Errorf("Wrong unit status received: %v, expected: %v", receivedUnitStatus, expectedUnitStatus) + } + + if !reflect.DeepEqual(softwareUpdater.RevertedServices, []string{"service0"}) { + t.Errorf("Incorrect reverted services: %v", softwareUpdater.RevertedServices) + } +} + +func TestUpdateInstancesStatus(t *testing.T) { + unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( + cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) + firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) + softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) + instanceRunner := unitstatushandler.NewTestInstanceRunner() + sender := unitstatushandler.NewTestSender() + + statusHandler, err := unitstatushandler.New( + cfg, unitstatushandler.NewTestNodeManager(nil), unitConfigUpdater, firmwareUpdater, softwareUpdater, + instanceRunner, unitstatushandler.NewTestDownloader(), unitstatushandler.NewTestStorage(), sender, + unitstatushandler.NewTestSystemQuotaAlertProvider()) + if err != nil { + t.Fatalf("Can't create unit status handler: %v", err) + } + defer statusHandler.Close() + + sender.Consumer.CloudConnected() + + go handleUpdateStatus(statusHandler) + + if err := statusHandler.ProcessRunStatus([]cloudprotocol.InstanceStatus{ + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, + ServiceVersion: "1.0.0", + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, + ServiceVersion: "1.0.0", + }, + { + InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, + ServiceVersion: "1.0.0", + }, + }); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -921,7 +1030,7 @@ func TestUpdateCachedSOTA(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus(unitstatushandler.RunInstancesStatus{}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -1036,8 +1145,7 @@ func TestNewComponents(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{}}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -1113,8 +1221,7 @@ func TestNodeInfoChanged(t *testing.T) { go handleUpdateStatus(statusHandler) - if err := statusHandler.ProcessRunStatus( - unitstatushandler.RunInstancesStatus{Instances: []cloudprotocol.InstanceStatus{}}); err != nil { + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -1225,6 +1332,9 @@ func compareUnitStatus(status1, status2 cloudprotocol.UnitStatus) (err error) { if err = compareStatus(len(status1.Services), len(status2.Services), func(index1, index2 int) (result bool) { + status1.Services[index1].ErrorInfo = nil + status2.Services[index2].ErrorInfo = nil + return reflect.DeepEqual(status1.Services[index1], status2.Services[index2]) }); err != nil { return aoserrors.Wrap(err) From 51d52d1a9826bdd4a9b14feeba41b0f8f153b935 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 1 Aug 2024 13:52:02 +0300 Subject: [PATCH 115/146] [smcontroller] Reaname in/out traffic fields to download/upload Signed-off-by: Oleksandr Grytsov --- amqphandler/amqphandler_test.go | 2 +- monitorcontroller/monitorcontroller_test.go | 2 +- smcontroller/smcontroller_test.go | 28 ++++++++++----------- smcontroller/smhandler.go | 12 ++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index cec7bedc..7ae00e9c 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -469,7 +469,7 @@ func TestSendMessages(t *testing.T) { nodeMonitoring := cloudprotocol.NodeMonitoringData{ Items: []aostypes.MonitoringData{ { - RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Disk: []aostypes.PartitionUsage{{ + RAM: 1024, CPU: 50, Download: 8192, Upload: 4096, Disk: []aostypes.PartitionUsage{{ Name: "p1", UsedSize: 100, }}, Timestamp: time.Now().UTC(), diff --git a/monitorcontroller/monitorcontroller_test.go b/monitorcontroller/monitorcontroller_test.go index efbc5943..d6eea03c 100644 --- a/monitorcontroller/monitorcontroller_test.go +++ b/monitorcontroller/monitorcontroller_test.go @@ -183,7 +183,7 @@ func getTestMonitoringData() (aostypes.NodeMonitoring, cloudprotocol.Monitoring) NodeID: "mainNode", Items: []aostypes.MonitoringData{ { - RAM: 1024, CPU: 50, InTraffic: 8192, OutTraffic: 4096, Timestamp: timestamp, + RAM: 1024, CPU: 50, Download: 8192, Upload: 4096, Timestamp: timestamp, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, }, }, diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 1ed28bfb..eee7edd7 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -545,7 +545,7 @@ func TestSMMonitoringNotifications(t *testing.T) { expectedMonitoring: aostypes.NodeMonitoring{ NodeID: nodeID, NodeData: aostypes.MonitoringData{ - RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 50, + RAM: 10, CPU: 20, Download: 40, Upload: 50, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: now, }, @@ -553,7 +553,7 @@ func TestSMMonitoringNotifications(t *testing.T) { }, sendMonitoring: &pbsm.InstantMonitoring{ NodeMonitoring: &pbsm.MonitoringData{ - Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 50, + Ram: 10, Cpu: 20, Download: 40, Upload: 50, Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: timestamppb.New(now), }, @@ -563,7 +563,7 @@ func TestSMMonitoringNotifications(t *testing.T) { expectedMonitoring: aostypes.NodeMonitoring{ NodeID: nodeID, NodeData: aostypes.MonitoringData{ - RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 50, + RAM: 10, CPU: 20, Download: 40, Upload: 50, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: now, }, @@ -571,7 +571,7 @@ func TestSMMonitoringNotifications(t *testing.T) { { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "s1", Instance: 1}, MonitoringData: aostypes.MonitoringData{ - RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 0, + RAM: 10, CPU: 20, Download: 40, Upload: 0, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: now, }, @@ -579,7 +579,7 @@ func TestSMMonitoringNotifications(t *testing.T) { { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "s1", Instance: 1}, MonitoringData: aostypes.MonitoringData{ - RAM: 20, CPU: 30, InTraffic: 50, OutTraffic: 10, + RAM: 20, CPU: 30, Download: 50, Upload: 10, Disk: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}}, Timestamp: now, }, @@ -588,7 +588,7 @@ func TestSMMonitoringNotifications(t *testing.T) { }, sendMonitoring: &pbsm.InstantMonitoring{ NodeMonitoring: &pbsm.MonitoringData{ - Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 50, + Ram: 10, Cpu: 20, Download: 40, Upload: 50, Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: timestamppb.New(now), }, @@ -596,7 +596,7 @@ func TestSMMonitoringNotifications(t *testing.T) { { Instance: &pbcommon.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1}, MonitoringData: &pbsm.MonitoringData{ - Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 0, + Ram: 10, Cpu: 20, Download: 40, Upload: 0, Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: timestamppb.New(now), }, @@ -604,7 +604,7 @@ func TestSMMonitoringNotifications(t *testing.T) { { Instance: &pbcommon.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1}, MonitoringData: &pbsm.MonitoringData{ - Ram: 20, Cpu: 30, InTraffic: 50, OutTraffic: 10, + Ram: 20, Cpu: 30, Download: 50, Upload: 10, Disk: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}}, Timestamp: timestamppb.New(now), }, @@ -1144,7 +1144,7 @@ func TestGetAverageMonitoring(t *testing.T) { expectedMonitoring = aostypes.NodeMonitoring{ NodeID: nodeID, NodeData: aostypes.MonitoringData{ - RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 50, + RAM: 10, CPU: 20, Download: 40, Upload: 50, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: currentTime, }, @@ -1152,7 +1152,7 @@ func TestGetAverageMonitoring(t *testing.T) { { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service1", SubjectID: "s1", Instance: 1}, MonitoringData: aostypes.MonitoringData{ - RAM: 10, CPU: 20, InTraffic: 40, OutTraffic: 0, + RAM: 10, CPU: 20, Download: 40, Upload: 0, Disk: []aostypes.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: currentTime, }, @@ -1160,7 +1160,7 @@ func TestGetAverageMonitoring(t *testing.T) { { InstanceIdent: aostypes.InstanceIdent{ServiceID: "service2", SubjectID: "s1", Instance: 1}, MonitoringData: aostypes.MonitoringData{ - RAM: 20, CPU: 30, InTraffic: 50, OutTraffic: 10, + RAM: 20, CPU: 30, Download: 50, Upload: 10, Disk: []aostypes.PartitionUsage{{Name: "p2", UsedSize: 50}}, Timestamp: currentTime, }, @@ -1170,7 +1170,7 @@ func TestGetAverageMonitoring(t *testing.T) { sendMonitoring = &pbsm.SMOutgoingMessages{SMOutgoingMessage: &pbsm.SMOutgoingMessages_AverageMonitoring{ AverageMonitoring: &pbsm.AverageMonitoring{ NodeMonitoring: &pbsm.MonitoringData{ - Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 50, + Ram: 10, Cpu: 20, Download: 40, Upload: 50, Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: timestamppb.New(currentTime), }, @@ -1178,7 +1178,7 @@ func TestGetAverageMonitoring(t *testing.T) { { Instance: &pbcommon.InstanceIdent{ServiceId: "service1", SubjectId: "s1", Instance: 1}, MonitoringData: &pbsm.MonitoringData{ - Ram: 10, Cpu: 20, InTraffic: 40, OutTraffic: 0, + Ram: 10, Cpu: 20, Download: 40, Upload: 0, Disk: []*pbsm.PartitionUsage{{Name: "p1", UsedSize: 100}}, Timestamp: timestamppb.New(currentTime), }, @@ -1186,7 +1186,7 @@ func TestGetAverageMonitoring(t *testing.T) { { Instance: &pbcommon.InstanceIdent{ServiceId: "service2", SubjectId: "s1", Instance: 1}, MonitoringData: &pbsm.MonitoringData{ - Ram: 20, Cpu: 30, InTraffic: 50, OutTraffic: 10, + Ram: 20, Cpu: 30, Download: 50, Upload: 10, Disk: []*pbsm.PartitionUsage{{Name: "p2", UsedSize: 50}}, Timestamp: timestamppb.New(currentTime), }, diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 967891f1..95016222 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -755,12 +755,12 @@ func instantMonitoringFromPB(instantMonitoring *pb.InstantMonitoring) aostypes.N func monitoringDataFromPB(pbMonitoring *pb.MonitoringData) aostypes.MonitoringData { monitoringData := aostypes.MonitoringData{ - Timestamp: pbMonitoring.GetTimestamp().AsTime(), - RAM: pbMonitoring.GetRam(), - CPU: pbMonitoring.GetCpu(), - InTraffic: pbMonitoring.GetInTraffic(), - OutTraffic: pbMonitoring.GetOutTraffic(), - Disk: make([]aostypes.PartitionUsage, len(pbMonitoring.GetDisk())), + Timestamp: pbMonitoring.GetTimestamp().AsTime(), + RAM: pbMonitoring.GetRam(), + CPU: pbMonitoring.GetCpu(), + Download: pbMonitoring.GetDownload(), + Upload: pbMonitoring.GetUpload(), + Disk: make([]aostypes.PartitionUsage, len(pbMonitoring.GetDisk())), } for i, pbData := range pbMonitoring.GetDisk() { From 5a7a8118e5f2aa76fbb202629fa37c1f4aa9085e Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 1 Aug 2024 13:52:36 +0300 Subject: [PATCH 116/146] [lint] Add known numbers Signed-off-by: Oleksandr Grytsov --- .golangci.yml | 6 +++++- communicationmanager.go | 4 ++-- launcher/launcher.go | 1 - umcontroller/umcontroller.go | 3 +-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7f5d8da7..b435c106 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,13 +37,17 @@ linters-settings: funlen: lines: 100 + statements: 50 + + gocognit: + min-complexity: 40 gosec: excludes: - G204 mnd: - ignored-numbers: 0o600,0o755,0o644,5,10,16,32,64,128,100,0xff,3 + ignored-numbers: 0o600,0o755,0o644,0.5,3,5,10,16,32,64,128,100,100.0,0xff ignored-files: config/config.go,fcrypt/utils.go interfacebloat: diff --git a/communicationmanager.go b/communicationmanager.go index 2e27af80..a05aa48d 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -121,7 +121,8 @@ func init() { * CommunicationManager **********************************************************************************************************************/ -func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err error) { //nolint:gocognit,funlen +//nolint:funlen +func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err error) { defer func() { if err != nil { cm.close() @@ -342,7 +343,6 @@ func (cm *communicationManager) close() { } } -//nolint:funlen func (cm *communicationManager) processMessage(message amqp.Message) (err error) { switch data := message.(type) { case *cloudprotocol.DesiredStatus: diff --git a/launcher/launcher.go b/launcher/launcher.go index 9d3b6602..f7a3d3db 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -471,7 +471,6 @@ func (launcher *Launcher) performPolicyBalancing(instances []cloudprotocol.Insta } } -//nolint:gocognit func (launcher *Launcher) performNodeBalancing(instances []cloudprotocol.InstanceInfo, rebalancing bool) { for _, instance := range instances { log.WithFields(log.Fields{ diff --git a/umcontroller/umcontroller.go b/umcontroller/umcontroller.go index 9521e02f..6f554a7a 100644 --- a/umcontroller/umcontroller.go +++ b/umcontroller/umcontroller.go @@ -309,7 +309,7 @@ func (umCtrl *Controller) GetStatus() ([]cloudprotocol.ComponentStatus, error) { // UpdateComponents updates components. // -//nolint:funlen,gocognit +//nolint:funlen func (umCtrl *Controller) UpdateComponents( components []cloudprotocol.ComponentInfo, chains []cloudprotocol.CertificateChain, certs []cloudprotocol.Certificate, @@ -466,7 +466,6 @@ func (umCtrl *Controller) processInternalMessages() { } } -//nolint:funlen func (umCtrl *Controller) handleNewConnection(umID string, handler *umHandler, status umStatus) { if handler == nil { log.Error("Handler is nil") From 70e90e43634d1cea6adb3b82f1dc01c949aaadbe Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Thu, 1 Aug 2024 14:52:07 +0300 Subject: [PATCH 117/146] [smcontroller] Rename alert Payload to AlertItem Signed-off-by: Oleksandr Grytsov --- smcontroller/smcontroller_test.go | 16 ++++++++-------- smcontroller/smhandler.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index eee7edd7..3ae353f6 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -355,7 +355,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemError, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_SystemAlert{ + AlertItem: &pbsm.Alert_SystemAlert{ SystemAlert: &pbsm.SystemAlert{Message: "SystemAlertMessage"}, }, }, @@ -368,7 +368,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagAosCore, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_CoreAlert{ + AlertItem: &pbsm.Alert_CoreAlert{ CoreAlert: &pbsm.CoreAlert{CoreComponent: "SM", Message: "CoreAlertMessage"}, }, }, @@ -386,7 +386,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagResourceValidate, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_ResourceValidateAlert{ + AlertItem: &pbsm.Alert_ResourceValidateAlert{ ResourceValidateAlert: &pbsm.ResourceValidateAlert{ Name: "someName", Errors: []*pbcommon.ErrorInfo{ @@ -407,7 +407,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagDeviceAllocate, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_DeviceAllocateAlert{ + AlertItem: &pbsm.Alert_DeviceAllocateAlert{ DeviceAllocateAlert: &pbsm.DeviceAllocateAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, Device: "someDevice", Message: "someMessage", @@ -423,7 +423,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemQuota, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_SystemQuotaAlert{ + AlertItem: &pbsm.Alert_SystemQuotaAlert{ SystemQuotaAlert: &pbsm.SystemQuotaAlert{ Parameter: "cpu", Value: 42, Status: resourcemonitor.AlertStatusRaise, }, @@ -438,7 +438,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagSystemQuota, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_SystemQuotaAlert{ + AlertItem: &pbsm.Alert_SystemQuotaAlert{ SystemQuotaAlert: &pbsm.SystemQuotaAlert{ Parameter: "ram", Value: 99, Status: resourcemonitor.AlertStatusRaise, }, @@ -454,7 +454,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagInstanceQuota, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_InstanceQuotaAlert{ + AlertItem: &pbsm.Alert_InstanceQuotaAlert{ InstanceQuotaAlert: &pbsm.InstanceQuotaAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, Parameter: "param1", Value: 42, Status: resourcemonitor.AlertStatusRaise, @@ -471,7 +471,7 @@ func TestSMAlertNotifications(t *testing.T) { sendAlert: &pbsm.Alert{ Tag: cloudprotocol.AlertTagServiceInstance, Timestamp: timestamppb.New(now), - Payload: &pbsm.Alert_InstanceAlert{ + AlertItem: &pbsm.Alert_InstanceAlert{ InstanceAlert: &pbsm.InstanceAlert{ Instance: &pbcommon.InstanceIdent{ServiceId: "id1", SubjectId: "s1", Instance: 1}, Message: "ServiceInstanceAlert", ServiceVersion: "42.0.0", diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 95016222..643e103e 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -466,7 +466,7 @@ func (handler *smHandler) processAlert(alert *pb.Alert) { var alertItem interface{} - switch data := alert.GetPayload().(type) { + switch data := alert.GetAlertItem().(type) { case *pb.Alert_SystemAlert: alertItem = cloudprotocol.SystemAlert{ AlertItem: cloudprotocol.AlertItem{Timestamp: timestamp, Tag: tag}, From ccab243e901973d710855ceb7fd606305e4aa8b3 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sat, 3 Aug 2024 17:07:54 +0300 Subject: [PATCH 118/146] [statestorage] Remove unused instance ID field Signed-off-by: Oleksandr Grytsov --- storagestate/storagestate.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/storagestate/storagestate.go b/storagestate/storagestate.go index c6b1da5f..179511e7 100644 --- a/storagestate/storagestate.go +++ b/storagestate/storagestate.go @@ -128,7 +128,6 @@ type StorageState struct { } type stateParams struct { - instanceID string stateFilePath string quota uint64 checksum []byte @@ -409,7 +408,7 @@ func (storageState *StorageState) initStateWatching() error { } for _, info := range infos { - if err = storageState.startStateWatching(info.InstanceIdent, info.InstanceID, + if err = storageState.startStateWatching(info.InstanceIdent, storageState.getStatePath(info.InstanceID), info.StateQuota); err != nil { log.WithField("instanceID", info.InstanceID).Errorf("Can't setup state watching: %v", err) } @@ -431,7 +430,7 @@ func (storageState *StorageState) prepareState( stateFilePath = storageState.getStatePath(instanceID) - if err = storageState.setupStateWatching(instanceID, stateFilePath, params); err != nil { + if err = storageState.setupStateWatching(stateFilePath, params); err != nil { return "", aoserrors.Wrap(err) } @@ -499,13 +498,13 @@ func (storageState *StorageState) checkChecksumAndSendUpdateRequest( return nil } -func (storageState *StorageState) setupStateWatching(instanceID, stateFilePath string, params SetupParams) error { +func (storageState *StorageState) setupStateWatching(stateFilePath string, params SetupParams) error { if err := createStateFileIfNotExist(stateFilePath, params.UID, params.GID); err != nil { return aoserrors.Wrap(err) } if err := storageState.startStateWatching( - params.InstanceIdent, instanceID, stateFilePath, params.StateQuota); err != nil { + params.InstanceIdent, stateFilePath, params.StateQuota); err != nil { return aoserrors.Wrap(err) } @@ -513,14 +512,13 @@ func (storageState *StorageState) setupStateWatching(instanceID, stateFilePath s } func (storageState *StorageState) startStateWatching( - instanceIdent aostypes.InstanceIdent, instanceID string, stateFilePath string, quota uint64, + instanceIdent aostypes.InstanceIdent, stateFilePath string, quota uint64, ) (err error) { if err = storageState.watcher.Add(stateFilePath); err != nil { return aoserrors.Wrap(err) } storageState.statesMap[instanceIdent] = &stateParams{ - instanceID: instanceID, stateFilePath: stateFilePath, quota: quota, changeTimerChannel: make(chan bool, 1), From 1c1b562628fbbd10900995ec899ed4478d6eb719 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sun, 4 Aug 2024 20:43:06 +0300 Subject: [PATCH 119/146] [unitstatushandler] Rework current status initialization Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 16 ++++ unitstatushandler/unitstatushandler.go | 104 +++++++++++++++++++++---- 2 files changed, 107 insertions(+), 13 deletions(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 6ccd76d5..f167ab7b 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -492,6 +492,12 @@ func (manager *softwareManager) getServiceStatus() (serviceStatuses []cloudproto } func (manager *softwareManager) getLayersStatus() (layerStatuses []cloudprotocol.LayerStatus, err error) { + manager.Lock() + defer manager.Unlock() + + manager.statusMutex.RLock() + defer manager.statusMutex.RUnlock() + layersStatus, err := manager.softwareUpdater.GetLayersStatus() if err != nil { return nil, aoserrors.Wrap(err) @@ -539,6 +545,16 @@ func (manager *softwareManager) getUnitConfigStatuses() (status []cloudprotocol. return status, nil } +func (manager *softwareManager) getInstancesStatus() ([]cloudprotocol.InstanceStatus, error) { + manager.Lock() + defer manager.Unlock() + + manager.statusMutex.RLock() + defer manager.statusMutex.RUnlock() + + return manager.InstanceStatuses, nil +} + /*********************************************************************************************************************** * Implementer **********************************************************************************************************************/ diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 166ae79b..abfc4142 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -253,6 +253,10 @@ func (instance *Instance) SendUnitStatus() error { instance.Lock() defer instance.Unlock() + if err := instance.initCurrentStatus(); err != nil { + return aoserrors.Wrap(err) + } + instance.sendCurrentStatus() return nil @@ -271,14 +275,7 @@ func (instance *Instance) ProcessRunStatus(instances []cloudprotocol.InstanceSta return aoserrors.Wrap(err) } - instance.unitStatus.instances = instances - - nodesInfo, err := instance.getAllNodesInfo() - if err != nil { - log.Errorf("Can't get nodes info: %v", err) - } - - instance.unitStatus.nodes = nodesInfo + instance.initDone = true instance.sendCurrentStatus() @@ -369,11 +366,8 @@ func (instance *Instance) CloudDisconnected() { * Private **********************************************************************************************************************/ -func (instance *Instance) initCurrentStatus() error { +func (instance *Instance) initUnitConfigStatus() error { instance.unitStatus.unitConfig = nil - instance.unitStatus.components = make(map[string]*itemStatus) - instance.unitStatus.services = make(map[string]*itemStatus) - instance.unitStatus.layers = make(map[string]*itemStatus) // Get initial unit config info @@ -392,6 +386,11 @@ func (instance *Instance) initCurrentStatus() error { instance.processUnitConfigStatus(status) } + return nil +} + +func (instance *Instance) initComponentsStatus() error { + instance.unitStatus.components = make(map[string]*itemStatus) // Get initial components info componentStatuses, err := instance.firmwareManager.getComponentStatuses() @@ -411,6 +410,12 @@ func (instance *Instance) initCurrentStatus() error { instance.processComponentStatus(status) } + return nil +} + +func (instance *Instance) initServicesStatus() error { + instance.unitStatus.services = make(map[string]*itemStatus) + // Get initial services and layers info serviceStatuses, err := instance.softwareManager.getServiceStatus() @@ -433,6 +438,12 @@ func (instance *Instance) initCurrentStatus() error { instance.processServiceStatus(status) } + return nil +} + +func (instance *Instance) initLayersStatus() error { + instance.unitStatus.layers = make(map[string]*itemStatus) + layerStatuses, err := instance.softwareManager.getLayersStatus() if err != nil { return aoserrors.Wrap(err) @@ -454,7 +465,74 @@ func (instance *Instance) initCurrentStatus() error { instance.processLayerStatus(status) } - instance.initDone = true + return nil +} + +func (instance *Instance) initInstancesStatus() error { + instancesStatus, err := instance.softwareManager.getInstancesStatus() + if err != nil { + return aoserrors.Wrap(err) + } + + for _, status := range instance.unitStatus.instances { + log.WithFields(log.Fields{ + "serviceID": status.InstanceIdent.ServiceID, + "subjectID": status.InstanceIdent.SubjectID, + "instance": status.InstanceIdent.Instance, + "version": status.ServiceVersion, + "status": status.Status, + "error": status.ErrorInfo, + }).Debug("Initial instance status") + } + + instance.unitStatus.instances = instancesStatus + + return nil +} + +func (instance *Instance) initNodesStatus() error { + nodesInfo, err := instance.getAllNodesInfo() + if err != nil { + log.Errorf("Can't get nodes info: %v", err) + } + + for _, status := range nodesInfo { + log.WithFields(log.Fields{ + "nodeID": status.NodeID, + "nodeType": status.NodeType, + "status": status.Status, + }).Debug("Initial node status") + } + + instance.unitStatus.nodes = nodesInfo + + return nil +} + +func (instance *Instance) initCurrentStatus() error { + if err := instance.initUnitConfigStatus(); err != nil { + return err + } + + if err := instance.initComponentsStatus(); err != nil { + return err + } + + if err := instance.initServicesStatus(); err != nil { + return err + } + + if err := instance.initLayersStatus(); err != nil { + return err + } + + if err := instance.initInstancesStatus(); err != nil { + return err + } + + if err := instance.initNodesStatus(); err != nil { + return err + } return nil } From dda6d3bbd64c0cfde7d825a4bb74c61c947dcb20 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Sun, 4 Aug 2024 20:46:24 +0300 Subject: [PATCH 120/146] [unitstatushandler] Use bool under lock instead of atomic int Signed-off-by: Oleksandr Grytsov --- unitstatushandler/unitstatushandler.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index abfc4142..c2931bda 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -22,7 +22,6 @@ import ( "encoding/json" "errors" "sync" - "sync/atomic" "time" "golang.org/x/exp/slices" @@ -145,7 +144,7 @@ type Instance struct { systemQuotaAlertChannel <-chan cloudprotocol.SystemQuotaAlert initDone bool - isConnected int32 + isConnected bool } type unitStatus struct { @@ -354,12 +353,18 @@ func (instance *Instance) StartSOTAUpdate() (err error) { // CloudConnected indicates unit connected to cloud. func (instance *Instance) CloudConnected() { - atomic.StoreInt32(&instance.isConnected, 1) + instance.statusMutex.Lock() + defer instance.statusMutex.Unlock() + + instance.isConnected = true } // CloudDisconnected indicates unit disconnected from cloud. func (instance *Instance) CloudDisconnected() { - atomic.StoreInt32(&instance.isConnected, 0) + instance.statusMutex.Lock() + defer instance.statusMutex.Unlock() + + instance.isConnected = false } /*********************************************************************************************************************** @@ -782,7 +787,7 @@ func (instance *Instance) sendCurrentStatus() { return } - if atomic.LoadInt32(&instance.isConnected) != 1 { + if !instance.isConnected { return } From 421138ccf87a37d75c4717296ee36384b07ac701 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 5 Aug 2024 00:29:37 +0300 Subject: [PATCH 121/146] [unitstatushandler] Implement sending delta status Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 29 +- unitstatushandler/unitstatushandler.go | 426 +++++------------- .../unitstatushandler_internal_test.go | 60 ++- unitstatushandler/unitstatushandler_test.go | 168 +++---- 4 files changed, 255 insertions(+), 428 deletions(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index f167ab7b..0f0bd898 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -57,7 +57,7 @@ type softwareStatusHandler interface { updateLayerStatus(status cloudprotocol.LayerStatus) updateServiceStatus(status cloudprotocol.ServiceStatus) updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) - setInstancesStatus(statuses []cloudprotocol.InstanceStatus) + updateInstanceStatus(status cloudprotocol.InstanceStatus) getNodesStatus() ([]cloudprotocol.NodeStatus, error) } @@ -485,7 +485,9 @@ func (manager *softwareManager) getServiceStatus() (serviceStatuses []cloudproto // Append currently processing info for _, service := range manager.ServiceStatuses { - serviceStatuses = append(serviceStatuses, *service) + if service.Status != cloudprotocol.InstalledStatus { + serviceStatuses = append(serviceStatuses, *service) + } } return serviceStatuses, nil @@ -514,7 +516,9 @@ func (manager *softwareManager) getLayersStatus() (layerStatuses []cloudprotocol } for _, layer := range manager.LayerStatuses { - layerStatuses = append(layerStatuses, *layer) + if layer.Status != cloudprotocol.InstalledStatus { + layerStatuses = append(layerStatuses, *layer) + } } return layerStatuses, nil @@ -540,7 +544,9 @@ func (manager *softwareManager) getUnitConfigStatuses() (status []cloudprotocol. return status, nil } - status = append(status, manager.UnitConfigStatus) + if manager.UnitConfigStatus.Status != cloudprotocol.InstalledStatus { + status = append(status, manager.UnitConfigStatus) + } return status, nil } @@ -1162,12 +1168,12 @@ func (manager *softwareManager) installLayers() (installErr error) { func (manager *softwareManager) removeLayers() (removeErr error) { return manager.processRemoveRestoreLayers( - manager.CurrentUpdate.RemoveLayers, "remove", cloudprotocol.RemovedStatus, manager.softwareUpdater.RemoveLayer) + manager.CurrentUpdate.RemoveLayers, "Remove", cloudprotocol.RemovedStatus, manager.softwareUpdater.RemoveLayer) } func (manager *softwareManager) restoreLayers() (restoreErr error) { return manager.processRemoveRestoreLayers( - manager.CurrentUpdate.RestoreLayers, "restore", cloudprotocol.InstalledStatus, manager.softwareUpdater.RestoreLayer) + manager.CurrentUpdate.RestoreLayers, "Restore", cloudprotocol.InstalledStatus, manager.softwareUpdater.RestoreLayer) } func (manager *softwareManager) processRemoveRestoreLayers( @@ -1391,7 +1397,7 @@ func (manager *softwareManager) removeServices() (removeErr error) { log.WithFields(log.Fields{ "id": service.ServiceID, "version": service.Version, - }).Errorf("Can't install service: %v", serviceErr) + }).Errorf("Can't remove service: %v", serviceErr) if errors.Is(serviceErr, context.Canceled) { return @@ -1469,16 +1475,17 @@ func (manager *softwareManager) runInstances() (runErr error) { for i := uint64(0); i < instance.NumInstances; i++ { ident.Instance = i - manager.InstanceStatuses = append(manager.InstanceStatuses, cloudprotocol.InstanceStatus{ + instanceStatus := cloudprotocol.InstanceStatus{ InstanceIdent: ident, ServiceVersion: version, Status: cloudprotocol.InstanceStateActivating, - }) + } + + manager.InstanceStatuses = append(manager.InstanceStatuses, instanceStatus) + manager.statusHandler.updateInstanceStatus(instanceStatus) } } - manager.statusHandler.setInstancesStatus(manager.InstanceStatuses) - if err := manager.instanceRunner.RunInstances( manager.CurrentUpdate.RunInstances, manager.CurrentUpdate.RebalanceRequest); err != nil { return aoserrors.Wrap(err) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index c2931bda..5d5d6c40 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -132,7 +132,7 @@ type Instance struct { statusMutex sync.Mutex - unitStatus unitStatus + unitStatus cloudprotocol.UnitStatus statusTimer *time.Timer sendStatusPeriod time.Duration @@ -147,22 +147,6 @@ type Instance struct { isConnected bool } -type unitStatus struct { - subjects []string - unitConfig itemStatus - components map[string]*itemStatus - layers map[string]*itemStatus - services map[string]*itemStatus - instances []cloudprotocol.InstanceStatus - nodes []cloudprotocol.NodeInfo -} - -type statusDescriptor struct { - amqpStatus interface{} -} - -type itemStatus []statusDescriptor - /*********************************************************************************************************************** * Public **********************************************************************************************************************/ @@ -191,11 +175,6 @@ func New( systemQuotaAlertChannel: systemQuotaAlertProvider.GetSystemQuoteAlertChannel(), } - // Initialize maps of statuses for avoiding situation of adding values to uninitialized map on go routine - instance.unitStatus.components = make(map[string]*itemStatus) - instance.unitStatus.layers = make(map[string]*itemStatus) - instance.unitStatus.services = make(map[string]*itemStatus) - groupDownloader := newGroupDownloader(downloader) if instance.firmwareManager, err = newFirmwareManager(instance, groupDownloader, firmwareUpdater, @@ -256,7 +235,7 @@ func (instance *Instance) SendUnitStatus() error { return aoserrors.Wrap(err) } - instance.sendCurrentStatus() + instance.sendCurrentStatus(false) return nil } @@ -266,6 +245,8 @@ func (instance *Instance) ProcessRunStatus(instances []cloudprotocol.InstanceSta instance.Lock() defer instance.Unlock() + log.Debug("Process run status") + if !instance.softwareManager.processRunStatus(instances) { return nil } @@ -276,17 +257,19 @@ func (instance *Instance) ProcessRunStatus(instances []cloudprotocol.InstanceSta instance.initDone = true - instance.sendCurrentStatus() + instance.sendCurrentStatus(false) return nil } // ProcessUpdateInstanceStatus process update instances status. -func (instance *Instance) ProcessUpdateInstanceStatus(status []cloudprotocol.InstanceStatus) { +func (instance *Instance) ProcessUpdateInstanceStatus(statuses []cloudprotocol.InstanceStatus) { instance.Lock() defer instance.Unlock() - instance.updateInstanceStatus(status) + for _, status := range statuses { + instance.updateInstanceStatus(status) + } } // ProcessDesiredStatus processes desired status. @@ -371,127 +354,72 @@ func (instance *Instance) CloudDisconnected() { * Private **********************************************************************************************************************/ -func (instance *Instance) initUnitConfigStatus() error { - instance.unitStatus.unitConfig = nil - - // Get initial unit config info +func (instance *Instance) resetUnitStatus() { + instance.unitStatus = cloudprotocol.UnitStatus{} +} +func (instance *Instance) initUnitConfigStatus() error { unitConfigStatuses, err := instance.softwareManager.getUnitConfigStatuses() if err != nil { return aoserrors.Wrap(err) } for _, status := range unitConfigStatuses { - log.WithFields(log.Fields{ - "status": status.Status, - "version": status.Version, - "error": status.ErrorInfo, - }).Debug("Initial unit config status") - - instance.processUnitConfigStatus(status) + instance.updateUnitConfigStatus(status) } return nil } func (instance *Instance) initComponentsStatus() error { - instance.unitStatus.components = make(map[string]*itemStatus) - // Get initial components info - componentStatuses, err := instance.firmwareManager.getComponentStatuses() if err != nil { return aoserrors.Wrap(err) } for _, status := range componentStatuses { - log.WithFields(log.Fields{ - "id": status.ComponentID, - "type": status.ComponentType, - "status": status.Status, - "version": status.Version, - "error": status.ErrorInfo, - }).Debug("Initial component status") - - instance.processComponentStatus(status) + instance.setComponentStatus(status) } return nil } func (instance *Instance) initServicesStatus() error { - instance.unitStatus.services = make(map[string]*itemStatus) - - // Get initial services and layers info - serviceStatuses, err := instance.softwareManager.getServiceStatus() if err != nil { return aoserrors.Wrap(err) } for _, status := range serviceStatuses { - if _, ok := instance.unitStatus.services[status.ServiceID]; !ok { - instance.unitStatus.services[status.ServiceID] = &itemStatus{} - } - - log.WithFields(log.Fields{ - "id": status.ServiceID, - "status": status.Status, - "version": status.Version, - "error": status.ErrorInfo, - }).Debug("Initial service status") - - instance.processServiceStatus(status) + instance.setServiceStatus(status) } return nil } func (instance *Instance) initLayersStatus() error { - instance.unitStatus.layers = make(map[string]*itemStatus) - layerStatuses, err := instance.softwareManager.getLayersStatus() if err != nil { return aoserrors.Wrap(err) } for _, status := range layerStatuses { - if _, ok := instance.unitStatus.layers[status.Digest]; !ok { - instance.unitStatus.layers[status.Digest] = &itemStatus{} - } - - log.WithFields(log.Fields{ - "id": status.LayerID, - "digest": status.Digest, - "status": status.Status, - "version": status.Version, - "error": status.ErrorInfo, - }).Debug("Initial layer status") - - instance.processLayerStatus(status) + instance.setLayerStatus(status) } return nil } func (instance *Instance) initInstancesStatus() error { - instancesStatus, err := instance.softwareManager.getInstancesStatus() + instances, err := instance.softwareManager.getInstancesStatus() if err != nil { return aoserrors.Wrap(err) } - for _, status := range instance.unitStatus.instances { - log.WithFields(log.Fields{ - "serviceID": status.InstanceIdent.ServiceID, - "subjectID": status.InstanceIdent.SubjectID, - "instance": status.InstanceIdent.Instance, - "version": status.ServiceVersion, - "status": status.Status, - "error": status.ErrorInfo, - }).Debug("Initial instance status") + for _, status := range instances { + instance.setInstanceStatus(status) } - instance.unitStatus.instances = instancesStatus - return nil } @@ -501,16 +429,10 @@ func (instance *Instance) initNodesStatus() error { log.Errorf("Can't get nodes info: %v", err) } - for _, status := range nodesInfo { - log.WithFields(log.Fields{ - "nodeID": status.NodeID, - "nodeType": status.NodeType, - "status": status.Status, - }).Debug("Initial node status") + for _, info := range nodesInfo { + instance.setNodeInfo(info) } - instance.unitStatus.nodes = nodesInfo - return nil } @@ -542,45 +464,7 @@ func (instance *Instance) initCurrentStatus() error { return nil } -func (descriptor *statusDescriptor) getStatus() (status string) { - switch amqpStatus := descriptor.amqpStatus.(type) { - case *cloudprotocol.UnitConfigStatus: - return amqpStatus.Status - - case *cloudprotocol.ComponentStatus: - return amqpStatus.Status - - case *cloudprotocol.LayerStatus: - return amqpStatus.Status - - case *cloudprotocol.ServiceStatus: - return amqpStatus.Status - - default: - return cloudprotocol.UnknownStatus - } -} - -func (descriptor *statusDescriptor) getVersion() (version string) { - switch amqpStatus := descriptor.amqpStatus.(type) { - case *cloudprotocol.UnitConfigStatus: - return amqpStatus.Version - - case *cloudprotocol.ComponentStatus: - return amqpStatus.Version - - case *cloudprotocol.LayerStatus: - return amqpStatus.Version - - case *cloudprotocol.ServiceStatus: - return amqpStatus.Version - - default: - return "" - } -} - -func (instance *Instance) updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { +func (instance *Instance) setUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() @@ -588,17 +472,26 @@ func (instance *Instance) updateUnitConfigStatus(status cloudprotocol.UnitConfig "status": status.Status, "version": status.Version, "error": status.ErrorInfo, - }).Debug("Update unit config status") + }).Debug("Set unit config status") + + index := slices.IndexFunc(instance.unitStatus.UnitConfig, func(unitConfigStatus cloudprotocol.UnitConfigStatus) bool { + return unitConfigStatus.Version == status.Version + }) + if index < 0 { + instance.unitStatus.UnitConfig = append(instance.unitStatus.UnitConfig, status) + } else { + instance.unitStatus.UnitConfig[index] = status + } - instance.processUnitConfigStatus(status) instance.statusChanged() } -func (instance *Instance) processUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { - instance.updateStatus(&instance.unitStatus.unitConfig, statusDescriptor{&status}) +func (instance *Instance) updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { + instance.setUnitConfigStatus(status) + instance.statusChanged() } -func (instance *Instance) updateComponentStatus(status cloudprotocol.ComponentStatus) { +func (instance *Instance) setComponentStatus(status cloudprotocol.ComponentStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() @@ -608,23 +501,24 @@ func (instance *Instance) updateComponentStatus(status cloudprotocol.ComponentSt "status": status.Status, "version": status.Version, "error": status.ErrorInfo, - }).Debug("Update component status") - - instance.processComponentStatus(status) - instance.statusChanged() -} + }).Debug("Set component status") -func (instance *Instance) processComponentStatus(status cloudprotocol.ComponentStatus) { - componentStatus, ok := instance.unitStatus.components[status.ComponentID] - if !ok { - componentStatus = &itemStatus{} - instance.unitStatus.components[status.ComponentID] = componentStatus + index := slices.IndexFunc(instance.unitStatus.Components, func(componentStatus cloudprotocol.ComponentStatus) bool { + return componentStatus.ComponentID == status.ComponentID && componentStatus.Version == status.Version + }) + if index < 0 { + instance.unitStatus.Components = append(instance.unitStatus.Components, status) + } else { + instance.unitStatus.Components[index] = status } +} - instance.updateStatus(componentStatus, statusDescriptor{&status}) +func (instance *Instance) updateComponentStatus(status cloudprotocol.ComponentStatus) { + instance.setComponentStatus(status) + instance.statusChanged() } -func (instance *Instance) updateLayerStatus(status cloudprotocol.LayerStatus) { +func (instance *Instance) setLayerStatus(status cloudprotocol.LayerStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() @@ -634,93 +528,78 @@ func (instance *Instance) updateLayerStatus(status cloudprotocol.LayerStatus) { "status": status.Status, "version": status.Version, "error": status.ErrorInfo, - }).Debug("Update layer status") - - instance.processLayerStatus(status) - instance.statusChanged() -} + }).Debug("Set layer status") -func (instance *Instance) processLayerStatus(status cloudprotocol.LayerStatus) { - layerStatus, ok := instance.unitStatus.layers[status.Digest] - if !ok { - layerStatus = &itemStatus{} - instance.unitStatus.layers[status.Digest] = layerStatus + index := slices.IndexFunc(instance.unitStatus.Layers, func(layerStatus cloudprotocol.LayerStatus) bool { + return layerStatus.LayerID == status.LayerID && layerStatus.Version == status.Version + }) + if index < 0 { + instance.unitStatus.Layers = append(instance.unitStatus.Layers, status) + } else { + instance.unitStatus.Layers[index] = status } - - instance.updateStatus(layerStatus, statusDescriptor{&status}) } -func (instance *Instance) updateServiceStatus(serviceInfo cloudprotocol.ServiceStatus) { - instance.statusMutex.Lock() - defer instance.statusMutex.Unlock() - - log.WithFields(log.Fields{ - "id": serviceInfo.ServiceID, - "status": serviceInfo.Status, - "version": serviceInfo.Version, - "error": serviceInfo.ErrorInfo, - }).Debug("Update service status") - - instance.processServiceStatus(serviceInfo) +func (instance *Instance) updateLayerStatus(status cloudprotocol.LayerStatus) { + instance.setLayerStatus(status) instance.statusChanged() } -func (instance *Instance) processServiceStatus(status cloudprotocol.ServiceStatus) { - serviceStatus, ok := instance.unitStatus.services[status.ServiceID] - if !ok { - serviceStatus = &itemStatus{} - instance.unitStatus.services[status.ServiceID] = serviceStatus - } - - instance.updateStatus(serviceStatus, statusDescriptor{&status}) -} - -func (instance *Instance) updateInstanceStatus(status []cloudprotocol.InstanceStatus) { +func (instance *Instance) setServiceStatus(status cloudprotocol.ServiceStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() - newStatuses := []cloudprotocol.InstanceStatus{} - -foundLoop: - for _, instanceStatus := range status { - for i := range instance.unitStatus.instances { - if instanceStatus.InstanceIdent == instance.unitStatus.instances[i].InstanceIdent && - instanceStatus.ServiceVersion == instance.unitStatus.instances[i].ServiceVersion { - log.WithFields(log.Fields{ - "serviceID": instanceStatus.InstanceIdent.ServiceID, - "subjectID": instanceStatus.InstanceIdent.SubjectID, - "instance": instanceStatus.InstanceIdent.Instance, - "version": instanceStatus.ServiceVersion, - "status": instanceStatus.Status, - "error": instanceStatus.ErrorInfo, - }).Debug("Update instance status") - - instance.unitStatus.instances[i].StateChecksum = instanceStatus.StateChecksum - instance.unitStatus.instances[i].Status = instanceStatus.Status - instance.unitStatus.instances[i].ErrorInfo = instanceStatus.ErrorInfo - - continue foundLoop - } - } + log.WithFields(log.Fields{ + "id": status.ServiceID, + "status": status.Status, + "version": status.Version, + "error": status.ErrorInfo, + }).Debug("Set service status") - newStatuses = append(newStatuses, instanceStatus) + index := slices.IndexFunc(instance.unitStatus.Services, func(serviceStatus cloudprotocol.ServiceStatus) bool { + return serviceStatus.ServiceID == status.ServiceID && serviceStatus.Version == status.Version + }) + if index < 0 { + instance.unitStatus.Services = append(instance.unitStatus.Services, status) + } else { + instance.unitStatus.Services[index] = status } +} - instance.unitStatus.instances = append(instance.unitStatus.instances, newStatuses...) - +func (instance *Instance) updateServiceStatus(status cloudprotocol.ServiceStatus) { + instance.setServiceStatus(status) instance.statusChanged() } -func (instance *Instance) setInstancesStatus(statuses []cloudprotocol.InstanceStatus) { +func (instance *Instance) setInstanceStatus(status cloudprotocol.InstanceStatus) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() - instance.unitStatus.instances = statuses + log.WithFields(log.Fields{ + "serviceID": status.InstanceIdent.ServiceID, + "subjectID": status.InstanceIdent.SubjectID, + "instance": status.InstanceIdent.Instance, + "version": status.ServiceVersion, + "status": status.Status, + "error": status.ErrorInfo, + }).Debug("Set instance status") + + index := slices.IndexFunc(instance.unitStatus.Instances, func(instanceStatus cloudprotocol.InstanceStatus) bool { + return instanceStatus.InstanceIdent == status.InstanceIdent + }) + if index < 0 { + instance.unitStatus.Instances = append(instance.unitStatus.Instances, status) + } else { + instance.unitStatus.Instances[index] = status + } +} +func (instance *Instance) updateInstanceStatus(status cloudprotocol.InstanceStatus) { + instance.setInstanceStatus(status) instance.statusChanged() } -func (instance *Instance) updateNodeInfo(nodeInfo cloudprotocol.NodeInfo) { +func (instance *Instance) setNodeInfo(nodeInfo cloudprotocol.NodeInfo) { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() @@ -728,23 +607,20 @@ func (instance *Instance) updateNodeInfo(nodeInfo cloudprotocol.NodeInfo) { "nodeID": nodeInfo.NodeID, "nodeType": nodeInfo.NodeType, "status": nodeInfo.Status, - }).Debug("Node info changed") - - nodeInfoFound := false - - for i, curNodeInfo := range instance.unitStatus.nodes { - if curNodeInfo.NodeID == nodeInfo.NodeID { - instance.unitStatus.nodes[i] = nodeInfo - nodeInfoFound = true - - break - } - } + }).Debug("Set node info") - if !nodeInfoFound { - instance.unitStatus.nodes = append(instance.unitStatus.nodes, nodeInfo) + index := slices.IndexFunc(instance.unitStatus.Nodes, func(node cloudprotocol.NodeInfo) bool { + return node.NodeID == nodeInfo.NodeID + }) + if index < 0 { + instance.unitStatus.Nodes = append(instance.unitStatus.Nodes, nodeInfo) + } else { + instance.unitStatus.Nodes[index] = nodeInfo } +} +func (instance *Instance) updateNodeInfo(nodeInfo cloudprotocol.NodeInfo) { + instance.setNodeInfo(nodeInfo) instance.statusChanged() } @@ -757,32 +633,20 @@ func (instance *Instance) statusChanged() { instance.statusMutex.Lock() defer instance.statusMutex.Unlock() - instance.sendCurrentStatus() + instance.sendCurrentStatus(true) }) } -func (instance *Instance) updateStatus(status *itemStatus, descriptor statusDescriptor) { - if descriptor.getStatus() == cloudprotocol.InstalledStatus { - *status = itemStatus{descriptor} - return - } - - for i, element := range *status { - if element.getVersion() == descriptor.getVersion() { - (*status)[i] = descriptor - return - } - } - - *status = append(*status, descriptor) -} - -func (instance *Instance) sendCurrentStatus() { +func (instance *Instance) sendCurrentStatus(deltaStatus bool) { if instance.statusTimer != nil { instance.statusTimer.Stop() instance.statusTimer = nil } + defer instance.resetUnitStatus() + + log.WithField("deltaStatus", deltaStatus).Debug("Send current status") + if !instance.initDone { return } @@ -791,63 +655,9 @@ func (instance *Instance) sendCurrentStatus() { return } - unitStatus := cloudprotocol.UnitStatus{ - UnitSubjects: instance.unitStatus.subjects, - Components: make([]cloudprotocol.ComponentStatus, 0, len(instance.unitStatus.components)), - Layers: make([]cloudprotocol.LayerStatus, 0, len(instance.unitStatus.layers)), - Services: make([]cloudprotocol.ServiceStatus, 0, len(instance.unitStatus.services)), - Instances: instance.unitStatus.instances, - Nodes: instance.unitStatus.nodes, - } - - for _, status := range instance.unitStatus.unitConfig { - unitConfig, ok := status.amqpStatus.(*cloudprotocol.UnitConfigStatus) - if !ok { - log.Error("Incorrect unit config type") - continue - } - - unitStatus.UnitConfig = append(unitStatus.UnitConfig, *unitConfig) - } - - for _, componentStatus := range instance.unitStatus.components { - for _, status := range *componentStatus { - status, ok := status.amqpStatus.(*cloudprotocol.ComponentStatus) - if !ok { - log.Error("Incorrect component status type") - continue - } - - unitStatus.Components = append(unitStatus.Components, *status) - } - } - - for _, layerStatus := range instance.unitStatus.layers { - for _, status := range *layerStatus { - status, ok := status.amqpStatus.(*cloudprotocol.LayerStatus) - if !ok { - log.Error("Incorrect layer status type") - continue - } - - unitStatus.Layers = append(unitStatus.Layers, *status) - } - } - - for _, serviceStatus := range instance.unitStatus.services { - for _, status := range *serviceStatus { - status, ok := status.amqpStatus.(*cloudprotocol.ServiceStatus) - if !ok { - log.Error("Incorrect service status type") - continue - } - - unitStatus.Services = append(unitStatus.Services, *status) - } - } - + instance.unitStatus.IsDeltaInfo = deltaStatus if err := instance.statusSender.SendUnitStatus( - unitStatus); err != nil && !errors.Is(err, amqphandler.ErrNotConnected) { + instance.unitStatus); err != nil && !errors.Is(err, amqphandler.ErrNotConnected) { log.Errorf("Can't send unit status: %s", err) } } diff --git a/unitstatushandler/unitstatushandler_internal_test.go b/unitstatushandler/unitstatushandler_internal_test.go index 73b2c5d6..2ee90a65 100644 --- a/unitstatushandler/unitstatushandler_internal_test.go +++ b/unitstatushandler/unitstatushandler_internal_test.go @@ -2037,53 +2037,51 @@ func newTestStatusHandler() *testStatusHandler { return &testStatusHandler{} } -func (statusHandler *testStatusHandler) updateComponentStatus(componentInfo cloudprotocol.ComponentStatus) { +func (statusHandler *testStatusHandler) updateComponentStatus(status cloudprotocol.ComponentStatus) { log.WithFields(log.Fields{ - "id": componentInfo.ComponentID, - "version": componentInfo.Version, - "status": componentInfo.Status, - "error": componentInfo.ErrorInfo, + "id": status.ComponentID, + "version": status.Version, + "status": status.Status, + "error": status.ErrorInfo, }).Debug("Update component status") } -func (statusHandler *testStatusHandler) updateUnitConfigStatus(unitConfigInfo cloudprotocol.UnitConfigStatus) { +func (statusHandler *testStatusHandler) updateUnitConfigStatus(status cloudprotocol.UnitConfigStatus) { log.WithFields(log.Fields{ - "version": unitConfigInfo.Version, - "status": unitConfigInfo.Status, - "error": unitConfigInfo.ErrorInfo, + "version": status.Version, + "status": status.Status, + "error": status.ErrorInfo, }).Debug("Update unit config status") } -func (statusHandler *testStatusHandler) updateLayerStatus(layerInfo cloudprotocol.LayerStatus) { +func (statusHandler *testStatusHandler) updateLayerStatus(status cloudprotocol.LayerStatus) { log.WithFields(log.Fields{ - "id": layerInfo.LayerID, - "digest": layerInfo.Digest, - "version": layerInfo.Version, - "status": layerInfo.Status, - "error": layerInfo.ErrorInfo, + "id": status.LayerID, + "digest": status.Digest, + "version": status.Version, + "status": status.Status, + "error": status.ErrorInfo, }).Debug("Update layer status") } -func (statusHandler *testStatusHandler) updateServiceStatus(serviceInfo cloudprotocol.ServiceStatus) { +func (statusHandler *testStatusHandler) updateServiceStatus(status cloudprotocol.ServiceStatus) { log.WithFields(log.Fields{ - "id": serviceInfo.ServiceID, - "version": serviceInfo.Version, - "status": serviceInfo.Status, - "error": serviceInfo.ErrorInfo, + "id": status.ServiceID, + "version": status.Version, + "status": status.Status, + "error": status.ErrorInfo, }).Debug("Update service status") } -func (statusHandler *testStatusHandler) setInstancesStatus(statuses []cloudprotocol.InstanceStatus) { - for _, instanceStatus := range statuses { - log.WithFields(log.Fields{ - "serviceID": instanceStatus.ServiceID, - "subjectID": instanceStatus.SubjectID, - "instanceID": instanceStatus.Instance, - "version": instanceStatus.ServiceVersion, - "error": instanceStatus.ErrorInfo, - "nodeID": instanceStatus.NodeID, - }).Debug("Update instance status") - } +func (statusHandler *testStatusHandler) updateInstanceStatus(status cloudprotocol.InstanceStatus) { + log.WithFields(log.Fields{ + "serviceID": status.ServiceID, + "subjectID": status.SubjectID, + "instanceID": status.Instance, + "version": status.ServiceVersion, + "error": status.ErrorInfo, + "nodeID": status.NodeID, + }).Debug("Update instance status") } func (statusHandler *testStatusHandler) getNodesStatus() ([]cloudprotocol.NodeStatus, error) { diff --git a/unitstatushandler/unitstatushandler_test.go b/unitstatushandler/unitstatushandler_test.go index 7f046ed2..8ee8d1b9 100644 --- a/unitstatushandler/unitstatushandler_test.go +++ b/unitstatushandler/unitstatushandler_test.go @@ -275,14 +275,13 @@ func TestUpdateComponents(t *testing.T) { // success update expectedUnitStatus := cloudprotocol.UnitStatus{ - UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ {ComponentID: "comp0", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, {ComponentID: "comp2", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, - Layers: []cloudprotocol.LayerStatus{}, - Services: []cloudprotocol.ServiceStatus{}, + Layers: []cloudprotocol.LayerStatus{}, + Services: []cloudprotocol.ServiceStatus{}, + IsDeltaInfo: true, } firmwareUpdater.UpdateComponentsInfo = expectedUnitStatus.Components @@ -308,18 +307,15 @@ func TestUpdateComponents(t *testing.T) { firmwareUpdater.UpdateError = aoserrors.New("some error occurs") expectedUnitStatus = cloudprotocol.UnitStatus{ - UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{ - {ComponentID: "comp0", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, - {ComponentID: "comp1", ComponentType: "type-1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { ComponentID: "comp1", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, ErrorInfo: &cloudprotocol.ErrorInfo{Message: firmwareUpdater.UpdateError.Error()}, }, - {ComponentID: "comp2", ComponentType: "type-1", Version: "2.0.0", Status: cloudprotocol.InstalledStatus}, }, - Layers: []cloudprotocol.LayerStatus{}, - Services: []cloudprotocol.ServiceStatus{}, + Layers: []cloudprotocol.LayerStatus{}, + Services: []cloudprotocol.ServiceStatus{}, + IsDeltaInfo: true, } firmwareUpdater.UpdateComponentsInfo = expectedUnitStatus.Components @@ -340,21 +336,10 @@ func TestUpdateComponents(t *testing.T) { } func TestUpdateLayers(t *testing.T) { - layerStatuses := []unitstatushandler.LayerStatus{ - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) - softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, layerStatuses) + softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() sender := unitstatushandler.NewTestSender() @@ -371,6 +356,18 @@ func TestUpdateLayers(t *testing.T) { go handleUpdateStatus(statusHandler) + softwareUpdater.AllLayers = []unitstatushandler.LayerStatus{ + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + } + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -415,6 +412,18 @@ func TestUpdateLayers(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } + softwareUpdater.AllLayers = []unitstatushandler.LayerStatus{ + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, + }}, + } + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -428,24 +437,6 @@ func TestUpdateLayers(t *testing.T) { t.Errorf("Wrong unit status received: %v, expected: %v", receivedUnitStatus, expectedUnitStatus) } - softwareUpdater.AllLayers = []unitstatushandler.LayerStatus{ - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.RemovedStatus, - }}, - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus, - }}, - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {LayerStatus: cloudprotocol.LayerStatus{ - LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, - }}, - } - // failed update softwareUpdater.UpdateError = aoserrors.New("some error occurs") @@ -454,9 +445,7 @@ func TestUpdateLayers(t *testing.T) { UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Components: []cloudprotocol.ComponentStatus{}, Layers: []cloudprotocol.LayerStatus{ - {LayerID: "layer0", Digest: "digest0", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, {LayerID: "layer1", Digest: "digest1", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, - {LayerID: "layer2", Digest: "digest2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, {LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, {LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { @@ -488,6 +477,19 @@ func TestUpdateLayers(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } + softwareUpdater.AllLayers = []unitstatushandler.LayerStatus{ + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer3", Digest: "digest3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {LayerStatus: cloudprotocol.LayerStatus{ + LayerID: "layer4", Digest: "digest4", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, + }}, + } + + if err := statusHandler.ProcessRunStatus(nil); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + if receivedUnitStatus, err = sender.WaitForStatus(waitStatusTimeout); err != nil { t.Fatalf("Can't receive unit status: %s", err) } @@ -498,21 +500,10 @@ func TestUpdateLayers(t *testing.T) { } func TestUpdateServices(t *testing.T) { - serviceStatuses := []unitstatushandler.ServiceStatus{ - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - } unitConfigUpdater := unitstatushandler.NewTestUnitConfigUpdater( cloudprotocol.UnitConfigStatus{Version: "1.0.0", Status: cloudprotocol.InstalledStatus}) firmwareUpdater := unitstatushandler.NewTestFirmwareUpdater(nil) - softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(serviceStatuses, nil) + softwareUpdater := unitstatushandler.NewTestSoftwareUpdater(nil, nil) instanceRunner := unitstatushandler.NewTestInstanceRunner() sender := unitstatushandler.NewTestSender() @@ -529,6 +520,18 @@ func TestUpdateServices(t *testing.T) { go handleUpdateStatus(statusHandler) + softwareUpdater.AllServices = []unitstatushandler.ServiceStatus{ + {ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: "service1", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + } + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -572,6 +575,18 @@ func TestUpdateServices(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } + softwareUpdater.AllServices = []unitstatushandler.ServiceStatus{ + {ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, + }}, + {ServiceStatus: cloudprotocol.ServiceStatus{ + ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, + }}, + } + if err := statusHandler.ProcessRunStatus(nil); err != nil { t.Fatalf("Can't process run status: %v", err) } @@ -587,20 +602,6 @@ func TestUpdateServices(t *testing.T) { // failed update - softwareUpdater.AllServices = []unitstatushandler.ServiceStatus{ - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service0", Version: "0.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, - }}, - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus, - }}, - {ServiceStatus: cloudprotocol.ServiceStatus{ - ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus, - }}, - } softwareUpdater.UpdateError = aoserrors.New("some error occurs") expectedUnitStatus = cloudprotocol.UnitStatus{ @@ -613,7 +614,6 @@ func TestUpdateServices(t *testing.T) { ErrorInfo: &cloudprotocol.ErrorInfo{Message: softwareUpdater.UpdateError.Error()}, }, {ServiceID: "service1", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, - {ServiceID: "service2", Version: "0.0.0", Status: cloudprotocol.RemovedStatus}, {ServiceID: "service3", Version: "1.0.0", Status: cloudprotocol.InstalledStatus}, { ServiceID: "service3", Version: "2.0.0", Status: cloudprotocol.ErrorStatus, @@ -647,6 +647,10 @@ func TestUpdateServices(t *testing.T) { t.Errorf("Wait run instances error: %v", err) } + if err := statusHandler.ProcessRunStatus(nil); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + if receivedUnitStatus, err = sender.WaitForStatus(waitStatusTimeout); err != nil { t.Fatalf("Can't receive unit status: %s", err) } @@ -935,23 +939,19 @@ func TestUpdateInstancesStatus(t *testing.T) { } expectedUnitStatus := cloudprotocol.UnitStatus{ - UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, Instances: []cloudprotocol.InstanceStatus{ { InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 0}, ServiceVersion: "1.0.0", Status: "fail", ErrorInfo: &cloudprotocol.ErrorInfo{Message: "someError"}, }, - { - InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv1", SubjectID: "Subj1", Instance: 1}, - ServiceVersion: "1.0.0", - }, { InstanceIdent: aostypes.InstanceIdent{ServiceID: "Serv2", SubjectID: "Subj2", Instance: 1}, ServiceVersion: "1.0.0", StateChecksum: "newState", }, }, + IsDeltaInfo: true, } statusHandler.ProcessUpdateInstanceStatus([]cloudprotocol.InstanceStatus{ @@ -1104,6 +1104,14 @@ func TestUpdateCachedSOTA(t *testing.T) { }, }) + if _, err := instanceRunner.WaitForRunInstance(waitRunInstanceTimeout); err != nil { + t.Errorf("Wait run instances error: %v", err) + } + + if err := statusHandler.ProcessRunStatus(nil); err != nil { + t.Fatalf("Can't process run status: %v", err) + } + receivedUnitStatus, err := sender.WaitForStatus(waitStatusTimeout) if err != nil { t.Fatalf("Can't receive unit status: %s", err) @@ -1187,8 +1195,8 @@ func TestNewComponents(t *testing.T) { } expectedUnitStatus = cloudprotocol.UnitStatus{ - UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, - Components: newComponents, + Components: newComponents, + IsDeltaInfo: true, } if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { @@ -1257,8 +1265,8 @@ func TestNodeInfoChanged(t *testing.T) { } expectedUnitStatus = cloudprotocol.UnitStatus{ - UnitConfig: []cloudprotocol.UnitConfigStatus{unitConfigUpdater.UnitConfigStatus}, - Nodes: nodeInfoProvider.GetAllNodesInfo(), + Nodes: newNodesInfo, + IsDeltaInfo: true, } if err = compareUnitStatus(receivedUnitStatus, expectedUnitStatus); err != nil { @@ -1354,6 +1362,10 @@ func compareUnitStatus(status1, status2 cloudprotocol.UnitStatus) (err error) { return aoserrors.Wrap(err) } + if status1.IsDeltaInfo != status2.IsDeltaInfo { + return aoserrors.New("IsDeltaInfo mismatch") + } + return nil } From dd9f89e7fd9ca57c02d07bbb32b34d278bb1a18a Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 5 Aug 2024 12:07:46 +0300 Subject: [PATCH 122/146] [launcher, unitstatus] Fix nil in UnitStatus instances, services Signed-off-by: Mykola Kobets --- launcher/launcher.go | 2 +- unitstatushandler/unitstatushandler.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index f7a3d3db..b693d46a 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -344,7 +344,7 @@ func (launcher *Launcher) processRunInstanceStatus(runStatus NodeRunInstanceStat } func (launcher *Launcher) sendCurrentStatus() { - var instancesStatus []cloudprotocol.InstanceStatus + instancesStatus := make([]cloudprotocol.InstanceStatus, 0) for _, node := range launcher.getNodesByPriorities() { if node.waitStatus { diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index 5d5d6c40..efaa3efd 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -175,6 +175,8 @@ func New( systemQuotaAlertChannel: systemQuotaAlertProvider.GetSystemQuoteAlertChannel(), } + instance.resetUnitStatus() + groupDownloader := newGroupDownloader(downloader) if instance.firmwareManager, err = newFirmwareManager(instance, groupDownloader, firmwareUpdater, @@ -355,7 +357,13 @@ func (instance *Instance) CloudDisconnected() { **********************************************************************************************************************/ func (instance *Instance) resetUnitStatus() { - instance.unitStatus = cloudprotocol.UnitStatus{} + instance.unitStatus = cloudprotocol.UnitStatus{ + Components: make([]cloudprotocol.ComponentStatus, 0), + Layers: make([]cloudprotocol.LayerStatus, 0), + Services: make([]cloudprotocol.ServiceStatus, 0), + Instances: make([]cloudprotocol.InstanceStatus, 0), + UnitSubjects: make([]string, 0), + } } func (instance *Instance) initUnitConfigStatus() error { From a18f117bb24872f076d4dcf8bea8acc2c39c1ccf Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 6 Aug 2024 19:17:39 +0300 Subject: [PATCH 123/146] [storagestate] Don't watch for state with StateQuota=0 Signed-off-by: Mykola Kobets --- storagestate/storagestate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storagestate/storagestate.go b/storagestate/storagestate.go index 179511e7..65ed3c60 100644 --- a/storagestate/storagestate.go +++ b/storagestate/storagestate.go @@ -408,6 +408,10 @@ func (storageState *StorageState) initStateWatching() error { } for _, info := range infos { + if info.StateQuota == 0 { + continue + } + if err = storageState.startStateWatching(info.InstanceIdent, storageState.getStatePath(info.InstanceID), info.StateQuota); err != nil { log.WithField("instanceID", info.InstanceID).Errorf("Can't setup state watching: %v", err) From 895eca5d14a5a957537666fc27469e49c65acf10 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 7 Aug 2024 13:55:08 +0300 Subject: [PATCH 124/146] [launcher] Fix yocto build Signed-off-by: Mykola Kobets --- launcher/nodehandler.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 42d20829..7894baa9 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -20,7 +20,8 @@ package launcher import ( "errors" "math" - "slices" + + "golang.org/x/exp/slices" "github.com/aosedge/aos_common/aoserrors" "github.com/aosedge/aos_common/aostypes" @@ -558,16 +559,16 @@ func getInstanceNode( return nil, aoserrors.Errorf("can't get top priority nodes") } - slices.SortStableFunc(resultNodes, func(node1, node2 *nodeHandler) int { + slices.SortStableFunc(resultNodes, func(node1, node2 *nodeHandler) bool { if node1.availableCPU < node2.availableCPU { - return 1 + return false } if node1.availableCPU > node2.availableCPU { - return -1 + return true } - return 0 + return false }) return resultNodes[0], nil From 087360045572b8c44a833b6293106a27f8bb5d7d Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 7 Aug 2024 12:46:12 +0300 Subject: [PATCH 125/146] [vendor] Vendor update Signed-off-by: Mykola Kobets --- go.mod | 2 +- go.sum | 4 ++-- .../aos_common/api/cloudprotocol/certificates.go | 14 ++++++-------- vendor/modules.txt | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 1f03b889..4ab214b2 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013 + github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 3dbf5b3b..a8310a99 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013 h1:VlIBKRo12pu2i0O74Lb7lfJqMqhSKcHubNFKZpCPaww= -github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= +github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c h1:+syptKk0KtaFuttYpoUW4VF4eUciUxP5VFeFDDcDNkA= +github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go index 4f65d5dc..526d8d54 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/certificates.go @@ -32,7 +32,7 @@ const ( ) // UnitSecretVersion specifies supported version of UnitSecret message. -const UnitSecretVersion = 2 +const UnitSecretVersion = "2.0.0" /*********************************************************************************************************************** * Types @@ -62,12 +62,10 @@ type RenewCertData struct { ValidTill time.Time `json:"validTill"` } -// UnitSecret keeps unit secret used to decode secure device password. -type UnitSecret struct { - Version int `json:"version"` - Data struct { - OwnerPassword string `json:"ownerPassword"` - } `json:"data"` +// UnitSecrets keeps secrets for nodes. +type UnitSecrets struct { + Version string `json:"version"` + Nodes map[string]string `json:"nodes"` } // IssueCertData issue certificate data. @@ -81,7 +79,7 @@ type IssueCertData struct { type RenewCertsNotification struct { MessageType string `json:"messageType"` Certificates []RenewCertData `json:"certificates"` - UnitSecret UnitSecret `json:"unitSecret"` + UnitSecrets UnitSecrets `json:"unitSecrets"` } // IssuedUnitCerts issued unit certificates info. diff --git a/vendor/modules.txt b/vendor/modules.txt index 32b0c0e6..f9277c0b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240801114759-a9662a53d013 +# github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From ee5361a4558126b58d769691ec4b459a79493f53 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 7 Aug 2024 13:10:23 +0300 Subject: [PATCH 126/146] [iamclient] RenewCertNotification adaptation Signed-off-by: Mykola Kobets --- amqphandler/amqphandler_test.go | 6 ++---- communicationmanager.go | 4 ++-- iamclient/iamclient.go | 9 ++++++++- iamclient/iamclient_test.go | 7 ++++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/amqphandler/amqphandler_test.go b/amqphandler/amqphandler_test.go index 7ae00e9c..ff0a42cc 100644 --- a/amqphandler/amqphandler_test.go +++ b/amqphandler/amqphandler_test.go @@ -299,11 +299,9 @@ func TestReceiveMessages(t *testing.T) { expectedData: &cloudprotocol.RenewCertsNotification{ MessageType: cloudprotocol.RenewCertsNotificationMessageType, Certificates: []cloudprotocol.RenewCertData{ - {Type: "online", Serial: "1234", ValidTill: testTime}, + {NodeID: "node0", Type: "online", Serial: "1234", ValidTill: testTime}, }, - UnitSecret: cloudprotocol.UnitSecret{Version: 1, Data: struct { - OwnerPassword string `json:"ownerPassword"` - }{OwnerPassword: "pwd"}}, + UnitSecrets: cloudprotocol.UnitSecrets{Version: "1.0.0", Nodes: map[string]string{"node0": "pwd"}}, }, }, { diff --git a/communicationmanager.go b/communicationmanager.go index a05aa48d..b0503844 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -394,12 +394,12 @@ func (cm *communicationManager) processMessage(message amqp.Message) (err error) case *cloudprotocol.RenewCertsNotification: log.Info("Receive renew certificates notification message") - if data.UnitSecret.Version != cloudprotocol.UnitSecretVersion { + if data.UnitSecrets.Version != cloudprotocol.UnitSecretVersion { return aoserrors.New("unit secure version mismatch") } if err = cm.iam.RenewCertificatesNotification( - data.UnitSecret.Data.OwnerPassword, data.Certificates); err != nil { + data.UnitSecrets, data.Certificates); err != nil { return aoserrors.Wrap(err) } diff --git a/iamclient/iamclient.go b/iamclient/iamclient.go index 0aabc2b0..b2f7758d 100644 --- a/iamclient/iamclient.go +++ b/iamclient/iamclient.go @@ -211,7 +211,9 @@ func (client *Client) SubscribeNodeInfoChange() <-chan cloudprotocol.NodeInfo { } // RenewCertificatesNotification renew certificates notification. -func (client *Client) RenewCertificatesNotification(pwd string, certInfo []cloudprotocol.RenewCertData) (err error) { +func (client *Client) RenewCertificatesNotification(secrets cloudprotocol.UnitSecrets, + certInfo []cloudprotocol.RenewCertData, +) (err error) { newCerts := make([]cloudprotocol.IssueCertData, 0, len(certInfo)) for _, cert := range certInfo { @@ -222,6 +224,11 @@ func (client *Client) RenewCertificatesNotification(pwd string, certInfo []cloud ctx, cancel := context.WithTimeout(context.Background(), iamRequestTimeout) defer cancel() + pwd, ok := secrets.Nodes[cert.NodeID] + if !ok { + return aoserrors.New("not found password for node: " + cert.NodeID) + } + request := &pb.CreateKeyRequest{Type: cert.Type, Password: pwd, NodeId: cert.NodeID} response, err := client.certificateService.CreateKey(ctx, request) diff --git a/iamclient/iamclient_test.go b/iamclient/iamclient_test.go index ab84f081..15b9e6d0 100644 --- a/iamclient/iamclient_test.go +++ b/iamclient/iamclient_test.go @@ -188,11 +188,12 @@ func TestRenewCertificatesNotification(t *testing.T) { defer client.Close() certInfo := []cloudprotocol.RenewCertData{ - {Type: "online", Serial: "serail1", ValidTill: time.Now()}, - {Type: "offline", Serial: "serail2", ValidTill: time.Now()}, + {NodeID: "node0", Type: "online", Serial: "serial1", ValidTill: time.Now()}, + {NodeID: "node0", Type: "offline", Serial: "serial2", ValidTill: time.Now()}, } + secrets := cloudprotocol.UnitSecrets{Nodes: map[string]string{"node0": "pwd"}} - if err = client.RenewCertificatesNotification("pwd", certInfo); err != nil { + if err = client.RenewCertificatesNotification(secrets, certInfo); err != nil { t.Fatalf("Can't process renew certificate notification: %s", err) } From 1978c4701c0aece4b185a722a50b79b659e598e0 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Wed, 7 Aug 2024 20:25:39 +0300 Subject: [PATCH 127/146] [unitstatus] Fix resetUnitStatus to init all the fields Signed-off-by: Mykola Kobets --- unitstatushandler/unitstatushandler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unitstatushandler/unitstatushandler.go b/unitstatushandler/unitstatushandler.go index efaa3efd..f753d8aa 100644 --- a/unitstatushandler/unitstatushandler.go +++ b/unitstatushandler/unitstatushandler.go @@ -358,10 +358,13 @@ func (instance *Instance) CloudDisconnected() { func (instance *Instance) resetUnitStatus() { instance.unitStatus = cloudprotocol.UnitStatus{ - Components: make([]cloudprotocol.ComponentStatus, 0), - Layers: make([]cloudprotocol.LayerStatus, 0), + MessageType: cloudprotocol.UnitStatusMessageType, + UnitConfig: make([]cloudprotocol.UnitConfigStatus, 0), + Nodes: make([]cloudprotocol.NodeInfo, 0), Services: make([]cloudprotocol.ServiceStatus, 0), Instances: make([]cloudprotocol.InstanceStatus, 0), + Layers: make([]cloudprotocol.LayerStatus, 0), + Components: make([]cloudprotocol.ComponentStatus, 0), UnitSubjects: make([]string, 0), } } From feb6275c3da4c95db1205a291b5a704df7e59f3f Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 12 Aug 2024 23:01:57 +0300 Subject: [PATCH 128/146] [unitconfig] Change unitConfigError after unit config updated Signed-off-by: Mykola Kobets --- unitconfig/unitconfig.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 5d3f32e0..f95b272d 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -191,6 +191,10 @@ func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) instance.Lock() defer instance.Unlock() + defer func() { + instance.unitConfigError = err + }() + if instance.unitConfigError != nil && instance.unitConfig.Version == "" { log.Warnf("Skip unit config version check due to error: %v", instance.unitConfigError) } else if err := instance.checkVersion(unitConfig.Version); err != nil { From 5022c30cf81f10e49e8d366e48c6eefe680d1aa5 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 13 Aug 2024 11:44:50 +0300 Subject: [PATCH 129/146] [unitconfig] Don't treat absent unit config as an error Signed-off-by: Mykola Kobets --- unitconfig/unitconfig.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index f95b272d..1a90c50f 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -250,7 +250,10 @@ func (instance *Instance) load() (err error) { byteValue, err := os.ReadFile(instance.unitConfigFile) if err != nil { - return aoserrors.Wrap(err) + // Don't treat absent config as an error. + instance.unitConfig = cloudprotocol.UnitConfig{Version: "0.0.0"} + + return nil } if err = json.Unmarshal(byteValue, &instance.unitConfig); err != nil { From 0dbf59d190bea7f4f91f698c7bbc630d2785c037 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Fri, 16 Aug 2024 12:12:07 +0300 Subject: [PATCH 130/146] [launcher] Fix sending run instances for paused nodes We don't initialize paused nodes as result run instances command is not sent for such nodes. The fix is to initialize all nodes except unprovisioned and selects only provisioned for balancing. In this case run instances command with no instances will be sent to paused, error etc. nodes. Signed-off-by: Oleksandr Grytsov --- launcher/launcher.go | 2 +- launcher/nodehandler.go | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index b693d46a..2662d18f 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -260,7 +260,7 @@ func (launcher *Launcher) initNodes(rebalancing bool) error { continue } - if nodeInfo.Status != cloudprotocol.NodeStatusProvisioned { + if nodeInfo.Status == cloudprotocol.NodeStatusUnprovisioned { log.WithField("nodeID", nodeID).Debug("Skip not provisioned node") continue diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 7894baa9..709279b1 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -360,7 +360,12 @@ func (node *nodeHandler) getRequestedRAM( func getNodesByStaticResources(nodes []*nodeHandler, serviceConfig aostypes.ServiceConfig, instanceInfo cloudprotocol.InstanceInfo, ) ([]*nodeHandler, error) { - resultNodes := getNodeByRunners(nodes, serviceConfig.Runners) + resultNodes := getActiveNodes(nodes) + if len(resultNodes) == 0 { + return resultNodes, aoserrors.Errorf("no active nodes") + } + + resultNodes = getNodeByRunners(nodes, serviceConfig.Runners) if len(resultNodes) == 0 { return resultNodes, aoserrors.Errorf("no nodes with runner: %s", serviceConfig.Runners) } @@ -378,6 +383,18 @@ func getNodesByStaticResources(nodes []*nodeHandler, return resultNodes, nil } +func getActiveNodes(nodes []*nodeHandler) []*nodeHandler { + resultNodes := make([]*nodeHandler, 0) + + for _, node := range nodes { + if node.nodeInfo.Status == cloudprotocol.NodeStatusProvisioned { + resultNodes = append(resultNodes, node) + } + } + + return resultNodes +} + func getNodesByDevices(nodes []*nodeHandler, desiredDevices []aostypes.ServiceDevice) []*nodeHandler { if len(desiredDevices) == 0 { return nodes From ed391b864789e77c47b8ef216793499e895ef65a Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Sat, 17 Aug 2024 14:58:29 +0300 Subject: [PATCH 131/146] [launcher] Pass activeNodes to getNodeByRunners Signed-off-by: Mykola Kobets --- launcher/nodehandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 709279b1..1c07db9b 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -365,7 +365,7 @@ func getNodesByStaticResources(nodes []*nodeHandler, return resultNodes, aoserrors.Errorf("no active nodes") } - resultNodes = getNodeByRunners(nodes, serviceConfig.Runners) + resultNodes = getNodeByRunners(resultNodes, serviceConfig.Runners) if len(resultNodes) == 0 { return resultNodes, aoserrors.Errorf("no nodes with runner: %s", serviceConfig.Runners) } From 8133340f9d1645ee9213346805d44d48379d4102 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 19 Aug 2024 12:35:23 +0300 Subject: [PATCH 132/146] [database] Remove GROUP BY from SELECT as it returns a single row Signed-off-by: Mykola Kobets --- database/database.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/database/database.go b/database/database.go index 07b901c2..db3fda70 100644 --- a/database/database.go +++ b/database/database.go @@ -348,7 +348,7 @@ func (db *Database) SetDownloadInfo(downloadInfo downloader.DownloadInfo) (err e // GetServicesInfo returns services info. func (db *Database) GetServicesInfo() ([]imagemanager.ServiceInfo, error) { - allServiceVersions, err := db.getServicesFromQuery(`SELECT * FROM services GROUP BY id`) + allServiceVersions, err := db.getServicesFromQuery(`SELECT * FROM services`) if err != nil { return nil, err } @@ -449,7 +449,7 @@ func (db *Database) RemoveService(serviceID string, version string) (err error) // GetAllServiceVersions returns all service versions. func (db *Database) GetServiceVersions(serviceID string) (services []imagemanager.ServiceInfo, err error) { if services, err = db.getServicesFromQuery( - "SELECT * FROM services WHERE id = ? GROUP BY version", serviceID); err != nil { + "SELECT * FROM services WHERE id = ?", serviceID); err != nil { return nil, err } @@ -992,10 +992,6 @@ func (db *Database) getServicesFromQuery( } defer rows.Close() - if rows.Err() != nil { - return nil, aoserrors.Wrap(rows.Err()) - } - for rows.Next() { var ( service imagemanager.ServiceInfo @@ -1025,6 +1021,10 @@ func (db *Database) getServicesFromQuery( services = append(services, service) } + if rows.Err() != nil { + return nil, aoserrors.Wrap(rows.Err()) + } + return services, nil } From 9ee0f48003853d86552c502d843936ee75f21512 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 19 Aug 2024 14:51:13 +0300 Subject: [PATCH 133/146] [database] Add test for GetService(s)Info Signed-off-by: Mykola Kobets --- database/database_internal_test.go | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/database/database_internal_test.go b/database/database_internal_test.go index afa14619..af5dc6b4 100644 --- a/database/database_internal_test.go +++ b/database/database_internal_test.go @@ -379,6 +379,70 @@ func TestServiceStore(t *testing.T) { } } +func TestGetServiceInfo(t *testing.T) { + serviceID := "service2" + services := []imagemanager.ServiceInfo{ + { + ServiceInfo: aostypes.ServiceInfo{ + ServiceID: serviceID, + Version: "1.1", + URL: "file:///path/service2", + Size: 60, + GID: 2000, + }, + RemoteURL: "http://path/service2", + Path: "/path/service2", Timestamp: time.Now().UTC(), Cached: true, + Config: aostypes.ServiceConfig{ + Hostname: allocateString("service2"), + Author: "test1", + Quotas: aostypes.ServiceQuotas{ + UploadSpeed: allocateUint64(500), + DownloadSpeed: allocateUint64(500), + }, + Resources: []string{"resource1", "resource2"}, + }, + }, + + { + ServiceInfo: aostypes.ServiceInfo{ + ServiceID: serviceID, + Version: "2.1", + URL: "file:///path/service2/new", + Size: 20, + GID: 1000, + }, + RemoteURL: "http://path/service2/new", + Path: "/path/service2/new", Timestamp: time.Now().UTC(), + }, + } + + latestService := services[1] + + for _, service := range services { + if err := testDB.AddService(service); err != nil { + t.Errorf("Can't add service: %v", err) + } + } + + service, err := testDB.GetServiceInfo(serviceID) + if err != nil { + t.Errorf("Can't get service info: %v", err) + } + + if !reflect.DeepEqual(service, latestService) { + t.Errorf("Wrong service info: actual %v != expected %v", service, latestService) + } + + serviceInfo, err := testDB.GetServicesInfo() + if err != nil { + t.Errorf("Can't get services info: %v", err) + } + + if len(serviceInfo) != 1 || !reflect.DeepEqual(serviceInfo[0], latestService) { + t.Errorf("Wrong service info: actual %v != expected %v", serviceInfo[0], latestService) + } +} + func TestLayerStore(t *testing.T) { cases := []struct { layer imagemanager.LayerInfo From 3eaa838064944a4202eafddb93c6a6ffe09d1f2a Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Mon, 19 Aug 2024 14:51:48 +0300 Subject: [PATCH 134/146] [communicationmanager] Fix govet lint message Signed-off-by: Mykola Kobets --- communicationmanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/communicationmanager.go b/communicationmanager.go index b0503844..66612895 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -539,7 +539,7 @@ func (hook *journalHook) Fire(entry *log.Entry) (err error) { return aoserrors.Wrap(err) } - err = journal.Print(hook.severityMap[entry.Level], logMessage) + err = journal.Print(hook.severityMap[entry.Level], "%s", logMessage) return aoserrors.Wrap(err) } From 5da0812b618124937cac6eb9fafdda94644996f3 Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 20 Aug 2024 11:38:32 +0300 Subject: [PATCH 135/146] [communicationmanager] Create unitconfig before resourcemonitor Signed-off-by: Mykola Kobets --- communicationmanager.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/communicationmanager.go b/communicationmanager.go index 66612895..b23d6acd 100644 --- a/communicationmanager.go +++ b/communicationmanager.go @@ -179,6 +179,15 @@ func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err return cm, aoserrors.Wrap(err) } + if cm.smController, err = smcontroller.New( + cfg, cm.amqp, cm.alerts, cm.monitorcontroller, cm.iam, cm.cryptoContext, false); err != nil { + return cm, aoserrors.Wrap(err) + } + + if cm.unitConfig, err = unitconfig.New(cfg, cm.iam, cm.smController); err != nil { + return cm, aoserrors.Wrap(err) + } + if cfg.Monitoring.MonitorConfig != nil { if cm.resourcemonitor, err = resourcemonitor.New(*cfg.Monitoring.MonitorConfig, cm.iam, cm.unitConfig, nil, cm.alerts); err != nil { @@ -201,19 +210,10 @@ func newCommunicationManager(cfg *config.Config) (cm *communicationManager, err return cm, aoserrors.Wrap(err) } - if cm.smController, err = smcontroller.New( - cfg, cm.amqp, cm.alerts, cm.monitorcontroller, cm.iam, cm.cryptoContext, false); err != nil { - return cm, aoserrors.Wrap(err) - } - if cm.umController, err = umcontroller.New(cfg, cm.db, cm.iam, cm.iam, cm.cryptoContext, cm.crypt, false); err != nil { return cm, aoserrors.Wrap(err) } - if cm.unitConfig, err = unitconfig.New(cfg, cm.iam, cm.smController); err != nil { - return cm, aoserrors.Wrap(err) - } - if cm.storageState, err = storagestate.New(cfg, cm.amqp, cm.db); err != nil { return cm, aoserrors.Wrap(err) } From 7ccb0ecf34d04a46a91ed0447c0ee34587e7cfed Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 20 Aug 2024 13:26:01 +0300 Subject: [PATCH 136/146] [vendor] Update vendor Signed-off-by: Mykola Kobets --- go.mod | 2 +- go.sum | 4 ++-- .../resourcemonitor/resourcemonitor.go | 18 ++++++++++-------- vendor/modules.txt | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 4ab214b2..795c50aa 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c + github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248 github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index a8310a99..bf450ca9 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c h1:+syptKk0KtaFuttYpoUW4VF4eUciUxP5VFeFDDcDNkA= -github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= +github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248 h1:EGMPa9KQV0pRIveBr1zt5O4BCxJENIgYztPsZGG+o4s= +github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go index 0ebcd4f0..0f925c79 100644 --- a/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go +++ b/vendor/github.com/aosedge/aos_common/resourcemonitor/resourcemonitor.go @@ -83,7 +83,7 @@ type NodeInfoProvider interface { // NodeConfigProvider interface to get node config. type NodeConfigProvider interface { GetCurrentNodeConfig() (cloudprotocol.NodeConfig, error) - CurrentNodeConfigChannel() <-chan cloudprotocol.NodeConfig + SubscribeCurrentNodeConfigChange() <-chan cloudprotocol.NodeConfig } // TrafficMonitoring interface to get network traffic. @@ -117,6 +117,7 @@ type ResourceMonitor struct { nodeAverageData averageMonitoring instanceMonitoringMap map[string]*instanceMonitoring alertProcessors *list.List + curNodeConfigListener <-chan cloudprotocol.NodeConfig cancelFunction context.CancelFunc } @@ -184,12 +185,13 @@ func New( log.Debug("Create monitor") monitor := &ResourceMonitor{ - nodeInfoProvider: nodeInfoProvider, - nodeConfigProvider: nodeConfigProvider, - alertSender: alertsSender, - trafficMonitoring: trafficMonitoring, - sourceSystemUsage: getSourceSystemUsage(config.Source), - monitoringChannel: make(chan aostypes.NodeMonitoring, monitoringChannelSize), + nodeInfoProvider: nodeInfoProvider, + nodeConfigProvider: nodeConfigProvider, + alertSender: alertsSender, + trafficMonitoring: trafficMonitoring, + sourceSystemUsage: getSourceSystemUsage(config.Source), + monitoringChannel: make(chan aostypes.NodeMonitoring, monitoringChannelSize), + curNodeConfigListener: nodeConfigProvider.SubscribeCurrentNodeConfigChange(), } nodeInfo, err := nodeInfoProvider.GetCurrentNodeInfo() @@ -474,7 +476,7 @@ func (monitor *ResourceMonitor) run(ctx context.Context) { case <-ctx.Done(): return - case nodeConfig := <-monitor.nodeConfigProvider.CurrentNodeConfigChannel(): + case nodeConfig := <-monitor.curNodeConfigListener: if err := monitor.setupSystemAlerts(nodeConfig); err != nil { log.Errorf("Can't setup system alerts: %v", err) } diff --git a/vendor/modules.txt b/vendor/modules.txt index f9277c0b..3eb0a94f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240807131318-ec6baf1da16c +# github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248 ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From e67a3d413e7fb5089b35ef1730ae649a14e1bc6b Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 20 Aug 2024 13:28:30 +0300 Subject: [PATCH 137/146] [unitconfig] Implement subscription on current node config change Signed-off-by: Mykola Kobets --- unitconfig/unitconfig.go | 44 +++++++++++++++++++++++------------ unitconfig/unitconfig_test.go | 10 +++++--- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index 1a90c50f..ed1fb96e 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -46,13 +46,13 @@ var ErrNotFound = errors.New("not found") type Instance struct { sync.Mutex - client Client - curNodeID string - curNodeType string - unitConfigFile string - unitConfig cloudprotocol.UnitConfig - currentNodeConfigChannel chan cloudprotocol.NodeConfig - unitConfigError error + client Client + curNodeID string + curNodeType string + unitConfigFile string + unitConfig cloudprotocol.UnitConfig + currentNodeConfigListeners []chan cloudprotocol.NodeConfig + unitConfigError error } // NodeInfoProvider node info provider interface. @@ -86,9 +86,9 @@ var ErrAlreadyInstalled = errors.New("already installed") // New creates new unit config instance. func New(cfg *config.Config, nodeInfoProvider NodeInfoProvider, client Client) (instance *Instance, err error) { instance = &Instance{ - client: client, - unitConfigFile: cfg.UnitConfigFile, - currentNodeConfigChannel: make(chan cloudprotocol.NodeConfig, 1), + client: client, + unitConfigFile: cfg.UnitConfigFile, + currentNodeConfigListeners: make([]chan cloudprotocol.NodeConfig, 0), } var nodeInfo cloudprotocol.NodeInfo @@ -181,9 +181,17 @@ func (instance *Instance) GetCurrentNodeConfig() (cloudprotocol.NodeConfig, erro return instance.GetNodeConfig(instance.curNodeID, instance.curNodeType) } -// CurrentNodeConfigChannel returns channel of current node config updates. -func (instance *Instance) CurrentNodeConfigChannel() <-chan cloudprotocol.NodeConfig { - return instance.currentNodeConfigChannel +// SubscribeCurrentNodeConfigChange subscribes new current node config listener. +func (instance *Instance) SubscribeCurrentNodeConfigChange() <-chan cloudprotocol.NodeConfig { + instance.Lock() + defer instance.Unlock() + + log.Debug("Subscribe to current node config change event") + + ch := make(chan cloudprotocol.NodeConfig, 1) + instance.currentNodeConfigListeners = append(instance.currentNodeConfigListeners, ch) + + return ch } // UpdateUnitConfig updates unit config. @@ -222,7 +230,7 @@ func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) } if nodeConfigStatus.NodeID == instance.curNodeID { - instance.currentNodeConfigChannel <- *nodeConfig + instance.updateCurrentNodeConfigListeners(*nodeConfig) } } } @@ -313,7 +321,7 @@ func (instance *Instance) handleNodeConfigStatus() { } if nodeConfigStatus.NodeID == instance.curNodeID { - instance.currentNodeConfigChannel <- *nodeConfig + instance.updateCurrentNodeConfigListeners(*nodeConfig) } } } @@ -333,3 +341,9 @@ func findNodeConfig(nodeID, nodeType string, unitConfig *cloudprotocol.UnitConfi return nil } + +func (instance *Instance) updateCurrentNodeConfigListeners(curNodeConfig cloudprotocol.NodeConfig) { + for _, listener := range instance.currentNodeConfigListeners { + listener <- curNodeConfig + } +} diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index be1c69c9..2f193c7e 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -350,8 +350,10 @@ func TestCurrentNodeConfigUpdate(t *testing.T) { t.Fatalf("Can't create unit config file: %v", err) } - client := newTestClient() - nodeInfoProvider := newTestInfoProvider("node0", "type1") + var ( + client = newTestClient() + nodeInfoProvider = newTestInfoProvider("node0", "type1") + ) instance, err := unitconfig.New( &config.Config{UnitConfigFile: path.Join(tmpDir, "aos_unit.cfg")}, nodeInfoProvider, client) @@ -359,6 +361,8 @@ func TestCurrentNodeConfigUpdate(t *testing.T) { t.Fatalf("Can't create unit config instance: %v", err) } + curNodeConfigListener := instance.SubscribeCurrentNodeConfigChange() + client.nodeConfigStatusChannel <- unitconfig.NodeConfigStatus{ NodeID: "node0", NodeType: "type1", @@ -373,7 +377,7 @@ func TestCurrentNodeConfigUpdate(t *testing.T) { t.Errorf("Wrong node config: %v", nodeConfig) } - case curNodeConfig := <-instance.CurrentNodeConfigChannel(): + case curNodeConfig := <-curNodeConfigListener: if !reflect.DeepEqual(curNodeConfig, cloudprotocol.NodeConfig{NodeID: &node0, NodeType: "type1"}) { t.Errorf("Wrong node config: %v", curNodeConfig) } From 5f2cfd0621a74dc98c53d731270ca98b79f70881 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 20 Aug 2024 15:38:53 +0300 Subject: [PATCH 138/146] [unitstatushandler] Do not return error on empty rebalancing Signed-off-by: Oleksandr Grytsov --- unitstatushandler/softwaremanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unitstatushandler/softwaremanager.go b/unitstatushandler/softwaremanager.go index 0f0bd898..aeefa93e 100644 --- a/unitstatushandler/softwaremanager.go +++ b/unitstatushandler/softwaremanager.go @@ -288,7 +288,7 @@ func (manager *softwareManager) requestRebalancing() error { log.Debug("Request rebalancing") if manager.CurrentUpdate == nil || len(manager.CurrentUpdate.RunInstances) == 0 { - return aoserrors.New("no previous update") + return nil } update := &softwareUpdate{ From 303f34749003da298123350ea3e4b26382780a50 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 20 Aug 2024 17:14:25 +0300 Subject: [PATCH 139/146] [unitconfig] Check not exist error on empty unitconfig Signed-off-by: Oleksandr Grytsov --- unitconfig/unitconfig.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index ed1fb96e..fddfb8a9 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -258,10 +258,14 @@ func (instance *Instance) load() (err error) { byteValue, err := os.ReadFile(instance.unitConfigFile) if err != nil { - // Don't treat absent config as an error. - instance.unitConfig = cloudprotocol.UnitConfig{Version: "0.0.0"} + if os.IsNotExist(err) { + // Don't treat absent config as an error. + instance.unitConfig = cloudprotocol.UnitConfig{Version: "0.0.0"} - return nil + return nil + } + + return aoserrors.Wrap(err) } if err = json.Unmarshal(byteValue, &instance.unitConfig); err != nil { From 427dc8aa3f8e94ede52891f07a4e3a1bd53a1c8c Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 20 Aug 2024 17:14:56 +0300 Subject: [PATCH 140/146] [vendor] Update vendor Signed-off-by: Oleksandr Grytsov --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/aosedge/aos_common/aostypes/aostypes.go | 2 +- vendor/modules.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 795c50aa..36b33733 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248 + github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index bf450ca9..e479b608 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248 h1:EGMPa9KQV0pRIveBr1zt5O4BCxJENIgYztPsZGG+o4s= -github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= +github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d h1:Arf3T/cAhSiOcSHrfJMWhVLXcKbmpBbs1q/7YNaXatg= +github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go index 71916847..279431ca 100644 --- a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go +++ b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go @@ -145,7 +145,7 @@ type ServiceDevice struct { // ServiceQuotas service quotas representation. type ServiceQuotas struct { - CPULimit *uint64 `json:"cpuLimit,omitempty"` + CPUDMIPSLimit *uint64 `json:"cpuDmipsLimit,omitempty"` RAMLimit *uint64 `json:"ramLimit,omitempty"` PIDsLimit *uint64 `json:"pidsLimit,omitempty"` NoFileLimit *uint64 `json:"noFileLimit,omitempty"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 3eb0a94f..09ac7cd8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240820101828-9451f51fe248 +# github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From 1d722d97378c8f7df6f107b417f540f64551bd06 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Tue, 20 Aug 2024 17:19:18 +0300 Subject: [PATCH 141/146] [launcher] Rename CPULimits to CPUDMIPSLimits in service quota Signed-off-by: Oleksandr Grytsov --- launcher/launcher_test.go | 20 ++++++++++---------- launcher/nodehandler.go | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/launcher/launcher_test.go b/launcher/launcher_test.go index 235d5bd9..85176c42 100644 --- a/launcher/launcher_test.go +++ b/launcher/launcher_test.go @@ -1635,7 +1635,7 @@ func testItemCPURatio() testData { serviceConfigs: map[string]aostypes.ServiceConfig{ service1: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, Runners: []string{runnerRunc}, }, @@ -1841,17 +1841,17 @@ func testItemRebalancing() testData { serviceConfigs: map[string]aostypes.ServiceConfig{ service1: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, service2: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, service3: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, }, @@ -1956,17 +1956,17 @@ func testItemRebalancingPolicy() testData { serviceConfigs: map[string]aostypes.ServiceConfig{ service1: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, service2: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, service3: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, BalancingPolicy: aostypes.BalancingDisabled, }, @@ -2072,17 +2072,17 @@ func testItemRebalancingPrevNode() testData { serviceConfigs: map[string]aostypes.ServiceConfig{ service1: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, service2: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, service3: { Quotas: aostypes.ServiceQuotas{ - CPULimit: newQuota(1000), + CPUDMIPSLimit: newQuota(1000), }, }, }, diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index 1c07db9b..d2d88c3c 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -312,8 +312,8 @@ func (node *nodeHandler) getRequestedCPU( ) uint64 { requestedCPU := uint64(0) - if serviceConfig.Quotas.CPULimit != nil { - requestedCPU = uint64(float64(*serviceConfig.Quotas.CPULimit)*getCPURequestRatio( + if serviceConfig.Quotas.CPUDMIPSLimit != nil { + requestedCPU = uint64(float64(*serviceConfig.Quotas.CPUDMIPSLimit)*getCPURequestRatio( serviceConfig.ResourceRatios, node.nodeConfig.ResourceRatios) + 0.5) } From 2cea2411db44c73872eaa5b67a423cf82dd9c79a Mon Sep 17 00:00:00 2001 From: Mykola Kobets Date: Tue, 27 Aug 2024 10:36:00 +0300 Subject: [PATCH 142/146] [smcontroller] Use SM LogStatus instead of hardcoded Signed-off-by: Mykola Kobets --- smcontroller/smcontroller_test.go | 5 +++-- smcontroller/smhandler.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 3ae353f6..0ec8a568 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -815,14 +815,15 @@ func TestLogMessages(t *testing.T) { ErrorInfo: &cloudprotocol.ErrorInfo{ Message: "this is error", }, - Status: "ok", + Status: cloudprotocol.LogStatusError, } smClient.sendMessageChannel <- &pbsm.SMOutgoingMessages{ SMOutgoingMessage: &pbsm.SMOutgoingMessages_Log{ Log: &pbsm.LogData{ LogId: "log0", PartCount: 2, Part: 1, Data: []byte("this is log"), - Error: &pbcommon.ErrorInfo{Message: "this is error"}, + Error: &pbcommon.ErrorInfo{Message: "this is error"}, + Status: cloudprotocol.LogStatusError, }, }, } diff --git a/smcontroller/smhandler.go b/smcontroller/smhandler.go index 643e103e..d80a51e6 100644 --- a/smcontroller/smhandler.go +++ b/smcontroller/smhandler.go @@ -572,7 +572,7 @@ func (handler *smHandler) processLogMessage(data *pb.LogData) { ExitCode: int(data.GetError().GetExitCode()), Message: data.GetError().GetMessage(), }, - Status: "ok", + Status: data.GetStatus(), }); err != nil { log.Errorf("Can't send log: %v", err) } From 7cb81a3946a920a0fd7a91e360fb752d0bde41ef Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 28 Aug 2024 14:49:34 +0300 Subject: [PATCH 143/146] [vendor] Update vendor Signed-off-by: Oleksandr Grytsov --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/aosedge/aos_common/aostypes/aostypes.go | 2 +- vendor/modules.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 36b33733..52c7d431 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d + github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06 github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index e479b608..4679e4cc 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d h1:Arf3T/cAhSiOcSHrfJMWhVLXcKbmpBbs1q/7YNaXatg= -github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= +github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06 h1:yFPGmxShLaO+h2NToVmjRYk7oSirizq6a6QeGZ2wkww= +github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go index 279431ca..3cc2c9b5 100644 --- a/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go +++ b/vendor/github.com/aosedge/aos_common/aostypes/aostypes.go @@ -327,7 +327,7 @@ func (d *Duration) UnmarshalJSON(b []byte) (err error) { switch value := v.(type) { case float64: - d.Duration = time.Duration(value) + d.Duration = time.Duration(int64(value*float64(time.Second) + 0.5)) return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index 09ac7cd8..1baa10b1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240820141235-b28ad667934d +# github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06 ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes From 23435a3658cba80b3ad4c9d00f3423d43f8bc122 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Wed, 28 Aug 2024 15:13:51 +0300 Subject: [PATCH 144/146] [unitconfig,smcontroller] Do not set optional node ID for node config Signed-off-by: Oleksandr Grytsov --- smcontroller/smcontroller.go | 16 +++-------- smcontroller/smcontroller_test.go | 10 +++---- unitconfig/unitconfig.go | 46 ++++++++++++------------------- unitconfig/unitconfig_test.go | 8 +++--- 4 files changed, 31 insertions(+), 49 deletions(-) diff --git a/smcontroller/smcontroller.go b/smcontroller/smcontroller.go index 5ae21d5f..577eb3f6 100644 --- a/smcontroller/smcontroller.go +++ b/smcontroller/smcontroller.go @@ -189,12 +189,8 @@ func (controller *Controller) GetNodeConfigStatus(nodeID string) (unitconfig.Nod } // CheckNodeConfig checks node config. -func (controller *Controller) CheckNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { - if nodeConfig.NodeID == nil { - return aoserrors.Errorf("node ID is not set") - } - - handler, err := controller.getNodeHandlerByID(*nodeConfig.NodeID) +func (controller *Controller) CheckNodeConfig(nodeID, version string, nodeConfig cloudprotocol.NodeConfig) error { + handler, err := controller.getNodeHandlerByID(nodeID) if err != nil { return err } @@ -207,12 +203,8 @@ func (controller *Controller) CheckNodeConfig(version string, nodeConfig cloudpr } // SetNodeConfig sets node config. -func (controller *Controller) SetNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { - if nodeConfig.NodeID == nil { - return aoserrors.Errorf("node ID is not set") - } - - handler, err := controller.getNodeHandlerByID(*nodeConfig.NodeID) +func (controller *Controller) SetNodeConfig(nodeID, version string, nodeConfig cloudprotocol.NodeConfig) error { + handler, err := controller.getNodeHandlerByID(nodeID) if err != nil { return err } diff --git a/smcontroller/smcontroller_test.go b/smcontroller/smcontroller_test.go index 0ec8a568..aa98a947 100644 --- a/smcontroller/smcontroller_test.go +++ b/smcontroller/smcontroller_test.go @@ -207,7 +207,7 @@ func TestNodeConfigMessages(t *testing.T) { NodeConfigStatus: &pbsm.NodeConfigStatus{Version: originalVersion}, }} newVersion = "2.0.0" - nodeConfig = fmt.Sprintf(`{"nodeId":"%s","nodeType":"%s"}`, nodeID, nodeType) + nodeConfig = fmt.Sprintf(`{"nodeType":"%s"}`, nodeType) ) controller, err := smcontroller.New(&config, messageSender, nil, nil, nil, nil, true) @@ -254,8 +254,8 @@ func TestNodeConfigMessages(t *testing.T) { <-testWaitChan go func() { - if err := controller.CheckNodeConfig(newVersion, - cloudprotocol.NodeConfig{NodeID: &nodeID, NodeType: nodeType}); err != nil { + if err := controller.CheckNodeConfig(nodeID, newVersion, + cloudprotocol.NodeConfig{NodeType: nodeType}); err != nil { t.Errorf("Error check unit config: %v", err) } @@ -279,8 +279,8 @@ func TestNodeConfigMessages(t *testing.T) { <-testWaitChan go func() { - if err := controller.SetNodeConfig(newVersion, - cloudprotocol.NodeConfig{NodeID: &nodeID, NodeType: nodeType}); err != nil { + if err := controller.SetNodeConfig(nodeID, newVersion, + cloudprotocol.NodeConfig{NodeType: nodeType}); err != nil { t.Errorf("Error check unit config: %v", err) } diff --git a/unitconfig/unitconfig.go b/unitconfig/unitconfig.go index fddfb8a9..786ab9be 100644 --- a/unitconfig/unitconfig.go +++ b/unitconfig/unitconfig.go @@ -62,8 +62,8 @@ type NodeInfoProvider interface { // Client client unit config interface. type Client interface { - CheckNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error - SetNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error + CheckNodeConfig(nodeID, version string, nodeConfig cloudprotocol.NodeConfig) error + SetNodeConfig(nodeID, version string, nodeConfig cloudprotocol.NodeConfig) error GetNodeConfigStatuses() ([]NodeConfigStatus, error) NodeConfigStatusChannel() <-chan NodeConfigStatus } @@ -143,14 +143,12 @@ func (instance *Instance) CheckUnitConfig(unitConfig cloudprotocol.UnitConfig) e for i, nodeConfigStatus := range nodeConfigStatuses { if nodeConfigStatus.Version != unitConfig.Version || nodeConfigStatus.Error != nil { - nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, &unitConfig) - if nodeConfig == nil { - continue - } + nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, unitConfig) nodeConfig.NodeID = &nodeConfigStatuses[i].NodeID - if err := instance.client.CheckNodeConfig(unitConfig.Version, *nodeConfig); err != nil { + if err := instance.client.CheckNodeConfig( + nodeConfigStatus.NodeID, unitConfig.Version, nodeConfig); err != nil { return aoserrors.Wrap(err) } } @@ -216,21 +214,17 @@ func (instance *Instance) UpdateUnitConfig(unitConfig cloudprotocol.UnitConfig) log.Errorf("Error getting node config statuses: %v", err) } - for i, nodeConfigStatus := range nodeConfigStatuses { + for _, nodeConfigStatus := range nodeConfigStatuses { if nodeConfigStatus.Version != unitConfig.Version || nodeConfigStatus.Error != nil { - nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, &unitConfig) - if nodeConfig == nil { - continue - } - - nodeConfig.NodeID = &nodeConfigStatuses[i].NodeID + nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, unitConfig) - if err := instance.client.SetNodeConfig(unitConfig.Version, *nodeConfig); err != nil { + if err := instance.client.SetNodeConfig( + nodeConfigStatus.NodeID, unitConfig.Version, nodeConfig); err != nil { return aoserrors.Wrap(err) } if nodeConfigStatus.NodeID == instance.curNodeID { - instance.updateCurrentNodeConfigListeners(*nodeConfig) + instance.updateCurrentNodeConfigListeners(nodeConfig) } } } @@ -313,37 +307,33 @@ func (instance *Instance) handleNodeConfigStatus() { continue } - nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, &instance.unitConfig) - if nodeConfig == nil { - continue - } + nodeConfig := findNodeConfig(nodeConfigStatus.NodeID, nodeConfigStatus.NodeType, instance.unitConfig) - nodeConfig.NodeID = &nodeConfigStatus.NodeID - - if err := instance.client.SetNodeConfig(instance.unitConfig.Version, *nodeConfig); err != nil { + if err := instance.client.SetNodeConfig( + nodeConfigStatus.NodeID, instance.unitConfig.Version, nodeConfig); err != nil { log.WithField("NodeID", nodeConfigStatus.NodeID).Errorf("Can't update node config: %v", err) } if nodeConfigStatus.NodeID == instance.curNodeID { - instance.updateCurrentNodeConfigListeners(*nodeConfig) + instance.updateCurrentNodeConfigListeners(nodeConfig) } } } -func findNodeConfig(nodeID, nodeType string, unitConfig *cloudprotocol.UnitConfig) *cloudprotocol.NodeConfig { +func findNodeConfig(nodeID, nodeType string, unitConfig cloudprotocol.UnitConfig) cloudprotocol.NodeConfig { for i, nodeConfig := range unitConfig.Nodes { if nodeConfig.NodeID != nil && *nodeConfig.NodeID == nodeID { - return &unitConfig.Nodes[i] + return unitConfig.Nodes[i] } } for i, nodeConfig := range unitConfig.Nodes { if nodeConfig.NodeType == nodeType { - return &unitConfig.Nodes[i] + return unitConfig.Nodes[i] } } - return nil + return cloudprotocol.NodeConfig{} } func (instance *Instance) updateCurrentNodeConfigListeners(curNodeConfig cloudprotocol.NodeConfig) { diff --git a/unitconfig/unitconfig_test.go b/unitconfig/unitconfig_test.go index 2f193c7e..fe07cad2 100644 --- a/unitconfig/unitconfig_test.go +++ b/unitconfig/unitconfig_test.go @@ -399,9 +399,9 @@ func newTestClient() *testClient { } } -func (client *testClient) CheckNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { +func (client *testClient) CheckNodeConfig(nodeID string, version string, nodeConfig cloudprotocol.NodeConfig) error { client.nodeConfigSetCheckChannel <- testNodeConfig{ - NodeID: *nodeConfig.NodeID, + NodeID: nodeID, NodeType: nodeConfig.NodeType, Version: version, } @@ -409,9 +409,9 @@ func (client *testClient) CheckNodeConfig(version string, nodeConfig cloudprotoc return nil } -func (client *testClient) SetNodeConfig(version string, nodeConfig cloudprotocol.NodeConfig) error { +func (client *testClient) SetNodeConfig(nodeID string, version string, nodeConfig cloudprotocol.NodeConfig) error { client.nodeConfigSetCheckChannel <- testNodeConfig{ - NodeID: *nodeConfig.NodeID, + NodeID: nodeID, NodeType: nodeConfig.NodeType, Version: version, } From ec2ad78017d65fda67c8a31d63e810c129b6bad1 Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 2 Sep 2024 12:32:47 +0300 Subject: [PATCH 145/146] [launcher] Fix typo in comment Signed-off-by: Oleksandr Grytsov --- launcher/nodehandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/nodehandler.go b/launcher/nodehandler.go index d2d88c3c..9c3cd1f3 100644 --- a/launcher/nodehandler.go +++ b/launcher/nodehandler.go @@ -118,7 +118,7 @@ func (node *nodeHandler) initAvailableResources(nodeManager NodeManager, rebalan totalCPU := node.nodeInfo.MaxDMIPs totalRAM := node.nodeInfo.TotalRAM - // For nodes required rebalancing, we need to increase resource consumption below the low threshold + // For nodes required rebalancing, we need to decrease resource consumption below the low threshold if node.needRebalancing { if node.nodeConfig.AlertRules.CPU != nil { totalCPU = uint64(math.Round(float64(node.nodeInfo.MaxDMIPs) * From d16e0c13d6e14e467aab6edd95d1f9d6baa121bb Mon Sep 17 00:00:00 2001 From: Oleksandr Grytsov Date: Mon, 2 Sep 2024 12:35:27 +0300 Subject: [PATCH 146/146] [vendor] Update vendor Signed-off-by: Oleksandr Grytsov --- go.mod | 2 +- go.sum | 4 ++-- .../aosedge/aos_common/api/cloudprotocol/unitstatus.go | 2 +- vendor/modules.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 52c7d431..36cf94a3 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/anexia-it/fsquota => github.com/aosedge/fsquota v0.0.0-202311 require ( code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b - github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06 + github.com/aosedge/aos_common v0.0.0-20240902084419-53e429d5c68a github.com/apparentlymart/go-cidr v1.1.0 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf diff --git a/go.sum b/go.sum index 4679e4cc..3b16eabe 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b h1:/2OEIBwZAaJ8n8iTXrM4v/+bdyLDTLwcW6RZtkO4+r0= code.cloudfoundry.org/bytefmt v0.0.0-20231017140541-3b893ed0421b/go.mod h1:CKNYSQxmKcMCNIKoRG5rRR4AIgJMIoK65ya+Z5xHnk4= -github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06 h1:yFPGmxShLaO+h2NToVmjRYk7oSirizq6a6QeGZ2wkww= -github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= +github.com/aosedge/aos_common v0.0.0-20240902084419-53e429d5c68a h1:vTyrUt3lGoPbiAAf+ckr2vreksbK4pGi/KmM9GNoUKI= +github.com/aosedge/aos_common v0.0.0-20240902084419-53e429d5c68a/go.mod h1:CG/e1tQPMo2fvdwRHi+Cx5StpNURu7InTZSgyfmBVYM= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f h1:xL5hA9axQFHnoVVF/Q8CkKl9JiTvA7U72jRDltMBB9M= github.com/aosedge/crypto11 v1.0.3-0.20220217163524-ddd0ace39e6f/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE= github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 h1:KR+SuYXJ9HigUaJdUwRlkDOOpkCrliFF3liBVKu2GKY= diff --git a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go index da11fa08..ac7dd55f 100644 --- a/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go +++ b/vendor/github.com/aosedge/aos_common/api/cloudprotocol/unitstatus.go @@ -120,7 +120,7 @@ type NodeInfo struct { NodeType string `json:"type"` Name string `json:"name"` Status string `json:"status"` - CPUs []CPUInfo `json:"cpus"` + CPUs []CPUInfo `json:"cpus,omitempty"` OSType string `json:"osType"` MaxDMIPs uint64 `json:"maxDmips"` TotalRAM uint64 `json:"totalRam"` diff --git a/vendor/modules.txt b/vendor/modules.txt index 1baa10b1..4b1517aa 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/ThalesIgnite/crypto11 # github.com/anexia-it/fsquota v0.0.0-00010101000000-000000000000 => github.com/aosedge/fsquota v0.0.0-20231127111317-842d831105a7 ## explicit; go 1.21 github.com/anexia-it/fsquota -# github.com/aosedge/aos_common v0.0.0-20240828112023-cf8d349b0d06 +# github.com/aosedge/aos_common v0.0.0-20240902084419-53e429d5c68a ## explicit; go 1.21 github.com/aosedge/aos_common/aoserrors github.com/aosedge/aos_common/aostypes